/**
  * Normalize the requirements
  *
  * @param FamilyInterface $family
  *
  * @return array
  */
 protected function normalizeRequirements(FamilyInterface $family)
 {
     $requirements = $this->attributeRequirementRepo->findRequiredAttributesCodesByFamily($family);
     $required = [];
     foreach ($requirements as $requirement) {
         $required[$requirement['channel']][] = $requirement['attribute'];
     }
     return $required;
 }
 /**
  * @param FamilyInterface    $family
  * @param AttributeInterface $attribute
  * @param string             $channelCode
  *
  * @return AttributeRequirementInterface
  */
 protected function createAttributeRequirement(FamilyInterface $family, AttributeInterface $attribute, $channelCode)
 {
     $channel = $this->channelRepository->findOneByIdentifier($channelCode);
     if (null === $channel) {
         throw new \InvalidArgumentException(sprintf('Channel with "%s" code does not exist', $channelCode));
     }
     $requirement = $this->requirementRepo->findOneBy(['attribute' => $attribute->getId(), 'channel' => $channel->getId(), 'family' => $family->getId()]);
     if (null === $requirement) {
         $requirement = $this->attrRequiFactory->createAttributeRequirement($attribute, $channel, true);
     }
     $requirement->setRequired(true);
     return $requirement;
 }
 /**
  * Normalize the requirements
  *
  * @param FamilyInterface $family
  *
  * @return array
  */
 protected function normalizeRequirements(FamilyInterface $family)
 {
     $requirements = $this->requirementsRepository->findRequiredAttributesCodesByFamily($family);
     $required = [];
     usort($requirements, function ($left, $right) {
         if ($left['channel'] !== $right['channel']) {
             return $left['channel'] < $right['channel'] ? -1 : 1;
         }
         if ($left['attribute'] !== $right['attribute']) {
             return $left['attribute'] < $right['attribute'] ? -1 : 1;
         }
         return 0;
     });
     foreach ($requirements as $requirement) {
         $required['requirements'][$requirement['channel']][] = $requirement['attribute'];
     }
     return $required;
 }