Browse Source

translation filter

develop
Charly 3 years ago
parent
commit
d83c42336c
2 changed files with 6 additions and 3 deletions
  1. +5
    -2
      Field/Filter/FilterManager.php
  2. +1
    -1
      Form/Common/FiltersFormType.php

+ 5
- 2
Field/Filter/FilterManager.php View File

use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use Lc\SovBundle\Repository\RepositoryQueryInterface; use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
{ {
protected $em; protected $em;
protected bool $isFiltered = false; protected bool $isFiltered = false;
protected $translatorAdmin;


use FilterTrait; use FilterTrait;


public function __construct(SessionInterface $session, EntityManagerInterface $entityManager)
public function __construct(SessionInterface $session, EntityManagerInterface $entityManager, TranslatorAdmin $translatorAdmin)
{ {
$this->session = $session; $this->session = $session;
$this->em = $entityManager; $this->em = $entityManager;
$this->translatorAdmin = $translatorAdmin;
} }




{ {
if ($fieldDto->getCustomOption('filter_fqcn')) { if ($fieldDto->getCustomOption('filter_fqcn')) {
$filterFqcn = $fieldDto->getCustomOption('filter_fqcn'); $filterFqcn = $fieldDto->getCustomOption('filter_fqcn');
$customFilter = new $filterFqcn;
$customFilter = new $filterFqcn($this->translatorAdmin);


$customFilter->applyFilter($repositoryQuery, $fieldDto, $filteredValue['value']); $customFilter->applyFilter($repositoryQuery, $fieldDto, $filteredValue['value']);
} else { } else {

+ 1
- 1
Form/Common/FiltersFormType.php View File

if ($fieldDto->isDisplayedOn(Crud::PAGE_INDEX) && $fieldDto->getCustomOption('filter')!==false) { if ($fieldDto->isDisplayedOn(Crud::PAGE_INDEX) && $fieldDto->getCustomOption('filter')!==false) {
if($fieldDto->getCustomOption('filter_fqcn')){ if($fieldDto->getCustomOption('filter_fqcn')){
$filterFqcn = $fieldDto->getCustomOption('filter_fqcn'); $filterFqcn = $fieldDto->getCustomOption('filter_fqcn');
$checkboxFilter = new $filterFqcn;
$checkboxFilter = new $filterFqcn($this->translatorAdmin);
$checkboxFilter->buildProperty($builder, $fieldDto, $options); $checkboxFilter->buildProperty($builder, $fieldDto, $options);
}else { }else {



Loading…
Cancel
Save