public function unSubscribeTheme(Profile $profile, Theme $theme)
 {
     $criteria = ['profile_id' => $profile->getId(), 'theme_id' => $theme->getId(), 'type' => Subscribe::TYPE_THEME];
     $subscribe = $this->getSubscribe($criteria);
     $em = $this->getEntityManager();
     $em->remove($subscribe);
     $em->flush();
 }
Beispiel #2
0
 public function createTheme(CreateThemeParameters $parameters) : Theme
 {
     $em = $this->getEntityManager();
     if ($parameters->hasForcedId()) {
         $forceId = $parameters->getForceId();
         if ($this->hasThemeWithId($forceId)) {
             throw new ThemeWithThisIdExistsException(sprintf('Theme with ID `%s` already exists', $forceId));
         }
         $themeEntity = new Theme($parameters->getTitle(), $forceId);
     } else {
         $themeEntity = new Theme($parameters->getTitle());
     }
     $themeEntity->setDescription($parameters->getDescription());
     if ($parameters->hasSpecifiedURL()) {
         $themeEntity->setURL($parameters->getSpecifiedURL());
     }
     if ($parameters->hasPreview()) {
         $themeEntity->setPreview($parameters->getPreview());
     }
     $parentId = $parameters->hasParent() ? $parameters->getParentId() : null;
     if ($parentId) {
         $themeEntity->setParent($em->getReference(Theme::class, $parentId));
     }
     $sameLevelThemes = $this->getThemesByParentId($parentId);
     $serialManager = new SerialManager($sameLevelThemes);
     $serialManager->insertLast($themeEntity);
     $serialManager->normalize();
     $em->persist($themeEntity);
     $em->flush($sameLevelThemes + [$themeEntity]);
     return $themeEntity;
 }
Beispiel #3
0
 public function setParent(Theme $parent = null) : self
 {
     if ($parent && $this->isPersisted() && $parent->getId() === $this->getId()) {
         throw new \Exception('Unable to setup parent');
     }
     $this->parent = $parent;
     return $this;
 }
Beispiel #4
0
 public function unSubscribeTheme(Profile $profile, Theme $subscribe)
 {
     $criteria = ['profileId' => $profile->getId(), 'subscribeId' => $subscribe->getId(), 'subscribeType' => Subscribe::TYPE_THEME];
     return $this->subscribeRepository->unSubscribeByCriteria($criteria);
 }