findUnitNodeByName() public method

public findUnitNodeByName ( $namespace, $name ) : TheSeer\fDOM\fDOMElement
$namespace
$name
return TheSeer\fDOM\fDOMElement
コード例 #1
0
ファイル: Project.php プロジェクト: rxz135cc/yii2webApp
        /**
         * @return array
         */
        public function save() {
            $map = array('class' => 'classes', 'trait' => 'traits', 'interface' => 'interfaces');
            foreach ($map as $col) {
                $path = $this->xmlDir . '/' . $col;
                if (!file_exists($path)) {
                    mkdir($path, 0755, TRUE);
                }
            }
            $indexDom = $this->index->export();
            $reportUnits = $this->saveUnits;
            foreach($this->saveUnits as $unit) {
                /** @var AbstractUnitObject $unit  */
                $indexNode = $this->index->findUnitNodeByName($unit->getNamespace(), $unit->getLocalName());
                if (!$indexNode) {
                    throw new ProjectException(
                        sprintf(
                            "Internal Error: Unit '%s' not found in index (ns: %s, n: %s).",
                            $unit->getName(),
                            $unit->getNamespace(),
                            $unit->getLocalName()
                        ),
                        ProjectException::UnitNotFoundInIndex
                    );
                }
                $name = str_replace('\\', '_', $unit->getName());
                $dom = $unit->export();
                $dom->formatOutput = TRUE;
                $dom->preserveWhiteSpace = FALSE;
                $fname = $map[$dom->documentElement->localName] . '/' . $name . '.xml';
                if ($indexNode->hasAttribute('xml')) {
                     $reportUnits = array_merge($reportUnits, $this->findAffectedUnits($fname));
                } else {
                    $indexNode->setAttribute('xml', $fname);
                }
                $dom->save($this->xmlDir . '/' . $fname);
            }
            $indexDom->formatOutput = TRUE;
            $indexDom->preserveWhiteSpace = FALSE;
            $indexDom->save($this->xmlDir . '/index.xml');

            $sourceDom = $this->source->export();
            $sourceDom->formatOutput = TRUE;
            $sourceDom->preserveWhiteSpace = FALSE;
            $sourceDom->save($this->xmlDir . '/source.xml');

            $this->saveUnits = array();

            return $reportUnits;
        }
コード例 #2
0
ファイル: Project.php プロジェクト: webkingashu/phpdox
 private function saveUnit(array $map, array $reportUnits, AbstractUnitObject $unit)
 {
     $indexNode = $this->index->findUnitNodeByName($unit->getNamespace(), $unit->getLocalName());
     if (!$indexNode) {
         throw new ProjectException(sprintf("Internal Error: Unit '%s' not found in index (ns: %s, n: %s).", $unit->getName(), $unit->getNamespace(), $unit->getLocalName()), ProjectException::UnitNotFoundInIndex);
     }
     $name = str_replace('\\', '_', $unit->getName());
     $dom = $unit->export();
     $dom->formatOutput = TRUE;
     $dom->preserveWhiteSpace = FALSE;
     $fname = $map[$dom->documentElement->localName] . '/' . $name . '.xml';
     try {
         $dom->save($this->xmlDir . '/' . $fname);
     } catch (fDOMException $e) {
         throw new ProjectException(sprintf("Internal Error: Unit '%s' could not be saved (ns: %s, n: %s).", $unit->getName(), $unit->getNamespace(), $unit->getLocalName()), ProjectException::UnitCouldNotBeSaved, $e);
     }
     if ($indexNode->hasAttribute('xml')) {
         $reportUnits = array_merge($reportUnits, $this->findAffectedUnits($fname));
     } else {
         $indexNode->setAttribute('xml', $fname);
     }
     return $reportUnits;
 }