system/library/template/Twig/Extension/DTwigManager.php

(开头部分) 12KB

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

<?php

/**
 * Opencart Extension class.
 *
 * This class is used by Opencart as a twig extension and must not be used directly.
 *
 */
class Twig_Extension_DTwigManager extends Twig_Extension
{
    protected $registry;
    protected $is_admin;

    /**
     * @param Registry $registry
     */
    public function __construct(\Registry $registry)
    {
        $this->registry = $registry;

        $this->is_admin = defined('DIR_CATALOG');
    }

    /**
     * {@inheritdoc}
     */
    public function getFunctions()
    {
        return array(
            new \Twig_SimpleFunction('link', array($this, 'linkFunction')),
            new \Twig_SimpleFunction('lang', array($this, 'langFunction')),
            new \Twig_SimpleFunction('config', array($this, 'configFunction')),
            new \Twig_SimpleFunction('paginate', array($this, 'paginateFunction')),
            new \Twig_SimpleFunction('image', array($this, 'imageFunction')),
            new \Twig_SimpleFunction('asset', array($this, 'assetFunction')),
            new \Twig_SimpleFunction('load', array($this, 'loadFunction')),
            new \Twig_SimpleFunction('can_access', array($this, 'canAccessFunction')),
            new \Twig_SimpleFunction('can_modify', array($this, 'canModifyFunction')),
            new \Twig_SimpleFunction('template', array($this, 'templateFunction')),
            new \Twig_SimpleFunction('content', array($this, 'contentFunction')),
        );
    }

    /**
     * @param null $route
     * @param array $args
     * @param bool $secure
     *
     * @return string
     */
    public function linkFunction($route = null, $args = array(), $secure = false)
    {
        $url = $this->registry->get('url');
        $session = $this->registry->get('session');
        $token = isset($session->data['token']) ? $session->data['token'] : null;

        if ($this->is_admin && $token) {
            $args['token'] = $token;
        }

后面还有 406 行代码,购买后查看完整代码

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

AI 解读

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

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