本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Repository\AttributeRepositoryInterface::getIdentifierCode方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeRepositoryInterface::getIdentifierCode方法的具体用法?PHP AttributeRepositoryInterface::getIdentifierCode怎么用?PHP AttributeRepositoryInterface::getIdentifierCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Repository\AttributeRepositoryInterface
的用法示例。
在下文中一共展示了AttributeRepositoryInterface::getIdentifierCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMissingChannelCodes
/**
* @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;
}
示例2: getIdentifierCode
/**
* @return string
*/
protected function getIdentifierCode()
{
if (null === $this->identifierCode) {
$this->identifierCode = $this->attributeRepository->getIdentifierCode();
}
return $this->identifierCode;
}
示例3: generate
/**
* {@inheritdoc}
*/
public function generate(array $config, $outputDir, ProgressHelper $progress, array $options = null)
{
$this->tmpFile = tempnam(sys_get_temp_dir(), 'data-gene');
if (!empty($config['filename'])) {
$this->outputFile = $outputDir . '/' . trim($config['filename']);
} else {
$this->outputFile = $outputDir . '/' . self::DEFAULT_FILENAME;
}
$count = (int) $config['count'];
$nbAttrBase = (int) $config['filled_attributes_count'];
$nbAttrDeviation = (int) $config['filled_attributes_standard_deviation'];
$startIndex = (int) $config['start_index'];
$categoriesCount = (int) $config['categories_count'];
$mandatoryAttributes = $config['mandatory_attributes'];
if (!is_array($mandatoryAttributes)) {
$mandatoryAttributes = [];
}
$delimiter = $config['delimiter'];
$this->delimiter = $delimiter != null ? $delimiter : self::DEFAULT_DELIMITER;
if (isset($config['force_values'])) {
$this->forcedValues = $config['force_values'];
} else {
$this->forcedValues = [];
}
$this->identifierCode = $this->attributeRepository->getIdentifierCode();
$this->faker = Faker\Factory::create();
for ($i = $startIndex; $i < $startIndex + $count; $i++) {
$product = [];
$product[$this->identifierCode] = self::IDENTIFIER_PREFIX . $i;
$family = $this->getRandomFamily($this->faker);
$product['family'] = $family->getCode();
if ($nbAttrBase > 0) {
if ($nbAttrDeviation > 0) {
$nbAttr = $this->faker->numberBetween($nbAttrBase - round($nbAttrDeviation / 2), $nbAttrBase + round($nbAttrDeviation / 2));
} else {
$nbAttr = $nbAttrBase;
}
}
$familyAttrCount = count($this->getAttributesFromFamily($family));
if (!isset($nbAttr) || $nbAttr > $familyAttrCount) {
$nbAttr = $familyAttrCount;
}
$attributes = $this->getRandomAttributesFromFamily($family, $nbAttr);
foreach ($attributes as $attribute) {
$valueData = $this->generateValue($attribute);
$product = array_merge($product, $valueData);
}
foreach ($mandatoryAttributes as $mandatoryAttribute) {
if (isset($this->attributesByFamily[$family->getCode()][$mandatoryAttribute])) {
$attribute = $this->attributesByFamily[$family->getCode()][$mandatoryAttribute];
$valueData = $this->generateValue($attribute);
$product = array_merge($product, $valueData);
}
}
$categories = $this->getRandomCategoryCodes($categoriesCount);
$product[self::CATEGORY_FIELD] = implode(',', $categories);
$this->bufferizeProduct($product);
$progress->advance();
}
$this->writeCsvFile();
unlink($this->tmpFile);
return $this;
}
示例4: getIdentifierProperties
/**
* {@inheritdoc}
*/
public function getIdentifierProperties()
{
return array($this->attributeRepository->getIdentifierCode());
}
示例5: isAttribute
/**
* @param string $code
*
* @return bool
*/
protected function isAttribute($code)
{
return null !== $this->attributeRepository->getIdentifierCode($code);
}
示例6: __construct
/**
* @param ProductRepositoryInterface $productRepository
* @param AttributeRepositoryInterface $attributeRepository
*/
public function __construct(ProductRepositoryInterface $productRepository, AttributeRepositoryInterface $attributeRepository)
{
$this->attributeRepository = $attributeRepository;
$this->identifierCode = $attributeRepository->getIdentifierCode();
}