remove() 공개 메소드

A removed entity will be removed from the database at or before transaction commit or as a result of the flush operation.
public remove ( object $entity )
$entity object The entity instance to remove.
예제 #1
1
 /**
  * Delete a given article
  * @param Article            $article
  */
 public function delete(Article $article, BusinessEntityPage $bep)
 {
     $this->entityManager->remove($bep);
     $this->entityManager->remove($article);
     //flush the modifications
     $this->entityManager->flush();
 }
예제 #2
0
 /**
  * @param $entity
  */
 public function removeEntity($entity)
 {
     $this->em->remove($entity);
     $this->em->flush();
     $isFound = $this->em->getRepository(get_class($entity))->findOneBy(['id' => $entity->getId()]);
     $this->assertNull($isFound);
 }
예제 #3
0
 /**
  * @param $object
  * @param bool $isFlush
  */
 protected function remove($object, $isFlush = false)
 {
     $this->em->remove($object);
     if ($isFlush) {
         $this->em->flush($object);
     }
 }
예제 #4
0
 /**
  * @param object $object
  * @param string $flush
  */
 public function delete($object, $flush = true)
 {
     $this->entityManager->remove($object);
     if ($flush) {
         $this->entityManager->flush();
     }
 }
예제 #5
0
 /**
  * @param Object $object
  * @param boolean $flush
  */
 public function remove($object, $flush = true)
 {
     $this->em->remove($object);
     if ($flush) {
         $this->em->flush();
     }
 }
 public function delete($invitation, $withFlush = false)
 {
     $this->entityManager->remove($invitation);
     if ($withFlush) {
         $this->entityManager->flush();
     }
 }
예제 #7
0
 protected function saveObjects()
 {
     // Product information korábbi elemeinek törlése
     $oldItems = $this->object->getInformation()->toArray();
     if ($oldItems) {
         foreach ($oldItems as $item) {
             $this->entityManager->remove($item);
             $this->object->removeInformation($item);
         }
     }
     // Product information-be új elemek hozzá adása
     if ($this->informationObjects) {
         foreach ($this->informationObjects as $item) {
             $this->object->addInformation($item);
         }
     }
     // Product persist
     $this->entityManager->persist($this->object);
     // Product information persistek
     if ($this->informationObjects) {
         foreach ($this->informationObjects as $object) {
             $this->entityManager->persist($object);
         }
     }
     //Flush
     $this->entityManager->flush();
 }
예제 #8
0
 /**
  * {@inheritdoc}
  */
 public function remove(BannerInterface $banner, $save = false)
 {
     $this->em->remove($banner);
     if (true === $save) {
         $this->save();
     }
 }
 /**
  * @param $id
  * @return integer
  */
 public function excluir($id)
 {
     $entity = $this->em->getReference('Admin\\Domain\\Entity\\OtherEntity', (int) $id);
     $this->em->remove($entity);
     $this->em->flush();
     return (int) $id;
 }
예제 #10
0
 /**
  * {@inheritdoc}
  */
 public function remove(SeoMetadataInterface $seoMetadata, $save = false)
 {
     $this->em->remove($seoMetadata);
     if (true === $save) {
         $this->save();
     }
 }
예제 #11
0
 /**
  * {@inheritdoc}
  */
 public function remove(TreeInterface $tree, $save = false)
 {
     $this->em->remove($tree);
     if (true === $save) {
         $this->save();
     }
 }
예제 #12
0
 /**
  * {@inheritdoc}
  */
 public function remove(TextNodeInterface $textNode, $save = false)
 {
     $this->em->remove($textNode);
     if (true === $save) {
         $this->save();
     }
 }
예제 #13
0
 /**
  * {@inheritdoc}
  */
 public function remove(SiteInterface $site, $save = false)
 {
     $this->em->remove($site);
     if (true === $save) {
         $this->save();
     }
 }
예제 #14
0
 /**
  * Save reminders
  *
  * @param RemindableInterface $entity
  */
 public function saveReminders(RemindableInterface $entity)
 {
     // Persist and flush new entity to get id
     if (!($entityId = $this->getEntityIdentifier($entity))) {
         $this->entityManager->persist($entity);
         $this->entityManager->flush($entity);
         $entityId = $this->getEntityIdentifier($entity);
     }
     $reminders = $entity->getReminders();
     $reminderData = $entity->getReminderData();
     $entityClass = $this->getEntityClassName($entity);
     if (!$reminders instanceof RemindersPersistentCollection) {
         foreach ($reminders as $reminder) {
             $this->syncEntityReminder($reminder, $reminderData, $entityClass, $entityId);
             $this->entityManager->persist($reminder);
         }
     } else {
         if ($reminders->isDirty()) {
             foreach ($reminders->getInsertDiff() as $reminder) {
                 $this->entityManager->persist($reminder);
             }
             foreach ($reminders->getDeleteDiff() as $reminder) {
                 $this->entityManager->remove($reminder);
             }
         }
         foreach ($reminders as $reminder) {
             $this->syncEntityReminder($reminder, $reminderData, $entityClass, $entityId);
         }
     }
 }
 /**
  * @param InstitutionMedicalCenter $center
  */
 function updateInstitutionMedicalCenterListing(InstitutionMedicalCenter $center)
 {
     $institution = $center->getInstitution();
     $criteria = array('institution' => $institution->getId(), 'institutionMedicalCenter' => $center->getId());
     $recentlyApprovedListing = $this->em->getRepository('AdminBundle:RecentlyApprovedListing')->findOneBy($criteria);
     if ($recentlyApprovedListing) {
         if ($center->getStatus() == InstitutionMedicalCenterStatus::APPROVED) {
             $recentlyApprovedListing->setDateUpdated(new \DateTime());
             $this->em->persist($recentlyApprovedListing);
         } else {
             $this->em->remove($recentlyApprovedListing);
         }
         $this->em->flush();
     } else {
         if ($center->getStatus() == InstitutionMedicalCenterStatus::APPROVED) {
             $recentlyApprovedListingService = new RecentlyApprovedListingService();
             $recentlyApprovedListingService->setEntityManager($this->em);
             $recentlyApprovedListing = new RecentlyApprovedListing();
             $recentlyApprovedListing->setInstitution($institution);
             $recentlyApprovedListing->setInstitutionMedicalCenter($center);
             $recentlyApprovedListing->setDateUpdated(new \DateTime());
             $recentlyApprovedListing->setStatus(1);
             $this->em->persist($recentlyApprovedListing);
             $this->em->flush($recentlyApprovedListing);
         }
     }
 }
예제 #16
0
 protected function doDeleteWithLock(AggregateRootInterface $aggregate)
 {
     $this->entityManager->remove($aggregate);
     if ($this->forceFlushOnSave) {
         $this->entityManager->flush();
     }
 }
예제 #17
0
파일: BaseManager.php 프로젝트: Robgd/Disko
 /**
  * @param $entity
  * @param bool $andFlush
  */
 public function delete($entity, $andFlush = true)
 {
     $this->em->remove($entity);
     if ($andFlush) {
         $this->em->flush();
     }
 }
 /**
  * @param string $pageName
  * @param string $programId
  */
 private function removeIfExists($pageName, $programId)
 {
     $page = $this->getPageEntity($pageName, $programId);
     if ($page) {
         $this->entityManager->remove($page);
     }
 }
예제 #19
0
 /**
  * {@inheritdoc}
  */
 public function remove(ImageInterface $image, $save = false)
 {
     $this->em->remove($image);
     if (true === $save) {
         $this->save();
     }
 }
예제 #20
0
 /**
  * @param Request $request
  * @return RedirectResponse
  * @throws \Doctrine\ORM\ORMException
  */
 public function deleteAction(Request $request)
 {
     $invoiceId = $request->get('invoiceId');
     $invoiceReference = $this->entityManager->getReference('Invoicity\\Business\\Entity\\Invoice', $invoiceId);
     $this->entityManager->remove($invoiceReference);
     $this->entityManager->flush();
     return new RedirectResponse($this->router->generate('invoicity_invoice_index'));
 }
예제 #21
0
 /**
  * {@inheritDoc}
  */
 public function remove($id)
 {
     if (false == ($readModel = $this->find($id))) {
         return false;
     }
     $this->entityManager->remove($readModel);
     $this->entityManager->flush();
 }
예제 #22
0
 /**
  * Delete a given article.
  *
  * @param Article $article
  */
 public function delete(Article $article, BusinessPage $bep)
 {
     $this->entityManager->remove($bep);
     $article->setVisibleOnFront(0);
     $article->setDeletedAt(new \DateTime());
     //flush the modifications
     $this->entityManager->flush();
 }
 public function delete($repository, $id)
 {
     $deleteItem = $this->em->getRepository($repository)->find($id);
     $this->assertNotNull($deleteItem);
     $this->em->remove($deleteItem);
     $this->em->flush();
     $this->assertNull($deleteItem->getId());
 }
 public function remove($deviceToken)
 {
     if (!is_object($deviceToken)) {
         $deviceToken = $this->repository->findOneBy(['deviceToken' => $deviceToken]);
     }
     $this->em->remove($deviceToken);
     $this->em->flush();
 }
 public function removeItem($itemId, User $user)
 {
     $wallItem = $this->wallItemRepository->findOneBy(array("id" => $itemId, "user" => $user));
     if ($wallItem !== null) {
         $this->em->remove($wallItem);
         $this->em->flush();
     }
 }
 /**
  * {@inheritDoc}
  */
 public function remove(EntityInterface $entity, $flush = true)
 {
     $this->entityManager->remove($entity);
     if ($flush === true) {
         $this->entityManager->flush();
     }
     return true;
 }
예제 #27
0
 public function removeTag(File $file, Tag $tag)
 {
     foreach ($file->getFileTags() as $tagRelation) {
         if ($tagRelation->getTag()->getId() == $tag->getId()) {
             $this->em->remove($tagRelation);
         }
     }
 }
예제 #28
0
 public function removeById($id)
 {
     $session = $this->findById($id);
     if (!is_null($session)) {
         $this->em->remove($session);
         $this->em->flush();
     }
 }
예제 #29
0
 /**
  * @param JobCalendar $jobCalendar
  */
 public function deleteJobCalendar(JobCalendar $jobCalendar)
 {
     $this->transformer->setMode(AbstractTransformer::MODE_FULL);
     $model = $this->transformer->entityToModel($jobCalendar);
     $this->manager->remove($jobCalendar);
     $this->manager->flush();
     $this->dispatcher->dispatch(JobCalendarEvents::DELETED, new JobCalendarDeletedEvent($model));
 }
예제 #30
0
 /**
  * Invalidate token
  *
  * @param Newscoop\Entity\User $user
  * @param string $action
  * @return void
  */
 public function invalidateTokens(User $user, $action = 'any')
 {
     $tokens = $this->em->getRepository('Newscoop\\Entity\\UserToken')->findBy(array('user' => $user->getId(), 'action' => $action));
     foreach ($tokens as $token) {
         $this->em->remove($token);
     }
     $this->em->flush();
 }