本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\GroupInterface::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP GroupInterface::getId方法的具体用法?PHP GroupInterface::getId怎么用?PHP GroupInterface::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Model\GroupInterface
的用法示例。
在下文中一共展示了GroupInterface::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_throws_an_error_if_type_is_unknown(GroupInterface $group)
{
$group->setCode('mycode')->shouldBeCalled();
$group->getId()->willReturn(null);
$values = ['code' => 'mycode', 'type' => 'UNKNOWN'];
$this->shouldThrow(new \InvalidArgumentException('Type "UNKNOWN" does not exist'))->during('update', [$group, $values, []]);
}
示例2:
function it_normalizes_an_existing_product_into_mongodb_document($mongoFactory, $serializer, ProductInterface $product, \MongoId $mongoId, \MongoDate $mongoDate, Association $assoc1, Association $assoc2, CategoryInterface $category1, CategoryInterface $category2, GroupInterface $group1, GroupInterface $group2, ProductValueInterface $value1, ProductValueInterface $value2, FamilyInterface $family)
{
$mongoFactory->createMongoId('product1')->willReturn($mongoId);
$mongoFactory->createMongoDate()->willReturn($mongoDate);
$family->getId()->willReturn(36);
$category1->getId()->willReturn(12);
$category2->getId()->willReturn(34);
$group1->getId()->willReturn(56);
$group2->getId()->willReturn(78);
$product->getId()->willReturn('product1');
$product->getCreated()->willReturn(null);
$product->getFamily()->willReturn($family);
$product->isEnabled()->willReturn(true);
$product->getGroups()->willReturn([$group1, $group2]);
$product->getCategories()->willReturn([$category1, $category2]);
$product->getAssociations()->willReturn([$assoc1, $assoc2]);
$product->getValues()->willReturn([$value1, $value2]);
$context = ['_id' => $mongoId];
$serializer->normalize($product, 'mongodb_json')->willReturn(['data' => 'data', 'completenesses' => 'completenesses']);
$serializer->normalize($value1, 'mongodb_document', $context)->willReturn('my_value_1');
$serializer->normalize($value2, 'mongodb_document', $context)->willReturn('my_value_2');
$serializer->normalize($assoc1, 'mongodb_document', $context)->willReturn('my_assoc_1');
$serializer->normalize($assoc2, 'mongodb_document', $context)->willReturn('my_assoc_2');
$this->normalize($product, 'mongodb_document')->shouldReturn(['_id' => $mongoId, 'created' => $mongoDate, 'updated' => $mongoDate, 'family' => 36, 'enabled' => true, 'groupIds' => [56, 78], 'categoryIds' => [12, 34], 'associations' => ['my_assoc_1', 'my_assoc_2'], 'values' => ['my_value_1', 'my_value_2'], 'normalizedData' => ['data' => 'data'], 'completenesses' => []]);
}
示例3: Attribute
function it_throws_an_error_if_axis_is_updated(GroupInterface $variantGroup)
{
$variantGroup->setCode('mycode')->shouldBeCalled();
$variantGroup->getId()->willReturn(42);
$attribute = new Attribute();
$attribute->setCode('other');
$variantGroup->getAxisAttributes()->willReturn(new ArrayCollection([$attribute]));
$values = ['code' => 'mycode', 'axis' => ['main_color']];
$this->shouldThrow(new \InvalidArgumentException('Attributes: This property cannot be changed.'))->during('update', [$variantGroup, $values, []]);
}
示例4:
function it_adds_a_violation_if_a_group_contains_axis_attributes($context, GroupInterface $group, GroupType $type, VariantGroupAxis $constraint, AttributeInterface $axis)
{
$group->getId()->willReturn(null);
$group->getType()->willReturn($type);
$group->getCode()->willReturn('xsell');
$type->isVariant()->willReturn(false);
$group->getAxisAttributes()->willReturn([$axis]);
$violationData = ['%group%' => 'xsell'];
$context->addViolation($constraint->unexpectedAxisMessage, $violationData)->shouldBeCalled();
$this->validate($group, $constraint);
}
示例5:
function it_adds_a_violation_if_axis_attributes_are_invalid($context, GroupInterface $variantGroup, GroupType $type, VariantGroupAxis $constraint, ConstraintViolationBuilderInterface $violation, AttributeInterface $invalidAxis)
{
$variantGroup->getId()->willReturn(12);
$variantGroup->getType()->willReturn($type);
$variantGroup->getCode()->willReturn('tshirt');
$type->isVariant()->willReturn(true);
$variantGroup->getAxisAttributes()->willReturn([$invalidAxis]);
$invalidAxis->getAttributeType()->willReturn(AttributeTypes::TEXT);
$invalidAxis->getCode()->willReturn('name');
$violationData = ['%group%' => 'tshirt', '%attribute%' => 'name'];
$context->buildViolation($constraint->invalidAxisMessage, $violationData)->shouldBeCalled()->willReturn($violation);
$this->validate($variantGroup, $constraint);
}
示例6:
function it_does_not_copy_values_to_products_when_template_is_empty(GroupInterface $variantGroup, ProductTemplateInterface $productTemplate, Collection $productCollection, ProductInterface $productOne, ProductInterface $productTwo, $productTplApplier, $stepExecution)
{
$variantGroup->getId()->willReturn(42);
$stepExecution->incrementSummaryInfo('update')->shouldBeCalled();
$variantGroup->getProductTemplate()->willReturn($productTemplate);
$productTemplate->getValuesData()->willReturn([]);
$variantGroup->getProducts()->willReturn($productCollection);
$productCollection->isEmpty()->willReturn(false);
$productCollection->toArray()->willReturn([$productOne, $productTwo]);
$productCollection->count()->willReturn(2);
$productTplApplier->apply($productTemplate, [$productOne, $productTwo])->shouldNotBeCalled();
$this->write([$variantGroup]);
}
示例7:
function it_normalize_products($productNormalizer, $versionNormalizer, $versionManager, $localeManager, ProductInterface $mug, AssociationInterface $upsell, AssociationTypeInterface $groupType, GroupInterface $group, ArrayCollection $groups)
{
$productNormalizer->normalize($mug, 'json', [])->willReturn(['normalized_property' => 'a nice normalized property']);
$mug->getId()->willReturn(12);
$versionManager->getOldestLogEntry($mug)->willReturn('create_version');
$versionNormalizer->normalize('create_version', 'internal_api')->willReturn('normalized_create_version');
$versionManager->getNewestLogEntry($mug)->willReturn('update_version');
$versionNormalizer->normalize('update_version', 'internal_api')->willReturn('normalized_update_version');
$localeManager->getActiveCodes()->willReturn(['en_US', 'fr_FR']);
$mug->getLabel('en_US')->willReturn('A nice Mug!');
$mug->getLabel('fr_FR')->willReturn('Un très beau Mug !');
$mug->getAssociations()->willReturn([$upsell]);
$upsell->getAssociationType()->willReturn($groupType);
$groupType->getCode()->willReturn('group');
$upsell->getGroups()->willReturn($groups);
$groups->toArray()->willReturn([$group]);
$group->getId()->willReturn(12);
$this->normalize($mug, 'internal_api', [])->shouldReturn(['normalized_property' => 'a nice normalized property', 'meta' => ['id' => 12, 'created' => 'normalized_create_version', 'updated' => 'normalized_update_version', 'label' => ['en_US' => 'A nice Mug!', 'fr_FR' => 'Un très beau Mug !'], 'associations' => ['group' => ['groupIds' => [12]]]]]);
}
示例8:
function it_does_not_add_violation_when_validating_product_in_groups_with_unique_combination_of_axis_attributes($context, $productRepository, GroupInterface $tShirtVariantGroup, GroupTypeInterface $tShirtGroupType, ProductInterface $redTShirtProduct, AttributeInterface $sizeAttribute, AttributeInterface $colorAttribute, ProductValueInterface $sizeProductValue, ProductValueInterface $redColorProductValue, UniqueVariantAxis $uniqueVariantAxisConstraint)
{
$tShirtVariantGroup->getId()->willReturn(1);
$tShirtVariantGroup->getLabel()->willReturn('TShirts');
$tShirtVariantGroup->getType()->willReturn($tShirtGroupType);
$tShirtGroupType->isVariant()->willReturn(true);
$tShirtVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]);
$sizeAttribute->getCode()->willReturn('size');
$sizeAttribute->isBackendTypeReferenceData()->willReturn(false);
$colorAttribute->getCode()->willReturn('color');
$colorAttribute->isBackendTypeReferenceData()->willReturn(false);
$redTShirtProduct->getVariantGroup()->willReturn($tShirtVariantGroup);
$redTShirtProduct->getId()->willReturn(1);
$redTShirtProduct->getValue('size')->willReturn($sizeProductValue);
$redTShirtProduct->getValue('color')->willReturn($redColorProductValue);
$sizeProductValue->getOption()->willReturn('XL');
$redColorProductValue->getOption()->willReturn('Red');
$criteria = [['attribute' => $sizeAttribute, 'option' => 'XL'], ['attribute' => $colorAttribute, 'option' => 'Red']];
$productRepository->findAllForVariantGroup($tShirtVariantGroup, $criteria)->willReturn([]);
$context->buildViolation()->shouldNotBeCalled(Argument::cetera());
$this->validate($redTShirtProduct, $uniqueVariantAxisConstraint);
}
示例9: getMatchingProducts
/**
* Get matching products
*
* @param GroupInterface $variantGroup the variant group
* @param ProductInterface $entity the product
* @param array $criteria query criterias
*
* @return ProductInterface[]
*/
protected function getMatchingProducts(GroupInterface $variantGroup, ProductInterface $entity = null, array $criteria = [])
{
if (!$variantGroup->getId()) {
return [];
}
$matchingProducts = $this->repository->findAllForVariantGroup($variantGroup, $criteria);
if ($entity) {
$matchingProducts = array_filter($matchingProducts, function ($product) use($entity) {
return $product->getId() !== $entity->getId();
});
}
return $matchingProducts;
}
示例10: incrementUpdatedVariantGroupCount
/**
* @param GroupInterface $group
*/
protected function incrementUpdatedVariantGroupCount(GroupInterface $group)
{
if (null === $group->getId()) {
$this->stepExecution->incrementSummaryInfo('create');
} else {
$this->stepExecution->incrementSummaryInfo('update');
}
}
示例11: getProductCountByGroup
/**
* {@inheritdoc}
*/
public function getProductCountByGroup(GroupInterface $group)
{
$qb = $this->createQueryBuilder('p')->hydrate(false)->field('groupIds')->in([$group->getId()]);
$count = $qb->getQuery()->execute()->count();
return $count;
}
示例12:
function it_normalizes_an_association_with_products_and_groups($mongoFactory, Association $assoc, AssociationTypeInterface $assocType, \MongoId $mongoId, \MongoDBRef $ownerRef, ProductInterface $product1, \MongoDBRef $product1Ref, ProductInterface $product2, \MongoDBRef $product2Ref, GroupInterface $group1, GroupInterface $group2)
{
$assocType->getId()->willReturn(8);
$assoc->getAssociationType()->willReturn($assocType);
$context = ['_id' => '1234abc', 'collection_name' => 'product'];
$mongoFactory->createMongoId()->willReturn($mongoId);
$mongoFactory->createMongoDBRef('product', '1234abc')->willReturn($ownerRef);
$mongoFactory->createMongoDBRef('product', 'product1')->willReturn($product1Ref);
$mongoFactory->createMongoDBRef('product', 'product2')->willReturn($product2Ref);
$product1->getId()->willReturn('product1');
$product2->getId()->willReturn('product2');
$assoc->getProducts()->willReturn([$product1, $product2]);
$group1->getId()->willReturn(1);
$group2->getId()->willReturn(2);
$assoc->getGroups()->willReturn([$group1, $group2]);
$this->normalize($assoc, 'mongodb_document', $context)->shouldReturn(['_id' => $mongoId, 'associationType' => 8, 'owner' => $ownerRef, 'products' => [$product1Ref, $product2Ref], 'groupIds' => [1, 2]]);
}
示例13: setAxes
/**
* @param GroupInterface $variantGroup
* @param array $axes
*
* @throws \InvalidArgumentException
*/
protected function setAxes(GroupInterface $variantGroup, array $axes)
{
if (null !== $variantGroup->getId()) {
if (array_diff($this->getOriginalAxes($variantGroup->getAxisAttributes()), array_values($axes))) {
throw new \InvalidArgumentException('Attributes: This property cannot be changed.');
}
}
foreach ($axes as $axis) {
$attribute = $this->attributeRepository->findOneByIdentifier($axis);
if (null !== $attribute) {
$variantGroup->addAxisAttribute($attribute);
} else {
throw new \InvalidArgumentException(sprintf('Attribute "%s" does not exist', $axis));
}
}
}
示例14:
function it_adds_a_violation_when_validating_product_in_groups_with_non_unique_combination_of_axis_attributes($context, $productRepository, GroupInterface $tShirtVariantGroup, GroupTypeInterface $tShirtGroupType, GroupInterface $clothesVariantGroup, GroupTypeInterface $clothesGroupType, ProductInterface $redTShirtProduct, AttributeInterface $sizeAttribute, AttributeInterface $colorAttribute, ProductValueInterface $sizeProductValue, ProductValueInterface $colorProductValue, ProductInterface $redTShirtProduct2, UniqueVariantAxis $uniqueVariantAxisConstraint)
{
$redTShirtProduct->getGroups()->willReturn([$tShirtVariantGroup, $clothesVariantGroup]);
$tShirtVariantGroup->getId()->willReturn(1);
$tShirtVariantGroup->getLabel()->willReturn('TShirts');
$tShirtVariantGroup->getType()->willReturn($tShirtGroupType);
$tShirtGroupType->isVariant()->willReturn(true);
$tShirtVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]);
$clothesVariantGroup->getId()->willReturn(2);
$clothesVariantGroup->getLabel()->willReturn('Clothes');
$clothesVariantGroup->getType()->willReturn($clothesGroupType);
$clothesGroupType->isVariant()->willReturn(true);
$clothesVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]);
$sizeAttribute->getCode()->willReturn('size');
$colorAttribute->getCode()->willReturn('color');
$redTShirtProduct->getValue('size')->willReturn($sizeProductValue);
$redTShirtProduct->getValue('color')->willReturn($colorProductValue);
$redTShirtProduct->getId()->willReturn(1);
$sizeProductValue->getOption()->willReturn('XL');
$colorProductValue->getOption()->willReturn('Red');
$redTShirtProduct2->getGroups()->willReturn([$clothesVariantGroup]);
$redTShirtProduct2->getValue('size')->willReturn($sizeProductValue);
$redTShirtProduct2->getValue('color')->willReturn($colorProductValue);
$redTShirtProduct2->getId()->willReturn(2);
$criteria = [['attribute' => $sizeAttribute, 'option' => 'XL'], ['attribute' => $colorAttribute, 'option' => 'Red']];
$productRepository->findAllForVariantGroup($tShirtVariantGroup, $criteria)->willReturn([]);
$productRepository->findAllForVariantGroup($clothesVariantGroup, $criteria)->willReturn([$redTShirtProduct2]);
$context->addViolation('Group "%variant group%" already contains another product with values "%values%"', ['%variant group%' => 'Clothes', '%values%' => 'size: XL, color: Red'])->shouldBeCalled();
$this->validate($redTShirtProduct, $uniqueVariantAxisConstraint);
}
示例15: iShouldBeOnTheVariantGroupPage
/**
* @param GroupInterface $group
*
* @Given /^I should be on the ("([^"]*)" variant group) page$/
*/
public function iShouldBeOnTheVariantGroupPage(GroupInterface $group)
{
$expectedAddress = $this->getPage('VariantGroup edit')->getUrl(['id' => $group->getId()]);
$this->assertAddress($expectedAddress);
}