Beispiel #1
0
 /**
  * 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);
 }
Beispiel #2
0
 /**
  * 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()));
 }