本文整理匯總了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]));
}
}
示例2: delete
public function delete(BaseEntityInterface $entity)
{
$this->entityManager->remove($entity);
if ($this->autoFlush) {
$this->entityManager->flush();
}
}
示例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();
}
示例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);
});
}
示例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();
}
示例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();
}
}
示例7: remove
/**
* @param object $entity
* @param bool $doFlush
*/
public function remove($entity, $doFlush = true)
{
$this->entityManager->remove($entity);
if ($doFlush) {
$this->entityManager->flush();
}
}
示例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();
}
示例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);
});
}
示例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);
}
}
示例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();
}
示例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');
}
}
示例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;
}
示例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;
}
示例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;
}