Browse Source

[Backend] Découpage et recherche sur champ user name/firstname/email

develop
Fab 3 years ago
parent
commit
f31a8367ca
2 changed files with 22 additions and 8 deletions
  1. +20
    -8
      ShopBundle/Controller/Backend/AdminController.php
  2. +2
    -0
      ShopBundle/Services/Utils.php

+ 20
- 8
ShopBundle/Controller/Backend/AdminController.php View File

$filter = $this->getListFilterParam($field['property']); $filter = $this->getListFilterParam($field['property']);
//$filter = $this->filtersForm->get($field['property'])->getData(); //$filter = $this->filtersForm->get($field['property'])->getData();
if ($filter !== null) { if ($filter !== null) {
if ($field['type_options']['multiple']) {
$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'] . '');
} else {
$queryBuilder->andWhere('entity.' . $field['property'] . ' = :' . $field['property'] . '');
}
if ($filter instanceof TreeInterface && $filter->getParent() == null) {
$queryBuilder->setParameter($field['property'], array_merge(array($filter), $filter->getChildrens()->toArray()));
} else {

//TODO Faut généraliser avec TreeInterface, ça ne doit pas être ici
if($field['property'] == 'productCategories') {

$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'].' OR product_categories.parent = :' . $field['property']);
$queryBuilder->setParameter($field['property'], $filter); $queryBuilder->setParameter($field['property'], $filter);
} }
else {
if ($field['type_options']['multiple']) {
$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'] . '');
}
else {
$queryBuilder->andWhere('entity.' . $field['property'] . ' = :' . $field['property'] . '');
}

if ($filter instanceof TreeInterface && $filter->getParent() == null) {
$queryBuilder->setParameter($field['property'], array_merge(array($filter), $filter->getChildrens()->toArray()));
}
else {
$queryBuilder->setParameter($field['property'], $filter);
}
}
} }
break; break;
case 'datetime': case 'datetime':

+ 2
- 0
ShopBundle/Services/Utils.php View File

use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Validator\Constraints\EqualTo; use Symfony\Component\Validator\Constraints\EqualTo;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;


class Utils class Utils
'class' => 'special-field' 'class' => 'special-field'
], ],
'constraints' => [ 'constraints' => [
new NotNull(),
new EqualTo(['value' => $this->parameterBag->get('app.captcha_value'), 'message' => 'Valeur incorrecte']) new EqualTo(['value' => $this->parameterBag->get('app.captcha_value'), 'message' => 'Valeur incorrecte'])
], ],
]); ]);

Loading…
Cancel
Save