當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。