add an interface for export which are lists

Lists does not supports aggregators.

The export manager will filter the aggregators applying on the export
depending on the interface implemented by the export: if the export implements
`Export\ListInterface`, no aggregators will be returned for this export.
This commit is contained in:
2016-12-09 19:52:54 +01:00
parent dc59c99f70
commit 9d18581db1
6 changed files with 44 additions and 3 deletions

View File

@@ -33,6 +33,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt
use Chill\MainBundle\Form\Type\Export\PickCenterType;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
use Chill\MainBundle\Form\Type\Export\ExportType;
use Chill\MainBundle\Export\ListInterface;
/**
* Collects all agregators, filters and export from
@@ -235,6 +236,11 @@ class ExportManager
return $this->filters[$alias];
}
/**
* get all filters
*
* @param \Generator $aliases
*/
public function getFilters(array $aliases)
{
foreach($aliases as $alias) {
@@ -273,6 +279,13 @@ class ExportManager
return $this->formatters[$alias];
}
/**
* Get all formatters which supports one of the given types.
*
*
* @param array $types
* @return \Generator
*/
public function getFormattersByTypes(array $types)
{
foreach ($this->formatters as $alias => $formatter) {
@@ -358,12 +371,17 @@ class ExportManager
}
/**
* Return a \Generator containing aggregators which support type
* Return a \Generator containing aggregators supported by the given export
*
* @internal This class check the interface implemented by export, and, if ´ListInterface´ is used, return an empty array
* @return AggregatorInterface[] a \Generator that contains aggretagors. The key is the filter's alias
*/
public function &getAggregatorsApplyingOn(ExportInterface $export, array $centers = null)
{
if ($export instanceof ListInterface) {
return array();
}
foreach ($this->aggregators as $alias => $aggregator) {
if (in_array($aggregator->applyOn(), $export->supportsModifiers()) &&
$this->isGrantedForElement($aggregator, $export, $centers)) {