getParameter('chill_calendar.remote_calendar_dsn'); if (true === $container->getParameter('chill_calendar')['remote_calendars_sync']['microsoft_graph']['enabled']) { $dsn = 'msgraph://default'; } else { $dsn = $config; } $scheme = parse_url($dsn, PHP_URL_SCHEME); if ('msgraph' === $scheme) { $connector = MSGraphRemoteCalendarConnector::class; $container->setAlias(HttpClientInterface::class.' $machineHttpClient', MachineHttpClient::class); } elseif ('zimbra+http' === $scheme || 'zimbra+https' === $scheme) { $connector = self::ZIMBRA_CONNECTOR; foreach (self::MS_GRAPH_SERVICES_TO_REMOVE as $serviceId) { $container->removeDefinition($serviceId); } } elseif ('null' === $scheme) { $connector = NullRemoteCalendarConnector::class; foreach (self::MS_GRAPH_SERVICES_TO_REMOVE as $serviceId) { $container->removeDefinition($serviceId); } } else { throw new \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('Unsupported remote calendar scheme: '.$scheme); } if (!$container->hasAlias(Azure::class) && $container->hasDefinition('knpu.oauth2.client.azure')) { $container->setAlias(Azure::class, 'knpu.oauth2.provider.azure'); } foreach ([ NullRemoteCalendarConnector::class, MSGraphRemoteCalendarConnector::class, self::ZIMBRA_CONNECTOR, ] as $serviceId) { if ($connector === $serviceId) { $container->getDefinition($serviceId) ->setDecoratedService(RemoteCalendarConnectorInterface::class); } else { // keep the container lighter by removing definitions if ($container->hasDefinition($serviceId)) { $container->removeDefinition($serviceId); } } } } }