src/AppBundle/Twig/Asset/VersionStrategy/StaticVersionStrategy.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace AppBundle\Twig\Asset\VersionStrategy;

use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;

/**
 * rewrite file of \Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy
 * Returns the same version for all assets.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 */
class StaticVersionStrategy implements VersionStrategyInterface
{
    private $version;
    private $format;
    private $plugins;

    /**
     * @param string $version Version number
     * @param string $format  Url format
     * @param object $biz
     */
    public function __construct($version, $format = null, $biz = null)
    {
        $this->version = $version;
        $this->format = $format ?: '%s?%s';

        $rootDir = $biz['root_directory'];
        $pluginFilePath = $rootDir.'app/config/plugin.php';
        if (file_exists($pluginFilePath)) {
            $this->plugins = require $pluginFilePath;
        }
    }

    /**
     * {@inheritdoc}
     */
    public function getVersion($path)
    {
        if (!$this->isEsCompileAssets($path)) {
            return $this->version;
        }
        $version = $this->parseVersionFromPlugin($path);
        if (empty($version)) {
            return $this->version;
        }

        return $version;
    }

    private function isEsCompileAssets($path)
    {
        return strpos($path, 'static-dist') !== false;
    }

    private function parseVersionFromPlugin($path)
    {
        $version = '';

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。