Example #1
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  * @throws \RuntimeException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!$this->getConfig()->hasGeneratorDirectory()) {
         throw new \RuntimeException("Generator directory is not set. Please run 'init' command first.");
     }
     $this->getIO()->writeComment('Directory: ', false);
     $this->getIO()->write($this->getConfig()->getGeneratorDirectory());
     $this->getIO()->newLine();
     $directoryIterator = $this->getDirectoryIterator();
     if (0 == iterator_count($directoryIterator)) {
         $this->getIO()->writeInfo('No Generator file found in given directory. Run "create-generator" command first');
         return;
     }
     $width = min(100, $this->getApplication()->getTerminalWidth());
     $table = Table::create($this->getIO(), $width);
     $table->addRow()->addColumn('<comment>Generator</comment>')->addColumn('<comment>Description</comment>');
     foreach ($directoryIterator as $generatorFile) {
         $description = ReflectionClass::createByPathname($generatorFile->getPathname())->getDescription();
         $table->addRow()->addColumn($generatorFile->getBasename('Generator.php'))->addColumn($description);
     }
     $table->end();
 }
Example #2
0
 /**
  * Expects pathname of generator-file,
  * and extracts namespace and classname out of the file
  *
  * @param $pathname
  * @return GeneratorBuilder
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  */
 public static function createByGeneratorPathname($pathname)
 {
     $classReader = ReflectionClass::createByPathname($pathname);
     return self::createByGeneratorClassName($classReader->getName());
 }