コード例 #1
0
ファイル: TodoCommand.php プロジェクト: activecollab/shade
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     ini_set('date.timezone', 'UTC');
     $project = new Project(getcwd());
     if ($project->isValid()) {
         Shade::initSmarty($project, Shade::getBuildTheme($project->getDefaultBuildTheme()));
         $this->renderEverything($project, $input->getOption('locale'));
         $todo_notes = Shade::getTodo();
         if (count($todo_notes)) {
             $table = new Table($output);
             $table->setHeaders(['Message', 'File']);
             $path_len = strlen(rtrim($project->getPath(), '/'));
             foreach ($todo_notes as $todo_note) {
                 $table->addRow([$todo_note['message'], substr($todo_note['file'], $path_len + 1)]);
             }
             $table->render();
             $output->writeln('');
             if (count($todo_notes) === 1) {
                 $output->writeln('1 todo note found');
             } else {
                 $output->writeln(count($todo_notes) . ' todo notes found');
             }
         } else {
             $output->writeln('0 todo notes found');
         }
     } else {
         $output->writeln('<error>This is not a valid Shade project</error>');
     }
 }
コード例 #2
0
ファイル: BuildCommand.php プロジェクト: activecollab/shade
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     ini_set('date.timezone', 'UTC');
     $project = new Project(getcwd());
     if ($project->isValid()) {
         $target_path = $this->getBuildTarget($input, $project);
         $theme = $this->getTheme($input, $project);
         if (!$this->isValidTargetPath($target_path)) {
             $output->writeln("Build target '{$target_path}' not found or not writable");
             return;
         }
         if (!$theme instanceof Theme) {
             $output->writeln("Theme not found");
             return;
         }
         $this->smarty =& Shade::initSmarty($project, $theme);
         $this->prepareTargetPath($input, $output, $project, $target_path, $theme);
         foreach ($project->getLocales() as $locale => $locale_name) {
             Shade\SmartyHelpers::setCurrentLocale($locale);
             $this->smarty->assign('current_locale', $locale);
             foreach (['buildLandingPage', 'buildWhatsNew', 'buildReleaseNotes', 'buildBooks', 'buildVideos'] as $build_step) {
                 try {
                     if (!$this->{$build_step}($input, $output, $project, $target_path, $theme, $locale)) {
                         $output->writeln("Build process failed at step '{$build_step}'. Aborting...");
                         return;
                     }
                 } catch (Exception $e) {
                     $output->writeln('Exception: ' . $e->getMessage());
                     $output->writeln($e->getTraceAsString());
                 }
             }
         }
     } else {
         $output->writeln('<error>This is not a valid Shade project</error>');
     }
 }