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

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -