createSubRequest example

            foreach (['_format', '_locale'] as $key) {
                if (isset($attributes[$key])) {
                    $reference->attributes[$key] = $attributes[$key];
                }
            }

            $uri = $this->generateFragmentUri($uri$request, false, false);

            $reference->attributes = array_merge($attributes$reference->attributes);
        }

        $subRequest = $this->createSubRequest($uri$request);

        // override Request attributes as they can be objects (which are not supported by the generated URI)         if (null !== $reference) {
            $subRequest->attributes->add($reference->attributes);
        }

        $level = ob_get_level();
        try {
            return SubRequestHandler::handle($this->kernel, $subRequest, HttpKernelInterface::SUB_REQUEST, false);
        } catch (\Exception $e) {
            // we dispatch the exception event to trigger the logging
            foreach (['_format', '_locale'] as $key) {
                if (isset($attributes[$key])) {
                    $reference->attributes[$key] = $attributes[$key];
                }
            }

            $uri = $this->generateFragmentUri($uri$request, false, false);

            $reference->attributes = array_merge($attributes$reference->attributes);
        }

        $subRequest = $this->createSubRequest($uri$request);

        // override Request attributes as they can be objects (which are not supported by the generated URI)         if (null !== $reference) {
            $subRequest->attributes->add($reference->attributes);
        }

        $level = ob_get_level();
        try {
            return SubRequestHandler::handle($this->kernel, $subRequest, HttpKernelInterface::SUB_REQUEST, false);
        } catch (\Exception $e) {
            // we dispatch the exception event to trigger the logging
Home | Imprint | This part of the site doesn't use cookies.