Example #1
0
 /**
  * @param string $sub_dir
  * @param string $locale
  * @return string
  */
 private function getLocalizedPath($sub_dir, $locale)
 {
     if ($this->project->isMultilingual()) {
         return $this->project->getPath() . "/{$locale}/{$sub_dir}";
     } else {
         return $this->project->getPath() . "/{$sub_dir}";
     }
 }
Example #2
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $project = new Project(getcwd());
     if ($project->isValid()) {
         $output->writeln('Project already initialized');
     } else {
         $configuration = ['name' => $input->getArgument('name'), 'default_build_theme' => 'bootstrap', 'video_groups' => [Video::GETTING_STARTED => 'Getting Started']];
         if (empty($configuration['name'])) {
             $configuration['name'] = basename($project->getPath());
         }
         $default_locale = $input->getOption('default-locale');
         if ($default_locale) {
             $configuration['is_multilingual'] = true;
             $configuration['default_locale'] = $default_locale;
         }
         if (file_put_contents($project->getPath() . '/project.json', json_encode($configuration, JSON_PRETTY_PRINT))) {
             $output->writeln('Project initialized');
         } else {
             $output->writeln('<error>Failed to create a project configuration file</error>');
         }
         if ($default_locale) {
             if (!mkdir($project->getPath() . '/' . $default_locale)) {
                 $output->writeln("<error>Failed to create '{$default_locale}' folder</error>");
             }
             if (!file_put_contents($project->getPath() . '/' . $default_locale . '/index.md', $this->getProjectIndexMd())) {
                 $output->writeln("<error>Failed to create '{$default_locale}/index.md' folder</error>");
             }
         } else {
             if (!file_put_contents($project->getPath() . '/index.md', $this->getProjectIndexMd())) {
                 $output->writeln("<error>Failed to create 'index.md' folder</error>");
             }
         }
         foreach (['books', 'releases', 'videos', 'whats_new'] as $what_to_make) {
             if ($default_locale) {
                 $what_to_make = "{$default_locale}/{$what_to_make}";
             }
             if (!mkdir($project->getPath() . '/' . $what_to_make)) {
                 $output->writeln("<error>Failed to create '{$what_to_make}' folder</error>");
             }
         }
         if (!mkdir($project->getPath() . '/temp')) {
             $output->writeln('<error>Failed to create /temp folder</error>');
         }
         if (!mkdir($project->getPath() . '/build')) {
             $output->writeln('<error>Failed to create /build folder</error>');
         }
     }
 }
Example #3
0
 /**
  * Method that is used for collecting to-do items
  *
  * @param string $message
  * @param Project|Element $element
  */
 public static function recordTodo($message, $element)
 {
     if ($element instanceof Element) {
         $path = $element->getPath();
     } elseif ($element instanceof Project) {
         $path = $element->getPath();
     } else {
         $path = '-UNKNOWN-';
     }
     self::$todo[] = ['message' => $message, 'file' => $path];
 }