fix deprecations: replace many strings by fqcn

This commit is contained in:
nobohan
2018-04-04 15:02:16 +02:00
parent 2eb81ab3ec
commit 678386ffd6
7 changed files with 168 additions and 159 deletions

View File

@@ -27,27 +27,28 @@ use Doctrine\ORM\Query\Expr;
use Symfony\Component\Security\Core\Role\Role;
use Chill\MainBundle\Export\ExportElementValidatedInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
/**
*
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class GenderFilter implements FilterInterface,
ExportElementValidatedInterface
{
public function applyOn()
{
return 'person';
}
/**
*
*
*/
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('accepted_genders', 'choice', array(
$builder->add('accepted_genders', ChoiceType::class, array(
'choices' => array(
Person::FEMALE_GENDER => 'Woman',
Person::MALE_GENDER => 'Man'
@@ -56,7 +57,7 @@ class GenderFilter implements FilterInterface,
'expanded' => false
));
}
public function validateForm($data, ExecutionContextInterface $context)
{
if (count($data['accepted_genders']) === 0) {
@@ -64,38 +65,38 @@ class GenderFilter implements FilterInterface,
->addViolation();
}
}
public function alterQuery(QueryBuilder $qb, $data)
{
$where = $qb->getDQLPart('where');
$clause = $qb->expr()->in('person.gender', ':person_gender');
if ($where instanceof Expr\Andx) {
$where->add($clause);
} else {
$where = $qb->expr()->andX($clause);
}
$qb->add('where', $where);
$qb->setParameter('person_gender', $data['accepted_genders']);
}
/**
* A title which will be used in the label for the form
*
*
* @return string
*/
public function getTitle()
{
return 'Filter by person gender';
}
public function addRole()
{
return NULL;
}
public function describeAction($data, $format = 'string')
{
switch($data['accepted_genders']) {