Example #1
0
 public function valueNode()
 {
     // date value (either a DateTime object, or null)
     $valueNode = parent::valueNode();
     // format('Y-m-d') method call on date object
     $args = new \Twig_Node_Expression_Array([], $this->lineno);
     $args->addElement(new \Twig_Node_Expression_Constant('j M, Y', $this->lineno));
     $formatNode = new \Twig_Node_Expression_MethodCall($valueNode, 'format', $args, $this->lineno);
     // conditional to check for a null value
     $conditionalNode = new \Twig_Node_Expression_Conditional($valueNode, $formatNode, $valueNode, $this->lineno);
     return $conditionalNode;
 }