mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
first bootstrap for handling calendar range sync frommsgraph
This commit is contained in:
@@ -14,12 +14,15 @@ namespace Chill\CalendarBundle\RemoteCalendar\DependencyInjection;
|
||||
use Chill\CalendarBundle\Command\AzureGrantAdminConsentAndAcquireToken;
|
||||
use Chill\CalendarBundle\Command\MapAndSubscribeUserCalendarCommand;
|
||||
use Chill\CalendarBundle\Controller\RemoteCalendarConnectAzureController;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MachineHttpClient;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MachineTokenStorage;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraphRemoteCalendarConnector;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\NullRemoteCalendarConnector;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\RemoteCalendarConnectorInterface;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use TheNetworg\OAuth2\Client\Provider\Azure;
|
||||
|
||||
class RemoteCalendarCompilerPass implements CompilerPassInterface
|
||||
@@ -30,16 +33,21 @@ class RemoteCalendarCompilerPass implements CompilerPassInterface
|
||||
$connector = null;
|
||||
|
||||
if (!$config['remote_calendars_sync']['enabled']) {
|
||||
$connector = MSGraphRemoteCalendarConnector::class;
|
||||
$connector = NullRemoteCalendarConnector::class;
|
||||
}
|
||||
|
||||
if ($config['remote_calendars_sync']['microsoft_graph']['enabled']) {
|
||||
$connector = MSGraphRemoteCalendarConnector::class;
|
||||
|
||||
$container->setAlias(HttpClientInterface::class.' $machineHttpClient', MachineHttpClient::class);
|
||||
} else {
|
||||
// remove services which cannot be loaded
|
||||
$container->removeDefinition(MapAndSubscribeUserCalendarCommand::class);
|
||||
$container->removeDefinition(AzureGrantAdminConsentAndAcquireToken::class);
|
||||
$container->removeDefinition(RemoteCalendarConnectAzureController::class);
|
||||
$container->removeDefinition(MachineTokenStorage::class);
|
||||
$container->removeDefinition(MachineHttpClient::class);
|
||||
$container->removeDefinition(MSGraphRemoteCalendarConnector::class);
|
||||
}
|
||||
|
||||
if (!$container->hasAlias(Azure::class) && $container->hasDefinition('knpu.oauth2.client.azure')) {
|
||||
@@ -58,7 +66,9 @@ class RemoteCalendarCompilerPass implements CompilerPassInterface
|
||||
->setDecoratedService(RemoteCalendarConnectorInterface::class);
|
||||
} else {
|
||||
// keep the container lighter by removing definitions
|
||||
$container->removeDefinition($serviceId);
|
||||
if ($container->hasDefinition($serviceId)) {
|
||||
$container->removeDefinition($serviceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user