refactor command to acquire admin consent

This commit is contained in:
2022-05-09 14:24:58 +02:00
parent d570145385
commit ee4a6e08fb
4 changed files with 34 additions and 37 deletions

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\CalendarBundle\RemoteCalendar\DependencyInjection;
use Chill\CalendarBundle\Command\MapUserCalendarCommand;
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraphRemoteCalendarConnector;
use Chill\CalendarBundle\RemoteCalendar\Connector\NullRemoteCalendarConnector;
use Chill\CalendarBundle\RemoteCalendar\Connector\RemoteCalendarConnectorInterface;
@@ -26,16 +27,19 @@ class RemoteCalendarCompilerPass implements CompilerPassInterface
$config = $container->getParameter('chill_calendar');
$connector = null;
if (!$config['remote_calendars_sync']['enabled']) {
if ($config['remote_calendars_sync']['enabled']) {
$connector = NullRemoteCalendarConnector::class;
} else {
if ($config['remote_calendars_sync']['microsoft_graph']['enabled']) {
$connector = MSGraphRemoteCalendarConnector::class;
}
if (!$container->hasAlias(Azure::class)) {
$container->setAlias(Azure::class, 'knpu.oauth2.provider.azure');
}
}
if ($config['remote_calendars_sync']['microsoft_graph']['enabled']) {
$connector = MSGraphRemoteCalendarConnector::class;
} else {
// remove services which cannot be loaded
$container->removeDefinition(MapUserCalendarCommand::class);
}
if (!$container->hasAlias(Azure::class)) {
$container->setAlias(Azure::class, 'knpu.oauth2.provider.azure');
}
if (null === $connector) {