public function up(EventEmitterInterface $globalEmitter)
 {
     $eq = $this->eq;
     $collectionService = $this->collectionService;
     $themeService = $this->themeService;
     $themeService->getEventEmitter()->on(ThemeService::EVENT_DELETE, function (Theme $theme) use($eq, $collectionService) {
         array_reduce($eq->getCollectionsByThemeId($theme->getId()), function (CollectionThemeEQEntity $eq) use($collectionService) {
             $collection = $collectionService->getCollectionById($eq->getCollectionId());
             $collection->setThemeIds(array_filter($collection->getThemeIds(), function ($input) use($eq) {
                 return (int) $input !== (int) $eq->getThemeId();
             }));
             if (!count($collection->getThemeIds())) {
                 $collection->setPublicOptions(['is_private' => $collection->isPrivate(), 'public_enabled' => false, 'moderation_contract' => false]);
             }
             // TODO:: Notification about turning off public
             $this->collectionRepository->saveCollection($collection);
         });
     });
     $collectionService->getEventEmitter()->on(CollectionService::EVENT_COLLECTION_CREATED, function (Collection $collection) use($eq) {
         $eq->sync($collection->getId(), $collection->getThemeIds());
     });
     $collectionService->getEventEmitter()->on(CollectionService::EVENT_COLLECTION_EDITED, function (Collection $collection) use($eq) {
         $eq->sync($collection->getId(), $collection->getThemeIds());
     });
     $collectionService->getEventEmitter()->on(CollectionService::EVENT_COLLECTION_DELETE, function (Collection $collection) use($eq) {
         $eq->deleteEQOfCollection($collection->getId());
     });
 }
Пример #2
0
 public function loadCollectionsByIds(array $collectionIds)
 {
     $this->collectionRepository->getCollectionsById($collectionIds);
 }