NestedElementHandler::init PHP Method

init() public method

This includes:

  • creation of the nested element
  • calling the setters for attributes
  • adding the element to the container object
  • adding a reference to the element (if id attribute is given)
public init ( $propType, $attrs )
    function init($propType, $attrs)
    {
        $configurator = $this->configurator;
        $project = $this->configurator->project;
        // introspect the parent class that is custom
        $parentClass = get_class($this->parent);
        $ih = IntrospectionHelper::getHelper($parentClass);
        try {
            if ($this->parent instanceof UnknownElement) {
                $this->child = new UnknownElement(strtolower($propType));
                $this->parent->addChild($this->child);
            } else {
                $this->child = $ih->createElement($project, $this->parent, strtolower($propType));
            }
            $configurator->configureId($this->child, $attrs);
            if ($this->parentWrapper !== null) {
                $this->childWrapper = new RuntimeConfigurable($this->child, $propType);
                $this->childWrapper->setAttributes($attrs);
                $this->parentWrapper->addChild($this->childWrapper);
            } else {
                $configurator->configure($this->child, $attrs, $project);
                $ih->storeElement($project, $this->parent, $this->child, strtolower($propType));
            }
        } catch (BuildException $exc) {
            throw new ExpatParseException("Error initializing nested element <{$propType}>", $exc, $this->parser->getLocation());
        }
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Checks for nested tags within the current one. Creates and calls
  * handlers respectively.
  *
  * @param  string  the tag that comes in
  * @param  array   attributes the tag carries
  * @access public
  */
 function startElement($name, $attrs)
 {
     //print(get_class($this) . " name = $name, attrs = " . implode(",",$attrs) . "\n");
     if ($this->child instanceof TaskContainer) {
         // taskcontainer nested element can contain other tasks - no other
         // nested elements possible
         $tc = new TaskHandler($this->parser, $this, $this->configurator, $this->child, $this->childWrapper, $this->target);
         $tc->init($name, $attrs);
     } else {
         $neh = new NestedElementHandler($this->parser, $this, $this->configurator, $this->child, $this->childWrapper, $this->target);
         $neh->init($name, $attrs);
     }
 }
All Usage Examples Of NestedElementHandler::init