diff --git a/Export/ExportInterface.php b/Export/ExportInterface.php index 5a9eba124..5b68b491f 100644 --- a/Export/ExportInterface.php +++ b/Export/ExportInterface.php @@ -25,6 +25,10 @@ use Doctrine\ORM\QueryBuilder; * Interface for Export. * * An export is a class which will initiate a query for an export. + * + * **Note** : the report implementing this class will be modified by + * both filters **and** aggregators. If the report does not support + * aggregation, use `ListInterface`. * * @example Chill\PersonBundle\Export\CountPerson an example of implementation * @author Julien Fastré diff --git a/Export/ExportManager.php b/Export/ExportManager.php index 35010b827..3a5e15afc 100644 --- a/Export/ExportManager.php +++ b/Export/ExportManager.php @@ -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)) { diff --git a/Export/Formatter/CSVListFormatter.php b/Export/Formatter/CSVListFormatter.php index a94b5f6a9..190c7308f 100644 --- a/Export/Formatter/CSVListFormatter.php +++ b/Export/Formatter/CSVListFormatter.php @@ -182,7 +182,8 @@ class CSVListFormatter implements FormatterInterface } foreach ($first_row as $key => $value) { - $header_line[] = $this->getLabel($key, '_header'); + $header_line[] = $this->translator->trans( + $this->getLabel($key, '_header')); } if (count($header_line) > 0) { diff --git a/Export/ListInterface.php b/Export/ListInterface.php new file mode 100644 index 000000000..2baab8565 --- /dev/null +++ b/Export/ListInterface.php @@ -0,0 +1,17 @@ +add($filterBuilder); - //add aggregators + //add aggregators $aggregators = $this->exportManager ->getAggregatorsApplyingOn($export, $options['picked_centers']); $aggregatorBuilder = $builder->create(self::AGGREGATOR_KEY, 'form', diff --git a/Resources/views/Form/fields.html.twig b/Resources/views/Form/fields.html.twig index 57c29f882..df758ce60 100644 --- a/Resources/views/Form/fields.html.twig +++ b/Resources/views/Form/fields.html.twig @@ -58,6 +58,7 @@ {{ form_widget(child) }} {{ form_label(child, '', {'label_attr': { 'class' : 'inline'} }) }} +
{% endfor %}