Class yii\twig\html\CssClassNode
| Inheritance | yii\twig\html\CssClassNode » yii\twig\html\BaseClassNode » Twig\Node\Node | 
|---|---|
| Source Code | https://github.com/yiisoft/yii2-twig/blob/master/src/html/CssClassNode.php | 
Public Methods
| Method | Description | Defined By | 
|---|---|---|
| __construct() | yii\twig\html\CssClassNode | |
| compile() | yii\twig\html\BaseClassNode | |
| getHelperMethod() | yii\twig\html\CssClassNode | 
Method Details
| public void __construct ( \Twig\Token $name, $value, \Twig\Token $operator, $lineno = 0, $tag = null ) | ||
| $name | ||
| $value | ||
| $operator | ||
| $lineno | ||
| $tag | ||
                public function __construct(Token $name, $value, Token $operator, $lineno = 0, $tag = null)
{
    parent::__construct(array('value' => $value), array('name' => $name, 'operator' => $operator), $lineno, $tag);
}
            
        Defined in: yii\twig\html\BaseClassNode::compile()
| public void compile ( \Twig\Compiler $compiler ) | ||
| $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");
}
            
        
| public void getHelperMethod ( ) | 
                public function getHelperMethod()
{
    $operator = $this->getAttribute('operator')->getValue();
    switch ($operator) {
        case '+':
            return 'addCssClass';
        case '-':
            return 'removeCssClass';
        default:
            throw new Error("Operator {$operator} no found;");
    }
}