Browse Source

Merge branch 'develop'

develop
Guillaume 3 years ago
parent
commit
5ec9e02b56
1 changed files with 30 additions and 18 deletions
  1. +30
    -18
      ShopBundle/Controller/Backend/AdminController.php

+ 30
- 18
ShopBundle/Controller/Backend/AdminController.php View File

if($easyadmin['view']=='listChildren') $view = 'list'; if($easyadmin['view']=='listChildren') $view = 'list';
if (($this->filtersForm->isSubmitted() && $this->filtersForm->isValid()) || $this->entity[$view]['filters']!==false) { if (($this->filtersForm->isSubmitted() && $this->filtersForm->isValid()) || $this->entity[$view]['filters']!==false) {
foreach ($listFields as $field) { foreach ($listFields as $field) {
//if ($this->filtersForm->has($field['property'])->getConfig()->getOption('AdminController')) {
if ($this->filtersForm->has($field['property'])) { if ($this->filtersForm->has($field['property'])) {
switch ($field['dataType']) { switch ($field['dataType']) {
case 'option': case 'option':
case 'string': case 'string':
case 'toggle': case 'toggle':
$filter = $this->getListFilterParam($field['property']); $filter = $this->getListFilterParam($field['property']);
//$filter = $this->filtersForm->get($field['property'])->getData();
if ($filter !== null) { if ($filter !== null) {

$queryBuilder->andWhere('entity.' . $field['property'] . ' LIKE :' . $field['property'] . ''); $queryBuilder->andWhere('entity.' . $field['property'] . ' LIKE :' . $field['property'] . '');
$queryBuilder->setParameter($field['property'], '%' . $filter . '%'); $queryBuilder->setParameter($field['property'], '%' . $filter . '%');
} }
break; break;
case 'association' : case 'association' :
$filter = $this->getListFilterParam($field['property']); $filter = $this->getListFilterParam($field['property']);
//$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 {

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':
} }




protected function getListParam($param, $default =null){
protected function getListParam($param, $default =null) {

$entityName = $this->entity['name']; $entityName = $this->entity['name'];
$sessionParam = $entityName.$param; $sessionParam = $entityName.$param;

//CUSTOM //CUSTOM
if($param == 'maxResults'){ if($param == 'maxResults'){
$val = $this->entity['list']['max_results'];
}else{
$val = $this->entity['list']['max_results'];
}
else{
$val = $this->request->query->get($param, $default); $val = $this->request->query->get($param, $default);
} }


if(isset($_GET[$param])){
if(isset($_GET[$param])) {
$val = $this->request->query->get($param); $val = $this->request->query->get($param);
$this->session->set($sessionParam, $val); $this->session->set($sessionParam, $val);
}else if($this->session->get($sessionParam)){
$val = $this->session->get($sessionParam);
}
elseif($this->session->get($sessionParam)) {
$val = $this->session->get($sessionParam);
$this->request->query->set($param, $val); $this->request->query->set($param, $val);
} }



Loading…
Cancel
Save