- CRUD - Create, Read, Update, Delete. So, CRUD controllers work with defined object. When you create actions in your CRUD controller you have to get the object, otherwise - your action won't know which object to create, update, delete, etc.
-
That's why you should to put object's id to your route.
public function superAction(Request $request, $id = null)
{
try {
if ($id !== null) {
$yourObject = $this->admin->getObject($id);
}
} catch (NotFoundHttpException $e) {
error_log($e->getMessage());
}
//... your logic
}
But! If your action doesn't supposed to use particular object - you can avoid object $id
in your route. Also you are able to pass the variables with GET method. As many as you wish.
Imagine, that you want to update all your objects. Then you can create updateAllAction()
and then add this route:
/**
* @param RouteCollection $collection
*/
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('updateAll', 'update/all');
}
As long as your action doesn't care of the particular object you can avoid $this->getRouterIdParameter()
in your uri.
Hope it is helpful.