本文整理汇总了PHP中Pim\Component\Catalog\Exception\InvalidArgumentException::validEntityCodeExpected方法的典型用法代码示例。如果您正苦于以下问题:PHP InvalidArgumentException::validEntityCodeExpected方法的具体用法?PHP InvalidArgumentException::validEntityCodeExpected怎么用?PHP InvalidArgumentException::validEntityCodeExpected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Component\Catalog\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']]);
}
示例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->getOption($attribute, $data);
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']);
}
示例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']);
}
示例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;
}
示例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']);
}