コード例 #1
0
 /**
  * {@inheritdoc}
  * @return AssociationTypeInterface
  */
 protected function createEntity(array $data)
 {
     $associationType = new AssociationType();
     $associationType->setCode($data['code']);
     foreach ($this->getLabels($data) as $locale => $label) {
         $translation = $associationType->getTranslation($locale);
         $translation->setLabel($label);
         $associationType->addTranslation($translation);
     }
     return $associationType;
 }
コード例 #2
0
 /**
  * Test getter/setter for translations property
  */
 public function testTranslations()
 {
     $this->assertCount(0, $this->associationType->getTranslations());
     // Change value and assert new
     $newTranslation = new AssociationTypeTranslation();
     $this->assertEntity($this->associationType->addTranslation($newTranslation));
     $this->assertCount(1, $this->associationType->getTranslations());
     $this->assertInstanceOf('Pim\\Bundle\\CatalogBundle\\Entity\\AssociationTypeTranslation', $this->associationType->getTranslations()->first());
     $this->associationType->addTranslation($newTranslation);
     $this->assertCount(1, $this->associationType->getTranslations());
     $this->assertEntity($this->associationType->removeTranslation($newTranslation));
     $this->assertCount(0, $this->associationType->getTranslations());
 }
 /**
  * {@inheritDoc}
  */
 public function addTranslation(\Pim\Bundle\TranslationBundle\Entity\AbstractTranslation $translation)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'addTranslation', array($translation));
     return parent::addTranslation($translation);
 }