Inheritance: extends AbstractUnitObject
Exemple #1
0
 public function getUnitByName($name)
 {
     $parts = explode('\\', $name);
     $local = array_pop($parts);
     $namespace = join('\\', $parts);
     $indexNode = $this->index->queryOne(sprintf('//phpdox:namespace[@name="%s"]/*[@name="%s"]', $namespace, $local));
     if (!$indexNode) {
         return;
     }
     $dom = new fDOMDocument();
     $dom->load($this->baseDir . '/' . $indexNode->getAttribute('xml'));
     switch ($indexNode->localName) {
         case 'interface':
             $unit = new InterfaceObject();
             $unit->import($dom);
             $this->project->addInterface($unit);
             break;
         case 'trait':
             $unit = new TraitObject();
             $unit->import($dom);
             $this->project->addTrait($unit);
             break;
         case 'class':
             $unit = new ClassObject();
             $unit->import($dom);
             $this->project->addClass($unit);
             break;
     }
     return $unit;
 }
Exemple #2
0
 public function getUnitByName($name)
 {
     $parts = explode('\\', $name);
     $local = array_pop($parts);
     $namespace = join('\\', $parts);
     $indexNode = $this->index->queryOne(sprintf('//phpdox:namespace[@name="%s"]/*[@name="%s"]', $namespace, $local));
     if (!$indexNode) {
         throw new DependencyException(sprintf("Unit '%s' not found", $name), DependencyException::UnitNotFound);
     }
     $dom = new fDOMDocument();
     $dom->load($this->baseDir . '/' . $indexNode->getAttribute('xml'));
     switch ($indexNode->localName) {
         case 'interface':
             $unit = new InterfaceObject();
             $unit->import($dom);
             $this->project->addInterface($unit);
             break;
         case 'trait':
             $unit = new TraitObject();
             $unit->import($dom);
             $this->project->addTrait($unit);
             break;
         case 'class':
             $unit = new ClassObject();
             $unit->import($dom);
             $this->project->addClass($unit);
             break;
         default:
             throw new DependencyException(sprintf("Invalid unit type '%s'", $indexNode->localName), DependencyException::InvalidUnitType);
     }
     return $unit;
 }
Exemple #3
0
 /**
  *
  */
 public function addTrait(TraitObject $trait)
 {
     $this->loadedUnits[$trait->getName()] = $trait;
     $this->registerForSaving($trait);
     $this->index->addTrait($trait);
 }