/**
  * @param FamilyInterface $family
  *
  * @return string[]
  */
 protected function getMissingChannelCodes(FamilyInterface $family)
 {
     $requirements = $family->getAttributeRequirements();
     $identifierCode = $this->attributeRepository->getIdentifierCode();
     $currentChannelCodes = [];
     foreach ($requirements as $requirement) {
         if ($requirement->getAttributeCode() === $identifierCode) {
             $currentChannelCodes[] = $requirement->getChannelCode();
         }
     }
     $expectedChannelCodes = $this->channelRepository->getChannelCodes();
     $missingChannelCodes = array_diff($expectedChannelCodes, $currentChannelCodes);
     return $missingChannelCodes;
 }
 /**
  * @param FamilyInterface $family
  * @param array           $requirements
  *
  * @return array
  */
 protected function addMissingIdentifierRequirements(FamilyInterface $family, array $requirements)
 {
     $channelCodes = $this->channelRepository->getChannelCodes();
     $existingChannelCode = [];
     foreach ($requirements as $requirement) {
         if (AttributeTypes::IDENTIFIER === $requirement->getAttribute()->getAttributeType()) {
             $existingChannelCode[] = $requirement->getChannelCode();
         }
     }
     $missingChannelCodes = array_diff($channelCodes, $existingChannelCode);
     $identifier = $this->attributeRepository->getIdentifier();
     foreach ($missingChannelCodes as $channelCode) {
         $requirements[] = $this->createAttributeRequirement($identifier, $family, $channelCode);
     }
     return $requirements;
 }
 /**
  * Checks that attributes in the header have existing locale, scope and currency.
  *
  * @throws \LogicException
  */
 protected function checkAttributesInHeader()
 {
     $channels = $this->channelRepository->getChannelCodes();
     $locales = $this->localeRepository->getActivatedLocaleCodes();
     $currencies = $this->currencyRepository->getActivatedCurrencyCodes();
     foreach ($this->fieldNames as $fieldName) {
         if (null !== ($info = $this->fieldExtractor->extractColumnInfo($fieldName))) {
             $locale = $info['locale_code'];
             $channel = $info['scope_code'];
             $currency = isset($info['price_currency']) ? $info['price_currency'] : null;
             if (null !== $locale && !in_array($locale, $locales)) {
                 throw new \LogicException(sprintf('Locale %s does not exist.', $locale));
             }
             if (null !== $channel && !in_array($channel, $channels)) {
                 throw new \LogicException(sprintf('Channel %s does not exist.', $channel));
             }
             if (null !== $currency && !in_array($currency, $currencies)) {
                 throw new \LogicException(sprintf('Currency %s does not exist.', $currency));
             }
         }
     }
 }
 /**
  * @return array
  */
 protected function getScopeCodes()
 {
     return $this->scopeRepository->getChannelCodes();
 }