mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
Merge branch '111_exports_suite' into calendar/finalization
This commit is contained in:
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\DependencyInjection\CompilerPass;
|
||||
|
||||
use Chill\MainBundle\Export\ExportManager;
|
||||
use LogicException;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
@@ -30,53 +31,19 @@ class ExportsCompilerPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->has('Chill\MainBundle\Export\ExportManager')) {
|
||||
throw new LogicException('service Chill\MainBundle\Export\ExportManager '
|
||||
if (!$container->has(ExportManager::class)) {
|
||||
throw new LogicException('service ' . ExportManager::class . ' '
|
||||
. 'is not defined. It is required by ExportsCompilerPass');
|
||||
}
|
||||
|
||||
$chillManagerDefinition = $container->findDefinition(
|
||||
'Chill\MainBundle\Export\ExportManager'
|
||||
ExportManager::class
|
||||
);
|
||||
|
||||
$this->compileExports($chillManagerDefinition, $container);
|
||||
$this->compileFilters($chillManagerDefinition, $container);
|
||||
$this->compileAggregators($chillManagerDefinition, $container);
|
||||
$this->compileFormatters($chillManagerDefinition, $container);
|
||||
$this->compileExportElementsProvider($chillManagerDefinition, $container);
|
||||
}
|
||||
|
||||
private function compileAggregators(
|
||||
Definition $chillManagerDefinition,
|
||||
ContainerBuilder $container
|
||||
) {
|
||||
$taggedServices = $container->findTaggedServiceIds(
|
||||
'chill.export_aggregator'
|
||||
);
|
||||
|
||||
$knownAliases = [];
|
||||
|
||||
foreach ($taggedServices as $id => $tagAttributes) {
|
||||
foreach ($tagAttributes as $attributes) {
|
||||
if (!isset($attributes['alias'])) {
|
||||
throw new LogicException("the 'alias' attribute is missing in your " .
|
||||
"service '{$id}' definition");
|
||||
}
|
||||
|
||||
if (array_search($attributes['alias'], $knownAliases, true)) {
|
||||
throw new LogicException('There is already a chill.export_aggregator service with alias '
|
||||
. $attributes['alias'] . '. Choose another alias.');
|
||||
}
|
||||
$knownAliases[] = $attributes['alias'];
|
||||
|
||||
$chillManagerDefinition->addMethodCall(
|
||||
'addAggregator',
|
||||
[new Reference($id), $attributes['alias']]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function compileExportElementsProvider(
|
||||
Definition $chillManagerDefinition,
|
||||
ContainerBuilder $container
|
||||
@@ -108,68 +75,6 @@ class ExportsCompilerPass implements CompilerPassInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function compileExports(
|
||||
Definition $chillManagerDefinition,
|
||||
ContainerBuilder $container
|
||||
) {
|
||||
$taggedServices = $container->findTaggedServiceIds(
|
||||
'chill.export'
|
||||
);
|
||||
|
||||
$knownAliases = [];
|
||||
|
||||
foreach ($taggedServices as $id => $tagAttributes) {
|
||||
foreach ($tagAttributes as $attributes) {
|
||||
if (!isset($attributes['alias'])) {
|
||||
throw new LogicException("the 'alias' attribute is missing in your " .
|
||||
"service '{$id}' definition");
|
||||
}
|
||||
|
||||
if (array_search($attributes['alias'], $knownAliases, true)) {
|
||||
throw new LogicException('There is already a chill.export service with alias '
|
||||
. $attributes['alias'] . '. Choose another alias.');
|
||||
}
|
||||
$knownAliases[] = $attributes['alias'];
|
||||
|
||||
$chillManagerDefinition->addMethodCall(
|
||||
'addExport',
|
||||
[new Reference($id), $attributes['alias']]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function compileFilters(
|
||||
Definition $chillManagerDefinition,
|
||||
ContainerBuilder $container
|
||||
) {
|
||||
$taggedServices = $container->findTaggedServiceIds(
|
||||
'chill.export_filter'
|
||||
);
|
||||
|
||||
$knownAliases = [];
|
||||
|
||||
foreach ($taggedServices as $id => $tagAttributes) {
|
||||
foreach ($tagAttributes as $attributes) {
|
||||
if (!isset($attributes['alias'])) {
|
||||
throw new LogicException("the 'alias' attribute is missing in your " .
|
||||
"service '{$id}' definition");
|
||||
}
|
||||
|
||||
if (array_search($attributes['alias'], $knownAliases, true)) {
|
||||
throw new LogicException('There is already a chill.export_filter service with alias '
|
||||
. $attributes['alias'] . '. Choose another alias.');
|
||||
}
|
||||
$knownAliases[] = $attributes['alias'];
|
||||
|
||||
$chillManagerDefinition->addMethodCall(
|
||||
'addFilter',
|
||||
[new Reference($id), $attributes['alias']]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function compileFormatters(
|
||||
Definition $chillManagerDefinition,
|
||||
ContainerBuilder $container
|
||||
|
Reference in New Issue
Block a user