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


PHP InvalidArgumentException::validEntityCodeExpected方法代码示例

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


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

示例1:

 function it_throws_an_exception_if_reference_data_does_not_exist($attrValidatorHelper, $repositoryResolver, ObjectRepository $repository, ProductInterface $product, AttributeInterface $attribute)
 {
     $attribute->getReferenceDataName()->willReturn('customMaterials');
     $attribute->getCode()->willReturn('lace_fabric');
     $attrValidatorHelper->validateLocale(Argument::cetera())->shouldBeCalled();
     $attrValidatorHelper->validateScope(Argument::cetera())->shouldBeCalled();
     $repositoryResolver->resolve('customMaterials')->willReturn($repository);
     $repository->findOneBy(['code' => 'hulk_retriever'])->willReturn(null);
     $exception = InvalidArgumentException::validEntityCodeExpected('lace_fabric', 'code', 'No reference data "customMaterials" with code "hulk_retriever" has been found', 'setter', 'reference data', 'hulk_retriever');
     $this->shouldThrow($exception)->during('setAttributeData', [$product, $attribute, 'hulk_retriever', ['locale' => 'fr_FR', 'scope' => 'mobile']]);
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:11,代码来源:ReferenceDataSetterSpec.php

示例2: setAttributeData

 /**
  * {@inheritdoc}
  *
  * Expected data input format: "option_code"
  */
 public function setAttributeData(ProductInterface $product, AttributeInterface $attribute, $data, array $options = [])
 {
     $options = $this->resolver->resolve($options);
     $this->checkLocaleAndScope($attribute, $options['locale'], $options['scope'], 'text');
     $this->checkData($attribute, $data);
     if (null === $data) {
         $option = null;
     } else {
         $option = $this->attrOptionRepository->findOneBy(['code' => $data, 'attribute' => $attribute]);
         if (null === $option) {
             throw InvalidArgumentException::validEntityCodeExpected($attribute->getCode(), 'code', 'The option does not exist', 'setter', 'simple select', $data);
         }
     }
     $this->setOption($product, $attribute, $option, $options['locale'], $options['scope']);
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:20,代码来源:SimpleSelectAttributeSetter.php

示例3: setAttributeData

 /**
  * {@inheritdoc}
  */
 public function setAttributeData(ProductInterface $product, AttributeInterface $attribute, $data, array $options = [])
 {
     $this->checkLocaleAndScope($attribute, $options['locale'], $options['scope'], 'reference data');
     $this->checkData($attribute, $data);
     if (empty($data)) {
         $referenceData = null;
     } else {
         $repository = $this->repositoryResolver->resolve($attribute->getReferenceDataName());
         $referenceData = $repository->findOneBy(['code' => $data]);
         if (null === $referenceData) {
             throw InvalidArgumentException::validEntityCodeExpected($attribute->getCode(), 'code', sprintf('No reference data "%s" with code "%s" has been found', $attribute->getReferenceDataName(), $data), 'setter', 'reference data', $data);
         }
     }
     $this->setReferenceData($attribute, $product, $referenceData, $options['locale'], $options['scope']);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:18,代码来源:ReferenceDataSetter.php

示例4: valueCodesToIds

 /**
  * @param AttributeInterface $attribute
  * @param string             $value
  *
  * @return int
  */
 protected function valueCodesToIds(AttributeInterface $attribute, $value)
 {
     try {
         $value = $this->idsResolver->resolve($attribute->getReferenceDataName(), $value);
     } catch (\LogicException $e) {
         throw InvalidArgumentException::validEntityCodeExpected($attribute->getCode(), 'code', $e->getMessage(), 'setter', 'reference data', implode(',', $value));
     }
     return $value;
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:15,代码来源:ReferenceDataFilter.php

示例5:

 function it_throws_an_error_if_the_attribute_data_option_does_not_exist(AttributeInterface $attribute, ProductInterface $product)
 {
     $attribute->getCode()->willReturn('attributeCode');
     $data = 'unknown code';
     $this->shouldThrow(InvalidArgumentException::validEntityCodeExpected('attributeCode', 'code', 'The option does not exist', 'setter', 'simple select', $data))->duringSetAttributeData($product, $attribute, $data, ['locale' => 'fr_FR', 'scope' => 'mobile']);
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:6,代码来源:SimpleSelectAttributeSetterSpec.php


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