mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 10:33:49 +00:00
fix deprecations: replace many strings by fqcn
This commit is contained in:
@@ -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']) {
|
||||
|
Reference in New Issue
Block a user