/** * {@inheritdoc} * * @return Family */ protected function createEntity(array $data) { $family = new Family(); $family->setCode('mycode'); foreach ($this->getLabels($data) as $locale => $label) { $translation = $family->getTranslation($locale); $translation->setLabel($label); $family->addTranslation($translation); } $codes = array('attribute1', 'attribute2', 'attribute3'); $attributes = array(); foreach ($codes as $code) { $attribute = new Attribute(); $attribute->setCode($code); $family->addAttribute($attribute); $attributes[] = $attribute; } $family->setAttributeAsLabel(current($attributes)); $channel1 = new Channel(); $channel1->setCode('channel1'); $channel2 = new Channel(); $channel2->setCode('channel2'); $requirements = array(array('attribute' => $attributes[0], 'channel' => $channel1, 'required' => true), array('attribute' => $attributes[1], 'channel' => $channel1, 'required' => true), array('attribute' => $attributes[2], 'channel' => $channel1, 'required' => false), array('attribute' => $attributes[0], 'channel' => $channel2, 'required' => true), array('attribute' => $attributes[1], 'channel' => $channel2, 'required' => false), array('attribute' => $attributes[2], 'channel' => $channel2, 'required' => true)); $attrRequirements = array(); foreach ($requirements as $requirement) { $attrRequirement = new AttributeRequirement(); $attrRequirement->setAttribute($requirement['attribute']); $attrRequirement->setChannel($requirement['channel']); $attrRequirement->setRequired($requirement['required']); $attrRequirements[] = $attrRequirement; } $family->setAttributeRequirements($attrRequirements); return $family; }
/** * Create and configure an attribute requirement instance * * @param AbstractAttribute $attribute * @param Channel $channel * @param boolean $required * * @return AttributeRequirement */ public function createAttributeRequirement(AbstractAttribute $attribute, Channel $channel, $required) { $requirement = new AttributeRequirement(); $requirement->setAttribute($attribute); $requirement->setChannel($channel); $requirement->setRequired($required); return $requirement; }
/** * Create attribute requirement entity * * @param ChannelInterface $channel * @param AttributeInterface $attribute * @param FamilyInterface $family * * @return AttributeRequirementInterface */ protected function createAttributeRequirement(ChannelInterface $channel, AttributeInterface $attribute, FamilyInterface $family) { $requirement = new AttributeRequirement(); $requirement->setChannel($channel); $requirement->setAttribute($attribute); $requirement->setFamily($family); return $requirement; }
/** * Create attribute requirement entity * * @param Channel $channel * @param AbstractAttribute $attribute * @param Family $family * * @return \Pim\Bundle\CatalogBundle\Entity\AttributeRequirement */ protected function createAttributeRequirement(Channel $channel, AbstractAttribute $attribute, Family $family) { $requirement = new AttributeRequirement(); $requirement->setChannel($channel); $requirement->setAttribute($attribute); $requirement->setFamily($family); return $requirement; }
/** * {@inheritDoc} */ public function setChannel(\Pim\Bundle\CatalogBundle\Model\ChannelInterface $channel) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setChannel', array($channel)); return parent::setChannel($channel); }