- 7.9. Opt_Xml_Buffer class
7.9.1. addAfter() - 7.9. Opt_Xml_Buffer class
« Previous - 7.9.2. addBefore()
Next »
7.9.1. addAfter()
| Status | public |
|---|---|
| Reference | void addAfter(int $buffer, string $code) |
Appends the code snippet $code to the end of the specified buffer $buffer.
class Opt_Processor_Foo extends Opt_Compiler_Processor { protected $_name = 'foo'; public function processNode(Opt_Xml_Node $node) { $node->addAfter(Opt_Xml_Buffer::TAG_BEFORE, 'echo \'hello\';'); } // end processNode(); } // end Opt_Processor_Foo;
To generate a PHP code with curly brackets and be sure that it is used in the correct order, we have to both this method and Opt_Xml_Buffer::addBefore(). The opening bracket must be added with the first one, and the closing with the second. There are two possible combinations:
The brackets enclose the tag, but they may appear within other brackets generated by other snippets:
$node->addAfter(Opt_Xml_Buffer::TAG_BEFORE, ' if($foo){ '); $node->addBefore(Opt_Xml_Buffer::TAG_AFTER, ' } ');
The brackets enclose both the tag and the rest of the currently added code snippets assigned to this node:
$node->addBefore(Opt_Xml_Buffer::TAG_BEFORE, ' if($foo){ '); $node->addAfter(Opt_Xml_Buffer::TAG_AFTER, ' } ');
See also:
- 7.9.1. addAfter()
7.9. Opt_Xml_Buffer class - « Previous
7.9. Opt_Xml_Buffer class - Next »
7.9.2. addBefore()