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


PHP InvalidArgumentException::expected方法代码示例

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


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

示例1:

 function it_fails_if_the_group_code_is_not_found($groupRepository, ProductInterface $product, GroupInterface $pack, GroupTypeInterface $nonVariantType)
 {
     $groupRepository->findOneByIdentifier('not valid code')->willReturn(null);
     $pack->getType()->willReturn($nonVariantType);
     $nonVariantType->isVariant()->willReturn(false);
     $this->shouldThrow(InvalidArgumentException::expected('variant_group', 'existing variant group code', 'setter', 'variant_group', 'not valid code'))->during('setFieldData', [$product, 'variant_group', 'not valid code']);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:7,代码来源:VariantGroupFieldSetterSpec.php

示例2:

 function it_fails_if_one_of_the_associated_group_does_not_exist($productBuilder, $groupRepository, ProductInterface $product, AssociationInterface $xsellAssociation)
 {
     $product->getAssociations()->willReturn([$xsellAssociation]);
     $productBuilder->addMissingAssociations($product)->shouldBeCalled();
     $product->getAssociationForTypeCode('xsell')->willReturn($xsellAssociation);
     $groupRepository->findOneByIdentifier('not existing group')->willReturn(null);
     $this->shouldThrow(InvalidArgumentException::expected('associations', 'existing group code', 'adder', 'association', 'not existing group'))->during('addFieldData', [$product, 'associations', ['xsell' => ['groups' => ['not existing group'], 'products' => []]]]);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:8,代码来源:AssociationFieldAdderSpec.php

示例3: addFieldFilter

 /**
  * {@inheritdoc}
  */
 public function addFieldFilter($field, $operator, $value, $locale = null, $scope = null, $options = [])
 {
     if (!is_string($value) && !is_array($value)) {
         throw InvalidArgumentException::expected($field, 'array or string value', 'filter', 'productId', $value);
     }
     $field = '_id';
     $value = is_array($value) ? $value : [$value];
     $this->applyFilter($value, $field, $operator);
     return $this;
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:13,代码来源:ProductIdFilter.php

示例4:

 function it_fails_if_the_group_code_does_not_correspond_to_a_simple_group($groupRepository, ProductInterface $product, GroupInterface $pack, GroupInterface $variant, GroupTypeInterface $nonVariantType, GroupTypeInterface $variantType)
 {
     $groupRepository->findOneByIdentifier('pack')->willReturn($pack);
     $pack->getType()->willReturn($nonVariantType);
     $nonVariantType->isVariant()->willReturn(false);
     $groupRepository->findOneByIdentifier('variant')->willReturn($variant);
     $variant->getType()->willReturn($variantType);
     $variantType->isVariant()->willReturn(true);
     $this->shouldThrow(InvalidArgumentException::expected('groups', 'non variant group code', 'remover', 'groups', 'variant'))->during('removeFieldData', [$product, 'groups', ['pack', 'variant']]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:10,代码来源:GroupFieldRemoverSpec.php

示例5: addFieldFilter

 /**
  * {@inheritdoc}
  */
 public function addFieldFilter($field, $operator, $value, $locale = null, $scope = null, $options = [])
 {
     if (!is_numeric($value) && !is_array($value)) {
         throw InvalidArgumentException::expected($field, 'array or numeric value', 'filter', 'productId', $value);
     }
     $field = current($this->qb->getRootAliases()) . '.' . $field;
     $condition = $this->prepareCriteriaCondition($field, $operator, $value);
     $this->qb->andWhere($condition);
     return $this;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:13,代码来源:ProductIdFilter.php

示例6: setFieldData

 /**
  * {@inheritdoc}
  *
  * Expected data input format : "family_code"
  */
 public function setFieldData(ProductInterface $product, $field, $data, array $options = [])
 {
     $this->checkData($field, $data);
     if (null !== $data && '' !== $data) {
         $family = $this->getFamily($data);
         if (null === $family) {
             throw InvalidArgumentException::expected($field, 'existing family code', 'setter', 'family', $data);
         }
         $product->setFamily($family);
     } else {
         $product->setFamily(null);
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:18,代码来源:FamilyFieldSetter.php

示例7: removeFieldData

 /**
  * {@inheritdoc}
  *
  * Expected data input format : ["category_code", "another_category_code"]
  */
 public function removeFieldData(ProductInterface $product, $field, $data, array $options = [])
 {
     $this->checkData($field, $data);
     $categories = [];
     foreach ($data as $categoryCode) {
         $category = $this->categoryRepository->findOneByIdentifier($categoryCode);
         if (null === $category) {
             throw InvalidArgumentException::expected($field, 'existing category code', 'remover', 'category', $categoryCode);
         }
         $categories[] = $category;
     }
     foreach ($categories as $categoryToRemove) {
         $product->removeCategory($categoryToRemove);
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:20,代码来源:CategoryFieldRemover.php

示例8: addFieldData

 /**
  * {@inheritdoc}
  *
  * Expected data input format : ["group_code"]
  */
 public function addFieldData(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', 'adder', 'groups', $groupCode);
         } elseif ($group->getType()->isVariant()) {
             throw InvalidArgumentException::expected($field, 'non variant group code', 'adder', 'groups', $groupCode);
         } else {
             $groups[] = $group;
         }
     }
     foreach ($groups as $group) {
         $product->addGroup($group);
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:23,代码来源:GroupFieldAdder.php

示例9: setFieldData

 /**
  * {@inheritdoc}
  *
  * Expected data input format : ["category_code"]
  */
 public function setFieldData(ProductInterface $product, $field, $data, array $options = [])
 {
     $this->checkData($field, $data);
     $categories = [];
     foreach ($data as $categoryCode) {
         $category = $this->getCategory($categoryCode);
         if (null === $category) {
             throw InvalidArgumentException::expected($field, 'existing category code', 'setter', 'category', $categoryCode);
         } else {
             $categories[] = $category;
         }
     }
     $oldCategories = $product->getCategories();
     foreach ($oldCategories as $category) {
         $product->removeCategory($category);
     }
     foreach ($categories as $category) {
         $product->addCategory($category);
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:25,代码来源:CategoryFieldSetter.php

示例10: 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

示例11: 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

示例12:

 function it_throws_an_exception_if_value_is_an_array_but_does_not_contain_two_values()
 {
     $this->shouldThrow(InvalidArgumentException::expected('release_date', 'array with 2 elements, string or \\Datetime', 'filter', 'date', print_r([123, 123, 'three'], true)))->during('addFieldFilter', ['release_date', '>', [123, 123, 'three']]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:4,代码来源:DateFilterSpec.php

示例13:

 function it_throws_an_exception_if_value_is_an_array_but_does_not_contain_two_values(AttributeInterface $attribute)
 {
     $attribute->getCode()->willReturn('release_date');
     $this->shouldThrow(InvalidArgumentException::expected('release_date', 'array with 2 elements, string or \\DateTime', 'filter', 'date', print_r([123, 123, 'three'], true)))->during('addAttributeFilter', [$attribute, '>', [123, 123, 'three']]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:5,代码来源:DateFilterSpec.php

示例14: storeFile

 /**
  * TODO: inform the user that this could take some time
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  *
  * @throws InvalidArgumentException If an invalid filePath is provided
  *
  * @return FileInfoInterface|null
  */
 protected function storeFile(AttributeInterface $attribute, $data)
 {
     if (null === $data || null === $data['filePath'] && null === $data['originalFilename']) {
         return null;
     }
     try {
         $rawFile = new UploadedFile($data['filePath'], $data['originalFilename']);
         $file = $this->storer->store($rawFile, FileStorage::CATALOG_STORAGE_ALIAS);
     } catch (FileNotFoundException $e) {
         throw InvalidArgumentException::expected($attribute->getCode(), 'a valid pathname', 'setter', 'media', $data['filePath']);
     }
     return $file;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:23,代码来源:MediaAttributeSetter.php

示例15:

 function it_fails_if_one_of_the_category_code_does_not_exist($categoryRepository, ProductInterface $product, CategoryInterface $mug, CategoryInterface $shirt)
 {
     $categoryRepository->findOneByIdentifier('mug')->willReturn($mug);
     $categoryRepository->findOneByIdentifier('non valid category code')->willReturn(null);
     $this->shouldThrow(InvalidArgumentException::expected('categories', 'existing category code', 'adder', 'category', 'non valid category code'))->during('addFieldData', [$product, 'categories', ['mug', 'non valid category code']]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:6,代码来源:CategoryFieldAdderSpec.php


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