Skip to content

Commit

Permalink
Merge pull request sonata-project#3392 from core23/request-parameter
Browse files Browse the repository at this point in the history
Added request parameter to batchAction
  • Loading branch information
OskarStark committed Oct 29, 2015
2 parents 2bc3685 + a7b74af commit 0620ec7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,18 @@ public function listAction(Request $request = null)
* Execute a batch delete.
*
* @param ProxyQueryInterface $query
* @param Request $request
*
* @return RedirectResponse
*
* @throws AccessDeniedException If access is not granted
*/
public function batchActionDelete(ProxyQueryInterface $query)
public function batchActionDelete(ProxyQueryInterface $query, Request $request = null)
{
$this->admin->checkAccess('batchDelete');

$request = $this->resolveRequest($request);

$modelManager = $this->admin->getModelManager();
try {
$modelManager->batchDelete($this->admin->getClass(), $query);
Expand Down Expand Up @@ -568,7 +571,7 @@ public function batchAction(Request $request = null)
$isRelevantAction = sprintf('batchAction%sIsRelevant', ucfirst($camelizedAction));

if (method_exists($this, $isRelevantAction)) {
$nonRelevantMessage = call_user_func(array($this, $isRelevantAction), $idx, $allElements);
$nonRelevantMessage = call_user_func(array($this, $isRelevantAction), $idx, $allElements, $request);
} else {
$nonRelevantMessage = count($idx) != 0 || $allElements; // at least one item is selected
}
Expand Down Expand Up @@ -629,7 +632,7 @@ public function batchAction(Request $request = null)
$query = null;
}

return call_user_func(array($this, $finalAction), $query);
return call_user_func(array($this, $finalAction), $query, $request);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions Resources/doc/reference/batch_actions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ granularity), the passed query is ``null``.
{
/**
* @param ProxyQueryInterface $selectedModelQuery
* @param Request $request
*
* @return RedirectResponse
*/
public function batchActionMerge(ProxyQueryInterface $selectedModelQuery)
public function batchActionMerge(ProxyQueryInterface $selectedModelQuery, Request $request = null)
{
if (!$this->admin->isGranted('EDIT') || !$this->admin->isGranted('DELETE')) {
throw new AccessDeniedException();
Expand Down Expand Up @@ -193,7 +194,7 @@ This method may return three different values:
class CRUDController extends BaseController
{
public function batchActionMergeIsRelevant(array $selectedIds, $allEntitiesSelected)
public function batchActionMergeIsRelevant(array $selectedIds, $allEntitiesSelected, Request $request = null)
{
// here you have access to all POST parameters, if you use some custom ones
// POST parameters are kept even after the confirmation page.
Expand Down

0 comments on commit 0620ec7

Please sign in to comment.