/** * Test getter/setter for translations property */ public function testTranslations() { $this->assertCount(0, $this->group->getTranslations()); // Change value and assert new $newTranslation = new AttributeGroupTranslation(); $this->assertEntity($this->group->addTranslation($newTranslation)); $this->assertCount(1, $this->group->getTranslations()); $this->assertInstanceOf('Pim\\Bundle\\CatalogBundle\\Entity\\AttributeGroupTranslation', $this->group->getTranslations()->first()); $this->group->addTranslation($newTranslation); $this->assertCount(1, $this->group->getTranslations()); $this->assertEntity($this->group->removeTranslation($newTranslation)); $this->assertCount(0, $this->group->getTranslations()); }
/** * {@inheritdoc} * @return AttributeGroupInterface */ protected function createEntity(array $data) { $group = new AttributeGroup(); $group->setCode($data['code']); foreach ($this->getLabels($data) as $locale => $label) { $translation = $group->getTranslation($locale); $translation->setLabel($label); $group->addTranslation($translation); } $group->setSortOrder($data['sortOrder']); foreach ($this->getAttributes($data) as $attribute) { $group->addAttribute($attribute); } return $group; }
/** * {@inheritDoc} */ public function addTranslation(\Pim\Bundle\TranslationBundle\Entity\AbstractTranslation $translation) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'addTranslation', array($translation)); return parent::addTranslation($translation); }