예제 #1
0
 private function lookupThemeTree(int $themeId, int $baseWeight) : array
 {
     $merge = [(string) $themeId => $baseWeight];
     $theme = $this->themeService->getThemeById($themeId);
     if ($theme->hasParent()) {
         $merge = array_merge($merge, $this->lookupThemeTree($theme->getParentId(), (int) ($baseWeight / 2)));
     }
     return $merge;
 }
예제 #2
0
 private function createTheme(array $themeJSON)
 {
     if (!$this->themeService->hasThemeWithId($themeJSON['id'])) {
         ++$this->counter;
         $this->output->writeln(sprintf(' * [#NEW THEME] id: %d, title: %s, parent_id: %s, preview: %s', $themeJSON['id'], $themeJSON['title'], $themeJSON['parent_id'], $themeJSON['image'] ?? '<NONE>'));
         $parameters = new CreateThemeParameters($themeJSON['title'], $themeJSON['description'] ?? '', null, $themeJSON['parent_id'], $themeJSON['id']);
         $theme = $this->themeService->createTheme($parameters);
         if ($themeJSON['image']) {
             $this->themeService->uploadImagePreview($theme->getId(), sprintf('%s/%s', self::THEMES_PREVIEW_DIR, $themeJSON['image']));
         }
     }
 }
예제 #3
0
 public function __invoke() : array
 {
     return ['themes' => $this->buildJSON($this->themeService->getThemesAsTree()), 'config' => ['themes' => ['www' => $this->wwwStorage]]];
 }