Answer the question
In order to leave comments, you need to log in
Why does $request->get('_route') return null in Symfony 2?
Applied the following listener
<?php
namespace Acme\HelloBundle\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
class AddressListener
{
public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
$routeName = $request->get('_route');
var_dump($routeName);
}
}
address:
path: /address/
defaults: { _controller: AcmeHelloBundle:Address:index }
requirements:
_method: GET
kernel.listener.address:
class: Acme\HelloBundle\EventListener\AddressListener
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question