Class yii\twig\html\StyleClassNode

Inheritanceyii\twig\html\StyleClassNode » yii\twig\html\BaseClassNode » Twig\Node\Node
Source Code https://github.com/yiisoft/yii2-twig/blob/master/html/StyleClassNode.php

Method Details

Hide inherited methods

__construct() public method
public __construct( \Twig\Token $name, mixed $value, \Twig\Token $operator, mixed $lineno = 0, string|null $tag = null ): mixed
$name \Twig\Token
$value mixed
$operator \Twig\Token
$lineno mixed
$tag string|null

                public function __construct(Token $name, $value, Token $operator, $lineno = 0, ?string $tag = null)
{
    parent::__construct(['value' => $value], ['name' => $name, 'operator' => $operator], $lineno, $tag);
}

            
compile() public method
public compile( \Twig\Compiler $compiler ): mixed
$compiler \Twig\Compiler

                public function compile(Compiler $compiler)
{
    $name = $this->getAttribute('name')->getValue();
    $method = $this->getHelperMethod();
    $compiler
        ->addDebugInfo($this)
        ->write("\yii\helpers\Html::{$method}(\$context[\"{$name}\"],")
        ->subcompile($this->getNode('value'))
        ->raw(");\n");
}

            
getHelperMethod() public method
public getHelperMethod( ): mixed

                public function getHelperMethod()
{
    $operator = $this->getAttribute('operator')->getValue();
    switch ($operator) {
        case '+':
            return 'addCssStyle';
        case '-':
            return 'removeCssStyle';
        default:
            throw new Error("Operator {$operator} no found;");
    }
}