Example #1
0
 public function _for(HtmlNode $node, TemplateNode $value)
 {
     $internal = new InternalNode();
     foreach ($node->getChildren() as $child) {
         $internal->append($child->detach());
     }
     $start = '$Form->formFor(' . PhpNode::expr($value)->code . ', ';
     if ($node->hasAttribute('action')) {
         $start .= PhpNode::expr($node->getAttribute('action'))->code . ', ';
         $node->removeAttribute('action');
     } else {
         $start .= 'array(), ';
     }
     $start .= PhpNode::attributes($node)->code . ')';
     $internal->prepend(new PhpNode($start, true));
     $internal->append(new PhpNode('$Form->end()'));
     $node->replaceWith($internal);
 }
Example #2
0
 /**
  * Adds a class.
  * @param HtmlNode $node Node.
  * @param TemplateNode|null $value Macro parameter.
  */
 public function _class(HtmlNode $node, TemplateNode $value)
 {
     if ($node->hasAttribute('class')) {
         $node->setAttribute('class', new PhpNode("'" . h($node->getAttribute('class')) . " ' . " . PhpNode::expr($value)->code));
     } else {
         $node->setAttribute('class', PhpNode::expr($value));
     }
 }