示例#1
0
 public function editCommunity(int $communityId, EditCommunityParameters $parameters) : Community
 {
     $community = $this->communityRepository->getCommunityById($communityId);
     $community->setTitle($parameters->getTitle());
     $community->setDescription($parameters->getDescription());
     if ($parameters->hasThemeId()) {
         $community->setTheme($this->themeRepository->getThemeById($parameters->getThemeId()));
     } else {
         $community->unsetTheme();
     }
     $this->communityRepository->saveCommunity($community);
     $this->getEventEmitter()->emit(self::EVENT_COMMUNITY_UPDATED, [$community]);
     return $community;
 }
示例#2
0
 public function uploadImagePreview(int $themeId, string $path) : string
 {
     $theme = $this->getThemeById($themeId);
     $dir = $theme->getId();
     $name = sprintf('%s.png', GenerateRandomString::gen(self::GENERATE_FILENAME_LENGTH));
     $newPath = sprintf('%s/%s', $dir, $name);
     if ($this->fileSystem->has($dir)) {
         $this->fileSystem->deleteDir($dir);
     }
     $this->fileSystem->write($newPath, file_get_contents($path));
     $theme->setPreview($newPath);
     $this->themeRepository->saveTheme($theme);
     return $theme->getPreview();
 }