onKernelRequestRedirect() публичный Метод

The request attributes "needsRedirect" and "semanticPathinfo" are originally set in the UrlAliasRouter. Note: The event propagation will be stopped to ensure that no response can be set later and override the redirection.
См. также: eZ\Publish\Core\MVC\Symfony\Routing\UrlAliasRouter
public onKernelRequestRedirect ( GetResponseEvent $event )
$event Symfony\Component\HttpKernel\Event\GetResponseEvent
    public function testOnKernelRequestRedirectPrependSiteaccess()
    {
        $queryParameters = array( 'some' => 'thing' );
        $cookieParameters = array( 'cookie' => 'value' );
        $siteaccessMatcher = $this->getMock( 'eZ\Publish\Core\MVC\Symfony\SiteAccess\URILexer' );
        $siteaccess = new SiteAccess( 'test', 'foo', $siteaccessMatcher );
        $semanticPathinfo = '/foo/something';

        $request = Request::create( '/test_sa/foo/bar', 'GET', $queryParameters, $cookieParameters );
        $request->attributes->set( 'semanticPathinfo', $semanticPathinfo );
        $request->attributes->set( 'needsRedirect', true );
        $request->attributes->set( 'siteaccess', $siteaccess );
        $request->attributes->set( 'prependSiteaccessOnRedirect', true );

        $expectedURI = "/test$semanticPathinfo";
        $siteaccessMatcher
            ->expects( $this->once() )
            ->method( 'analyseLink' )
            ->with( $semanticPathinfo )
            ->will( $this->returnValue( $expectedURI ) );

        $event = new GetResponseEvent( $this->httpKernel, $request, HttpKernelInterface::MASTER_REQUEST );
        $this->requestEventListener->onKernelRequestRedirect( $event );
        $this->assertTrue( $event->hasResponse() );
        /** @var RedirectResponse $response */
        $response = $event->getResponse();
        $this->assertInstanceOf( 'Symfony\Component\HttpFoundation\RedirectResponse', $response );
        $this->assertSame( "$expectedURI?some=thing", $response->getTargetUrl() );
        $this->assertSame( 301, $response->getStatusCode() );
        $this->assertTrue( $event->isPropagationStopped() );
    }