当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityManager::remove方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:blitzik,项目名称:CMS,代码行数:12,代码来源:PageRemover.php

示例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;
     }
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:13,代码来源:ListingsWriter.php

示例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;
 }
开发者ID:krupaj,项目名称:my-blog,代码行数:16,代码来源:TagRepository.php

示例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();
 }
开发者ID:Kotys,项目名称:eventor.io,代码行数:14,代码来源:Event.php

示例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;
     }
 }
开发者ID:blitzik,项目名称:CMS,代码行数:15,代码来源:RoleRemover.php

示例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();
     }
 }
开发者ID:CSHH,项目名称:website,代码行数:15,代码来源:FileManager.php

示例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;
     }
 }
开发者ID:blitzik,项目名称:CMS,代码行数:18,代码来源:UserRemover.php

示例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();
     }
 }
开发者ID:blitzik,项目名称:CMS,代码行数:18,代码来源:CommentRemover.php

示例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);
 }
开发者ID:MrTommy1979,项目名称:reference,代码行数:28,代码来源:EventService.php

示例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);
         }
     });
 }
开发者ID:brosland,项目名称:framework,代码行数:17,代码来源:Authorizator.php

示例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;
 }
开发者ID:krupaj,项目名称:my-blog,代码行数:25,代码来源:VoteRepository.php

示例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;
     }
 }
开发者ID:blitzik,项目名称:CMS,代码行数:26,代码来源:TagRemover.php

示例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();
 }
开发者ID:ParalelniPolis,项目名称:bitcoinJukebox,代码行数:21,代码来源:SongsManager.php

示例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;
 }
开发者ID:CSHH,项目名称:website,代码行数:24,代码来源:WikiRepository.php

示例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;
 }
开发者ID:krupaj,项目名称:my-blog,代码行数:42,代码来源:VoteFormFactory.php


注:本文中的Kdyby\Doctrine\EntityManager::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。