*/ class ImageFilter { use FilterTrait; public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array()) { $targetEntity = $options['entity_dto']->getPropertyMetadata($fieldDto->getProperty())->get('targetEntity'); $builder->add( $fieldDto->getProperty(), ChoiceType::class, array( 'required' => false, 'choices' => array( 'Sans image' => 0, 'Avec image' => 1, ), 'attr' => array( 'class' => 'select2 input-sm', 'form' => 'filters-form', ), ) ); } public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null) { $fieldProperty = $this->getFieldProperty($fieldDto); if ($filteredValue !== null) { if($filteredValue === 1){ $repositoryQuery->andWhere( '.' . $fieldProperty . ' IS NOT NULL' ); }else{ $repositoryQuery->andWhere( '.' . $fieldProperty . ' IS NULL' ); } } } }