mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 22:04:23 +00:00
Merge remote-tracking branch 'framagit-julien/export' into export
This commit is contained in:
commit
4efbfd4bfc
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
31
Export/Declarations.php
Normal 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';
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user