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