本文整理汇总了PHP中Sylius\Component\Resource\Repository\RepositoryInterface::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP RepositoryInterface::remove方法的具体用法?PHP RepositoryInterface::remove怎么用?PHP RepositoryInterface::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Resource\Repository\RepositoryInterface
的用法示例。
在下文中一共展示了RepositoryInterface::remove方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: iDeleteTheProduct
/**
* @When /^I delete the ("[^"]+" product)$/
* @When /^I try to delete the ("([^"]+)" product)$/
*/
public function iDeleteTheProduct(ProductInterface $product)
{
try {
$this->sharedStorage->set('product_id', $product->getId());
$this->productRepository->remove($product);
} catch (DBALException $exception) {
$this->sharedStorage->set('last_exception', $exception);
}
}
示例2:
function it_throws_exception_while_trying_to_remove_a_coupon_and_actually_removing_it(SharedStorageInterface $sharedStorage, RepositoryInterface $couponRepository, CouponInterface $coupon)
{
$coupon->getId()->willReturn(5);
$couponRepository->remove($coupon)->shouldBeCalled();
$sharedStorage->set('last_exception', Argument::any())->shouldNotBeCalled();
$this->shouldThrow(\Exception::class)->during('iTryToDeleteCoupon', [$coupon]);
}
示例3: theStoreDoesNotHaveAnyZonesDefined
/**
* @Given the store does not have any zones defined
*/
public function theStoreDoesNotHaveAnyZonesDefined()
{
$zones = $this->zoneRepository->findAll();
foreach ($zones as $zone) {
$this->zoneRepository->remove($zone);
}
}
示例4: theStoreDoesNotHaveLocale
/**
* @Given the locale :localeCode does not exist in the store
*/
public function theStoreDoesNotHaveLocale($localeCode)
{
/** @var LocaleInterface $locale */
$locale = $this->localeRepository->findOneBy(['code' => $localeCode]);
if (null !== $locale) {
$this->localeRepository->remove($locale);
}
}
示例5: deleteAction
/**
* @param Request $request
*
* @return Response
*/
public function deleteAction(Request $request)
{
$configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
$this->isGrantedOr403($configuration, ResourceActions::DELETE);
$resource = $this->findOr404($configuration);
$event = $this->eventDispatcher->dispatchPreEvent(ResourceActions::DELETE, $configuration, $resource);
if ($event->isStopped() && !$configuration->isHtmlRequest()) {
throw new HttpException($event->getErrorCode(), $event->getMessage());
}
if ($event->isStopped()) {
$this->flashHelper->addFlashFromEvent($configuration, $event);
return $this->redirectHandler->redirectToIndex($configuration, $resource);
}
$this->repository->remove($resource);
$this->eventDispatcher->dispatchPostEvent(ResourceActions::DELETE, $configuration, $resource);
if (!$configuration->isHtmlRequest()) {
return $this->viewHandler->handle($configuration, View::create(null, 204));
}
$this->flashHelper->addSuccessFlash($configuration, ResourceActions::DELETE, $resource);
return $this->redirectHandler->redirectToIndex($configuration, $resource);
}
示例6: deleteAction
/**
* @param Request $request
*
* @return Response
*/
public function deleteAction(Request $request)
{
$configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
$this->isGrantedOr403($configuration, ResourceActions::DELETE);
$resource = $this->findOr404($configuration);
if ($configuration->isCsrfProtectionEnabled() && !$this->isCsrfTokenValid($resource->getId(), $request->get('_csrf_token'))) {
throw new HttpException(Response::HTTP_FORBIDDEN, 'Invalid csrf token.');
}
$event = $this->eventDispatcher->dispatchPreEvent(ResourceActions::DELETE, $configuration, $resource);
if ($event->isStopped() && !$configuration->isHtmlRequest()) {
throw new HttpException($event->getErrorCode(), $event->getMessage());
}
if ($event->isStopped()) {
$this->flashHelper->addFlashFromEvent($configuration, $event);
return $this->redirectHandler->redirectToIndex($configuration, $resource);
}
$this->repository->remove($resource);
$this->eventDispatcher->dispatchPostEvent(ResourceActions::DELETE, $configuration, $resource);
if (!$configuration->isHtmlRequest()) {
return $this->viewHandler->handle($configuration, View::create(null, Response::HTTP_NO_CONTENT));
}
$this->flashHelper->addSuccessFlash($configuration, ResourceActions::DELETE, $resource);
return $this->redirectHandler->redirectToIndex($configuration, $resource);
}
示例7: iDeleteCoupon
/**
* @When /^I delete ("([^"]+)" coupon)$/
*/
public function iDeleteCoupon(CouponInterface $coupon)
{
$this->sharedStorage->set('coupon', $coupon);
$this->couponRepository->remove($coupon);
}
示例8: accountWasDeleted
/**
* @Given the account of :email was deleted
*/
public function accountWasDeleted($email)
{
$user = $this->userRepository->findOneByEmail($email);
$this->sharedStorage->set('customer', $user->getCustomer());
$this->userRepository->remove($user);
}
示例9:
function it_tries_to_delete_a_product_that_does_not_exist(SharedStorageInterface $sharedStorage, RepositoryInterface $productRepository, ProductInterface $product)
{
$product->getId()->willReturn(1);
$productRepository->find(1)->willReturn(null);
$sharedStorage->set('deleted_product', $product)->shouldBeCalled();
$productRepository->remove($product)->willThrow(DBALException::class);
$sharedStorage->set('last_exception', Argument::type(DBALException::class))->shouldBeCalled();
$this->iDeleteTheProduct($product);
}