public function onKernelRequest(GetResponseEvent $event) { // In legacy_mode, roles and policies must be delegated to legacy kernel. if ($this->configResolver->getParameter('legacy_mode')) { return; } parent::onKernelRequest($event); }
public function testOnKernelRequestAccessGranted() { $request = new Request(); $request->attributes->set('siteaccess', new SiteAccess()); $event = new GetResponseEvent($this->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface'), $request, HttpKernelInterface::MASTER_REQUEST); $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface'); $token->expects($this->any())->method('getUsername')->will($this->returnValue('foo')); $this->tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($token)); $this->authChecker->expects($this->once())->method('isGranted')->will($this->returnValue(true)); // Nothing should happen or should be returned. $this->listener->onKernelRequest($event); }