/** * @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])); } }
public function delete(BaseEntityInterface $entity) { $this->entityManager->remove($entity); if ($this->autoFlush) { $this->entityManager->flush(); } }
/** * @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(); }
/** * @param Category $category * @throws \Exception */ public function tryDelete(Category $category) { $this->tryValidate($category); $this->em->transactional(function () use($category) { $this->em->remove($category); }); }
public function processDelete(ProcessHook $hook) { $repository = $this->entityManager->getRepository('CmfcmfMediaModule:HookedObject\\HookedObjectEntity'); $hookedObject = $repository->getByHookOrCreate($hook); $this->entityManager->remove($hookedObject); $this->entityManager->flush(); }
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(); } }
/** * @param object $entity * @param bool $doFlush */ public function remove($entity, $doFlush = true) { $this->entityManager->remove($entity); if ($doFlush) { $this->entityManager->flush(); } }
/** * @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(); }
/** * @param Article $article * @throws \Exception */ public function tryDelete(Article $article) { $this->tryValidate($article); $this->em->transactional(function () use($article) { // TODO 画像の削除処理必要 $this->em->remove($article); }); }
/** * @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); } }
/** * @param Contribution $contribution */ public function remove(Contribution $contribution) { if (!$contribution->getFileName()) { return; } unlink($this->pathGenerator->getFileAbsolutePath($contribution)); $this->entityManager->remove($contribution); $this->entityManager->flush(); }
public function remove(User $user) { try { $this->entityManager->remove($user); $this->entityManager->flush(); } catch (DBALException $e) { throw new UserException('Uživatel nebyl vymazán'); } }
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; }
/** * 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; }
/** * @inheritdoc */ public function deleteFile($id) { $file = $this->getFile($id); if ($file === null) { return false; } $this->entityManager->remove($file); $this->entityManager->flush(); return true; }
/** * @param Form $form * @param Request $request * * @return bool */ public function process(Form $form, Request $request) { if (!$request->isMethod('POST')) { return false; } $form->handleRequest($request); if ($form->isValid()) { $data = $form->getData(); $this->em->remove($data); $this->em->flush(); return true; } return false; }
/** * Deletes an entity if it is in relation to another entity * * Doctrine is obviously unable to entities detached from the relational entity when merging the relational entity, * so this had to be implemented. * * @param object $relationalEntity * @param string $fieldName * @param ClassMetadata $metadata * @param boolean $recomputeChangeSet */ public function deleteOnRelationalModification($relationalEntity, $fieldName, ClassMetadata $metadata, $recomputeChangeSet = true) { if ($recomputeChangeSet) { $this->unitOfWork->computeChangeSet($metadata, $relationalEntity); } $changeSet = $this->unitOfWork->getEntityChangeSet($relationalEntity); if (!isset($changeSet[$fieldName])) { return; } $orgValue = $changeSet[$fieldName][0]; if (null !== $orgValue && $this->entityManager->contains($orgValue)) { $this->entityManager->remove($orgValue); } }
/** * @param Schema $schema */ public function down(Schema $schema) { $rep = $this->em->getRepository('AnimeDbCatalogBundle:Studio'); // rename studios /* @var $studio Studio */ foreach ($this->rename as $from => $to) { $studio = $rep->findOneBy(['name' => $to]); $studio->setName($from); $this->em->persist($studio); } // remove studios foreach ($this->add as $name) { $this->em->remove($rep->findOneBy(['name' => $name])); } }
function it_handles_a_delete_command(Entity $entity, Delete $command, EntityManagerInterface $em) { $command->getEntity()->willReturn($entity); $em->remove($entity)->shouldBeCalled(); $em->flush()->shouldBeCalled(); $this->handle($command); }
/** * {@inheritdoc} */ public function schedule(ProductInterface $product) { foreach ($product->getCompletenesses() as $completeness) { $this->manager->remove($completeness); } $product->getCompletenesses()->clear(); }
protected function cleanTable($entityName) { $o = $this->em->getRepository($entityName)->findAll(); foreach ($o as $e) { $this->em->remove($e); } $this->em->flush(); }
/** * Deletes all the fixtures job */ public function deleteJobs() { $jobs = $this->em->getRepository($this->container->getParameter('akeneo_batch.entity.job_instance.class'))->findBy(array('type' => FixtureJobLoader::JOB_TYPE)); foreach ($jobs as $job) { $this->em->remove($job); } $this->em->flush(); }
/** * @Given /^there is no "([^"]*)" association type named "([^"]*)"$/ * * @param $code * @param $name */ public function thereIsNoAssociationType($code, $name) { $associationType = $this->getAssociationType($code, $name); if ($associationType) { $this->entityManager->remove($associationType); $this->entityManager->flush(); } }
/** * remove an entity from persistent storage * * @param EntityInterface $entity */ public function destroy(EntityInterface $entity) { /* * run dependency check */ $this->checkDependencies(); $this->entityManager->remove($entity); }
public function removeResource($entityName, $id) { $resource = $this->getResource($entityName, $id); $eventData = new RemoveActionEventData($entityName, $resource); $this->dispatchActionEvent(new ActionEvent(ActionEvent::PRE, $eventData)); $this->entityManager->remove($resource); $this->dispatchActionEvent(new ActionEvent(ActionEvent::POST, $eventData)); return $resource; }
/** * Deletes a user * * @param $id * * @throws EntityNotFoundException */ public function deleteUser($id) { $user = $this->repository->find($id); if (!$user) { throw new EntityNotFoundException(); } $this->em->remove($user); $this->em->flush(); }
/** * deleteImages * * This method delete the images given in a collection * * @param array : $aImagesCollection */ private function deleteImages($aImagesCollection) { if (!empty($aImagesCollection)) { foreach ($aImagesCollection as $oAnnonceImages) { $this->oEm->remove($oAnnonceImages); } $this->oEm->flush(); } }
/** * @param $ticketDetail */ private function removeVisitor() { self::$entityManager->clear(); $ticketDetail = self::$entityManager->getRepository('AppBundle:TicketDetail')->find(self::$ticketDetailId); $visitor = $ticketDetail->getVisitor(); $ticketDetail->setVisitor(); self::$entityManager->remove($visitor); self::$entityManager->flush(); }
/** * @param integer $eventId * @throws EventNotFoundException */ public function delete($eventId) { $event = $this->eventRepository->find($eventId); if (!$event) { throw new EventNotFoundException($eventId); } $this->entityManager->remove($event); $this->entityManager->flush(); }
/** * Removes conditions from condition groups when they are not in the given array. * * @param ConditionGroupEntity $conditionGroup * @param array $conditionIds */ protected function removeNonExistentConditions($conditionGroup, $conditionIds) { foreach ($conditionGroup->getConditions() as $condition) { if ($condition->getId() && !in_array($condition->getId(), $conditionIds)) { $conditionGroup->removeCondition($condition); $this->em->remove($condition); } } }