/** * Test for __toString method */ public function testToString() { $newCode = 'toStringCode'; $expectedCode = '[' . $newCode . ']'; $this->type->setCode($newCode); $this->assertEquals($expectedCode, $this->type->__toString()); $newLabel = 'toStringLabel'; $this->assertEntity($this->type->setLocale('en_US')); $this->assertEntity($this->type->setLabel($newLabel)); $this->assertEquals($newLabel, $this->type->__toString()); $this->type->setLocale('fr_FR'); $this->assertEquals($expectedCode, $this->type->__toString()); $this->type->setLabel(''); $this->assertEquals($expectedCode, $this->type->__toString()); }
/** * {@inheritdoc} * * @return Group */ protected function createEntity(array $data) { $group = new Group(); $group->setCode($data['code']); $type = new GroupType(); $type->setCode($data['type']); $type->setVariant($data['type'] === 'VARIANT'); $group->setType($type); foreach ($this->getLabels($data) as $locale => $label) { $translation = $group->getTranslation($locale); $translation->setLabel($label); $group->addTranslation($translation); } foreach ($this->getAttributes($data) as $attribute) { $group->addAttribute($attribute); } return $group; }
/** * @param string $code * @param string $label * @param bool $isVariant * * @return \Pim\Bundle\CatalogBundle\Model\GroupTypeInterface */ protected function createGroupType($code, $label, $isVariant) { $type = new GroupType(); $type->setCode($code); $type->setVariant($isVariant); $type->setLocale('en_US')->setLabel($label); $this->validate($type); $this->persist($type); return $type; }
/** * {@inheritDoc} */ public function setCode($code) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCode', array($code)); return parent::setCode($code); }
/** * @param string $code * @param string $label * @param bool $isVariant * * @return \Pim\Component\Catalog\Model\GroupTypeInterface */ protected function createGroupType($code, $label, $isVariant) { $type = new GroupType(); $type->setCode($code); $type->setVariant($isVariant); $type->setLocale('en_US')->setLabel($label); $this->validate($type); $this->getContainer()->get('pim_catalog.saver.group_type')->save($type); return $type; }