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


PHP ProductInterface::removeGroup方法代码示例

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


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

示例1:

 function it_removes_groups_field($groupRepository, ProductInterface $product, GroupInterface $packGroup, GroupInterface $crossGroup, GroupTypeInterface $nonVariantType)
 {
     $groupRepository->findOneByIdentifier('pack')->willReturn($packGroup);
     $groupRepository->findOneByIdentifier('cross')->willReturn($crossGroup);
     $packGroup->getType()->willReturn($nonVariantType);
     $crossGroup->getType()->willReturn($nonVariantType);
     $nonVariantType->isVariant()->willReturn(false);
     $product->removeGroup($packGroup)->shouldBeCalled();
     $product->removeGroup($crossGroup)->shouldBeCalled();
     $this->removeFieldData($product, 'groups', ['pack', 'cross']);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:11,代码来源:GroupFieldRemoverSpec.php

示例2:

 function it_sets_variant_group_field($groupRepository, ProductInterface $product, GroupInterface $shirt, GroupInterface $cross, GroupInterface $up, GroupTypeInterface $variantType, GroupTypeInterface $nonVariantType)
 {
     $groupRepository->findOneByIdentifier('shirt')->willReturn($shirt);
     $shirt->getType()->willReturn($variantType);
     $variantType->isVariant()->willReturn(true);
     $product->getGroups()->willReturn([$up, $cross]);
     $up->getType()->willReturn($nonVariantType);
     $nonVariantType->isVariant()->willReturn(false);
     $cross->getType()->willReturn($variantType);
     $variantType->isVariant()->willReturn(true);
     $product->removeGroup($cross)->shouldBeCalled();
     $product->addGroup($shirt)->shouldBeCalled();
     $this->setFieldData($product, 'variant_group', 'shirt');
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:14,代码来源:VariantGroupFieldSetterSpec.php

示例3: removeFieldData

 /**
  * {@inheritdoc}
  *
  * Expected data input format : ["group_code", "another_group_code"]
  */
 public function removeFieldData(ProductInterface $product, $field, $data, array $options = [])
 {
     $this->checkData($field, $data);
     $groups = [];
     foreach ($data as $groupCode) {
         $group = $this->groupRepository->findOneByIdentifier($groupCode);
         if (null === $group) {
             throw InvalidArgumentException::expected($field, 'existing group code', 'remover', 'groups', $groupCode);
         }
         if ($group->getType()->isVariant()) {
             throw InvalidArgumentException::expected($field, 'non variant group code', 'remover', 'groups', $groupCode);
         }
         $groups[] = $group;
     }
     foreach ($groups as $group) {
         $product->removeGroup($group);
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:23,代码来源:GroupFieldRemover.php

示例4: setFieldData

 /**
  * {@inheritdoc}
  *
  * Expected data input format : ["group_code"]
  */
 public function setFieldData(ProductInterface $product, $field, $data, array $options = [])
 {
     $this->checkData($field, $data);
     $groups = [];
     foreach ($data as $groupCode) {
         $group = $this->groupRepository->findOneByIdentifier($groupCode);
         if (null === $group) {
             throw InvalidArgumentException::expected($field, 'existing group code', 'setter', 'groups', $groupCode);
         } else {
             $groups[] = $group;
         }
     }
     $oldGroups = $product->getGroups();
     foreach ($oldGroups as $group) {
         $product->removeGroup($group);
     }
     foreach ($groups as $group) {
         $product->addGroup($group);
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:25,代码来源:GroupFieldSetter.php

示例5: setFieldData

 /**
  * {@inheritdoc}
  *
  * Expected data input format : "variant_group_code"
  */
 public function setFieldData(ProductInterface $product, $field, $data, array $options = [])
 {
     $this->checkData($field, $data);
     if (null !== $data) {
         $variantGroup = $this->groupRepository->findOneByIdentifier($data);
         if (null === $variantGroup) {
             throw InvalidArgumentException::expected($field, 'existing variant group code', 'setter', 'variant_group', $data);
         }
         if (!$variantGroup->getType()->isVariant()) {
             throw InvalidArgumentException::expected($field, 'variant group code', 'setter', 'variant_group', $data);
         }
     }
     $existingGroups = $product->getGroups();
     foreach ($existingGroups as $group) {
         if ($group->getType()->isVariant()) {
             $product->removeGroup($group);
         }
     }
     if (null !== $data) {
         $product->addGroup($variantGroup);
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:27,代码来源:VariantGroupFieldSetter.php

示例6: denormalizeGroups

 /**
  * Denormalize product groups
  *
  * @param string           $data
  * @param string           $format
  * @param array            $context
  * @param ProductInterface $product
  */
 protected function denormalizeGroups($data, $format, array $context, ProductInterface $product)
 {
     foreach ($product->getGroups() as $group) {
         $product->removeGroup($group);
     }
     $groupCodes = strlen($data) > 0 ? explode(",", $data) : [];
     foreach ($groupCodes as $groupCode) {
         $product->addGroup($this->serializer->denormalize($groupCode, $this->groupClass, $format, $context));
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:18,代码来源:ProductDenormalizer.php


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