remove() 공개 메소드

public remove ( object | array $entity ) : EntityManager
$entity object | array
리턴 EntityManager
예제 #1
0
파일: PageRemover.php 프로젝트: blitzik/CMS
 /**
  * @param Page $page
  */
 private function removePageUrl(Page $page)
 {
     /** @var Url $url */
     $url = $this->urlFacade->getByPath($page->getUrlPath());
     if ($url !== null) {
         $this->cache->clean([Cache::TAGS => $url->getCacheKey()]);
         $this->em->remove($url);
     }
 }
예제 #2
0
 /**
  * @param Listing $listing
  * @throws \Exception
  */
 public function removeListing(Listing $listing)
 {
     try {
         $this->em->remove($listing)->flush();
     } catch (\Exception $e) {
         $this->onCritical(sprintf('Removal of Listing #id(%s) failed. [%s]', $listing->getId(), 'removeListing'), $e, self::class);
         throw $e;
     }
 }
예제 #3
0
 /**
  * Odstraneni konkretniho tagu
  * @param \App\Model\Entities\Tag $tag
  * @return boolean
  */
 public function deleteTag(Entities\Tag $tag)
 {
     try {
         $this->em->remove($tag);
         $result = $this->em->flush();
     } catch (\Doctrine\ORM\ORMException $e) {
         Debugger::log($e, Debugger::INFO);
         $result = FALSE;
     }
     return $result;
 }
예제 #4
0
파일: Event.php 프로젝트: Kotys/eventor.io
 /**
  * @param Entity\Event $event
  */
 public function delete(Entity\Event $event)
 {
     foreach ($event->performances as $performance) {
         foreach ($performance->children as $child) {
             $this->em->remove($child);
         }
         $this->em->remove($performance);
     }
     $this->em->remove($event);
     $this->em->flush();
 }
예제 #5
0
파일: RoleRemover.php 프로젝트: blitzik/CMS
 /**
  * @param Role $role
  * @throws ForeignKeyConstraintViolationException
  */
 public function remove(Role $role)
 {
     try {
         $roleID = $role->getId();
         $this->em->remove($role);
         $this->em->flush();
         $this->onSuccessRoleRemoval($role, $roleID);
     } catch (ForeignKeyConstraintViolationException $e) {
         throw $e;
     }
 }
예제 #6
0
 /**
  * @param FileEntityInterface $entity
  */
 public function removeFile(FileEntityInterface $entity)
 {
     --$entity->joints;
     if ($entity->joints === 0) {
         $this->em->remove($entity);
         $this->em->flush();
         $this->unlinkFile($this->uploadDir . '/' . $entity->year . '/' . $entity->month . '/' . $entity->name . '.' . $entity->extension);
     } else {
         $this->em->persist($entity);
         $this->em->flush();
     }
 }
예제 #7
0
파일: UserRemover.php 프로젝트: blitzik/CMS
 /**
  * @param User $user
  * @throws ForeignKeyConstraintViolationException
  */
 public function remove(User $user)
 {
     try {
         $this->cache->remove($user);
         // will be recreated if an error occur
         $userID = $user->getId();
         $this->em->remove($user);
         $this->em->flush();
         $this->onSuccessUserRemoval($user, $userID);
     } catch (ForeignKeyConstraintViolationException $e) {
         // todo log
         throw $e;
     }
 }
예제 #8
0
 /**
  * @param Comment $comment
  * @throws ActionFailedException
  */
 public function remove(Comment $comment)
 {
     try {
         $this->em->beginTransaction();
         $this->em->remove($comment)->flush();
         $this->em->createQuery('UPDATE ' . Comment::class . ' c SET c.order = c.order - 1
              WHERE c.page = :page and c.order > :order')->execute(['page' => $comment->getPageId(), 'order' => $comment->getOrder()]);
         $this->em->commit();
     } catch (\Exception $e) {
         $this->em->rollback();
         $this->em->close();
         throw new ActionFailedException();
     }
 }
예제 #9
0
 function saveSetList($setList, $event)
 {
     $oldSetlists = $event->getSetListGroups();
     foreach ($oldSetlists as $group) {
         $oldSetListItems = $group->getSetListItems();
         $this->em->remove($oldSetListItems);
     }
     $this->em->remove($oldSetlists);
     $this->em->flush();
     $setListGroup = new \App\Model\Entity\SetListGroup();
     $setListGroup->setName('Program');
     $setListGroup->setEvent($event);
     foreach ($setList as $day) {
         foreach ($day->times as $dayItem) {
             $setListItem = new \App\Model\Entity\setListItem();
             $setListItem->setDateTime(\DateTime::createFromFormat('Y-m-d H:i', $day->day . ' ' . $dayItem->time));
             $setListItem->setName($dayItem->name);
             $setListItem->setDescription($dayItem->description);
             $setListItem->setType('item');
             $setListItem->setSetListGroup($setListGroup);
             $this->em->persist($setListItem);
             $setListGroup->addSetListItem($setListItem);
         }
     }
     $this->em->persist($setListGroup);
     $event->addSetListGroup($setListGroup);
     return $this->saveEvent($event);
 }
예제 #10
0
 public function setup()
 {
     $this->entityManager->transactional(function () {
         $privileges = $this->createPrivileges();
         if (!empty($privileges)) {
             $this->entityManager->persist($privileges);
         }
         $invalidPrivileges = $this->findInvalidPrivileges($privileges);
         if (!empty($invalidPrivileges)) {
             $this->entityManager->remove($invalidPrivileges);
         }
         $roles = $this->createRoles($privileges);
         if (!empty($roles)) {
             $this->entityManager->persist($roles);
         }
     });
 }
예제 #11
0
 /**
  * Odstraneni konkretni ankety, vcetne odpovedi
  * @param \App\Model\Entities\Vote $vote
  * @return boolean
  */
 public function deleteVote(Entities\Vote $vote)
 {
     try {
         $options = $vote->getOptions();
         //odstraneni ankety/otazky
         $this->em->remove($vote);
         //odstraneni odpovedi otazky
         foreach ($options as $option) {
             if ($option !== NULL) {
                 $this->em->remove($option);
             }
         }
         //provedeni zmen
         $result = $this->em->flush();
     } catch (\Doctrine\ORM\ORMException $e) {
         Debugger::log($e, Debugger::INFO);
         $result = FALSE;
     }
     return $result;
 }
예제 #12
0
파일: TagRemover.php 프로젝트: blitzik/CMS
 /**
  * @param $tagID
  * @throws \Exception
  */
 public function remove($tagID)
 {
     try {
         $this->em->beginTransaction();
         /** @var Tag $tag */
         $tag = $this->tagRepository->find($tagID);
         if ($tag === null) {
             $this->em->commit();
             return;
         }
         $tagSearchUrl = $this->urlFacade->getUrl('Pages:Front:Search', 'tag', $tag->getId());
         $this->em->remove($tag);
         $this->em->remove($tagSearchUrl);
         $this->em->flush();
         $this->em->commit();
         $this->onSuccessTagRemoval($tag, $tagID);
     } catch (\Exception $e) {
         $this->em->rollback();
         $this->em->close();
         throw $e;
     }
 }
예제 #13
0
 /**
  * @param string $songId
  * @return string
  * @throws CantDeleteException
  * @throws DBALException
  */
 public function deleteSong(string $songId) : string
 {
     /** @var Song $song */
     $song = $this->songRepository->find($songId);
     if ($song === null) {
         throw new CantDeleteException('file does not exist');
     }
     $this->entityManager->remove($song);
     $this->entityManager->flush($song);
     if (file_exists($this->getSongPath($song->getId()))) {
         //deleting of file is after database delete due to exceptions
         unlink($this->getSongPath($song->getId()));
     }
     return $song->getName();
 }
예제 #14
0
 /**
  * @param  Entities\WikiEntity      $e
  * @param  Entities\WikiDraftEntity $draft
  * @return Entities\WikiEntity
  */
 public function updateWithDraft(Entities\WikiEntity $e, Entities\WikiDraftEntity $draft)
 {
     $e->perex = $draft->perex;
     $e->text = $this->htmlPurifier->purify($draft->text);
     $e->lastUpdatedBy = $draft->user;
     $e->updatedAt = $draft->createdAt;
     foreach (array_reverse($e->drafts->toArray()) as $d) {
         if ($draft->id < $d->id) {
             break;
         }
         if ($e->contributors->contains($d->user) === false) {
             $e->contributors->add($d->user);
         }
         $e->drafts->removeElement($d);
         $this->em->remove($d);
     }
     $this->persistAndFlush($this->em, $e);
     return $e;
 }
예제 #15
0
 /**
  * @param Nette\Utils\ArrayHash $values Hodnoty z formulare
  * @return boolean Editace provedena uspesne?
  */
 protected function editVote($values)
 {
     $result = TRUE;
     try {
         /** @var \App\Model\Entities\Vote $editVote */
         $editVote = $this->repository->getById($values->id);
         if (!$editVote) {
             return FALSE;
         }
         // nastaveni atributu
         $editVote->setQuestion($values->question);
         $editVote->setExpire($values->expiration);
         if ($editVote->getTypeVote()->getId() !== $values->type) {
             $typeVote = $this->em->getReference(\App\Model\Entities\TypeVote::class, $values->id);
             $editVote->setTypeVote($typeVote);
         }
         $options = [];
         foreach ($values->options as $option) {
             if (empty($option->option)) {
                 continue;
             }
             $options[] = $option->option;
         }
         $result = $editVote->setOptions($options);
         foreach ($result['remove'] as $removeOption) {
             if ($removeOption === NULL) {
                 continue;
             }
             $this->em->remove($removeOption);
         }
         //ulozeni zmeny
         $this->em->flush();
     } catch (\Exception $e) {
         \Tracy\Debugger::log($e, \Tracy\Debugger::INFO);
         $result = FALSE;
     }
     return $result;
 }
예제 #16
0
 public function delete($id)
 {
     $entity = $this->getById($id);
     $this->entityManager->remove($entity);
     $this->entityManager->flush();
 }
예제 #17
0
 /**
  * Odstraneni uzivatele
  * @param \App\Model\Entities\User $user
  */
 public function deleteUser(Entities\User $user)
 {
     $this->em->remove($user);
     $this->em->flush();
 }
예제 #18
0
 public function delete($entity)
 {
     $this->em->remove($entity);
     $this->em->flush();
 }
예제 #19
0
 /**
  * Remove entity from DB
  *
  * @param BaseEntity $baseEntity
  * @throws \Exception
  */
 protected function removeEntity(BaseEntity $baseEntity)
 {
     $this->entityManager->remove($baseEntity);
     $this->entityManager->flush();
 }
예제 #20
0
 /**
  * @param EntityManager       $em
  * @param Entities\BaseEntity $e
  */
 protected function removeAndFlush(EntityManager $em, Entities\BaseEntity $e)
 {
     $em->remove($e);
     $em->flush();
 }
예제 #21
0
 /**
  * @param Entity\Performance $performance
  */
 public function delete(Entity\Performance $performance)
 {
     $this->em->remove($performance);
     $this->em->flush();
 }
예제 #22
0
파일: Child.php 프로젝트: Kotys/eventor.io
 /**
  * @param \App\Model\Event\Entity\Child $child
  *
  * @throws \Exception
  */
 public function delete(Entity\Child $child)
 {
     $this->em->remove($child);
     $this->em->flush();
 }