当前位置: 首页>>代码示例>>PHP>>正文


PHP AttributeInterface::getId方法代码示例

本文整理汇总了PHP中Pim\Component\Catalog\Model\AttributeInterface::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeInterface::getId方法的具体用法?PHP AttributeInterface::getId怎么用?PHP AttributeInterface::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pim\Component\Catalog\Model\AttributeInterface的用法示例。


在下文中一共展示了AttributeInterface::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 function it_throws_an_exception_when_the_scope_is_not_provided(AttributeInterface $price)
 {
     $price->getId()->willReturn(42);
     $price->isLocalizable()->willReturn(false);
     $price->isScopable()->willReturn(true);
     $price->getCode()->willReturn('price');
     $this->shouldThrow('\\InvalidArgumentException')->duringPrepareCondition($price, 'alias', 'en_US', null);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:8,代码来源:ValueJoinSpec.php

示例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();
         }
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:15,代码来源:SingleIdentifierAttributeValidator.php

示例3:

 function it_throws_an_exception_if_value_is_not_a_valid_array(AttributeInterface $attribute)
 {
     $attribute->getId()->willReturn(1);
     $attribute->getCode()->willReturn('color');
     $value = 'string';
     $this->shouldThrow(InvalidArgumentException::arrayExpected('color', 'filter', 'reference_data', $value))->during('addAttributeFilter', [$attribute, '=', $value, null, null, ['field' => 'color']]);
     $value = ['foo'];
     $this->shouldThrow(InvalidArgumentException::numericExpected('color', 'filter', 'reference_data', 'string'))->during('addAttributeFilter', [$attribute, '=', $value, null, null, ['field' => 'color']]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:9,代码来源:ReferenceDataFilterSpec.php

示例4: getChoiceUrlParams

 /**
  * @param AttributeInterface $attribute
  *
  * @return array
  */
 protected function getChoiceUrlParams(AttributeInterface $attribute)
 {
     $referenceDataName = $attribute->getReferenceDataName();
     $referenceData = $this->registry->get($referenceDataName);
     if (null === $referenceData) {
         throw new \InvalidArgumentException(sprintf('Reference data "%s" does not exist', $referenceDataName));
     }
     return ['class' => $referenceData->getClass(), 'dataLocale' => $this->userContext->getCurrentLocaleCode(), 'collectionId' => $attribute->getId()];
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:14,代码来源:ReferenceDataFilter.php

示例5:

 function it_gets_ids_from_code_with_attribute($managerRegistry, ObjectManager $manager, ObjectRepository $repository, AttributeOptionInterface $purple, AttributeInterface $attribute)
 {
     $managerRegistry->getManagerForClass('optionClass')->willReturn($manager);
     $manager->getRepository('optionClass')->willReturn($repository);
     $attribute->getId()->willReturn(12);
     $repository->findOneBy(['code' => 'purple', 'attribute' => 12])->willReturn($purple);
     $purple->getId()->willReturn(2);
     $this->getIdsFromCodes('option', ['purple'], $attribute)->shouldReturn([2]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:9,代码来源:ObjectIdResolverSpec.php

示例6:

 function it_provides_available_axis_as_a_sorted_choice($attRepository, AttributeInterface $attribute1, AttributeInterface $attribute2)
 {
     $attribute1->getId()->willReturn(1);
     $attribute1->getLabel()->willReturn('Foo');
     $attribute2->getId()->willReturn(2);
     $attribute2->getLabel()->willReturn('Bar');
     $attRepository->findAllAxis()->willReturn([$attribute1, $attribute2]);
     $this->getAvailableAxisChoices()->shouldReturn([2 => 'Bar', 1 => 'Foo']);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:9,代码来源:GroupManagerSpec.php

示例7:

 function it_updates_a_family($attrRequiFactory, $channelRepository, FamilyTranslation $translation, FamilyInterface $family, AttributeRepositoryInterface $attributeRepository, AttributeInterface $skuAttribute, AttributeInterface $nameAttribute, AttributeInterface $descAttribute, AttributeInterface $priceAttribute, AttributeRequirementInterface $skuMobileRqrmt, AttributeRequirementInterface $nameMobileRqrmt, AttributeRequirementInterface $skuPrintRqrmt, AttributeRequirementInterface $namePrintRqrmt, AttributeRequirementInterface $descPrintRqrmt, ChannelInterface $mobileChannel, ChannelInterface $printChannel)
 {
     $values = ['code' => 'mycode', 'attributes' => ['sku', 'name', 'description', 'price'], 'attribute_as_label' => 'name', 'requirements' => ['mobile' => ['sku', 'name'], 'print' => ['name', 'description']], 'labels' => ['fr_FR' => 'Moniteurs', 'en_US' => 'PC Monitors']];
     $family->getAttributeRequirements()->willReturn([$skuMobileRqrmt, $skuPrintRqrmt]);
     $family->getAttributes()->willReturn([$skuAttribute, $nameAttribute, $descAttribute, $priceAttribute]);
     $family->removeAttribute($nameAttribute)->shouldBeCalled();
     $family->removeAttribute($priceAttribute)->shouldBeCalled();
     $family->removeAttribute($descAttribute)->shouldBeCalled();
     $family->getId()->willReturn(42);
     $skuAttribute->getId()->willReturn(1);
     $nameAttribute->getId()->willReturn(2);
     $descAttribute->getId()->willReturn(3);
     $priceAttribute->getId()->willReturn(4);
     $skuMobileRqrmt->getAttribute()->willReturn($skuAttribute);
     $skuMobileRqrmt->getChannelCode()->willReturn('mobile');
     $skuPrintRqrmt->getAttribute()->willReturn($skuAttribute);
     $skuPrintRqrmt->getChannelCode()->willReturn('print');
     $attributeRepository->findOneByIdentifier('sku')->willReturn($skuAttribute);
     $attributeRepository->findOneByIdentifier('name')->willReturn($nameAttribute);
     $attributeRepository->findOneByIdentifier('description')->willReturn($descAttribute);
     $attributeRepository->findOneByIdentifier('price')->willReturn($priceAttribute);
     $attributeRepository->getIdentifier()->willReturn($skuAttribute);
     $skuAttribute->getAttributeType()->willReturn('pim_catalog_identifier');
     $nameAttribute->getAttributeType()->willReturn('pim_catalog_text');
     $descAttribute->getAttributeType()->willReturn('pim_catalog_textarea');
     $priceAttribute->getAttributeType()->willReturn('pim_catalog_price_collection');
     $channelRepository->getChannelCodes()->willReturn(['mobile', 'print']);
     $channelRepository->findOneByIdentifier('mobile')->willReturn($mobileChannel);
     $channelRepository->findOneByIdentifier('print')->willReturn($printChannel);
     $attrRequiFactory->createAttributeRequirement($nameAttribute, $mobileChannel, true)->willReturn($nameMobileRqrmt);
     $attrRequiFactory->createAttributeRequirement($nameAttribute, $printChannel, true)->willReturn($namePrintRqrmt);
     $attrRequiFactory->createAttributeRequirement($descAttribute, $printChannel, true)->willReturn($descPrintRqrmt);
     $nameMobileRqrmt->getAttribute()->willReturn($nameAttribute);
     $namePrintRqrmt->getAttribute()->willReturn($nameAttribute);
     $descPrintRqrmt->getAttribute()->willReturn($descAttribute);
     $family->setAttributeRequirements([$skuMobileRqrmt, $skuPrintRqrmt, $nameMobileRqrmt, $namePrintRqrmt, $descPrintRqrmt])->shouldBeCalled();
     $family->setCode('mycode')->shouldBeCalled();
     $nameMobileRqrmt->setRequired(true)->shouldBeCalled();
     $namePrintRqrmt->setRequired(true)->shouldBeCalled();
     $descPrintRqrmt->setRequired(true)->shouldBeCalled();
     $family->addAttribute($skuAttribute)->shouldBeCalled();
     $family->addAttribute($nameAttribute)->shouldBeCalled();
     $family->addAttribute($skuAttribute)->shouldBeCalled();
     $family->addAttribute($skuAttribute)->shouldBeCalled();
     $family->setLocale('en_US')->shouldBeCalled();
     $family->setLocale('fr_FR')->shouldBeCalled();
     $family->getTranslation()->willReturn($translation);
     $translation->setLabel('label en us');
     $translation->setLabel('label fr fr');
     $family->addAttribute($skuAttribute)->shouldBeCalled();
     $family->addAttribute($nameAttribute)->shouldBeCalled();
     $family->addAttribute($descAttribute)->shouldBeCalled();
     $family->addAttribute($priceAttribute)->shouldBeCalled();
     $family->setAttributeAsLabel($nameAttribute)->shouldBeCalled();
     $this->update($family, $values, []);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:56,代码来源:FamilyUpdaterSpec.php

示例8:

 function it_adds_a_violation_if_attribute_identifier_already_exists($context, $attributeRepository, AttributeInterface $attribute, AttributeInterface $identifier, SingleIdentifierAttribute $constraint, ConstraintViolationBuilderInterface $violation)
 {
     $attribute->getAttributeType()->willReturn('pim_catalog_identifier');
     $attribute->getId()->willReturn(2);
     $attributeRepository->getIdentifier()->willReturn($identifier);
     $identifier->getId()->willReturn(1);
     $context->buildViolation($constraint->message)->shouldBeCalled()->willReturn($violation);
     $violation->atPath('attribute_type')->shouldBeCalled()->willReturn($violation);
     $violation->addViolation()->shouldBeCalled();
     $this->validate($attribute, $constraint);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:11,代码来源:SingleIdentifierAttributeValidatorSpec.php

示例9: let

 function let(QueryBuilder $qb, AttributeValidatorHelper $attrValidatorHelper, Expr $expr, AttributeInterface $image)
 {
     $this->beConstructedWith($attrValidatorHelper, ['pim_catalog_image', 'pim_catalog_file'], ['STARTS WITH', 'ENDS WITH', 'CONTAINS', 'DOES NOT CONTAIN', '=', 'EMPTY', 'NOT EMPTY', '!=']);
     $this->setQueryBuilder($qb);
     $qb->getRootAlias()->willReturn('p');
     $qb->expr()->willReturn($expr);
     $image->getId()->willReturn(1);
     $image->getCode()->willReturn('picture');
     $image->isLocalizable()->willReturn(false);
     $image->isScopable()->willReturn(false);
     $image->getBackendType()->willReturn('media');
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:12,代码来源:MediaFilterSpec.php

示例10:

 function it_throws_an_exception_if_no_groups_found($attrGroupRepo, AttributeInterface $attribute, AttributeTranslation $translation)
 {
     $attribute->getId()->willReturn(null);
     $attribute->getAttributeType()->willReturn('pim_reference_data_simpleselect');
     $data = ['labels' => ['en_US' => 'Test1', 'fr_FR' => 'Test2'], 'group' => 'marketing', 'attributeType' => 'pim_catalog_text'];
     $attribute->setLocale('en_US')->shouldBeCalled();
     $attribute->setLocale('fr_FR')->shouldBeCalled();
     $attribute->getTranslation()->willReturn($translation);
     $translation->setLabel('Test1')->shouldBeCalled();
     $translation->setLabel('Test2')->shouldBeCalled();
     $attrGroupRepo->findOneByIdentifier('marketing')->willReturn(null);
     $this->shouldThrow(new \InvalidArgumentException('AttributeGroup "marketing" does not exist'))->during('update', [$attribute, $data]);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:13,代码来源:AttributeUpdaterSpec.php

示例11:

 function it_normalizes_a_product_value_into_mongodb_document($mongoFactory, $serializer, ProductValueInterface $value, AttributeInterface $attribute, \MongoDBRef $mongoDBRef, \MongoId $mongoId)
 {
     $context = ['_id' => $mongoId, 'collection_name' => 'product'];
     $mongoFactory->createMongoId()->willReturn($mongoId);
     $mongoFactory->createMongoDBRef('product', $mongoId)->willReturn($mongoDBRef);
     $attribute->getId()->willReturn(123);
     $attribute->getBackendType()->willReturn('text');
     $value->getAttribute()->willReturn($attribute);
     $value->getData()->willReturn('my description');
     $value->getLocale()->willReturn(null);
     $value->getScope()->willReturn(null);
     $this->normalize($value, 'mongodb_document', $context)->shouldReturn(['_id' => $mongoId, 'attribute' => 123, 'entity' => $mongoDBRef, 'text' => 'my description']);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:13,代码来源:ProductValueNormalizerSpec.php

示例12:

 function it_adds_a_sorter_to_the_query($qb, AttributeInterface $metric)
 {
     $metric->getId()->willReturn(42);
     $metric->getCode()->willReturn('metric_code');
     $metric->getBackendType()->willReturn('metric');
     $metric->isLocalizable()->willReturn(false);
     $metric->isScopable()->willReturn(false);
     $condition = "sorterVmetric_code.attribute = 42";
     $qb->getRootAlias()->willReturn('r');
     $qb->leftJoin('r.values', 'sorterVmetric_code', 'WITH', $condition)->shouldBeCalled();
     $qb->leftJoin('sorterVmetric_code.metric', 'sorterMmetric_code')->shouldBeCalled();
     $qb->addOrderBy('sorterMmetric_code.baseData', 'DESC')->shouldBeCalled();
     $qb->addOrderBy('r.id')->shouldBeCalled();
     $this->addAttributeSorter($metric, 'DESC');
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:15,代码来源:MetricSorterSpec.php

示例13:

 function it_adds_an_equal_filter_on_an_attribute_in_the_query($qb, $attrValidatorHelper, AttributeInterface $attribute, Expr $expr)
 {
     $attribute->getBackendType()->willReturn('backend_type');
     $attribute->getCode()->willReturn('code');
     $attribute->getId()->willReturn(42);
     $attribute->isLocalizable()->willReturn(false);
     $attribute->isScopable()->willReturn(false);
     $attrValidatorHelper->validateLocale($attribute, Argument::any())->shouldBeCalled();
     $attrValidatorHelper->validateScope($attribute, Argument::any())->shouldBeCalled();
     $qb->expr()->willReturn($expr);
     $qb->getRootAlias()->willReturn('p');
     $expr->eq(Argument::any(), true)->willReturn('filtercode.backend_type = true');
     $expr->literal(true)->willReturn(true);
     $qb->innerJoin('p.values', Argument::any(), 'WITH', Argument::any())->shouldBeCalled();
     $this->addAttributeFilter($attribute, '=', true);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:16,代码来源:BooleanFilterSpec.php

示例14: prepareCondition

 /**
  * Prepare join to attribute condition with current locale and scope criterias
  *
  * @param AttributeInterface $attribute the attribute
  * @param string             $joinAlias the value join alias
  * @param string             $locale    the locale
  * @param string             $scope     the scope
  *
  * @return string
  */
 public function prepareCondition(AttributeInterface $attribute, $joinAlias, $locale = null, $scope = null)
 {
     $condition = $joinAlias . '.attribute = ' . $attribute->getId();
     if ($attribute->isLocalizable() && null === $locale) {
         throw new \InvalidArgumentException(sprintf('Cannot prepare condition on localizable attribute "%s" without locale', $attribute->getCode()));
     }
     if ($attribute->isLocalizable()) {
         $condition .= ' AND ' . $joinAlias . '.locale = ' . $this->qb->expr()->literal($locale);
     }
     if ($attribute->isScopable() && null === $scope) {
         throw new \InvalidArgumentException(sprintf('Cannot prepare condition on scopable attribute "%s" without scope', $attribute->getCode()));
     }
     if ($attribute->isScopable()) {
         $condition .= ' AND ' . $joinAlias . '.scope = ' . $this->qb->expr()->literal($scope);
     }
     return $condition;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:27,代码来源:ValueJoin.php

示例15:

 function it_adds_a_sorter_to_the_query($qb, AttributeInterface $attribute, Expr $expr)
 {
     $attribute->getId()->willReturn('42');
     $attribute->getCode()->willReturn('entity_code');
     $attribute->isLocalizable()->willReturn(false);
     $attribute->isScopable()->willReturn(false);
     $attribute->getBackendType()->willReturn('entity');
     $qb->getRootAlias()->willReturn('r');
     $qb->expr()->willReturn($expr);
     $qb->leftJoin('r.values', 'sorterVentity_code', 'WITH', 'sorterVentity_code.attribute = 42')->shouldBeCalled();
     $qb->leftJoin('sorterVentity_code.entity', 'sorterOentity_code', 'WITH', 'sorterOentity_code.attribute = 42')->shouldBeCalled();
     $expr->literal('en_US')->shouldBeCalled()->willReturn('en_US');
     $qb->leftJoin('sorterOentity_code.optionValues', 'sorterOVentity_code', 'WITH', 'sorterOVentity_code.locale = en_US')->shouldBeCalled();
     $qb->addOrderBy('sorterOentity_code.code', 'DESC')->shouldBeCalled();
     $qb->addOrderBy('sorterOVentity_code.value', 'DESC')->shouldBeCalled();
     $qb->addOrderBy('r.id')->shouldBeCalled();
     $this->addAttributeSorter($attribute, 'DESC', 'en_US');
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:18,代码来源:EntitySorterSpec.php


注:本文中的Pim\Component\Catalog\Model\AttributeInterface::getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。