/**
  * 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 new NotFoundHttpException(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->request->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return new RedirectResponse($this->router->generate('pim_enrich_attributegroup_edit', ['id' => $group->getId()]));
     }
 }
 /**
  * @param AttributeGroupInterface $attributeGroup
  * @param string[]                $data
  */
 protected function setAttributes(AttributeGroupInterface $attributeGroup, array $data)
 {
     if ('other' === $attributeGroup->getCode()) {
         return;
     }
     $defaultGroup = $this->attributeGroupRepository->findDefaultAttributeGroup();
     foreach ($attributeGroup->getAttributes() as $attribute) {
         if (!in_array($attribute->getCode(), $data)) {
             $defaultGroup->addAttribute($attribute);
         }
     }
     foreach ($data as $attributeCode) {
         $attribute = $this->findAttribute($attributeCode);
         if (null === $attribute) {
             throw new \InvalidArgumentException(sprintf('Attribute with "%s" code does not exist', $attributeCode));
         }
         $attributeGroup->addAttribute($attribute);
     }
 }