routes - How to know who called an action of controller in symfony -
i'm working in symfony2 project, , have action of controller called 2 different pages. how can know page called action, can return different response according made request :
here's example of wanna do
public function deleteaction(file $file) { // delete file if (// request made first page) { return $this->redirect($this->generateurl('route_of_first_page'); } elseif (// request made second page) { return $this->redirect($this->generateurl('route_of_second_page'); } }
this way can stay in page made request
you need action have request parameter:
public function deleteaction(request $request, file $file)
and referer request object:
$previousurl = $request->headers->get('referer');
edit:
route object:
$router = $this->get('router'); $route = $router->match($previousurl);
Comments
Post a Comment