mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 18:13:48 +00:00
adapt filters to new interface + add message for nationality filter
This commit is contained in:
@@ -84,4 +84,9 @@ class GenderFilter implements FilterInterface
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,9 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Chill\MainBundle\Entity\Country;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -32,6 +34,17 @@ use Symfony\Component\Security\Core\Role\Role;
|
||||
*/
|
||||
class NationalityFilter implements FilterInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var TranslatableStringHelper
|
||||
*/
|
||||
private $translatableStringHelper;
|
||||
|
||||
public function __construct(TranslatableStringHelper $helper)
|
||||
{
|
||||
$this->translatableStringHelper = $helper;
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return 'person';
|
||||
@@ -69,4 +82,18 @@ class NationalityFilter implements FilterInterface
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
$countries = $data['nationalities'];
|
||||
|
||||
$names = array_map(function(Country $c) {
|
||||
return $this->translatableStringHelper->localize($c->getName());
|
||||
}, array($countries));
|
||||
|
||||
return array(
|
||||
"Filtered by nationality : %nationalities%",
|
||||
array('%nationalities%' => implode(", ", $names))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user