I'm new in Symfony, but I see that it's very good framework. Now I'm working with Yii and some moments in Symfony can't understand... Sorry)
How can I take GET-parameter from any controller (for example ?ref=), processing it parameter (save REF ID in session) and return current user for current page but without this GET-parameter?
kernel.request
event. Return a redirect response to the very same URL but without ref
parameter:
public function onKernelRequest(GetResponseEvent $event) { if (!$event->isMasterRequest()) { return; } if (!$event->getRequest()->query->has('ref')) { return; } $ref = $event->getRequest()->query->get('ref'); // do whatever you need $url = ...; // prepare redirect URL $event->setResponse(new RedirectResponse($url)); }
You need to use next construction:
http://example?ref=123
public function indexAction(Request $request)
{
$ref = $request->query->get('ref');
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.