followed by batch action documentation in sonata admin's website, created this custom batch action called AnalayseController.php:
<?php
namespace Admin\Store\Receipt\ReceiptBundle\Controller;
use Sonata\AdminBundle\Controller\CRUDController as BaseController;
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
class AnalyseController extends BaseController
{
/**
* @param ProxyQueryInterface $selectedModelQuery
* @param Request $request
*
* @return RedirectResponse
*/
public function batchActionAnalyse(ProxyQueryInterface $selectedModelQuery, Request $request = null)
{
$request = $this->get('request');
$modelManager = $this->admin->getModelManager();
$target = $modelManager->find($this->admin->getClass(), $request->get('targetId'));
if ($target === null){
$this->addFlash('sonata_flash_info', 'No target!');
return new RedirectResponse(
$this->admin->generateUrl('list', $this->admin->getFilterParameters())
);
}
$selectedModels = $selectedModelQuery->execute();
$this->addFlash('sonata_flash_success', 'Done');
return new RedirectResponse(
$this->admin->generateUrl('list', $this->admin->getFilterParameters())
);
}
}
but I'm getting this error: Catchable Fatal Error: Argument 1 passed to Admin\Store\Receipt\ReceiptBundle\Controller\AnalyseController::batchActionAnalyse() must implement interface Sonata\AdminBundle\Datagrid\ProxyQueryInterface, string given, called in /home/aien/Web/Mr Alef/MRA_Dev/app/cache/dev/appDevDebugProjectContainer.php on line 852 and defined
.
looked everywhere, but couldn't find any solution!