private function addResolvedRoute(array $context, $template)
    {
        if (!isset($context['record'])) {
            return;
        }

        $content = $context['record'];
        $request = $this->app['request_stack']->getCurrentRequest();

        $homepage = $this->getOption('theme/homepage') ?: $this->getOption('general/homepage');
        $uriID = $content->contenttype['singular_slug'] . '/' . $content->get('id');
        $uriSlug = $content->contenttype['singular_slug'] . '/' . $content->get('slug');

        if (($uriID === $homepage || $uriSlug === $homepage) && ($template === $this->getOption('general/homepage_template'))) {
            $request->attributes->add(['_route' => 'homepage', '_route_params' => []]);

            return;
        }

        // In case we're previewing a record, this will override the `_route`, but keep the original
        // one, used to see if we need to disable the XSS protection header.
        // See PR https://github.com/bolt/bolt/pull/7458
        list($routeName, $routeParams) = $content->getRouteNameAndParams();
        if ($routeName) {
            /** @deprecated since 3.4 to be removed in 4.0 */
            $request->attributes->add([
                '_route'          => $routeName,
                '_route_params'   => $routeParams,
                '_internal_route' => $request->attributes->get('_route'),
            ]);
        }
    }
private function addResolvedRoute(array $context, $template)
    {
        if (!isset($context['record'])) {
            return;
        }

        $content = $context['record'];
        $request = $this->app['request_stack']->getCurrentRequest();

        $homepage = $this->getOption('theme/homepage') ?: $this->getOption('general/homepage');
        $uriID = $content->contenttype['singular_slug'] . '/' . $content->get('id');
        $uriSlug = $content->contenttype['singular_slug'] . '/' . $content->get('slug');

        if (($uriID === $homepage || $uriSlug === $homepage) && ($template === $this->getOption('general/homepage_template'))) {
            $request->attributes->add(['_route' => 'homepage', '_route_params' => []]);

            return;
        }

        // In case we're previewing a record, this will override the `_route`, but keep the original
        // one, used to see if we need to disable the XSS protection header.
        // See PR https://github.com/bolt/bolt/pull/7458
        list($routeName, $routeParams) = $content->getRouteNameAndParams();
        if ($routeName) {
            /** @deprecated since 3.4 to be removed in 4.0 */
            $request->attributes->add([
                '_route'          => $routeName,
                '_route_params'   => $routeParams,
                '_internal_route' => $request->attributes->get('_route'),
            ]);
        }
    }
private function addResolvedRoute ( array $ context , $ template ) { if ( ! isset ( $ context [ 'record' ] ) ) { return ; } $ content = $ context [ 'record' ] ; $ request = $ this -> app [ 'request_stack' ] -> getCurrentRequest ( ) ; $ homepage = $ this -> getOption ( 'theme/homepage' ) ? : $ this -> getOption ( 'general/homepage' ) ; $ uriID = $ content -> contenttype [ 'singular_slug' ] . '/' . $ content -> get ( 'id' ) ; $ uriSlug = $ content -> contenttype [ 'singular_slug' ] . '/' . $ content -> get ( 'slug' ) ; if ( ( $ uriID === $ homepage || $ uriSlug === $ homepage ) && ( $ template === $ this -> getOption ( 'general/homepage_template' ) ) ) { $ request -> attributes -> add ( [ '_route' => 'homepage' , '_route_params' => [ ] ] ) ; return ; } // In case we're previewing a record, this will override the `_route`, but keep the original // one, used to see if we need to disable the XSS protection header. // See PR https://github.com/bolt/bolt/pull/7458 list ( $ routeName , $ routeParams ) = $ content -> getRouteNameAndParams ( ) ; if ( $ routeName ) { /** @deprecated since 3.4 to be removed in 4.0 */ $ request -> attributes -> add ( [ '_route' => $ routeName , '_route_params' => $ routeParams , '_internal_route' => $ request -> attributes -> get ( '_route' ) , ] ) ; } }
Update the route attributes to change the canonical URL generated.

@param array  $context
@param string $template
Update the route attributes to change the canonical URL generated .