Procházet zdrojové kódy

Correctif mineur

packProduct
Fabien Normand před 3 roky
rodič
revize
9b3f24e73c
5 změnil soubory, kde provedl 169 přidání a 5 odebrání
  1. +9
    -3
      Definition/Field/User/UserMerchantFieldDefinition.php
  2. +38
    -0
      Field/Filter/User/UserMerchantEmailFilter.php
  3. +38
    -0
      Field/Filter/User/UserMerchantFirstnameFilter.php
  4. +41
    -0
      Field/Filter/User/UserMerchantLastnameFilter.php
  5. +43
    -2
      Repository/User/UserMerchantRepositoryQuery.php

+ 9
- 3
Definition/Field/User/UserMerchantFieldDefinition.php Zobrazit soubor

@@ -7,6 +7,9 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Field\AssociationField;
use Lc\CaracoleBundle\Field\Filter\User\UserMerchantEmailFilter;
use Lc\CaracoleBundle\Field\Filter\User\UserMerchantFirstnameFilter;
use Lc\CaracoleBundle\Field\Filter\User\UserMerchantLastnameFilter;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;


@@ -38,9 +41,12 @@ class UserMerchantFieldDefinition extends AbstractFieldDefinition

return [
'id'=> IntegerField::new('id')->onlyOnIndex()->setSortable(true),
'lastname'=> TextField::new('user.lastname')->setSortable(true),
'firstname'=> TextField::new('user.firstname')->setSortable(true),
'email'=> TextField::new('user.email')->setSortable(true),
'lastname'=> TextField::new('user.lastname')->setSortable(true)
->setCustomOption('filter_fqcn', UserMerchantLastnameFilter::class),
'firstname'=> TextField::new('user.firstname')->setSortable(true)
->setCustomOption('filter_fqcn', UserMerchantFirstnameFilter::class),
'email'=> TextField::new('user.email')->setSortable(true)
->setCustomOption('filter_fqcn', UserMerchantEmailFilter::class),
'credit'=> NumberField::new('credit')->setSortable(true)
->setTemplatePath('@LcSov/adminlte/crud/field/amount.html.twig')
->setCustomOption('appendHtml', '€'),

+ 38
- 0
Field/Filter/User/UserMerchantEmailFilter.php Zobrazit soubor

@@ -0,0 +1,38 @@
<?php

namespace Lc\CaracoleBundle\Field\Filter\User;

use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use Lc\SovBundle\Field\Filter\AssociationFilter;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* @author La clic ! <contact@laclic.fr>
*/
class UserMerchantEmailFilter extends AssociationFilter
{
public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array())
{
$builder->add(
$this->getFieldPropertySnake($fieldDto->getProperty()),
TextType::class,
array(
'required' => false,
'attr' => array(
'class' => ' input-sm',
'form' => 'filters-form',
),
)
);
}

public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null)
{
if ($filteredValue !== null) {
$repositoryQuery->filterByEmail('%'.$filteredValue.'%');
}
}

}

+ 38
- 0
Field/Filter/User/UserMerchantFirstnameFilter.php Zobrazit soubor

@@ -0,0 +1,38 @@
<?php

namespace Lc\CaracoleBundle\Field\Filter\User;

use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use Lc\SovBundle\Field\Filter\AssociationFilter;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* @author La clic ! <contact@laclic.fr>
*/
class UserMerchantFirstnameFilter extends AssociationFilter
{
public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array())
{
$builder->add(
$this->getFieldPropertySnake($fieldDto->getProperty()),
TextType::class,
array(
'required' => false,
'attr' => array(
'class' => ' input-sm',
'form' => 'filters-form',
),
)
);
}

public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null)
{
if ($filteredValue !== null) {
$repositoryQuery->filterByFirstname('%'.$filteredValue.'%');
}
}

}

+ 41
- 0
Field/Filter/User/UserMerchantLastnameFilter.php Zobrazit soubor

@@ -0,0 +1,41 @@
<?php

namespace Lc\CaracoleBundle\Field\Filter\User;

use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use Lc\SovBundle\Field\Filter\AssociationFilter;
use Lc\SovBundle\Field\Filter\FilterTrait;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* @author La clic ! <contact@laclic.fr>
*/
class UserMerchantLastnameFilter
{
use FilterTrait;
public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array())
{

$builder->add(
$this->getFieldPropertySnake($fieldDto->getProperty()),
TextType::class,
array(
'required' => false,
'attr' => array(
'class' => ' input-sm',
'form' => 'filters-form',
),
)
);
}

public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null)
{
if ($filteredValue !== null) {
$repositoryQuery->filterByLastname('%'.$filteredValue.'%');
}
}

}

+ 43
- 2
Repository/User/UserMerchantRepositoryQuery.php Zobrazit soubor

@@ -11,6 +11,9 @@ class UserMerchantRepositoryQuery extends AbstractRepositoryQuery
{
use MerchantRepositoryQueryTrait;

protected $isJoinUser = false;


public function __construct(UserMerchantRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'userMerchant', $paginator);
@@ -19,8 +22,46 @@ class UserMerchantRepositoryQuery extends AbstractRepositoryQuery
public function filterByUser(UserInterface $user)
{
return $this
->andWhere('.user = :user')
->setParameter('user', $user);
->andWhere('.user = :user')
->setParameter('user', $user);
}

public function joinUser(): self
{
if (!$this->isJoinUser) {
$this->isJoinUser = true;

return $this
->leftJoin('.user', 'user');
}
return $this;
}

public function filterByFirstname(string $firstname)
{
$this->joinUser();

return $this
->andWhere('user.firstname LIKE :firstname')
->setParameter('firstname', $firstname);
}

public function filterByLastname(string $lastname)
{
$this->joinUser();

return $this
->andWhere('user.lastname LIKE :lastname')
->setParameter('lastname', $lastname);
}

public function filterByEmail(string $email)
{
$this->joinUser();

return $this
->andWhere('user.email LIKE :email')
->setParameter('email', $email);
}

public function filterIsCreditActive()

Načítá se…
Zrušit
Uložit