diff --git a/src/Bundle/ChillActivityBundle/config/services/export.yaml b/src/Bundle/ChillActivityBundle/config/services/export.yaml index 69565e29a..d4548109e 100644 --- a/src/Bundle/ChillActivityBundle/config/services/export.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/export.yaml @@ -4,18 +4,15 @@ services: autoconfigure: true ## Indicators - chill.activity.export.count_activity_linked_to_person: - class: Chill\ActivityBundle\Export\Export\LinkedToPerson\CountActivity + Chill\ActivityBundle\Export\Export\LinkedToPerson\CountActivity: tags: - { name: chill.export, alias: 'count_activity_linked_to_person' } - chill.activity.export.sum_activity_duration_linked_to_person: - class: Chill\ActivityBundle\Export\Export\LinkedToPerson\StatActivityDuration + Chill\ActivityBundle\Export\Export\LinkedToPerson\StatActivityDuration: tags: - { name: chill.export, alias: 'sum_activity_duration_linked_to_person' } - chill.activity.export.list_activity_linked_to_person: - class: Chill\ActivityBundle\Export\Export\LinkedToPerson\ListActivity + Chill\ActivityBundle\Export\Export\LinkedToPerson\ListActivity: tags: - { name: chill.export, alias: 'list_activity_linked_to_person' } @@ -116,8 +113,7 @@ services: - { name: chill.export_filter, alias: 'activity_userscope_filter' } ## Aggregators - chill.activity.export.reason_aggregator: - class: Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator + Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator: tags: - { name: chill.export_aggregator, alias: activity_reason_aggregator } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ExportsCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ExportsCompilerPass.php index ae85ba22c..30d099e6a 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ExportsCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ExportsCompilerPass.php @@ -18,7 +18,7 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; /** - * Compiles the services tagged with :. + * Compiles the services tagged with : * * - chill.export * - chill.export_formatter @@ -39,11 +39,11 @@ class ExportsCompilerPass implements CompilerPassInterface 'Chill\MainBundle\Export\ExportManager' ); - $this->compileExports($chillManagerDefinition, $container); - $this->compileFilters($chillManagerDefinition, $container); - $this->compileAggregators($chillManagerDefinition, $container); - $this->compileFormatters($chillManagerDefinition, $container); - $this->compileExportElementsProvider($chillManagerDefinition, $container); + //$this->compileExports($chillManagerDefinition, $container); + //$this->compileFilters($chillManagerDefinition, $container); + //$this->compileAggregators($chillManagerDefinition, $container); + //$this->compileFormatters($chillManagerDefinition, $container); + //$this->compileExportElementsProvider($chillManagerDefinition, $container); } private function compileAggregators( @@ -119,6 +119,12 @@ class ExportsCompilerPass implements CompilerPassInterface $knownAliases = []; foreach ($taggedServices as $id => $tagAttributes) { + + if (!$container->has($id)) { + dump('the service was removed'); + continue; + } + foreach ($tagAttributes as $attributes) { if (!isset($attributes['alias'])) { throw new LogicException("the 'alias' attribute is missing in your " . diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index aec5998ff..2a2905efb 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -85,13 +85,26 @@ class ExportManager EntityManagerInterface $em, AuthorizationCheckerInterface $authorizationChecker, AuthorizationHelperInterface $authorizationHelper, - TokenStorageInterface $tokenStorage + TokenStorageInterface $tokenStorage, + iterable $exports, + iterable $aggregators, + iterable $filters, + iterable $formatters, + iterable $exportElementProvider ) { $this->logger = $logger; $this->em = $em; $this->authorizationChecker = $authorizationChecker; $this->authorizationHelper = $authorizationHelper; $this->user = $tokenStorage->getToken()->getUser(); + $this->exports = iterator_to_array($exports); + $this->aggregators = iterator_to_array($aggregators); + $this->filters = iterator_to_array($filters); + $this->formatters = iterator_to_array($formatters); + + foreach ($exportElementProvider as $prefix => $provider) { + $this->addExportElementsProvider($provider, $prefix); + } } /** @@ -159,7 +172,7 @@ class ExportManager * @internal used by DI * * @param DirectExportInterface|ExportInterface $export - * @param type $alias + * @param string $alias */ public function addExport($export, $alias) { @@ -213,7 +226,7 @@ class ExportManager * * @internal used by DI * - * @param type $alias + * @param string $alias */ public function addFormatter(FormatterInterface $formatter, $alias) { diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml index 74c495bff..4c7406577 100644 --- a/src/Bundle/ChillMainBundle/config/services.yaml +++ b/src/Bundle/ChillMainBundle/config/services.yaml @@ -90,6 +90,12 @@ services: Chill\MainBundle\Export\ExportManager: autoconfigure: true autowire: true + arguments: + $exports: !tagged_iterator { tag: chill.export, index_by: alias } + $aggregators: !tagged_iterator { tag: chill.export_aggregator, index_by: alias } + $filters: !tagged_iterator { tag: chill.export_filter, index_by: alias } + $formatters: !tagged_iterator { tag: chill.export_formatter, index_by: alias } + $exportElementProvider: !tagged_iterator { tag: chill.export_elements_provider, index_by: prefix } Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface: '@Chill\MainBundle\Security\Resolver\CenterResolverDispatcher'