本文整理汇总了PHP中Twig_Node_Expression::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Node_Expression::getAttribute方法的具体用法?PHP Twig_Node_Expression::getAttribute怎么用?PHP Twig_Node_Expression::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twig_Node_Expression
的用法示例。
在下文中一共展示了Twig_Node_Expression::getAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extractTmpAttribute
/**
* Método
* @param \Twig_Node_Expression|\Twig_Node_Expression_Conditional|null $node
* @param \Twig_Node_Expression|\Twig_Node_Expression_Conditional|null $value
*
* @return array
*/
protected function extractTmpAttribute($node = null, $value = null)
{
$tmp = array();
if (NULL === $node) {
$node = $value;
} else {
$tmp = $this->getTmpAttribute($node);
}
$tmp[] = $value->getAttribute("value");
return array($tmp, $node);
}
示例2: invalidArgumentTypeParseError
/**
* Throws an exception with detailled error message in case of argument parse errors.
*
* @param Twig_Node_Expression $argument The invalid/unexpected argument node.
* @param Twig_Node_Expression $node The Filter or Function node to which the $argument belongs.
* @throws InvalidArgumentException (The main purpose.)
* @throws LogicException In case an unexpected $node argument was passed.
*/
protected function invalidArgumentTypeParseError(Twig_Node_Expression $argument, Twig_Node_Expression $node)
{
switch (true) {
case $node instanceof Twig_Node_Expression_Function:
$name = $node->getAttribute('name');
break;
case $node instanceof Twig_Node_Expression_Filter:
$name = $node->getNode('filter')->getAttribute('value');
break;
default:
throw new LogicException(sprintf("Don't know how to get name of node %s to throw an InvalidArgumentException", get_class($node)));
}
throw new InvalidArgumentException(sprintf('Invalid argument of type %s for %s in %s on line %d', get_class($argument), $name, $this->file, $node->getLine()));
}