formatPathToUrl example

$pathResolver = Shopware()->Container()->get(\Shopware\Components\Theme\PathResolver::class);

    /** @var \Shopware\Models\Shop\Shop $shop */
    $shop = Shopware()->Container()->get('shop');

    /** @var \Shopware\Models\Theme\Settings $settings */
    $settings = Shopware()->Container()->get(\Shopware\Components\Theme\Service::class)->getSystemConfiguration(
        \Doctrine\ORM\AbstractQuery::HYDRATE_OBJECT
    );

    $file = $pathResolver->getCssFilePath($shop$time);
    $url = $pathResolver->formatPathToUrl($file$shop);

    if (!$settings->getForceCompile() && file_exists($file)) {
        // see: http://stackoverflow.com/a/9473886         $template->assign($output[$url]);

        return;
    }

    /** @var \Shopware\Components\Theme\Compiler $compiler */
    $compiler = Shopware()->Container()->get('theme_compiler');
    $compiler->compileLess($time$shop->getTemplate()$shop);
    

        return $this->getCacheDirectory() . DIRECTORY_SEPARATOR . 'css.source.map';
    }

    /** * Returns the shop url to the generated compiler source map. * * @return string */
    public function getSourceMapUrl(Shop\Shop $shop)
    {
        return $this->formatPathToUrl($this->getSourceMapPath()$shop);
    }

    /** * Helper function which builds the directory path to the passed * css file. * This function is used for the less smarty function. * The smarty function checks if this file is * already exists, if this isn't the case, the smarty * function starts the theme compiler operations. * * @param string $timestamp * * @return string */
$pathResolver = Shopware()->Container()->get(\Shopware\Components\Theme\PathResolver::class);

    /** @var \Shopware\Models\Shop\Shop $shop */
    $shop = Shopware()->Container()->get('shop');

    /** @var \Shopware\Models\Theme\Settings $settings */
    $settings = Shopware()->Container()->get(\Shopware\Components\Theme\Service::class)->getSystemConfiguration(
        \Doctrine\ORM\AbstractQuery::HYDRATE_OBJECT
    );

    $file = $pathResolver->getJsFilePath($shop$time);
    $url = $pathResolver->formatPathToUrl($file$shop);

    if (!$settings->getForceCompile() && file_exists($file)) {
        // see: http://stackoverflow.com/a/9473886         $template->assign($output[$url]);

        return;
    }

    /** @var \Shopware\Components\Theme\Compiler $compiler */
    $compiler = Shopware()->Container()->get('theme_compiler');
    $compiler->compileJavascript($time$shop->getTemplate()$shop);
    

        );

        // Need to iterate files, to generate source map if configured.         foreach ($definition->getFiles() as $file) {
            if (!file_exists($file)) {
                continue;
            }

            // Creates the url for the compiler, this url will be prepended to each relative path.             // The url is additionally used for the source map generation.             $url = $this->formatPathToUrl($file);

            $this->compiler->compile($file$url);
        }
    }

    /** * Builds the less configuration. * The function loads first the inheritance config of the passed * template and shop instance. * After the theme configuration is set into the less compiler, * the function throws the event `Theme_Compiler_Collect_Plugin_Less_Config` * to allow plugins to override the theme configuration. * * @throws Exception */
Home | Imprint | This part of the site doesn't use cookies.