3.5.2. configure()

array configure

The method to overwrite by the programmer. It returns the list of instruction tags to register with their types. The returned array must have the following structure:

public function configure()
{
	return array(
		0 => 'processorname',
		// registered tags
		'tag' => OPT_TAGTYPE,
		'tag' => OPT_TAGTYPE,
		'tag' => OPT_TAGTYPE,
		...
	);
} // end configure();

The tag type is one of the following:

  1. OPT_COMMAND - standalone block, without subnodes (for example {tag/})
  2. OPT_MASTER - opening block, probably contains nodes with nested elements: {tag}.
  3. OPT_ALT - alternative block, also could contain some nodes: {tagelse}.
  4. OPT_ENDER - closing block, without subnodes: {/tag}.
  5. OPT_ATTRIBUTE - dynamic attribute: namespace:name="value"

Note: if you want to use namespaces, they must be also specified in the tag name, for example: 'namespace:sometag' => OPT_MASTER. Below, we provide a real example of registering section tags:

Example 3.15. Registering section tags

<?php
		public function configure()
		{
			return array(
				// processor name
				0 => 'section',
				// instructions
				'section' => OPT_MASTER,
				'sectionelse' => OPT_ALT,
				'/section' => OPT_ENDER,
				'show' => OPT_MASTER,
				'showelse' => OPT_ALT,
				'/show' => OPT_ENDER,
				'sectionfirst' => OPT_ATTRIBUTE, // use the "opt" namespace here
				'sectionlast' => OPT_ATTRIBUTE,
				'sectioncycle' => OPT_ATTRIBUTE
			);
		} // end configure();
?>