Вход Регистрация
Файл: upload/core/vendor/twig/twig/src/Node/Expression/MacroReferenceExpression.php
Строк: 57
<?php

/*
 * This file is part of Twig.
 *
 * (c) Fabien Potencier
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace TwigNodeExpression;

use 
TwigCompiler;
use 
TwigNodeExpressionVariableTemplateVariable;

/**
 * Represents a macro call node.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 */
class MacroReferenceExpression extends AbstractExpression implements SupportDefinedTestInterface
{
    use 
SupportDefinedTestDeprecationTrait;
    use 
SupportDefinedTestTrait;

    public function 
__construct(TemplateVariable $templatestring $nameAbstractExpression $argumentsint $lineno)
    {
        
parent::__construct(['template' => $template'arguments' => $arguments], ['name' => $name], $lineno);
    }

    public function 
compile(Compiler $compiler): void
    
{
        if (
$this->definedTest) {
            
$compiler
                
->subcompile($this->getNode('template'))
                ->
raw('->hasMacro(')
                ->
repr($this->getAttribute('name'))
                ->
raw(', $context')
                ->
raw(')')
            ;

            return;
        }

        
$compiler
            
->subcompile($this->getNode('template'))
            ->
raw('->getTemplateForMacro(')
            ->
repr($this->getAttribute('name'))
            ->
raw(', $context, ')
            ->
repr($this->getTemplateLine())
            ->
raw(', $this->getSourceContext())')
            ->
raw(sprintf('->%s'$this->getAttribute('name')))
            ->
raw('(...')
            ->
subcompile($this->getNode('arguments'))
            ->
raw(')')
        ;
    }
}
Онлайн: 0
Реклама