Пример #1
0
 public function createCollection(CreateCollectionParameters $parameters, bool $disableAccess = false)
 {
     $collection = new Collection($parameters->getOwnerSID());
     if (!$disableAccess) {
         $this->getEventEmitter()->emit(self::EVENT_COLLECTION_ACCESS, [$collection]);
     }
     $collection->setTitle($parameters->getTitle())->setDescription($parameters->getDescription())->setThemeIds($parameters->getThemeIds());
     $this->collectionRepository->createCollection($collection);
     $this->avatarService->generateImage(new CollectionImageStrategy($collection, $this->images, $this->wwwImagesDir));
     $this->backdropService->backdropPreset($collection, $this->presetFactory, $this->presetFactory->getListIds()[array_rand($this->presetFactory->getListIds())]);
     $this->collectionRepository->saveCollection($collection);
     $this->getEventEmitter()->emit(self::EVENT_COLLECTION_CREATED, [$collection]);
     return $collection;
 }