protected function rewriteLinksForProduction($content)
    {
        $urlManager = $this->urlManager;

        $content = preg_replace_callback('/(\<a[^\>]+href[="\s]+)([^"\s]+)?([^\>]+\>)/s', function ($matches) use ($urlManager) {
            $url = $matches[2];

            if (preg_match('/route:([^"]+)/i', $url, $route)) {
                $url = sprintf("{{ path(%s) }}", html_entity_decode($route[1], ENT_QUOTES));

                return $matches[1] . $url . $matches[3];
            }

            $route = $urlManager
                ->fromUrl($url)
                ->getProductionRoute();

            if (null !== $route) {
                $url = sprintf("{{ path('%s') }}", $route);
            }

            return $matches[1] . $url . $matches[3];
        }, $content);

        return $content;
    }
protected function rewriteLinksForProduction($content)
    {
        $urlManager = $this->urlManager;

        $content = preg_replace_callback('/(\<a[^\>]+href[="\s]+)([^"\s]+)?([^\>]+\>)/s', function ($matches) use ($urlManager) {
            $url = $matches[2];

            if (preg_match('/route:([^"]+)/i', $url, $route)) {
                $url = sprintf("{{ path(%s) }}", html_entity_decode($route[1], ENT_QUOTES));

                return $matches[1] . $url . $matches[3];
            }

            $route = $urlManager
                ->fromUrl($url)
                ->getProductionRoute();

            if (null !== $route) {
                $url = sprintf("{{ path('%s') }}", $route);
            }

            return $matches[1] . $url . $matches[3];
        }, $content);

        return $content;
    }
protected function rewriteLinksForProduction ( $ content ) { $ urlManager = $ this -> urlManager ; $ content = preg_replace_callback ( '/(\<a[^\>]+href[="\s]+)([^"\s]+)?([^\>]+\>)/s' , function ( $ matches ) use ( $ urlManager ) { $ url = $ matches [ 2 ] ; if ( preg_match ( '/route:([^"]+)/i' , $ url , $ route ) ) { $ url = sprintf ( "{{ path(%s) }}" , html_entity_decode ( $ route [ 1 ] , ENT_QUOTES ) ) ; return $ matches [ 1 ] . $ url . $ matches [ 3 ] ; } $ route = $ urlManager -> fromUrl ( $ url ) -> getProductionRoute ( ) ; if ( null !== $ route ) { $ url = sprintf ( "{{ path('%s') }}" , $ route ) ; } return $ matches [ 1 ] . $ url . $ matches [ 3 ] ; } , $ content ) ; return $ content ; }
Rewrites the website links for the production environment

@param  string $content
@return string
Rewrites the website links for the production environment