mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-02 14:07:43 +00:00
DX: use tags and dependency injection to build ExportManager
This commit is contained in:
parent
50e12375f8
commit
4ce56a01a7
@ -4,18 +4,15 @@ services:
|
|||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
|
|
||||||
## Indicators
|
## Indicators
|
||||||
chill.activity.export.count_activity_linked_to_person:
|
Chill\ActivityBundle\Export\Export\LinkedToPerson\CountActivity:
|
||||||
class: Chill\ActivityBundle\Export\Export\LinkedToPerson\CountActivity
|
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export, alias: 'count_activity_linked_to_person' }
|
- { name: chill.export, alias: 'count_activity_linked_to_person' }
|
||||||
|
|
||||||
chill.activity.export.sum_activity_duration_linked_to_person:
|
Chill\ActivityBundle\Export\Export\LinkedToPerson\StatActivityDuration:
|
||||||
class: Chill\ActivityBundle\Export\Export\LinkedToPerson\StatActivityDuration
|
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export, alias: 'sum_activity_duration_linked_to_person' }
|
- { name: chill.export, alias: 'sum_activity_duration_linked_to_person' }
|
||||||
|
|
||||||
chill.activity.export.list_activity_linked_to_person:
|
Chill\ActivityBundle\Export\Export\LinkedToPerson\ListActivity:
|
||||||
class: Chill\ActivityBundle\Export\Export\LinkedToPerson\ListActivity
|
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export, alias: 'list_activity_linked_to_person' }
|
- { name: chill.export, alias: 'list_activity_linked_to_person' }
|
||||||
|
|
||||||
@ -116,8 +113,7 @@ services:
|
|||||||
- { name: chill.export_filter, alias: 'activity_userscope_filter' }
|
- { name: chill.export_filter, alias: 'activity_userscope_filter' }
|
||||||
|
|
||||||
## Aggregators
|
## Aggregators
|
||||||
chill.activity.export.reason_aggregator:
|
Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator:
|
||||||
class: Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator
|
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: activity_reason_aggregator }
|
- { name: chill.export_aggregator, alias: activity_reason_aggregator }
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ use Symfony\Component\DependencyInjection\Definition;
|
|||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles the services tagged with :.
|
* Compiles the services tagged with :
|
||||||
*
|
*
|
||||||
* - chill.export
|
* - chill.export
|
||||||
* - chill.export_formatter
|
* - chill.export_formatter
|
||||||
@ -39,11 +39,11 @@ class ExportsCompilerPass implements CompilerPassInterface
|
|||||||
'Chill\MainBundle\Export\ExportManager'
|
'Chill\MainBundle\Export\ExportManager'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->compileExports($chillManagerDefinition, $container);
|
//$this->compileExports($chillManagerDefinition, $container);
|
||||||
$this->compileFilters($chillManagerDefinition, $container);
|
//$this->compileFilters($chillManagerDefinition, $container);
|
||||||
$this->compileAggregators($chillManagerDefinition, $container);
|
//$this->compileAggregators($chillManagerDefinition, $container);
|
||||||
$this->compileFormatters($chillManagerDefinition, $container);
|
//$this->compileFormatters($chillManagerDefinition, $container);
|
||||||
$this->compileExportElementsProvider($chillManagerDefinition, $container);
|
//$this->compileExportElementsProvider($chillManagerDefinition, $container);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function compileAggregators(
|
private function compileAggregators(
|
||||||
@ -119,6 +119,12 @@ class ExportsCompilerPass implements CompilerPassInterface
|
|||||||
$knownAliases = [];
|
$knownAliases = [];
|
||||||
|
|
||||||
foreach ($taggedServices as $id => $tagAttributes) {
|
foreach ($taggedServices as $id => $tagAttributes) {
|
||||||
|
|
||||||
|
if (!$container->has($id)) {
|
||||||
|
dump('the service was removed');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($tagAttributes as $attributes) {
|
foreach ($tagAttributes as $attributes) {
|
||||||
if (!isset($attributes['alias'])) {
|
if (!isset($attributes['alias'])) {
|
||||||
throw new LogicException("the 'alias' attribute is missing in your " .
|
throw new LogicException("the 'alias' attribute is missing in your " .
|
||||||
|
@ -85,13 +85,26 @@ class ExportManager
|
|||||||
EntityManagerInterface $em,
|
EntityManagerInterface $em,
|
||||||
AuthorizationCheckerInterface $authorizationChecker,
|
AuthorizationCheckerInterface $authorizationChecker,
|
||||||
AuthorizationHelperInterface $authorizationHelper,
|
AuthorizationHelperInterface $authorizationHelper,
|
||||||
TokenStorageInterface $tokenStorage
|
TokenStorageInterface $tokenStorage,
|
||||||
|
iterable $exports,
|
||||||
|
iterable $aggregators,
|
||||||
|
iterable $filters,
|
||||||
|
iterable $formatters,
|
||||||
|
iterable $exportElementProvider
|
||||||
) {
|
) {
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->authorizationChecker = $authorizationChecker;
|
$this->authorizationChecker = $authorizationChecker;
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
$this->user = $tokenStorage->getToken()->getUser();
|
$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
|
* @internal used by DI
|
||||||
*
|
*
|
||||||
* @param DirectExportInterface|ExportInterface $export
|
* @param DirectExportInterface|ExportInterface $export
|
||||||
* @param type $alias
|
* @param string $alias
|
||||||
*/
|
*/
|
||||||
public function addExport($export, $alias)
|
public function addExport($export, $alias)
|
||||||
{
|
{
|
||||||
@ -213,7 +226,7 @@ class ExportManager
|
|||||||
*
|
*
|
||||||
* @internal used by DI
|
* @internal used by DI
|
||||||
*
|
*
|
||||||
* @param type $alias
|
* @param string $alias
|
||||||
*/
|
*/
|
||||||
public function addFormatter(FormatterInterface $formatter, $alias)
|
public function addFormatter(FormatterInterface $formatter, $alias)
|
||||||
{
|
{
|
||||||
|
@ -90,6 +90,12 @@ services:
|
|||||||
Chill\MainBundle\Export\ExportManager:
|
Chill\MainBundle\Export\ExportManager:
|
||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
autowire: 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'
|
Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface: '@Chill\MainBundle\Security\Resolver\CenterResolverDispatcher'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user