vendor/codeages/plugin-bundle/Locator/ThemeFileLocator.php

(开头部分) 1KB

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

<?php

namespace Codeages\PluginBundle\Locator;

use Symfony\Component\Config\FileLocator as BaseFileLocator;
use Codeages\PluginBundle\System\PluginableHttpKernelInterface;

class ThemeFileLocator extends BaseFileLocator
{
    private $kernel;
    private $path;

    public function __construct(PluginableHttpKernelInterface $kernel, $path = null, array $paths = array())
    {
        $this->kernel = $kernel;
        if (null !== $path) {
            $this->path = $path;
            $paths[] = $path;
        }

        $themeDir = $this->kernel->getPluginConfigurationManager()->getActiveThemeDirectory();
        $paths = array_merge(array($themeDir), $paths);

        parent::__construct($paths);
    }

    public function locate($file, $currentPath = null, $first = true)
    {
        if (isset($file[0]) && '@' === $file[0]) {
            return $this->locateResource($file, $this->path, $first);
        }

        return parent::locate($file, $currentPath, $first);
    }

    protected function locateResource($name, $dir = null, $first = true)
    {
        if (false !== strpos($name, '..')) {
            throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name));
        }

        $bundleName = substr($name, 1);
        $path = '';
        if (false !== strpos($bundleName, '/')) {
            list($bundleName, $path) = explode('/', $bundleName, 2);
        }

        $isResource = 0 === strpos($path, 'Resources') && null !== $dir;
        $overridePath = substr($path, 9);
        $resourceBundle = null;
        $bundles = $this->kernel->getBundle($bundleName, false);
        $files = array();

        $themeDir = $this->kernel->getPluginConfigurationManager()->getActiveThemeDirectory();

        foreach ($bundles as $bundle) {
            $lookupFiles = array();
            if ($themeDir) {
                $lookupFiles[] = sprintf('%s/views/%s/%s', $themeDir, $bundle->getName(), substr($overridePath, 7));
                // @todo this will remove in future.

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

AI 解读 AI

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

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