예제 #1
0
 /**
  * Process annotations from summary XML file
  *
  * @param string $path
  * @param string $summaryXml
  * @return void
  */
 protected function processAnnotations($path, $summaryXml)
 {
     $doc = new \DOMDocument();
     $doc->load($summaryXml);
     $xpath = new \DOMXPath($doc);
     // Add line numbers to all entities
     foreach ($xpath->query('//class') as $classNode) {
         $files = $classNode->getElementsByTagName('file');
         if ($files->length === 0) {
             continue;
         }
         $file = $files->item(0)->getAttribute('name');
         $processor = $this->factory->factory($file);
         $classNode->setAttribute('line', $processor->getLineForEntity($classNode->getAttribute('name'), 'class'));
         foreach ($classNode->getElementsByTagName('method') as $methodNode) {
             $methodNode->setAttribute('line', $processor->getLineForEntity($methodNode->getAttribute('name'), 'function'));
         }
     }
     // Replace all paths in summary.xml with relative paths
     foreach ($xpath->query('//file') as $fileNode) {
         $fileNode->setAttribute('name', str_replace($path, '', $fileNode->getAttribute('name')));
     }
     $doc->save($summaryXml);
     $this->model->load($summaryXml);
     foreach ($this->model->getAnnotations() as $annotation) {
         $this->gateway->create($annotation);
     }
 }
예제 #2
0
 /**
  * Show project overview
  *
  * @param RMF\Request $request
  * @return Struct\Response
  */
 public function show(RMF\Request $request)
 {
     $path = $request->variables['path'] ?: '/';
     $source = array();
     $annotations = array();
     $index = array();
     if (file_exists($file = $this->source . '/' . $path) && is_file($file)) {
         $processor = $this->factory->factory($file);
         $processor->addAnnotations($annotations = $this->gateway->getAnnotationsForFile($path));
         $source = $processor->getSourceData();
         $index = $processor->getIndex();
     }
     return new Struct\Response('source.twig', array('path' => $path, 'tree' => $this->getSourceTree($path), 'source' => $source, 'index' => $index, 'annotations' => $annotations, 'dependencies' => $this->getClassMetainformation($path)));
 }