Exemplo n.º 1
0
 /**
  * Execute the command.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function execute()
 {
     $this->getApplication()->outputTitle('Make Documentation');
     $this->usePBar = $this->getApplication()->get('cli-application.progress-bar');
     if ($this->getApplication()->input->get('noprogress')) {
         $this->usePBar = false;
     }
     $this->github = $this->getContainer()->get('gitHub');
     $this->getApplication()->displayGitHubRateLimit();
     /* @type \Joomla\Database\DatabaseDriver $db */
     $db = $this->getContainer()->get('db');
     $docuBase = JPATH_ROOT . '/Documentation';
     /* @type  \RecursiveDirectoryIterator $it */
     $it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($docuBase, \FilesystemIterator::SKIP_DOTS));
     $this->out('Compiling documentation in: ' . $docuBase)->out();
     $table = new ArticlesTable($db);
     // @todo compile the md text here.
     $table->setGitHub($this->github);
     while ($it->valid()) {
         if ($it->isDir()) {
             $it->next();
             continue;
         }
         $file = new \stdClass();
         $file->filename = $it->getFilename();
         $path = $it->getSubPath();
         $page = substr($it->getFilename(), 0, strrpos($it->getFilename(), '.'));
         $this->debugOut('Compiling: ' . $page);
         $table->reset();
         $table->{$table->getKeyName()} = null;
         try {
             $table->load(array('alias' => $page, 'path' => $path));
         } catch (\RuntimeException $e) {
             // New item
         }
         $table->is_file = '1';
         $table->path = $it->getSubPath();
         $table->alias = $page;
         $table->text_md = file_get_contents($it->key());
         $table->store();
         $this->out('.', false);
         $it->next();
     }
     $this->out()->out('Finished =;)');
 }