當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EntityManagerInterface::remove方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\EntityManagerInterface::remove方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityManagerInterface::remove方法的具體用法?PHP EntityManagerInterface::remove怎麽用?PHP EntityManagerInterface::remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\EntityManagerInterface的用法示例。


在下文中一共展示了EntityManagerInterface::remove方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: down

 /**
  * @param Schema $schema
  */
 public function down(Schema $schema)
 {
     $rep = $this->em->getRepository('AnimeDbCatalogBundle:Genre');
     foreach (array_keys($this->genres) as $en) {
         $this->em->remove($rep->findOneBy(['name' => $en]));
     }
 }
開發者ID:anime-db,項目名稱:catalog-bundle,代碼行數:10,代碼來源:Version20140408113030_AddItemGenres.php

示例2: delete

 public function delete(BaseEntityInterface $entity)
 {
     $this->entityManager->remove($entity);
     if ($this->autoFlush) {
         $this->entityManager->flush();
     }
 }
開發者ID:phpcommerce,項目名稱:phpcommerce,代碼行數:7,代碼來源:DoctrineBaseDao.php

示例3: up

 /**
  * @param Schema $schema
  */
 public function up(Schema $schema)
 {
     $rep = $this->em->getRepository('AnimeDbCatalogBundle:Genre');
     /* @var $genre Genre */
     foreach ($this->rename as $from => $to) {
         $genre = $rep->findOneBy(['name' => $from]);
         if (is_array($to)) {
             $genre->setName($to[1])->setTranslatableLocale('ru');
             $this->em->persist($genre);
             $this->em->flush($genre);
             $to = $to[0];
         }
         $genre->setName($to)->setTranslatableLocale('en');
         $this->em->persist($genre);
     }
     // remove
     $genre = $rep->findOneBy(['name' => 'Mystery play']);
     $this->em->remove($genre);
     // rename russian
     $genre = $rep->findOneBy(['name' => 'History']);
     $genre->setName('Исторический')->setTranslatableLocale('ru');
     $this->em->persist($genre);
     $genre = $rep->findOneBy(['name' => 'War']);
     $genre->setName('Военное')->setTranslatableLocale('ru');
     $this->em->persist($genre);
     $this->em->flush();
 }
開發者ID:anime-db,項目名稱:catalog-bundle,代碼行數:30,代碼來源:Version20140407162508_RenameItemGenres.php

示例4: tryDelete

 /**
  * @param Category $category
  * @throws \Exception
  */
 public function tryDelete(Category $category)
 {
     $this->tryValidate($category);
     $this->em->transactional(function () use($category) {
         $this->em->remove($category);
     });
 }
開發者ID:pinekta,項目名稱:mysymfonysample,代碼行數:11,代碼來源:CategoryManager.php

示例5: processDelete

 public function processDelete(ProcessHook $hook)
 {
     $repository = $this->entityManager->getRepository('CmfcmfMediaModule:HookedObject\\HookedObjectEntity');
     $hookedObject = $repository->getByHookOrCreate($hook);
     $this->entityManager->remove($hookedObject);
     $this->entityManager->flush();
 }
開發者ID:shefik,項目名稱:MediaModule,代碼行數:7,代碼來源:AbstractHookHandler.php

示例6: execute

 public function execute()
 {
     $criteria = new Criteria(['owner' => $this->user], null, null, null);
     $items = $this->basketRepository->findByCriteria($criteria);
     $order = $this->orderRepository->findActive();
     $connection = $this->entityManager->getConnection();
     $connection->beginTransaction();
     try {
         $orderItems = [];
         foreach ($items as $item) {
             /** @var Basket $item */
             $previousOrderItem = $this->orderItemRepository->findOneByCriteria(new Criteria(['owner' => $item->getOwner(), 'product' => $item->getProduct()]));
             if ($previousOrderItem) {
                 /** @var OrderItem $orderItem */
                 $orderItem = $previousOrderItem;
                 $orderItem->increaseQuantityBy($item->getQuantity());
             } else {
                 $orderItem = OrderItem::createFromBasket($item, $order);
             }
             $this->entityManager->persist($orderItem);
             $this->entityManager->remove($item);
             $orderItems[] = $orderItem;
         }
         $this->entityManager->flush();
         $connection->commit();
     } catch (\Exception $e) {
         $connection->rollBack();
         return $e->getMessage();
     }
 }
開發者ID:drymek,項目名稱:fcs-backend,代碼行數:30,代碼來源:BasketItemOrderAction.php

示例7: remove

 /**
  * @param object $entity
  * @param bool $doFlush
  */
 public function remove($entity, $doFlush = true)
 {
     $this->entityManager->remove($entity);
     if ($doFlush) {
         $this->entityManager->flush();
     }
 }
開發者ID:keylightberlin,項目名稱:util,代碼行數:11,代碼來源:EntityManager.php

示例8: delete

 /**
  * @param ModelInterface $entity
  * @return void
  */
 public function delete(ModelInterface $entity)
 {
     if (!$entity instanceof CourseInterface) {
         throw new InvalidArgumentException('expect an CourseInterface object');
     }
     $this->em->remove($entity);
     $this->em->flush();
 }
開發者ID:viettut,項目名稱:todo,代碼行數:12,代碼來源:CourseManager.php

示例9: tryDelete

 /**
  * @param Article $article
  * @throws \Exception
  */
 public function tryDelete(Article $article)
 {
     $this->tryValidate($article);
     $this->em->transactional(function () use($article) {
         // TODO 畫像の削除処理必要
         $this->em->remove($article);
     });
 }
開發者ID:pinekta,項目名稱:mysymfonysample,代碼行數:12,代碼來源:ArticleManager.php

示例10: delete

 /**
  * @param ResourceEntityInterface $entity
  */
 public function delete(ResourceEntityInterface $entity)
 {
     try {
         $this->em->remove($entity);
         $this->em->flush();
     } catch (ORMException $e) {
         throw new PersistenceException(self::ERROR_COULD_NOT_DELETE);
     }
 }
開發者ID:gointegro,項目名稱:hateoas,代碼行數:12,代碼來源:DefaultDeleter.php

示例11: remove

 /**
  * @param Contribution $contribution
  */
 public function remove(Contribution $contribution)
 {
     if (!$contribution->getFileName()) {
         return;
     }
     unlink($this->pathGenerator->getFileAbsolutePath($contribution));
     $this->entityManager->remove($contribution);
     $this->entityManager->flush();
 }
開發者ID:austinphp,項目名稱:haphpy-birthday,代碼行數:12,代碼來源:ContributionPersister.php

示例12: remove

 public function remove(User $user)
 {
     try {
         $this->entityManager->remove($user);
         $this->entityManager->flush();
     } catch (DBALException $e) {
         throw new UserException('Uživatel nebyl vymazán');
     }
 }
開發者ID:Nemrtvej,項目名稱:symfony-template,代碼行數:9,代碼來源:UserFacade.php

示例13: renderDeletePost

 public function renderDeletePost()
 {
     //	$post = $this->getPostRepository()
     //			->find(1);
     // nekomunikuje s db, vyžaduje jistotu, že záznam s id existuje
     $post = $this->entityManager->getReference(Post::class, 1);
     $this->entityManager->remove($post);
     $this->entityManager->flush();
     die;
 }
開發者ID:TomasVotruba,項目名稱:lekarna-se-skoli-doctrine,代碼行數:10,代碼來源:HomepagePresenter.php

示例14: delete

 /**
  * delete entity
  * 
  * @param int $id
  * @return bool
  */
 public function delete($id)
 {
     $entity = $this->get($id);
     if (!is_null($entity)) {
         $this->entityManager->remove($entity);
         $this->entityManager->flush();
         return true;
     }
     return false;
 }
開發者ID:phpfriq,項目名稱:zf-crud-helper,代碼行數:16,代碼來源:DoctrineEntityMapper.php

示例15: deleteFile

 /**
  * @inheritdoc
  */
 public function deleteFile($id)
 {
     $file = $this->getFile($id);
     if ($file === null) {
         return false;
     }
     $this->entityManager->remove($file);
     $this->entityManager->flush();
     return true;
 }
開發者ID:nordsoftware,項目名稱:lumen-file-manager,代碼行數:13,代碼來源:FileStorage.php


注:本文中的Doctrine\ORM\EntityManagerInterface::remove方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。