adapt elements to new interface definition

This commit is contained in:
Julien Fastré 2016-01-31 23:43:53 +01:00
parent e79aebabff
commit e616626cc2
6 changed files with 47 additions and 15 deletions

View File

@ -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;
}
}

View File

@ -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)

31
Export/Declarations.php Normal file
View File

@ -0,0 +1,31 @@
<?php
/*
* Copyright (C) 2016 Champs-Libres <info@champs-libres.coop>
*
* 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 <http://www.gnu.org/licenses/>.
*/
namespace Chill\PersonBundle\Export;
/**
* This class declare constants used for the export framework.
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
abstract class Declarations
{
CONST PERSON_TYPE = 'person';
}

View File

@ -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()
@ -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,7 +103,7 @@ class CountPerson implements ExportInterface
public function getAllowedFormattersTypes()
{
return array('tabular');
return array(FormatterInterface::TYPE_TABULAR);
}
public function buildForm(FormBuilderInterface $builder) {
@ -114,7 +116,7 @@ class CountPerson implements ExportInterface
public function supportsModifiers()
{
return array('person');
return array(Declarations::PERSON_TYPE);
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}