deleteAction() 보호된 메소드

Updated edited element action
protected deleteAction ( Request $request, Mixed $entity, string $redirectPath = null ) : RedirectResponse
$request Symfony\Component\HttpFoundation\Request Request
$entity Mixed Entity to delete
$redirectPath string Redirect path
리턴 Symfony\Component\HttpFoundation\RedirectResponse Redirect response
예제 #1
0
 /**
  * Delete entity
  *
  * @param Request $request      Request
  * @param mixed   $entity       Entity to delete
  * @param string  $redirectPath Redirect path
  *
  * @return RedirectResponse Redirect response
  *
  * @Route(
  *      path = "/{id}/delete",
  *      name = "admin_customer_delete",
  *      methods = {"GET", "POST"}
  * )
  *
  * @EntityAnnotation(
  *      class = "elcodi.entity.customer.class",
  *      mapping = {
  *          "id" = "~id~"
  *      }
  * )
  */
 public function deleteAction(Request $request, $entity, $redirectPath = null)
 {
     return parent::deleteAction($request, $entity, $this->generateUrl('admin_customer_list'));
 }
예제 #2
0
 /**
  * Delete entity
  *
  * @param Request $request      Request
  * @param mixed   $entity       Entity to delete
  * @param string  $redirectPath Redirect path
  *
  * @return RedirectResponse Redirect response
  *
  * @Route(
  *      path = "/{id}/delete",
  *      name = "admin_shipping_range_delete",
  *      methods = {"GET", "POST"}
  * )
  *
  * @EntityAnnotation(
  *      class = "elcodi.entity.shipping_range.class",
  *      mapping = {
  *          "id" = "~id~"
  *      }
  * )
  */
 public function deleteAction(Request $request, $entity, $redirectPath = null)
 {
     /**
      * @var ShippingRangeInterface $entity
      */
     $carrierId = $entity->getCarrier()->getId();
     parent::deleteAction($request, $entity, $this->generateUrl('admin_carrier_edit', ['id' => $carrierId]));
 }
예제 #3
0
 /**
  * Delete element action
  *
  * @param Request $request      Request
  * @param mixed   $variant      Variant to delete
  * @param string  $redirectPath Redirect path
  *
  * @return RedirectResponse Redirect response
  *
  * @Route(
  *      path = "/{id}/delete",
  *      name = "admin_product_variant_delete"
  * )
  * @Method({"GET", "POST"})
  *
  * @EntityAnnotation(
  *     class = "elcodi.entity.product.class",
  *     name = "product",
  *     mapping = {
  *         "id": "~productId~"
  *     }
  * )
  * @EntityAnnotation(
  *      class = "elcodi.entity.product_variant.class",
  *      name = "variant",
  *      mapping = {
  *          "id" = "~id~"
  *      }
  * )
  */
 public function deleteAction(Request $request, $variant, $redirectPath = null)
 {
     /**
      * @var ProductInterface $product
      * @var VariantInterface $variant
      */
     $product = $variant->getProduct();
     /*
      * Getting the list of unique Attributes associated with
      * the Variant to be deleted. This is a safety check,
      * since a Variant should *not* have more than one
      * option with the same Attribute
      */
     $variantAttributes = $this->getUniqueAttributesFromVariant($variant);
     $notRemovableAttributes = [];
     /**
      * @var VariantInterface $iteratedVariant
      *
      * Getting all the Attributes by iterating over the parent
      * product Variants (except for the Variant being deleted)
      * to see if we can safetly remove from the product collection
      * the Attributes associated with the Variant to be removed
      *
      */
     foreach ($product->getVariants() as $iteratedVariant) {
         /*
          * We want to collect Attributes from Varints other
          * than the one we want to delete
          */
         if ($iteratedVariant == $variant) {
             /*
              * Do not add attributes from Variant to be deleted
              */
             continue;
         }
         $notRemovableAttributes = array_merge($notRemovableAttributes, $this->getUniqueAttributesFromVariant($iteratedVariant));
     }
     /**
      * @var AttributeInterface $variantAttribute
      *
      * Checking whether we can safely de-associate
      * Attributes from the Variant we are deleting
      * from parent product Attribute collection
      */
     foreach ($variantAttributes as $variantAttribute) {
         if (in_array($variantAttribute, $notRemovableAttributes)) {
             continue;
         }
         $product->removeAttribute($variantAttribute);
     }
     $this->flush($product);
     return parent::deleteAction($request, $variant);
 }
예제 #4
0
 /**
  * Delete entity
  *
  * @param Request $request      Request
  * @param mixed   $entity       Entity to delete
  * @param string  $redirectPath Redirect path
  *
  * @return RedirectResponse Redirect response
  *
  * @Route(
  *      path = "/{id}/delete",
  *      name = "admin_purchasable_pack_delete"
  * )
  * @Method({"GET", "POST"})
  *
  * @EntityAnnotation(
  *      class = "elcodi.entity.purchasable_pack.class",
  *      mapping = {
  *          "id" = "~id~"
  *      }
  * )
  */
 public function deleteAction(Request $request, $entity, $redirectPath = null)
 {
     return parent::deleteAction($request, $entity, $this->generateUrl('admin_purchasable_pack_list'));
 }
예제 #5
0
 /**
  * Delete entity
  *
  * @param Request $request      Request
  * @param mixed   $entity       Entity to delete
  * @param string  $redirectPath Redirect path
  *
  * @return RedirectResponse Redirect response
  *
  * @Route(
  *      path = "/{id}/delete",
  *      name = "admin_page_delete",
  *      methods = {"GET", "POST"},
  * )
  *
  * @EntityAnnotation(
  *      class = "elcodi.entity.page.class",
  *      mapping = {
  *          "id" = "~id~"
  *      }
  * )
  */
 public function deleteAction(Request $request, $entity, $redirectPath = null)
 {
     try {
         $this->canBeDeactivated($entity);
     } catch (AccessDeniedException $exception) {
         return $this->getFailResponse($request, $exception);
     }
     return parent::deleteAction($request, $entity, $this->generateUrl('admin_page_list'));
 }
 /**
  * Delete entity
  *
  * @param Request $request      Request
  * @param mixed   $entity       Entity to delete
  * @param string  $redirectPath Redirect path
  *
  * @return RedirectResponse Redirect response
  *
  * @Route(
  *      path = "/{id}/delete",
  *      name = "admin_newsletter_subscription_delete"
  * )
  * @Method({"GET"})
  *
  * @EntityAnnotation(
  *      class = "elcodi.entity.newsletter_subscription.class",
  *      mapping = {
  *          "id" = "~id~"
  *      }
  * )
  * @JsonResponse
  */
 public function deleteAction(Request $request, $entity, $redirectPath = null)
 {
     return parent::deleteAction($request, $entity, $this->generateUrl('admin_newsletter_subscription_list'));
 }
예제 #7
0
 /**
  * Delete entity
  *
  * @param Request $request      Request
  * @param mixed   $entity       Entity to delete
  * @param string  $redirectPath Redirect path
  *
  * @return RedirectResponse Redirect response
  *
  * @Route(
  *      path = "/{id}/delete",
  *      name = "admin_admin_user_delete",
  *      methods = {"GET", "POST"}
  * )
  *
  * @EntityAnnotation(
  *      class = "elcodi.entity.admin_user.class",
  *      mapping = {
  *          "id" = "~id~"
  *      }
  * )
  */
 public function deleteAction(Request $request, $entity, $redirectPath = null)
 {
     if ($this->isSameUser($entity)) {
         $this->denyWithMessage('admin.admin_user.error.cant_delete_yourself');
     }
     return parent::deleteAction($request, $entity, $this->generateUrl('admin_admin_user_list'));
 }
예제 #8
0
 /**
  * Delete entity
  *
  * @param Request $request      Request
  * @param mixed   $entity       Entity to delete
  * @param string  $redirectPath Redirect path
  *
  * @return RedirectResponse Redirect response
  *
  * @Route(
  *      path = "/{id}/delete",
  *      name = "admin_image_delete"
  * )
  * @Method({"GET", "POST"})
  *
  * @EntityAnnotation(
  *      class = "elcodi.entity.image.class",
  *      mapping = {
  *          "id" = "~id~"
  *      }
  * )
  */
 public function deleteAction(Request $request, $entity, $redirectPath = null)
 {
     $redirectPathParam = $request->query->get('redirect-path');
     $redirectPath = is_null($redirectPathParam) ? $this->generateUrl('admin_image_list') : $redirectPath;
     return parent::deleteAction($request, $entity, $redirectPath);
 }