Inheritance: extends AbstractEvent
Example #1
0
        public function enrichStart(PHPDoxStartEvent $event) {
            $dom = $event->getIndex()->asDom();
            /** @var fDOMElement $enrichtment */
            $enrichtment = $this->getEnrichtmentContainer($dom->documentElement, 'git');

            $binary = $this->config->getGitBinary();

            $devNull = strtolower(substr(PHP_OS, 0, 3)) == 'win' ? 'NUL' : '/dev/null';

            $cwd = getcwd();
            chdir($this->config->getSourceDirectory());
            $describe = exec($binary . ' describe --always --dirty 2>'.$devNull, $foo, $rc);
            if ($rc !== 0) {
                $enrichtment->appendChild(
                    $dom->createComment('Not a git repository or no git binary available')
                );
                chdir($cwd);
                $this->noGitAvailable = true;
                return;
            }

            exec($binary . ' tag 2>'.$devNull, $tags, $rc);
            if (count($tags)) {
                $tagsNode = $enrichtment->appendElementNS(self::GITNS, 'tags');
                foreach($tags as $tagName) {
                    $tag = $tagsNode->appendElementNS(self::GITNS, 'tag');
                    $tag->setAttribute('name', $tagName);
                }
            }

            $currentBranch = 'master';
            exec($binary . ' branch --no-color 2>'.$devNull, $branches, $rc);
            if (count($branches)) {
                $branchesNode = $enrichtment->appendElementNS(self::GITNS, 'branches');
                foreach($branches as $branchName) {
                    $branch = $branchesNode->appendElementNS(self::GITNS, 'branch');
                    if ($branchName[0] == '*') {
                        $branchName = trim(substr($branchName, 1));
                        $currentBranch = $branchName;
                    } else {
                        $branchName = trim($branchName);
                    }
                    $branch->setAttribute('name', $branchName);
                }
            }

            $current = $enrichtment->appendElementNS(self::GITNS, 'current');
            $current->setAttribute('describe', $describe);
            $current->setAttribute('branch', $currentBranch);

            $this->commitSha1 = exec($binary . " rev-parse HEAD 2>".$devNull);
            $current->setAttribute('commit', $this->commitSha1);

            chdir($cwd);
        }
Example #2
0
 public function enrichStart(PHPDoxStartEvent $event)
 {
     $index = $event->getIndex()->asDom();
     $enrichment = $this->getEnrichtmentContainer($index->documentElement, 'phploc');
     // Import nodes in a loop to fix empty namespaces until sebastian fixes phploc to generate
     // "proper" xml ;)
     foreach ($this->dom->documentElement->getElementsByTagName('*') as $node) {
         /** @var \DOMNode $node */
         $enrichment->appendChild($index->createElementNS('http://xml.phpdox.net/src#', $node->localName, $node->nodeValue));
     }
 }
Example #3
0
 public function buildStart(PHPDoxStartEvent $event)
 {
     $this->clearDirectory($this->outputDir);
     $index = $event->getIndex();
     $this->hasNamespaces = $index->hasNamespaces();
     $this->hasInterfaces = $index->hasInterfaces();
     $this->hasTraits = $index->hasTraits();
     $this->hasClasses = $index->hasClasses();
     $this->xslClass = $this->getXSLTProcessor('class.xsl');
     $this->xslClass->setParameter('', 'base', '../');
     $this->xslInterface = $this->getXSLTProcessor('interface.xsl');
     $this->xslInterface->setParameter('', 'base', '../');
     $this->xslMethod = $this->getXSLTProcessor('method.xsl');
     $this->xslMethod->setParameter('', 'base', '../../');
 }
Example #4
0
 public function enrichStart(PHPDoxStartEvent $event)
 {
     $this->genericProcess($event->getIndex()->asDom());
 }