change params given to the callback of a global batch action (page removed, add selected items)
This commit is contained in:
parent
b9b07c1409
commit
67f79083ef
|
@ -287,7 +287,21 @@ abstract class CrudController extends AdminController
|
||||||
$useSelection = 'selection' === $target;
|
$useSelection = 'selection' === $target;
|
||||||
|
|
||||||
if ($batchAction['isGlobal']) {
|
if ($batchAction['isGlobal']) {
|
||||||
$result = $callback($query, $useSelection, $entityManager);
|
$selection = null;
|
||||||
|
|
||||||
|
if ($useSelection) {
|
||||||
|
$queryClone = clone $query;
|
||||||
|
$pager = $queryClone->paginate($page, $configuration->getMaxPerPage($context));
|
||||||
|
$selection = [];
|
||||||
|
|
||||||
|
foreach ($pager as $key => $entity) {
|
||||||
|
if (isset($items[$key + 1])) {
|
||||||
|
$selection[] = $entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $callback($query, $entityManager, $selection);
|
||||||
|
|
||||||
if ($result instanceof Response) {
|
if ($result instanceof Response) {
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -295,11 +309,11 @@ abstract class CrudController extends AdminController
|
||||||
|
|
||||||
return $this->redirect($request->query->get('redirectTo'));
|
return $this->redirect($request->query->get('redirectTo'));
|
||||||
}
|
}
|
||||||
if ('selection' === $target) {
|
|
||||||
$pager = $query->paginate($page, $configuration->getMaxPerPage($context));
|
$pager = $useSelection
|
||||||
} else {
|
? $query->paginate($page, $configuration->getMaxPerPage($context))
|
||||||
$pager = $query->find();
|
: $query->find()
|
||||||
}
|
;
|
||||||
|
|
||||||
foreach ($pager as $key => $entity) {
|
foreach ($pager as $key => $entity) {
|
||||||
if (($useSelection && isset($items[$key + 1])) || !$useSelection) {
|
if (($useSelection && isset($items[$key + 1])) || !$useSelection) {
|
||||||
|
|
Loading…
Reference in a new issue