コード例 #1
0
ファイル: BuildCommand.php プロジェクト: activecollab/shade
 /**
  * Build videos
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @param Project         $project
  * @param string          $target_path
  * @param Theme           $theme
  * @param string          $locale
  * @return bool
  * @throws Exception
  * @throws \SmartyException
  */
 public function buildVideos(InputInterface $input, OutputInterface $output, Project $project, $target_path, Theme $theme, $locale)
 {
     $videos_path = $locale === $project->getDefaultLocale() ? "{$target_path}/videos" : "{$target_path}/{$locale}/videos";
     Shade::createDir($videos_path, function ($path) use(&$output) {
         $output->writeln("Directory '{$path}' created");
     });
     if (is_dir($project->getFinder()->getVideosPath($locale) . '/images')) {
         $video_images_path = $locale === $project->getDefaultLocale() ? "{$target_path}/assets/images/videos" : "{$target_path}/assets/images/{$locale}/videos";
         Shade::createDir($video_images_path, function ($path) use(&$output) {
             $output->writeln("Directory '{$path}' created");
         });
         Shade::copyDir($project->getFinder()->getVideosPath($locale) . '/images', $video_images_path, null, function ($path) use(&$output) {
             $output->writeln("{$path} copied");
         });
     }
     $videos = $project->getVideos();
     if (!$videos->count()) {
         return true;
         // Skip video section rendering
     }
     $video_groups = $project->getVideoGroups();
     $this->smarty->assign(['video_groups' => $video_groups, 'videos' => $videos, 'page_level' => 1, 'video_player' => $project->getVideoPlayer(), 'current_video' => $this->getCurrentVideo($video_groups, $videos), 'current_section' => 'videos']);
     Shade::writeFile("{$videos_path}/index.html", $this->smarty->fetch('videos.tpl'), function ($path) use(&$output) {
         $output->writeln("File '{$path}' created");
     });
     foreach ($videos as $video) {
         $this->smarty->assign(['current_video' => $video]);
         Shade::writeFile("{$videos_path}/" . $video->getSlug() . ".html", $this->smarty->fetch('videos.tpl'), function ($path) use(&$output) {
             $output->writeln("File '{$path}' created");
         });
     }
     return true;
 }