vendor/codeages/plugin-bundle/Twig/DictExtension.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Codeages\PluginBundle\Twig;
class DictExtension extends \Twig_Extension
{
protected $collector;
protected $locale;
protected $container;
public function __construct($collector, $container)
{
$this->collector = $collector;
$this->container = $container;
}
public function getFunctions()
{
return array(
new \Twig_SimpleFunction('dict', array($this, 'getDict')),
new \Twig_SimpleFunction('dict_text', array($this, 'getDictText'), array('is_safe' => array('html'))),
);
}
public function getDict($name)
{
$locale = $this->getLocale();
return $this->collector->getDictMap($locale, $name);
}
public function getDictText($name, $key, $default = '')
{
$locale = $this->getLocale();
return $this->collector->getDictText($locale, $name, $key, $default);
}
public function getName()
{
return 'codeages_plugin_dict_extension';
}
private function getLocale()
{
if (!$this->locale) {
$locale = $this->container->get('request')->getLocale();
$this->locale = $locale;
}
return $this->locale;
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。