Esempio n. 1
0
 /**
  * @param array             $changed
  * @param Project           $project
  * @param InheritanceConfig $config
  *
  * @throws ProjectException
  * @throws UnitObjectException
  */
 public function resolve(array $changed, Project $project, InheritanceConfig $config)
 {
     if (count($changed) == 0) {
         return;
     }
     $this->logger->reset();
     $this->logger->log("Resolving inheritance\n");
     $this->project = $project;
     $this->config = $config;
     $this->setupDependencies();
     foreach ($changed as $unit) {
         /** @var AbstractUnitObject $unit */
         if ($unit->hasExtends()) {
             foreach ($unit->getExtends() as $name) {
                 try {
                     $extendedUnit = $this->getUnitByName($name);
                     $this->processExtends($unit, $extendedUnit);
                 } catch (ProjectException $e) {
                     $this->addUnresolved($unit, $name);
                 }
             }
         }
         if ($unit->hasImplements()) {
             foreach ($unit->getImplements() as $implements) {
                 try {
                     $implementsUnit = $this->getUnitByName($implements);
                     $this->processImplements($unit, $implementsUnit);
                 } catch (ProjectException $e) {
                     $this->addUnresolved($unit, $implements);
                 }
             }
         }
         if ($unit->usesTraits()) {
             foreach ($unit->getUsedTraits() as $traitName) {
                 try {
                     $traitUnit = $this->getUnitByName($traitName);
                     $this->processTraitUse($unit, $unit->getTraitUse($traitName), $traitUnit);
                 } catch (ProjectException $e) {
                     $this->addUnresolved($unit, $traitName);
                 }
             }
         }
         $unitName = $unit->getName();
         if (isset($this->unresolved[$unitName])) {
             foreach ($this->unresolved[$unitName] as $missingUnit) {
                 $unit->markDependencyAsUnresolved($missingUnit);
             }
         }
         $this->logger->progress('processed');
     }
     $this->project->save();
     $this->logger->completed();
 }
Esempio n. 2
0
 /**
  * Run Documentation generation process
  *
  * @param GeneratorConfig $config
  *
  * @throws ApplicationException
  * @return void
  */
 public function runGenerator(GeneratorConfig $config)
 {
     $this->logger->reset();
     $this->logger->log("Starting generator");
     $engineFactory = $this->factory->getEngineFactory();
     $enricherFactory = $this->factory->getEnricherFactory();
     $failed = array_diff($config->getRequiredEngines(), $engineFactory->getEngineList());
     if (count($failed)) {
         $list = join("', '", $failed);
         throw new ApplicationException("The engine(s) '{$list}' is/are not registered", ApplicationException::UnknownEngine);
     }
     $failed = array_diff($config->getRequiredEnrichers(), $enricherFactory->getEnricherList());
     if (count($failed)) {
         $list = join("', '", $failed);
         throw new ApplicationException("The enricher(s) '{$list}' is/are not registered", ApplicationException::UnknownEnricher);
     }
     $generator = $this->factory->getGenerator();
     foreach ($config->getActiveBuilds() as $buildCfg) {
         $generator->addEngine($engineFactory->getInstanceFor($buildCfg));
     }
     $this->logger->log('Loading enrichers');
     foreach ($config->getActiveEnrichSources() as $type => $enrichCfg) {
         try {
             $enricher = $enricherFactory->getInstanceFor($enrichCfg);
             $generator->addEnricher($enricher);
             $this->logger->log(sprintf('Enricher %s initialized successfully', $enricher->getName()));
         } catch (EnricherException $e) {
             $this->logger->log(sprintf("Exception while initializing enricher %s:\n\n    %s\n", $type, $e->getMessage()));
         }
     }
     $pconfig = $config->getProjectConfig();
     if (!file_exists($pconfig->getWorkDirectory() . '/index.xml')) {
         throw new ApplicationException('Workdirectory does not contain an index.xml file. Did you run the collector?', ApplicationException::IndexMissing);
     }
     if (!file_exists($pconfig->getWorkDirectory() . '/source.xml')) {
         throw new ApplicationException('Workdirectory does not contain an source.xml file. Did you run the collector?', ApplicationException::SourceMissing);
     }
     $srcDir = $pconfig->getSourceDirectory();
     if (!file_exists($srcDir) || !is_dir($srcDir)) {
         throw new ApplicationException(sprintf('Invalid src directory "%s" specified', $srcDir), ApplicationException::InvalidSrcDirectory);
     }
     $this->logger->log("Starting event loop.\n");
     $generator->run(new \TheSeer\phpDox\Generator\Project($srcDir, $pconfig->getWorkDirectory()));
     $this->logger->log("Generator process completed");
 }