mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 18:13:48 +00:00
add exportElementProvider to provide elements dynamically to export manager
This commit is contained in:
@@ -31,6 +31,7 @@ use Symfony\Component\DependencyInjection\Definition;
|
||||
* - chill.export_formatter
|
||||
* - chill.export_aggregator
|
||||
* - chill.export_filter
|
||||
* - chill.export_elements_provider
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
@@ -53,6 +54,7 @@ class ExportsCompilerPass implements CompilerPassInterface
|
||||
$this->compileFilters($chillManagerDefinition, $container);
|
||||
$this->compileAggregators($chillManagerDefinition, $container);
|
||||
$this->compileFormatters($chillManagerDefinition, $container);
|
||||
$this->compileExportElementsProvider($chillManagerDefinition, $container);
|
||||
}
|
||||
|
||||
private function compileExports(Definition $chillManagerDefinition,
|
||||
@@ -174,5 +176,35 @@ class ExportsCompilerPass implements CompilerPassInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function compileExportElementsProvider(Definition $chillManagerDefinition,
|
||||
ContainerBuilder $container)
|
||||
{
|
||||
$taggedServices = $container->findTaggedServiceIds(
|
||||
'chill.export_elements_provider'
|
||||
);
|
||||
|
||||
$knownAliases = array();
|
||||
|
||||
foreach ($taggedServices as $id => $tagAttributes) {
|
||||
foreach ($tagAttributes as $attributes) {
|
||||
if (!isset($attributes["prefix"])) {
|
||||
throw new \LogicException("the 'prefix' attribute is missing in your ".
|
||||
"service '$id' definition");
|
||||
}
|
||||
|
||||
if (array_search($attributes["prefix"], $knownAliases)) {
|
||||
throw new \LogicException("There is already a chill.export_elements_provider service with prefix "
|
||||
.$attributes["prefix"].". Choose another prefix.");
|
||||
}
|
||||
$knownAliases[] = $attributes["prefix"];
|
||||
|
||||
$chillManagerDefinition->addMethodCall(
|
||||
'addExportElementsProvider',
|
||||
array(new Reference($id), $attributes["prefix"])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user