*/ class ChoiceFilter { use FilterTrait; protected $translatorAdmin; public function __construct(?TranslatorAdmin $translatorAdmin = null) { $this->translatorAdmin = $translatorAdmin; } public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array()) { if($fieldDto->getCustomOption('choices')){ $choices = $fieldDto->getCustomOption('choices'); }else if($fieldDto->getFormTypeOption('choices') !=null){ $choices = $fieldDto->getFormTypeOption('choices'); }else{ $choices = array(); } $builder->add( $fieldDto->getProperty(), ChoiceType::class, array( 'required' => false, 'choices' => $choices, 'attr' => array( 'class' => 'select2 input-sm', 'form' => 'filters-form', ), ) ); } public function applyFilter(RepositoryQueryInterface $repositoryQuery , FieldDto $fieldDto, string $filteredValue = null) { $fieldProperty = $this->getFieldProperty($fieldDto); if ($filteredValue !== null) { $repositoryQuery->andWhere( '.'.$fieldProperty.' LIKE :'.$fieldProperty.'' ); $repositoryQuery->setParameter($fieldProperty, $filteredValue); } } }