/** * Remove an attribute * * @param int $groupId * @param int $attributeId * * @AclAncestor("pim_enrich_attributegroup_remove_attribute") * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function removeAttributeAction($groupId, $attributeId) { $group = $this->findAttributeGroupOr404($groupId); $attribute = $this->findAttributeOr404($attributeId); if (false === $group->hasAttribute($attribute)) { throw $this->createNotFoundException(sprintf('Attribute "%s" is not attached to "%s"', $attribute, $group)); } if ($group === $this->getDefaultGroup()) { throw new \LogicException($this->translator->trans('flash.attribute group.not removed default attributes')); } $this->manager->removeAttribute($group, $attribute); if ($this->getRequest()->isXmlHttpRequest()) { return new Response('', 204); } else { return $this->redirectToRoute('pim_enrich_attributegroup_edit', ['id' => $group->getId()]); } }