vendor/codeages/plugin-bundle/System/Slot/SlotInjectionCollector.php

(开头部分) 1KB

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

<?php

namespace Codeages\PluginBundle\System\Slot;

use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Resource\FileResource;

class SlotInjectionCollector
{
    protected $injections = array();

    protected $serial = PHP_INT_MAX;

    public function __construct(array $files, $cacheDir, $debug)
    {
        $cacheFile = $cacheDir.'/slot.php';
        $cache = new ConfigCache($cacheFile, $debug);

        if ($cache->isFresh() === false) {
            $resources = array();
            $slots = array();

            foreach ($files as $file) {
                $resources[] = new FileResource($file);
                $injections = Yaml::parse(file_get_contents($file));
                if (empty($injections) || !is_array($injections)) {
                    $injections = array();
                }
                $this->mergeInjections($injections);
            }

            $this->writeCacheFile($cache, $resources);
        } else {
            $this->injections = require $cacheFile;
        }
    }

    protected function mergeInjections($injections = array())
    {
        foreach ($injections as $injection) {
            if (!isset($this->injections[$injection['name']])) {
                $this->injections[$injection['name']] = new \SplPriorityQueue();
            }

            if (!isset($injection['priority'])) {
                $injection['priority'] = 0;
            }

            $this->injections[$injection['name']]->insert($injection, array($injection['priority'], $this->serial--));
        }
    }

    protected function writeCacheFile($cache, $resources)
    {
        $injections = array();

        foreach ($this->injections as $name => $priorityInjections) {
            foreach ($priorityInjections as $injection) {
                $injections[$name][] = $injection['class'];

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

AI 解读 AI

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

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