mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 10:33:49 +00:00
add exportElementProvider to provide elements dynamically to export manager
This commit is contained in:
@@ -169,6 +169,26 @@ class ExportManager
|
||||
$this->formatters[$alias] = $formatter;
|
||||
}
|
||||
|
||||
public function addExportElementsProvider(ExportElementsProviderInterface $provider, $prefix)
|
||||
{
|
||||
foreach ($provider->getExportElements() as $suffix => $element) {
|
||||
$alias = $prefix.'_'.$suffix;
|
||||
|
||||
if ($element instanceof ExportInterface) {
|
||||
$this->addExport($element, $alias);
|
||||
} elseif ($element instanceof FilterInterface) {
|
||||
$this->addFilter($element, $alias);
|
||||
} elseif ($element instanceof AggregatorInterface) {
|
||||
$this->addAggregator($element, $alias);
|
||||
} elseif ($element instanceof FormatterInterface) {
|
||||
$this->addFormatter($element, $alias);
|
||||
} else {
|
||||
throw new \LogicException("This element ".\get_class($element)." "
|
||||
. "is not an instance of export element");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string[] the existing type for known exports
|
||||
|
Reference in New Issue
Block a user