DataTypeHandler::init PHP Метод

init() публичный Метод

This includes:

  • creation of the datatype object
  • calling the setters for attributes
  • adding the type to the target object if any
  • adding a reference to the task (if id attribute is given)
public init ( $propType, $attrs )
    function init($propType, $attrs)
    {
        // shorthands
        $project = $this->configurator->project;
        $configurator = $this->configurator;
        try {
            //try
            $this->element = $project->createDataType($propType);
            if ($this->element === null) {
                throw new BuildException("Unknown data type {$propType}");
            }
            if ($this->target !== null) {
                $this->wrapper = new RuntimeConfigurable($this->element, $propType);
                $this->wrapper->setAttributes($attrs);
                $this->target->addDataType($this->wrapper);
            } else {
                $configurator->configure($this->element, $attrs, $project);
                $configurator->configureId($this->element, $attrs);
            }
        } catch (BuildException $exc) {
            throw new ExpatParseException($exc, $this->parser->getLocation());
        }
    }

Usage Example

Пример #1
0
 /**
  * Handles start elements within the <project> tag by creating and
  * calling the required handlers for the detected element.
  *
  * @param  string  the tag that comes in
  * @param  array   attributes the tag carries
  * @throws ExpatParseException if a unxepected element occurs
  * @access public
  */
 function startElement($name, $attrs)
 {
     $project = $this->configurator->project;
     $types = $project->getDataTypeDefinitions();
     if ($name == "target") {
         $tf = new TargetHandler($this->parser, $this, $this->configurator);
         $tf->init($name, $attrs);
     } elseif (isset($types[$name])) {
         $tyf = new DataTypeHandler($this->parser, $this, $this->configurator);
         $tyf->init($name, $attrs);
     } else {
         $tf = new TaskHandler($this->parser, $this, $this->configurator);
         $tf->init($name, $attrs);
     }
 }
All Usage Examples Of DataTypeHandler::init