public function buildLegacyKernelHandlerWeb($webHandlerClass, array $defaultLegacyOptions = [])
    {
        $legacyRootDir = $this->legacyRootDir;
        $webrootDir = $this->webrootDir;
        $uriHelper = $this->uriHelper;
        $eventDispatcher = $this->eventDispatcher;
        $container = $this->container;
        $that = $this;

        return function () use ($legacyRootDir, $webrootDir, $container, $defaultLegacyOptions, $webHandlerClass, $uriHelper, $eventDispatcher, $that) {
            if (!$that->getWebHandler()) {
                chdir($legacyRootDir);

                $legacyParameters = new ParameterBag($defaultLegacyOptions);
                $legacyParameters->set('service-container', $container);
                $request = $this->requestStack->getCurrentRequest();

                if ($that->getBuildEventsEnabled()) {
                    // PRE_BUILD_LEGACY_KERNEL for non request related stuff
                    $eventDispatcher->dispatch(LegacyEvents::PRE_BUILD_LEGACY_KERNEL, new PreBuildKernelEvent($legacyParameters));

                    // Pure web stuff
                    $eventDispatcher->dispatch(
                        LegacyEvents::PRE_BUILD_LEGACY_KERNEL_WEB,
                        new PreBuildKernelWebHandlerEvent($legacyParameters, $request)
                    );
                }

                $interfaces = class_implements($webHandlerClass);
                if (!isset($interfaces['ezpKernelHandler'])) {
                    throw new \InvalidArgumentException('A legacy kernel handler must be an instance of ezpKernelHandler.');
                }

                $that->setWebHandler(new $webHandlerClass($legacyParameters->all()));
                // Fix up legacy URI for global use cases (i.e. using runCallback()).
                $uriHelper->updateLegacyURI($request);
                chdir($webrootDir);
            }

            return $that->getWebHandler();
        };
    }
public function buildLegacyKernelHandlerWeb($webHandlerClass, array $defaultLegacyOptions = [])
    {
        $legacyRootDir = $this->legacyRootDir;
        $webrootDir = $this->webrootDir;
        $uriHelper = $this->uriHelper;
        $eventDispatcher = $this->eventDispatcher;
        $container = $this->container;
        $that = $this;

        return function () use ($legacyRootDir, $webrootDir, $container, $defaultLegacyOptions, $webHandlerClass, $uriHelper, $eventDispatcher, $that) {
            if (!$that->getWebHandler()) {
                chdir($legacyRootDir);

                $legacyParameters = new ParameterBag($defaultLegacyOptions);
                $legacyParameters->set('service-container', $container);
                $request = $this->requestStack->getCurrentRequest();

                if ($that->getBuildEventsEnabled()) {
                    // PRE_BUILD_LEGACY_KERNEL for non request related stuff
                    $eventDispatcher->dispatch(LegacyEvents::PRE_BUILD_LEGACY_KERNEL, new PreBuildKernelEvent($legacyParameters));

                    // Pure web stuff
                    $eventDispatcher->dispatch(
                        LegacyEvents::PRE_BUILD_LEGACY_KERNEL_WEB,
                        new PreBuildKernelWebHandlerEvent($legacyParameters, $request)
                    );
                }

                $interfaces = class_implements($webHandlerClass);
                if (!isset($interfaces['ezpKernelHandler'])) {
                    throw new \InvalidArgumentException('A legacy kernel handler must be an instance of ezpKernelHandler.');
                }

                $that->setWebHandler(new $webHandlerClass($legacyParameters->all()));
                // Fix up legacy URI for global use cases (i.e. using runCallback()).
                $uriHelper->updateLegacyURI($request);
                chdir($webrootDir);
            }

            return $that->getWebHandler();
        };
    }
public function buildLegacyKernelHandlerWeb ( $ webHandlerClass , array $ defaultLegacyOptions = [ ] ) { $ legacyRootDir = $ this -> legacyRootDir ; $ webrootDir = $ this -> webrootDir ; $ uriHelper = $ this -> uriHelper ; $ eventDispatcher = $ this -> eventDispatcher ; $ container = $ this -> container ; $ that = $ this ; return function ( ) use ( $ legacyRootDir , $ webrootDir , $ container , $ defaultLegacyOptions , $ webHandlerClass , $ uriHelper , $ eventDispatcher , $ that ) { if ( ! $ that -> getWebHandler ( ) ) { chdir ( $ legacyRootDir ) ; $ legacyParameters = new ParameterBag ( $ defaultLegacyOptions ) ; $ legacyParameters -> set ( 'service-container' , $ container ) ; $ request = $ this -> requestStack -> getCurrentRequest ( ) ; if ( $ that -> getBuildEventsEnabled ( ) ) { // PRE_BUILD_LEGACY_KERNEL for non request related stuff $ eventDispatcher -> dispatch ( LegacyEvents :: PRE_BUILD_LEGACY_KERNEL , new PreBuildKernelEvent ( $ legacyParameters ) ) ; // Pure web stuff $ eventDispatcher -> dispatch ( LegacyEvents :: PRE_BUILD_LEGACY_KERNEL_WEB , new PreBuildKernelWebHandlerEvent ( $ legacyParameters , $ request ) ) ; } $ interfaces = class_implements ( $ webHandlerClass ) ; if ( ! isset ( $ interfaces [ 'ezpKernelHandler' ] ) ) { throw new \ InvalidArgumentException ( 'A legacy kernel handler must be an instance of ezpKernelHandler.' ) ; } $ that -> setWebHandler ( new $ webHandlerClass ( $ legacyParameters -> all ( ) ) ) ; // Fix up legacy URI for global use cases (i.e. using runCallback()). $ uriHelper -> updateLegacyURI ( $ request ) ; chdir ( $ webrootDir ) ; } return $ that -> getWebHandler ( ) ; } ; }
Builds up the legacy kernel web handler and encapsulates it inside a closure, allowing lazy loading.

@param string $webHandlerClass The legacy kernel handler class to use
@param array $defaultLegacyOptions Hash of options to pass to the legacy kernel handler

@return \Closure
Builds up the legacy kernel web handler and encapsulates it inside a closure allowing lazy loading .