本文整理汇总了PHP中Kdyby\Doctrine\EntityManager::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::remove方法的具体用法?PHP EntityManager::remove怎么用?PHP EntityManager::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kdyby\Doctrine\EntityManager
的用法示例。
在下文中一共展示了EntityManager::remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removePageUrl
/**
* @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: removeListing
/**
* @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: deleteTag
/**
* 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: delete
/**
* @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: remove
/**
* @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: removeFile
/**
* @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: remove
/**
* @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: remove
/**
* @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: saveSetList
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: setup
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: deleteVote
/**
* 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: remove
/**
* @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: deleteSong
/**
* @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: updateWithDraft
/**
* @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: editVote
/**
* @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;
}