Class yii\twig\html\CssClassNode

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

Method Details

Hide inherited methods

__construct() public method

public void __construct ( \Twig_Token $name, $value, \Twig_Token $operator, $lineno 0, $tag null )
$name
$value
$operator
$lineno
$tag

                public function __construct(\Twig_Token $name, $value, \Twig_Token $operator, $lineno = 0, $tag = null)
{
    parent::__construct(array('value' => $value), array('name' => $name, 'operator' => $operator), $lineno, $tag);
}

            
compile() public method
public void compile ( \Twig_Compiler $compiler )
$compiler

                public function compile(\Twig_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 void getHelperMethod ( )

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