|
- <?php
-
- namespace Lc\SovBundle\Field\Filter;
-
-
- use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
- use Symfony\Component\Form\Extension\Core\Type\IntegerType;
- use Symfony\Component\Form\FormBuilderInterface;
-
- /**
- * @author La clic ! <contact@laclic.fr>
- */
- class IntegerFilter
- {
- use FilterTrait;
-
-
- public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array())
- {
- $builder->add(
- str_replace('.', '_', $fieldDto->getProperty()),
- IntegerType::class,
- array(
- 'required' => false,
- 'attr' => array(
- 'class' => ' input-sm',
- 'form' => 'filters-form',
- ),
- )
- );
- }
-
- public function applyFilter(RepositoryQueryInterface $repositoryQuery, string $fieldProperty, string $filteredValue= null)
- {
- if ($filteredValue !== null) {
- $repositoryQuery->andWhere(
- '.'.$fieldProperty.' = :'.$fieldProperty.''
- );
- $repositoryQuery->setParameter($fieldProperty, $filteredValue);
- }
- }
-
- }
|