/**
  * Delete a comment with its children
  *
  * @param Request $request
  * @param string  $id
  *
  * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function deleteAction(Request $request, $id)
 {
     $manager = $this->getManagerForClass($this->commentClassName);
     $comment = $manager->find($this->commentClassName, $id);
     if (null === $comment) {
         throw new NotFoundHttpException(sprintf('Comment with id %s not found.', $id));
     }
     if ($comment->getAuthor() !== $this->getUser()) {
         throw new AccessDeniedException('You are not allowed to delete this comment.');
     }
     $this->commentRemover->remove($comment);
     return new JsonResponse();
 }
 /**
  * Remove a sequential edit for a specific user
  *
  * @param UserInterface $user
  */
 public function removeByUser(UserInterface $user)
 {
     $sequentialEdit = $this->findByUser($user);
     if (null !== $sequentialEdit) {
         $this->remover->remove($sequentialEdit);
     }
 }
 /**
  * Remove a notification
  *
  * @param UserInterface $user
  * @param int           $id
  *
  * @deprecated will be removed in 1.7. Please use Akeneo\Bundle\StorageUtilsBundle\Doctrine\Common\Remover\BaseRemove::remove()
  */
 public function remove(UserInterface $user, $id)
 {
     $notification = $this->userNotifRepository->findOneBy(['id' => $id, 'user' => $user]);
     if ($notification) {
         $this->userNotifRemover->remove($notification);
     }
 }
 /**
  * Remove an association type
  *
  * @param AssociationType $associationType
  *
  * @AclAncestor("pim_enrich_associationtype_remove")
  *
  * @return Response|RedirectResponse
  */
 public function removeAction(AssociationType $associationType)
 {
     $this->assocTypeRemover->remove($associationType);
     if ($this->getRequest()->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return $this->redirectToRoute('pim_enrich_associationtype_index');
     }
 }
 /**
  * Remove a group
  *
  * TODO : find a way to use param converter with interfaces
  *
  * @param Group $group
  *
  * @AclAncestor("pim_enrich_group_remove")
  *
  * @return Response|RedirectResponse
  */
 public function removeAction(Group $group)
 {
     $this->groupRemover->remove($group);
     if ($this->getRequest()->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return $this->redirectToRoute('pim_enrich_group_index');
     }
 }
 /**
  * Remove a family
  *
  * @param Family $family
  *
  * @AclAncestor("pim_enrich_family_remove")
  *
  * @return \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function removeAction(Family $family)
 {
     $this->familyRemover->remove($family);
     if ($this->getRequest()->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return $this->redirectToRoute('pim_enrich_family_index');
     }
 }
 /**
  * Remove a variant group
  *
  * @param string $code
  *
  * @AclAncestor("pim_enrich_group_remove")
  *
  * @return JsonResponse
  */
 public function removeAction($code)
 {
     $group = $this->groupRepository->findOneByIdentifier($code);
     if (null === $group) {
         throw new NotFoundHttpException(sprintf('Group with code "%s" not found', $code));
     }
     $this->remover->remove($group);
     return new JsonResponse();
 }
 /**
  * Delete an option of an attribute
  *
  * @param int $attributeOptionId
  *
  * @return JsonResponse
  *
  * @AclAncestor("pim_enrich_attribute_edit")
  */
 public function deleteAction($attributeOptionId)
 {
     $attributeOption = $this->findAttributeOptionOr404($attributeOptionId);
     try {
         $this->optionRemover->remove($attributeOption);
     } catch (\Exception $e) {
         return new JsonResponse(['message' => $e->getMessage()], $e->getCode());
     }
     return new JsonResponse();
 }
 /**
  * Remove product
  *
  * @param Request $request
  * @param integer $id
  *
  * @AclAncestor("pim_enrich_product_remove")
  * @return Response|RedirectResponse
  */
 public function removeAction(Request $request, $id)
 {
     $product = $this->findProductOr404($id);
     $this->productRemover->remove($product);
     if ($request->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return $this->redirectToRoute('pim_enrich_product_index');
     }
 }
 /**
  * Remove attribute
  *
  * @param Request $request
  * @param int     $id
  *
  * @AclAncestor("pim_enrich_attribute_remove")
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
  */
 public function removeAction(Request $request, $id)
 {
     $attribute = $this->findAttributeOr404($id);
     $this->validateRemoval($attribute);
     $this->attributeRemover->remove($attribute);
     if ($request->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return $this->redirectToRoute('pim_enrich_attribute_index');
     }
 }
 /**
  * Remove a notification
  *
  * @param int $id
  *
  * @return JsonResponse
  */
 public function removeAction($id)
 {
     $user = $this->userContext->getUser();
     if (null !== $user) {
         $notification = $this->userNotifRepository->findOneBy(['id' => $id, 'user' => $user]);
         if ($notification) {
             $this->userNotifRemover->remove($notification);
         }
     }
     return new JsonResponse();
 }
 /**
  * Remove the Datagrid View with the given $identifier.
  *
  * If any errors occur during the process, a Json response is sent with {'errors' => 'Error message'}.
  * If success, return an empty Json response with code 204 (No content).
  *
  * @param Request $request
  * @param string  $identifier
  *
  * @return JsonResponse
  */
 public function removeAction(Request $request, $identifier)
 {
     $user = $this->tokenStorage->getToken()->getUser();
     $view = $this->datagridViewRepo->findOneBy(['owner' => $user, 'id' => $identifier]);
     if (null === $view) {
         return new JsonResponse($this->translator->trans('grid.view_selector.flash.not_removable'), 404);
     }
     $this->remover->remove($view);
     $request->getSession()->getFlashBag()->add('success', new Message('grid.view_selector.flash.removed'));
     return new JsonResponse(null, 204);
 }
 /**
  * Remove category tree
  *
  * @param int $id
  *
  * @AclAncestor("pim_enrich_category_remove")
  *
  * @return Response|RedirectResponse
  */
 public function removeAction($id)
 {
     $category = $this->findCategory($id);
     $parent = $category->getParent();
     $params = $parent !== null ? ['node' => $parent->getId()] : [];
     $this->categoryRemover->remove($category, ['flush' => true]);
     if ($this->getRequest()->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return $this->redirectToRoute('pim_enrich_categorytree_index', $params);
     }
 }
 /**
  * Remove a family
  *
  * @param int $id
  *
  * @AclAncestor("pim_enrich_family_remove")
  *
  * @return \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function removeAction($id)
 {
     $family = $this->familyRepository->find($id);
     if (null === $family) {
         throw new NotFoundHttpException(sprintf('%s entity not found', $this->familyClass));
     }
     $this->familyRemover->remove($family);
     if ($this->request->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return new RedirectResponse($this->router->generate('pim_enrich_family_index'));
     }
 }
 /**
  * Remove channel
  *
  * @param Request $request
  * @param Channel $channel
  *
  * @AclAncestor("pim_enrich_channel_remove")
  *
  * @return Response
  */
 public function removeAction(Request $request, Channel $channel)
 {
     // TODO This validation should be moved to a validator and that validation trigered by the remover
     $channelCount = $this->channelRepository->countAll();
     if ($channelCount <= 1) {
         throw new DeleteException($this->getTranslator()->trans('flash.channel.not removable'));
     }
     $this->channelRemover->remove($channel);
     if ($request->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return $this->redirect($this->generateUrl('pim_enrich_channel_index'));
     }
 }
 /**
  * Remove a group type
  *
  * @param GroupType $groupType
  *
  * @AclAncestor("pim_enrich_grouptype_remove")
  *
  * @return Response|RedirectResponse
  */
 public function removeAction(GroupType $groupType)
 {
     if ($groupType->isVariant()) {
         throw new DeleteException($this->getTranslator()->trans('flash.group type.cant remove variant'));
     } elseif (count($groupType->getGroups()) > 0) {
         throw new DeleteException($this->getTranslator()->trans('flash.group type.cant remove used'));
     } else {
         $this->groupTypeRemover->remove($groupType);
     }
     if ($this->getRequest()->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return $this->redirectToRoute('pim_enrich_grouptype_index');
     }
 }
 /**
  * Remove category tree
  *
  * @param int $id
  *
  * @throws AccessDeniedException
  *
  * @return Response|RedirectResponse
  */
 public function removeAction($id)
 {
     if (false === $this->securityFacade->isGranted($this->buildAclName('category_remove'))) {
         throw new AccessDeniedException();
     }
     $category = $this->findCategory($id);
     $parent = $category->getParent();
     $params = null !== $parent ? ['node' => $parent->getId()] : [];
     $this->categoryRemover->remove($category, ['flush' => true]);
     if ($this->getRequest()->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return $this->redirectToRoute($this->buildRouteName('categorytree_index'), $params);
     }
 }
 /**
  * Remove channel
  *
  * @param Request $request
  * @param Channel $channel
  *
  * @AclAncestor("pim_enrich_channel_remove")
  * @return Response
  */
 public function removeAction(Request $request, Channel $channel)
 {
     $channelCount = $this->getRepository('PimCatalogBundle:Channel')->countAll();
     if ($channelCount <= 1) {
         throw new DeleteException($this->getTranslator()->trans('flash.channel.not removable'));
     }
     foreach ($channel->getLocales() as $locale) {
         $locale->removeChannel($channel);
     }
     $this->channelRemover->remove($channel);
     if ($request->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return $this->redirect($this->generateUrl('pim_enrich_channel_index'));
     }
 }
 /**
  * Remove category tree
  *
  * @param int $id
  *
  * @AclAncestor("pim_enrich_category_remove")
  *
  * @return Response|RedirectResponse
  */
 public function removeAction($id)
 {
     $category = $this->findCategory($id);
     $parent = $category->getParent();
     $params = $parent !== null ? ['node' => $parent->getId()] : [];
     $this->categoryRemover->remove($category, ['flush' => false]);
     // TODO: In case of MongoDB storage for products, we need to flush both managers,
     // we should move this logic in remover
     foreach ($this->doctrine->getManagers() as $manager) {
         $manager->flush();
     }
     if ($this->getRequest()->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return $this->redirectToRoute('pim_enrich_categorytree_index', $params);
     }
 }
 /**
  * Remove attribute group
  *
  * @param Request        $request
  * @param AttributeGroup $group
  *
  * @throws DeleteException
  *
  * @AclAncestor("pim_enrich_attributegroup_remove")
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function removeAction(Request $request, AttributeGroup $group)
 {
     if ($group === $this->getDefaultGroup()) {
         throw new DeleteException($this->translator->trans('flash.attribute group.not removed default'));
     }
     if (0 !== $group->getAttributes()->count()) {
         $this->request->getSession()->getFlashBag()->add('error', new Message('flash.attribute group.not removed attributes'));
         throw new DeleteException($this->translator->trans('flash.attribute group.not removed attributes'));
     }
     $this->attrGroupRemover->remove($group);
     if ($request->get('_redirectBack')) {
         $referer = $request->headers->get('referer');
         if ($referer) {
             return new RedirectResponse($referer);
         }
     }
     if ($request->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return new RedirectResponse($this->router->generate('pim_enrich_attributegroup_create'));
     }
 }
 /**
  * Remove product
  *
  * @param int $id
  *
  * @AclAncestor("pim_enrich_product_remove")
  *
  * @return JsonResponse
  */
 public function removeAction($id)
 {
     $product = $this->findProductOr404($id);
     $this->productRemover->remove($product);
     return new JsonResponse();
 }
 /**
  * {@inheritdoc}
  *
  * @deprecated will be removed in 1.5 please use RemoverInterface::remove
  */
 public function remove($object, array $options = [])
 {
     $this->remover->remove($object, $options);
 }