*/ 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) { // if ($this->isRelationField($fieldProperty)) { // $aliasRelation = $this->getFieldPropertyRelationAlias($fieldProperty); // if (array_search($aliasRelation, $repositoryQuery->getAllAliases()) === false) { // $repositoryQuery->innerJoin('entity.'.$aliasRelation, $aliasRelation); // } // $repositoryQuery->andWhere( // $fieldProperty.' LIKE :'.$this->getFieldPropertySnake($fieldProperty).'' // ); // $repositoryQuery->setParameter( // $this->getFieldPropertySnake($fieldProperty), // '%'.$filteredValue.'%' // ); // } else { $repositoryQuery->andWhere( '.'.$fieldProperty.' LIKE :'.$fieldProperty.'' ); $repositoryQuery->setParameter($fieldProperty, '%'.$filteredValue.'%'); } } }