/** * @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); } }
/** * @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; } }
/** * 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; }
/** * @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(); }
/** * @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; } }
/** * @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(); } }
/** * @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; } }
/** * @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(); } }
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); }
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); } }); }
/** * 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; }
/** * @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; } }
/** * @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(); }
/** * @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; }
/** * @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; }
public function delete($id) { $entity = $this->getById($id); $this->entityManager->remove($entity); $this->entityManager->flush(); }
/** * Odstraneni uzivatele * @param \App\Model\Entities\User $user */ public function deleteUser(Entities\User $user) { $this->em->remove($user); $this->em->flush(); }
public function delete($entity) { $this->em->remove($entity); $this->em->flush(); }
/** * Remove entity from DB * * @param BaseEntity $baseEntity * @throws \Exception */ protected function removeEntity(BaseEntity $baseEntity) { $this->entityManager->remove($baseEntity); $this->entityManager->flush(); }
/** * @param EntityManager $em * @param Entities\BaseEntity $e */ protected function removeAndFlush(EntityManager $em, Entities\BaseEntity $e) { $em->remove($e); $em->flush(); }
/** * @param Entity\Performance $performance */ public function delete(Entity\Performance $performance) { $this->em->remove($performance); $this->em->flush(); }
/** * @param \App\Model\Event\Entity\Child $child * * @throws \Exception */ public function delete(Entity\Child $child) { $this->em->remove($child); $this->em->flush(); }