src/Event/Subscriber/ZoneSubscriber.php
/**
     * Determine the zone and return it.
     */
Determine the zone and return it.
Determine the zone and return it .
protected function determineZone(Request $request): string
    {
        if ($request->isXmlHttpRequest()) {
            return RequestZone::ASYNC;
        }
        $controller = $request->attributes->get('_controller');
        if (! is_string($controller)) {
            return RequestZone::NOWHERE;
        }
        $controller = explode('::', $controller);
        try {
            $reflection = new ReflectionClass($controller[0]);
            if ($reflection->implementsInterface(BackendZoneInterface::class)) {
                return RequestZone::BACKEND;
            } elseif ($reflection->implementsInterface(FrontendZoneInterface::class)) {
                return RequestZone::FRONTEND;
            } elseif ($reflection->implementsInterface(AsyncZoneInterface::class)) {
                return RequestZone::ASYNC;
            } elseif ($reflection->implementsInterface(ErrorZoneInterface::class)) {
                return RequestZone::ERROR;
            }
        } catch (\ReflectionException $e) {
        }
        return RequestZone::NOWHERE;
    }
protected function determineZone ( Request $ request ) : string { if ( $ request -> isXmlHttpRequest ( ) ) { return RequestZone :: ASYNC ; } $ controller = $ request -> attributes -> get ( '_controller' ) ; if ( ! is_string ( $ controller ) ) { return RequestZone :: NOWHERE ; } $ controller = explode ( '::' , $ controller ) ; try { $ reflection = new ReflectionClass ( $ controller [ 0 ] ) ; if ( $ reflection -> implementsInterface ( BackendZoneInterface :: class ) ) { return RequestZone :: BACKEND ; } elseif ( $ reflection -> implementsInterface ( FrontendZoneInterface :: class ) ) { return RequestZone :: FRONTEND ; } elseif ( $ reflection -> implementsInterface ( AsyncZoneInterface :: class ) ) { return RequestZone :: ASYNC ; } elseif ( $ reflection -> implementsInterface ( ErrorZoneInterface :: class ) ) { return RequestZone :: ERROR ; } } catch ( \ ReflectionException $ e ) { } return RequestZone :: NOWHERE ; }
Determine the zone and return it.
Determine the zone and return it .
// If this happens, we're usually in the middle of handling an Exception // Alas…