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

@@ -10,6 +10,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -31,13 +32,15 @@ class FilterManager
{
protected $em;
protected bool $isFiltered = false;
protected $translatorAdmin;

use FilterTrait;

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


@@ -93,7 +96,7 @@ class FilterManager
{
if ($fieldDto->getCustomOption('filter_fqcn')) {
$filterFqcn = $fieldDto->getCustomOption('filter_fqcn');
$customFilter = new $filterFqcn;
$customFilter = new $filterFqcn($this->translatorAdmin);

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

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

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


Loading…
Cancel
Save