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


PHP GroupInterface::getCode方法代码示例

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


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

示例1: prepareVariantGroupMedia

 /**
  * Prepares media files present in the product template of the variant group for export.
  * Returns an array of files to be copied from 'filePath' to 'exportPath'.
  *
  * @param GroupInterface $group
  *
  * @throws InvalidItemException If a media file is not found
  *
  * @return array
  */
 protected function prepareVariantGroupMedia(GroupInterface $group)
 {
     $mediaValues = $this->getProductTemplateMediaValues($group->getProductTemplate());
     if (count($mediaValues) < 1) {
         return [];
     }
     try {
         return $this->normalizer->normalize($mediaValues, $this->format, ['field_name' => 'media', 'prepare_copy' => true, 'identifier' => $group->getCode()]);
     } catch (FileNotFoundException $e) {
         throw new InvalidItemException($e->getMessage(), ['item' => $group->getCode(), 'uploadDirectory' => $this->uploadDirectory]);
     }
 }
开发者ID:umpirsky,项目名称:pim-community-dev,代码行数:22,代码来源:VariantGroupProcessor.php

示例2:

 function it_provides_formatted_batch_config_for_the_job(GroupInterface $oroTshirt)
 {
     $oroTshirt->getCode()->willReturn('oro_tshirt');
     $this->setGroup($oroTshirt);
     $this->setFilters([['id', 'IN', ['22', '7']]]);
     $this->getBatchConfig()->shouldReturn('{\\"filters\\":[[\\"id\\",\\"IN\\",[\\"22\\",\\"7\\"]]],\\"actions\\":{\\"field\\":\\"variant_group\\",\\"value\\":\\"oro_tshirt\\"}}');
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:7,代码来源:AddToVariantGroupSpec.php

示例3: validateAttributeAxis

 /**
  * @param VariantGroupAxis $constraint
  * @param GroupInterface   $variantGroup
  */
 protected function validateAttributeAxis(VariantGroupAxis $constraint, GroupInterface $variantGroup)
 {
     $allowedTypes = [AttributeTypes::OPTION_SIMPLE_SELECT, AttributeTypes::REFERENCE_DATA_SIMPLE_SELECT];
     foreach ($variantGroup->getAxisAttributes() as $attribute) {
         if (!in_array($attribute->getAttributeType(), $allowedTypes)) {
             $this->addInvalidAxisViolation($constraint, $variantGroup->getCode(), $attribute->getCode());
         }
     }
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:13,代码来源:VariantGroupAxisValidator.php

示例4: FileNotFoundException

 function it_throws_an_exception_if_media_of_variant_group_is_not_found($normalizer, $denormalizer, ArrayCollection $productValuesCollection, ArrayCollection $mediaCollection, ProductMediaInterface $media, GroupInterface $variantGroup, ProductTemplateInterface $productTemplate, ProductValueInterface $productValue)
 {
     $variantGroup->getProductTemplate()->willReturn($productTemplate);
     $variantGroup->getCode()->willReturn('my_variant_group');
     $productTemplate->getValuesData()->willReturn([$productValue]);
     $denormalizer->denormalize([$productValue], 'ProductValue[]', 'json')->willReturn($productValuesCollection);
     $productValuesCollection->filter(Argument::cetera())->willReturn($mediaCollection);
     $mediaCollection->toArray()->willReturn([$media]);
     $normalizer->normalize([$media], 'csv', ['field_name' => 'media', 'prepare_copy' => true, 'identifier' => 'my_variant_group'])->willThrow(new FileNotFoundException('upload/path/img.jpg'));
     $this->shouldThrow(new InvalidItemException('The file "upload/path/img.jpg" does not exist', ['item' => 'my_variant_group', 'uploadDirectory' => 'upload/path/']))->duringProcess($variantGroup);
 }
开发者ID:paulclarkin,项目名称:pim-community-dev,代码行数:11,代码来源:VariantGroupProcessorSpec.php

示例5:

 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);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:11,代码来源:VariantGroupAxisValidatorSpec.php

示例6:

 function it_provides_formatted_batch_config_for_the_job(GroupInterface $officeGroup, GroupInterface $bedroomGroup, ArrayCollection $groupCollection)
 {
     $officeGroup->getCode()->willReturn('office_room');
     $bedroomGroup->getCode()->willReturn('bedroom');
     $groupCollection->add($officeGroup);
     $groupCollection->add($bedroomGroup);
     $this->setGroups($groupCollection);
     $groupCollection->map(Argument::type('closure'))->willReturn($groupCollection);
     $groupCollection->toArray()->willReturn(['office_room', 'bedroom']);
     $this->setFilters([['id', 'IN', ['22', '7']]]);
     $this->getBatchConfig()->shouldReturn('{\\"filters\\":[[\\"id\\",\\"IN\\",[\\"22\\",\\"7\\"]]],\\"actions\\":[{\\"field\\":\\"groups\\",\\"value\\":[\\"office_room\\",\\"bedroom\\"]}]}');
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:12,代码来源:AddToGroupsSpec.php

示例7:

 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);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:13,代码来源:VariantGroupAxisValidatorSpec.php

示例8: validateProductTemplateValues

 /**
  * Validate variant group product template values
  *
  * @param GroupInterface $variantGroup
  * @param Constraint     $constraint
  */
 protected function validateProductTemplateValues(GroupInterface $variantGroup, Constraint $constraint)
 {
     $template = $variantGroup->getProductTemplate();
     $valuesData = $template->getValuesData();
     $forbiddenAttrCodes = $this->attributeRepository->findUniqueAttributeCodes();
     foreach ($variantGroup->getAxisAttributes() as $axisAttribute) {
         $forbiddenAttrCodes[] = $axisAttribute->getCode();
     }
     $invalidAttrCodes = array_intersect($forbiddenAttrCodes, array_keys($valuesData));
     if (count($invalidAttrCodes) > 0) {
         $this->context->addViolation($constraint->message, array('%group%' => $variantGroup->getCode(), '%attributes%' => $this->formatValues($invalidAttrCodes)));
     }
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:19,代码来源:VariantGroupValuesValidator.php

示例9:

 function it_adds_a_violation_when_validates_a_product_with_missing_value_for_an_axe_of_its_variant_group($context, ProductInterface $product, GroupInterface $tShirtVariantGroup, AttributeInterface $sizeAttribute, AttributeInterface $colorAttribute, ProductValueInterface $sizeValue, ProductValueInterface $identifierValue, HasVariantAxes $constraint, ConstraintViolationBuilderInterface $violation)
 {
     $tShirtVariantGroup->getCode()->willReturn('tshirt');
     $tShirtVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]);
     $sizeAttribute->getCode()->willReturn('size');
     $colorAttribute->getCode()->willReturn('color');
     $product->getIdentifier()->willReturn($identifierValue);
     $product->getVariantGroup()->willReturn($tShirtVariantGroup);
     $product->getValue('size')->willReturn($sizeValue);
     $product->getValue('color')->willReturn(null);
     $sizeValue->getData()->willReturn('XL');
     $context->buildViolation('The product "%product%" is in the variant group "%variant%" but it misses the following axes: %axes%.', ['%product%' => $identifierValue, '%variant%' => 'tshirt', '%axes%' => 'color'])->shouldBeCalled()->willReturn($violation);
     $this->validate($product, $constraint);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:14,代码来源:HasVariantAxesValidatorSpec.php

示例10:

 function it_saves_a_variant_group_and_copies_values_to_products($optionsResolver, $objectManager, $templateApplier, GroupInterface $group, GroupType $type, ProductInterface $product, ProductTemplateInterface $template, ArrayCollection $products)
 {
     $optionsResolver->resolveSaveOptions(['copy_values_to_products' => true])->willReturn(['flush' => true, 'copy_values_to_products' => true, 'add_products' => [], 'remove_products' => []]);
     $group->getType()->willReturn($type);
     $group->getCode()->willReturn('my_code');
     $objectManager->persist($group)->shouldBeCalled();
     $objectManager->flush()->shouldBeCalled();
     $type->isVariant()->willReturn(true);
     $group->getProductTemplate()->willReturn($template);
     $group->getProducts()->willReturn($products);
     $products->toArray()->willReturn([$product]);
     $templateApplier->apply($template, [$product])->shouldBeCalled();
     $this->save($group, ['copy_values_to_products' => true]);
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:14,代码来源:GroupSaverSpec.php

示例11:

 function it_adds_a_violation_if_variant_group_template_contains_a_unique_attribute(GroupInterface $variantGroup, GroupType $type, ProductTemplateInterface $template, VariantGroupValues $constraint, $attributeRepository, $context)
 {
     $variantGroup->getType()->willReturn($type);
     $variantGroup->getCode()->willReturn('tshirt');
     $type->isVariant()->willReturn(true);
     $variantGroup->getProductTemplate()->willReturn($template);
     $variantGroup->getAxisAttributes()->willReturn([]);
     $attributeRepository->findUniqueAttributeCodes()->willReturn(['sku', 'barcode']);
     $template->getValuesData()->willReturn(['sku' => 'SKU-001']);
     $violationData = ['%group%' => 'tshirt', '%attributes%' => '"sku"'];
     $context->addViolation($constraint->message, $violationData)->shouldBeCalled();
     $this->validate($variantGroup, $constraint);
     $template->getValuesData()->willReturn(['sku' => 'SKU-001', 'barcode' => 01122334455]);
     $violationData = ['%group%' => 'tshirt', '%attributes%' => '"sku", "barcode"'];
     $context->addViolation($constraint->message, $violationData)->shouldBeCalled();
     $this->validate($variantGroup, $constraint);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:17,代码来源:VariantGroupValuesValidatorSpec.php

示例12:

 function it_normalizes_product_with_associations($filter, ProductInterface $product, AttributeInterface $skuAttribute, ProductValueInterface $sku, Association $myCrossSell, AssociationTypeInterface $crossSell, Association $myUpSell, AssociationTypeInterface $upSell, GroupInterface $associatedGroup1, GroupInterface $associatedGroup2, ProductInterface $associatedProduct1, ProductInterface $associatedProduct2, ProductValueInterface $skuAssocProduct1, ProductValueInterface $skuAssocProduct2, Collection $values, FamilyInterface $family, $serializer)
 {
     $family->getCode()->willReturn('shoes');
     $skuAttribute->getCode()->willReturn('sku');
     $skuAttribute->getAttributeType()->willReturn('pim_catalog_identifier');
     $skuAttribute->isLocalizable()->willReturn(false);
     $skuAttribute->isScopable()->willReturn(false);
     $sku->getAttribute()->willReturn($skuAttribute);
     $sku->getData()->willReturn('sku-001');
     $crossSell->getCode()->willReturn('cross_sell');
     $myCrossSell->getAssociationType()->willReturn($crossSell);
     $myCrossSell->getGroups()->willReturn([]);
     $myCrossSell->getProducts()->willReturn([]);
     $upSell->getCode()->willReturn('up_sell');
     $myUpSell->getAssociationType()->willReturn($upSell);
     $associatedGroup1->getCode()->willReturn('associated_group1');
     $associatedGroup2->getCode()->willReturn('associated_group2');
     $myUpSell->getGroups()->willReturn([$associatedGroup1, $associatedGroup2]);
     $skuAssocProduct1->getAttribute()->willReturn($skuAttribute);
     $skuAssocProduct2->getAttribute()->willReturn($skuAttribute);
     $skuAssocProduct1->__toString()->willReturn('sku_assoc_product1');
     $skuAssocProduct2->__toString()->willReturn('sku_assoc_product2');
     $associatedProduct1->getIdentifier()->willReturn($skuAssocProduct1);
     $associatedProduct2->getIdentifier()->willReturn($skuAssocProduct2);
     $myUpSell->getProducts()->willReturn([$associatedProduct1, $associatedProduct2]);
     $product->getIdentifier()->willReturn($sku);
     $product->getFamily()->willReturn($family);
     $product->isEnabled()->willReturn(true);
     $product->getGroupCodes()->willReturn('group1,group2,variant_group_1');
     $product->getCategoryCodes()->willReturn('nice shoes, converse');
     $product->getAssociations()->willReturn([$myCrossSell, $myUpSell]);
     $product->getValues()->willReturn($values);
     $filter->filterCollection($values, 'pim.transform.product_value.flat', Argument::cetera())->willReturn([$sku]);
     $serializer->normalize($sku, 'flat', Argument::any())->willReturn(['sku' => 'sku-001']);
     $this->normalize($product, 'flat', [])->shouldReturn(['sku' => 'sku-001', 'family' => 'shoes', 'groups' => 'group1,group2,variant_group_1', 'categories' => 'nice shoes, converse', 'cross_sell-groups' => '', 'cross_sell-products' => '', 'up_sell-groups' => 'associated_group1,associated_group2', 'up_sell-products' => 'sku_assoc_product1,sku_assoc_product2', 'enabled' => 1]);
 }
开发者ID:umpirsky,项目名称:pim-community-dev,代码行数:36,代码来源:ProductNormalizerSpec.php

示例13:

 function it_normalizes_group($normalizer, GroupInterface $group)
 {
     $group->getCode()->willReturn('mongo');
     $normalizer->normalize($group, 'mongodb_json', [])->willReturn(['label' => 'translations']);
     $this->normalize($group, 'mongodb_json', [])->shouldReturn(['code' => 'mongo', 'label' => 'translations']);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:6,代码来源:GroupNormalizerSpec.php

示例14: getGroupAttributeCodes

 /**
  * Returns the attribute codes for a group
  *
  * @param GroupInterface $group
  *
  * @return array
  */
 protected function getGroupAttributeCodes(GroupInterface $group)
 {
     $code = $group->getCode();
     if (!isset($this->groupAttributeCodes[$code])) {
         $this->groupAttributeCodes[$code] = $this->getAttributeCodes($group);
     }
     return $this->groupAttributeCodes[$code];
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:15,代码来源:AttributeCache.php


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