vendor/codeages/plugin-bundle/System/DictCollector.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Codeages\PluginBundle\System;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Resource\FileResource;
class DictCollector
{
protected $locale;
protected $cacheDir;
protected $debug;
protected $files;
public function __construct(array $files, $cacheDir, $debug, $locale)
{
$this->files = $files;
$this->cacheDir = $cacheDir;
$this->debug = $debug;
$this->locale = $locale;
}
private function loadDictFile()
{
$resources = array();
$dict = array();
$defaultDict = array();
foreach ($this->files as $file) {
$resources[] = new FileResource($file);
$basename = basename($file);
$basenameParts = explode('.', $basename);
$locale = $basenameParts[1];
$localeDict = isset($dict[$locale]) ? $dict[$locale] : array();
$dict[$locale] = array_merge($localeDict, Yaml::parse(file_get_contents($file)));
if ($locale == $this->locale) {
$defaultDict = array_merge($defaultDict, Yaml::parse(file_get_contents($file)));
}
}
$this->cacheDictFile($dict, $defaultDict, $resources);
}
private function cacheDictFile($dict, $defaultDict, $resources)
{
foreach ($dict as $key => $localDict) {
$cacheFile = $this->cacheDir."/dict.{$key}.php";
$cache = new ConfigCache($cacheFile, $this->debug);
if ($key != $this->locale) {
$localDict = array_merge($defaultDict, $localDict);
}
$cache->write(sprintf('<?php return %s;', var_export($localDict, true)), $resources);
}
}
private function getDict($userLocale)
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。