vendor/symfony/assetic-bundle/Twig/AsseticNodeVisitor.php
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Symfony\Bundle\AsseticBundle\Twig;
use Assetic\Extension\Twig\AsseticFilterFunction;
use Symfony\Bundle\AsseticBundle\Exception\InvalidBundleException;
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
use Symfony\Component\Templating\TemplateNameParserInterface;
/**
* Assetic node visitor.
*
* @author Kris Wallsmith <kris@symfony.com>
*/
class AsseticNodeVisitor extends \Twig_BaseNodeVisitor
{
private $templateNameParser;
private $enabledBundles;
public function __construct(TemplateNameParserInterface $templateNameParser, array $enabledBundles)
{
$this->templateNameParser = $templateNameParser;
$this->enabledBundles = $enabledBundles;
}
protected function doEnterNode(\Twig_Node $node, \Twig_Environment $env)
{
return $node;
}
protected function doLeaveNode(\Twig_Node $node, \Twig_Environment $env)
{
if (!$formula = $this->checkNode($node, $env, $name)) {
return $node;
}
// check the bundle
$templateRef = $this->templateNameParser->parse($env->getParser()->getStream()->getFilename());
$bundle = $templateRef instanceof TemplateReference ? $templateRef->get('bundle') : null;
if ($bundle && !in_array($bundle, $this->enabledBundles)) {
throw new InvalidBundleException($bundle, "the $name() function", $templateRef->getLogicalName(), $this->enabledBundles);
}
list($input, $filters, $options) = $formula;
$line = $node->getLine();
// check context and call either asset() or path()
return new \Twig_Node_Expression_Conditional(
new \Twig_Node_Expression_GetAttr(
new \Twig_Node_Expression_Name('assetic', $line),
new \Twig_Node_Expression_Constant('use_controller', $line),
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。