diff --git a/Export/Aggregator/GenderAggregator.php b/Export/Aggregator/GenderAggregator.php index 56cbfacfa..bc75c4350 100644 --- a/Export/Aggregator/GenderAggregator.php +++ b/Export/Aggregator/GenderAggregator.php @@ -24,8 +24,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Translation\TranslatorInterface; use Chill\PersonBundle\Entity\Person; -use Chill\PersonBundle\Security\Authorization\PersonVoter; -use Symfony\Component\Security\Core\Role\Role; +use Chill\PersonBundle\Export\Declarations; /** * @@ -48,7 +47,7 @@ class GenderAggregator implements AggregatorInterface public function applyOn() { - return 'person'; + return Declarations::PERSON_TYPE; } @@ -85,9 +84,9 @@ class GenderAggregator implements AggregatorInterface ); } - public function requiredRole() + public function addRole() { - return new Role(PersonVoter::STATS); + return NULL; } } diff --git a/Export/Aggregator/NationalityAggregator.php b/Export/Aggregator/NationalityAggregator.php index dbbaaa596..834921f68 100644 --- a/Export/Aggregator/NationalityAggregator.php +++ b/Export/Aggregator/NationalityAggregator.php @@ -125,9 +125,9 @@ class NationalityAggregator implements AggregatorInterface return array('nationality_aggregator'); } - public function requiredRole() + public function addRole() { - return new Role(PersonVoter::STATS); + return NULL; } public function getLabels($key, array $values, $data) diff --git a/Export/Declarations.php b/Export/Declarations.php new file mode 100644 index 000000000..6c0735d18 --- /dev/null +++ b/Export/Declarations.php @@ -0,0 +1,31 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\PersonBundle\Export; + +/** + * This class declare constants used for the export framework. + * + * + * @author Julien Fastré + */ +abstract class Declarations +{ + CONST PERSON_TYPE = 'person'; +} diff --git a/Export/Export/CountPerson.php b/Export/Export/CountPerson.php index 9adeee712..df7611c25 100644 --- a/Export/Export/CountPerson.php +++ b/Export/Export/CountPerson.php @@ -25,6 +25,8 @@ use Symfony\Component\Form\FormBuilderInterface; use Doctrine\ORM\Query; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Symfony\Component\Security\Core\Role\Role; +use Chill\PersonBundle\Export\Declarations; +use Chill\MainBundle\Export\FormatterInterface; /** * @@ -38,7 +40,7 @@ class CountPerson implements ExportInterface */ public function getType() { - return 'person'; + return Declarations::PERSON_TYPE; } public function getDescription() @@ -62,7 +64,7 @@ class CountPerson implements ExportInterface * @param QueryBuilder $qb * @return QueryBuilder */ - public function initiateQuery(QueryBuilder $qb, array $requiredModifiers, $acl) + public function initiateQuery(QueryBuilder $qb, array $requiredModifiers, array $acl, array $data = array()) { $centers = array_map(function($el) { return $el['center']; }, $acl); @@ -77,7 +79,7 @@ class CountPerson implements ExportInterface return $qb; } - public function getResult($qb, $data) + public function getResult(QueryBuilder $qb, $data) { return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); } @@ -101,20 +103,16 @@ class CountPerson implements ExportInterface public function getAllowedFormattersTypes() { - return array('tabular'); + return array(FormatterInterface::TYPE_TABULAR); } public function buildForm(FormBuilderInterface $builder) { - throw new \LogicException('This export does not require a form'); - } - - public function hasForm(){ - return false; + } public function supportsModifiers() { - return array('person'); + return array(Declarations::PERSON_TYPE); } } diff --git a/Export/Filter/GenderFilter.php b/Export/Filter/GenderFilter.php index f1ae8f7e2..14aba4376 100644 --- a/Export/Filter/GenderFilter.php +++ b/Export/Filter/GenderFilter.php @@ -80,8 +80,8 @@ class GenderFilter implements FilterInterface return 'Filter by person gender'; } - public function requiredRole() + public function addRole() { - return new Role(\Chill\PersonBundle\Security\Authorization\PersonVoter::STATS); + return NULL; } } diff --git a/Export/Filter/NationalityFilter.php b/Export/Filter/NationalityFilter.php index 6b2d5966e..136002853 100644 --- a/Export/Filter/NationalityFilter.php +++ b/Export/Filter/NationalityFilter.php @@ -65,8 +65,8 @@ class NationalityFilter implements FilterInterface return "Filter by person's nationality"; } - public function requiredRole() + public function addRole() { - return new Role(\Chill\PersonBundle\Security\Authorization\PersonVoter::STATS); + return NULL; } }