|
|
@@ -60,7 +60,7 @@ class AdminController extends EasyAdminController |
|
|
|
]) ; |
|
|
|
} |
|
|
|
|
|
|
|
protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null) |
|
|
|
protected function commonDqlFilterQueryBuilder($entityClass, $dqlFilter) |
|
|
|
{ |
|
|
|
if ($pos = strpos($dqlFilter, 'currentMerchant')) { |
|
|
|
$dqlFilter = sprintf(str_replace('currentMerchant', $this->getUser()->getMerchant()->getId(), $dqlFilter)); |
|
|
@@ -71,14 +71,32 @@ class AdminController extends EasyAdminController |
|
|
|
else $dqlFilter .= sprintf(' entity.status > = 0'); |
|
|
|
} |
|
|
|
|
|
|
|
$queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter); |
|
|
|
return $dqlFilter; |
|
|
|
} |
|
|
|
|
|
|
|
protected function commonQueryFilter($entityClass, $queryBuilder) |
|
|
|
{ |
|
|
|
if ($entityClass == 'App\Entity\PointSale') { |
|
|
|
$queryBuilder->andWhere(':currentMerchant MEMBER OF entity.merchant') |
|
|
|
->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId()); |
|
|
|
} |
|
|
|
|
|
|
|
return $queryBuilder; |
|
|
|
} |
|
|
|
|
|
|
|
protected function createSearchQueryBuilder($entityClass, $searchQuery, array $searchableFields, $sortField = null, $sortDirection = null, $dqlFilter = null) |
|
|
|
{ |
|
|
|
$dqlFilter = $this->commonDqlFilterQueryBuilder($entityClass, $dqlFilter) ; |
|
|
|
$queryBuilder = parent::createSearchQueryBuilder($entityClass, $searchQuery, $searchableFields, $sortField, $sortDirection, $dqlFilter) ; |
|
|
|
$this->commonQueryFilter($entityClass, $queryBuilder) ; |
|
|
|
return $queryBuilder ; |
|
|
|
} |
|
|
|
|
|
|
|
protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null) |
|
|
|
{ |
|
|
|
$dqlFilter = $this->commonDqlFilterQueryBuilder($entityClass, $dqlFilter) ; |
|
|
|
$queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter); |
|
|
|
$this->commonQueryFilter($entityClass, $queryBuilder) ; |
|
|
|
return $queryBuilder ; |
|
|
|
} |
|
|
|
|
|
|
|
|