We need to access to database info in a listener. We configure the listener in a service.yml The listener is like:
namespace companyMyBundleListener;
use SymfonyComponentHttpKernelEventGetResponseEvent;
use SymfonyComponentHttpKernelHttpKernelInterface;
use SymfonyComponentDependencyInjectionContainerInterface;
use SymfonyComponentSecurityCoreAuthenticationTokenTokenInterface;
use SymfonyComponentHttpFoundationRedirectResponse;
use SymfonyBundleFrameworkBundleControllerController;
class RequestListener
{
protected $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function onKernelRequest(GetResponseEvent $event)
{
...
我们怎样才能利用关于争端解决的理论?
我试图从控制员那里延伸,并做到:
$em = $this->getDoctrine()->getEntityManager();
这种做法是好的。