/** * {@inheritdoc} */ protected function doPerform(FamilyInterface $family) { foreach ($this->attRequirements as $attributeRequirement) { $family->addAttribute($attributeRequirement->getAttribute()); $family->addAttributeRequirement($this->factory->createAttributeRequirement($attributeRequirement->getAttribute(), $attributeRequirement->getChannel(), $attributeRequirement->isRequired())); } }
/** * Sets the requirements for a channel * * @param string $class * @param FamilyInterface $family * @param string $channelCode * @param array $attributeCodes */ protected function setChannelRequirements($class, FamilyInterface $family, $channelCode, $attributeCodes) { foreach ($attributeCodes as $attributeCode) { $data = array('attribute' => $attributeCode, 'channel' => $channelCode, 'required' => true); $requirement = $this->transformNestedEntity($class, 'requirements', $this->requirementClass, $data); if ($requirement->getAttribute() === null) { throw new \Exception(sprintf('The attribute "%s" used as requirement in family "%s" is not known', $attributeCode, $family->getCode())); } $family->addAttributeRequirement($requirement); } }