/** * Normalize the attributes * * @param AttributeGroup $group * * @return array */ protected function normalizeAttributes(AttributeGroup $group) { $attributes = array(); foreach ($group->getAttributes() as $attribute) { $attributes[] = $attribute->getCode(); } return $attributes; }
/** * Test getter/setter for attributes property */ public function testAttributes() { $this->assertCount(0, $this->group->getAttributes()); // Change value and assert new $newAttribute = new Attribute(); $this->assertEntity($this->group->addAttribute($newAttribute)); $this->assertCount(1, $this->group->getAttributes()); $this->assertInstanceOf('Pim\\Bundle\\CatalogBundle\\Entity\\Attribute', $this->group->getAttributes()->first()); $this->assertTrue($this->group->hasAttribute($newAttribute)); $this->assertEntity($this->group->removeAttribute($newAttribute)); $this->assertCount(0, $this->group->getAttributes()); }
/** * 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')); } }
/** * {@inheritDoc} */ public function getAttributes() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAttributes', array()); return parent::getAttributes(); }