本文整理汇总了PHP中Pim\Component\Catalog\Repository\AttributeRepositoryInterface::getIdentifier方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeRepositoryInterface::getIdentifier方法的具体用法?PHP AttributeRepositoryInterface::getIdentifier怎么用?PHP AttributeRepositoryInterface::getIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Component\Catalog\Repository\AttributeRepositoryInterface
的用法示例。
在下文中一共展示了AttributeRepositoryInterface::getIdentifier方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolveIdentifierField
/**
* @return string
*/
public function resolveIdentifierField()
{
if (empty($this->identifierField)) {
$attribute = $this->attributeRepository->getIdentifier();
$this->identifierField = $attribute->getCode();
}
return $this->identifierField;
}
示例2: validate
/**
* Don't allow creating an identifier attribute if one already exists
*
* @param AttributeInterface $attribute
* @param Constraint $constraint
*/
public function validate($attribute, Constraint $constraint)
{
if (AttributeTypes::IDENTIFIER === $attribute->getAttributeType()) {
$identifier = $this->attributeRepository->getIdentifier();
if ($identifier && $identifier->getId() !== $attribute->getId()) {
$this->context->buildViolation($constraint->message)->atPath('attribute_type')->addViolation();
}
}
}
示例3: createFamily
/**
* @return FamilyInterface
*/
public function createFamily()
{
$family = new $this->familyClass();
$identifier = $this->attributeRepository->getIdentifier();
$family->addAttribute($identifier);
$family->setAttributeAsLabel($identifier);
foreach ($this->getChannels() as $channel) {
$requirement = $this->factory->createAttributeRequirement($identifier, $channel, true);
$family->addAttributeRequirement($requirement);
}
return $family;
}
示例4: createProduct
/**
* {@inheritdoc}
*/
public function createProduct($identifier = null, $familyCode = null)
{
$product = new $this->productClass();
$identifierAttribute = $this->attributeRepository->getIdentifier();
$productValue = $this->createProductValue($identifierAttribute);
$product->addValue($productValue);
if (null !== $identifier) {
$productValue->setData($identifier);
}
if (null !== $familyCode) {
$family = $this->familyRepository->findOneByIdentifier($familyCode);
$product->setFamily($family);
}
$event = new GenericEvent($product);
$this->eventDispatcher->dispatch(ProductEvents::CREATE, $event);
return $product;
}
示例5: addMissingIdentifierRequirements
/**
* @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;
}
示例6: let
function let(ProductValueConverter $valueConverter, AttributeRepositoryInterface $attributeRepository, AttributeInterface $identifierAttribute)
{
$attributeRepository->getIdentifier()->willReturn($identifierAttribute);
$identifierAttribute->getCode()->willReturn('sku');
$this->beConstructedWith($valueConverter, $attributeRepository);
}
示例7: it_should_not_remove_identifier_requirements_when_other_requirements_are_provided
public function it_should_not_remove_identifier_requirements_when_other_requirements_are_provided($attrRequiFactory, $channelRepository, FamilyInterface $family, AttributeRepositoryInterface $attributeRepository, AttributeInterface $skuAttribute, AttributeInterface $nameAttribute, AttributeInterface $descAttribute, AttributeRequirementInterface $skuMobileRqrmt, AttributeRequirementInterface $skuPrintRqrmt, AttributeRequirementInterface $namePrintRqrmt, AttributeRequirementInterface $descPrintRqrmt, ChannelInterface $mobileChannel, ChannelInterface $printChannel)
{
$values = ['code' => 'mycode', 'requirements' => ['print' => ['name', 'description']]];
$family->getAttributeRequirements()->willReturn([$skuMobileRqrmt, $skuPrintRqrmt]);
$family->getId()->willReturn(42);
$skuMobileRqrmt->getAttribute()->willReturn($skuAttribute);
$skuPrintRqrmt->getAttribute()->willReturn($skuAttribute);
$skuMobileRqrmt->getChannelCode()->willReturn('mobile');
$skuPrintRqrmt->getChannelCode()->willReturn('print');
$skuAttribute->getAttributeType()->willReturn(AttributeTypes::IDENTIFIER);
$channelRepository->findOneByIdentifier('print')->willReturn($printChannel);
$attributeRepository->findOneByIdentifier('name')->willReturn($nameAttribute);
$attributeRepository->findOneByIdentifier('description')->willReturn($descAttribute);
$attrRequiFactory->createAttributeRequirement($nameAttribute, $printChannel, true)->willReturn($namePrintRqrmt);
$attrRequiFactory->createAttributeRequirement($descAttribute, $printChannel, true)->willReturn($descPrintRqrmt);
$namePrintRqrmt->getAttribute()->willReturn($nameAttribute);
$descPrintRqrmt->getAttribute()->willReturn($descAttribute);
$channelRepository->getChannelCodes()->willReturn(['mobile', 'print']);
$channelRepository->findOneByIdentifier('mobile')->willReturn($mobileChannel);
$channelRepository->findOneByIdentifier('print')->willReturn($printChannel);
$attributeRepository->getIdentifier()->willReturn($skuAttribute);
$family->setCode('mycode')->shouldBeCalled();
$family->setAttributeRequirements([$skuMobileRqrmt, $skuPrintRqrmt, $namePrintRqrmt, $descPrintRqrmt])->shouldBeCalled();
$this->update($family, $values, []);
}