Exemplo n.º 1
0
 /**
  * Escapes all the variables passed using 'with'
  *
  * @param  \Twig_Node_Expression_Array $vars
  * @param  int                         $lineno
  * @return \Twig_Node_Expression_Array
  */
 protected function escapeWithVariables($vars, $lineno)
 {
     $pairs = $vars->getKeyValuePairs();
     $vars = new \Twig_Node_Expression_Array(array(), $lineno);
     foreach ($pairs as $pair) {
         $vars->addElement($this->escapeNodeIfNecessary($pair['value'], $lineno), $pair['key']);
     }
     return $vars;
 }
 /**
  * @param ArrayNode $node
  * @return array
  */
 protected function nodeToArray(ArrayNode $node)
 {
     $array = array();
     foreach ($node->getKeyValuePairs() as $pair) {
         if (!$pair['key'] instanceof ConstantNode) {
             continue;
         }
         $array[$pair['key']->getAttribute('value')] = $pair['value'];
     }
     return $array;
 }
 /**
  * @param ArrayNode $node
  * @return array
  */
 private function collectConstantValues(ArrayNode $node)
 {
     $values = array();
     foreach ($node->getKeyValuePairs() as $pair) {
         if (!$pair['key'] instanceof ConstantNode) {
             continue;
         }
         $value = null;
         if ($pair['value'] instanceof ConstantNode) {
             $value = $pair['value']->getAttribute('value');
         } elseif ($pair['value'] instanceof ArrayNode) {
             $value = $this->collectConstantValues($pair['value']);
         }
         $values[$pair['key']->getAttribute('value')] = $value;
     }
     return $values;
 }