lainchan/inc/lib/Twig/Node/Expression/GetAttr.php

54 lines
2.2 KiB
PHP
Raw Normal View History

2011-10-05 00:22:53 -04:00
<?php
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
* (c) 2009 Armin Ronacher
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
{
2013-08-01 15:20:12 -04:00
public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression_Array $arguments, $type, $lineno)
2011-10-05 00:22:53 -04:00
{
2013-08-01 15:20:12 -04:00
parent::__construct(array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno);
2011-10-05 00:22:53 -04:00
}
public function compile(Twig_Compiler $compiler)
{
2013-08-01 15:20:12 -04:00
if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) {
$compiler->raw('twig_template_get_attributes($this, ');
2011-10-05 00:22:53 -04:00
} else {
2013-08-01 15:20:12 -04:00
$compiler->raw('$this->getAttribute(');
2011-10-05 00:22:53 -04:00
}
2013-08-01 15:20:12 -04:00
if ($this->getAttribute('ignore_strict_check')) {
$this->getNode('node')->setAttribute('ignore_strict_check', true);
2011-10-05 00:22:53 -04:00
}
2013-08-01 15:20:12 -04:00
$compiler->subcompile($this->getNode('node'));
$compiler->raw(', ')->subcompile($this->getNode('attribute'));
2013-09-19 02:08:25 -04:00
if (count($this->getNode('arguments')) || Twig_Template::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) {
2013-08-01 15:20:12 -04:00
$compiler->raw(', ')->subcompile($this->getNode('arguments'));
2013-09-19 02:08:25 -04:00
if (Twig_Template::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) {
2013-08-01 15:20:12 -04:00
$compiler->raw(', ')->repr($this->getAttribute('type'));
}
if ($this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) {
$compiler->raw(', '.($this->getAttribute('is_defined_test') ? 'true' : 'false'));
}
if ($this->getAttribute('ignore_strict_check')) {
$compiler->raw(', '.($this->getAttribute('ignore_strict_check') ? 'true' : 'false'));
}
}
$compiler->raw(')');
2011-10-05 00:22:53 -04:00
}
}