Ejemplo n.º 1
0
    /**
     * Rewrite a link with the title
     *
     * @param string $link
     * @param string $title
     * @return string
     */
    public static function rewriteLink($link = null, $title = null)
    {
        if(!isset(self::$shopConfig)) {
            self::$shopConfig = Shopware()->Config();
            self::$baseFile = self::$shopConfig->baseFile;
        }

        if (strpos($link, self::$baseFile) !== 0) {
            return $link;
        }

        $url = str_replace(',', '=', $link);
        $url = html_entity_decode($url);
        $query = parse_url($url, PHP_URL_QUERY);
        parse_str($query, $query);

        if (!empty($title)) {
            $query['title'] = $title;
        }

        return Shopware()->Front()->Router()->assemble($query);
    }