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


PHP InvalidArgumentException::arrayInvalidKey方法代码示例

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


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

示例1:

 function it_throws_an_error_if_attribute_data_value_does_not_contain_valid_currency($currencyManager, AttributeInterface $attribute, ProductInterface $product)
 {
     $attribute->getCode()->willReturn('attributeCode');
     $currencyManager->getActiveCodes()->willReturn(['EUR', 'USD']);
     $data = [['data' => 123, 'currency' => 'invalid currency']];
     $this->shouldThrow(InvalidArgumentException::arrayInvalidKey('attributeCode', 'currency', 'The currency does not exist', 'remover', 'prices collection', 'invalid currency'))->during('removeAttributeData', [$product, $attribute, $data, ['locale' => 'fr_FR', 'scope' => 'mobile']]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:7,代码来源:PriceCollectionAttributeRemoverSpec.php

示例2:

 function it_throws_an_error_if_an_option_code_is_unknown_on_attribute_data_set($attrOptionRepository, ProductInterface $product, AttributeInterface $attribute)
 {
     $attribute->getCode()->willReturn('attributeCode');
     $data = ['unknown code'];
     $attrOptionRepository->findOneByIdentifier('attributeCode.unknown code')->shouldBeCalledTimes(1)->willReturn(null);
     $this->shouldThrow(InvalidArgumentException::arrayInvalidKey('attributeCode', 'code', 'The option does not exist', 'setter', 'multi select', 'unknown code'))->during('setAttributeData', [$product, $attribute, $data, ['locale' => 'fr_FR', 'scope' => 'mobile']]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:7,代码来源:MultiSelectAttributeSetterSpec.php

示例3: setAttributeData

 /**
  * {@inheritdoc}
  *
  * Expected data input format: ["option_code", "other_option_code"]
  */
 public function setAttributeData(ProductInterface $product, AttributeInterface $attribute, $data, array $options = [])
 {
     $this->checkLocaleAndScope($attribute, $options['locale'], $options['scope'], 'multi select');
     $this->checkData($attribute, $data);
     $attributeOptions = [];
     foreach ($data as $optionCode) {
         $option = $this->getOption($attribute, $optionCode);
         if (null === $option) {
             throw InvalidArgumentException::arrayInvalidKey($attribute->getCode(), 'code', 'The option does not exist', 'setter', 'multi select', $optionCode);
         }
         $attributeOptions[] = $option;
     }
     $this->setOptions($product, $attribute, $attributeOptions, $options['locale'], $options['scope']);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:19,代码来源:MultiSelectAttributeSetter.php

示例4: setAttributeData

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

示例5: checkData

 /**
  * Check if data are valid
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  *
  * @return mixed
  */
 protected function checkData(AttributeInterface $attribute, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'adder', 'prices collection', gettype($data));
     }
     foreach ($data as $price) {
         if (!is_array($price)) {
             throw InvalidArgumentException::arrayOfArraysExpected($attribute->getCode(), 'adder', 'prices collection', gettype($data));
         }
         if (!array_key_exists('data', $price)) {
             throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'data', 'adder', 'prices collection', print_r($data, true));
         }
         if (!array_key_exists('currency', $price)) {
             throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'currency', 'adder', 'prices collection', print_r($data, true));
         }
         if (!is_numeric($price['data']) && null !== $price['data']) {
             throw InvalidArgumentException::arrayNumericKeyExpected($attribute->getCode(), 'data', 'adder', 'prices collection', gettype($price['data']));
         }
         if (!in_array($price['currency'], $this->currencyRepository->getActivatedCurrencyCodes())) {
             throw InvalidArgumentException::arrayInvalidKey($attribute->getCode(), 'currency', 'The currency does not exist', 'adder', 'prices collection', $price['currency']);
         }
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:31,代码来源:PriceCollectionAttributeAdder.php

示例6:

 function it_throws_an_exception_if_value_had_not_a_valid_currency($currencyRepository, AttributeInterface $attribute)
 {
     $currencyRepository->getActivatedCurrencyCodes()->willReturn(['EUR', 'USD']);
     $attribute->getCode()->willReturn('price_code');
     $value = ['data' => 132, 'currency' => 'FOO'];
     $this->shouldThrow(InvalidArgumentException::arrayInvalidKey('price_code', 'currency', 'The currency does not exist', 'filter', 'price', 'FOO'))->during('addAttributeFilter', [$attribute, '=', $value]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:7,代码来源:PriceFilterSpec.php

示例7:

 function it_throws_an_exception_if_value_had_not_a_valid_unit($measureManager, AttributeInterface $attribute)
 {
     $attribute->getMetricFamily()->willReturn('length');
     $measureManager->getUnitSymbolsForFamily('length')->willReturn(['CENTIMETER' => 'cm', 'METER' => 'm', 'KILOMETER' => 'km']);
     $attribute->getCode()->willReturn('metric_code');
     $value = ['data' => 132, 'unit' => 'foo'];
     $this->shouldThrow(InvalidArgumentException::arrayInvalidKey('metric_code', 'unit', 'The unit does not exist in the attribute\'s family "length"', 'filter', 'metric', 'foo'))->during('addAttributeFilter', [$attribute, '=', $value]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:8,代码来源:MetricFilterSpec.php

示例8: checkValue

 /**
  * @param AttributeInterface $attribute
  * @param mixed              $data
  */
 protected function checkValue(AttributeInterface $attribute, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'filter', 'price', gettype($data));
     }
     if (!array_key_exists('data', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'data', 'filter', 'price', print_r($data, true));
     }
     if (!array_key_exists('currency', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'currency', 'filter', 'price', print_r($data, true));
     }
     if (null !== $data['data'] && !is_numeric($data['data'])) {
         throw InvalidArgumentException::arrayNumericKeyExpected($attribute->getCode(), 'data', 'filter', 'price', gettype($data['data']));
     }
     if (!is_string($data['currency'])) {
         throw InvalidArgumentException::arrayStringKeyExpected($attribute->getCode(), 'currency', 'filter', 'price', gettype($data['currency']));
     }
     if (!in_array($data['currency'], $this->currencyRepository->getActivatedCurrencyCodes())) {
         throw InvalidArgumentException::arrayInvalidKey($attribute->getCode(), 'currency', 'The currency does not exist', 'filter', 'price', $data['currency']);
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:25,代码来源:PriceFilter.php

示例9: checkValue

 /**
  * Check if value is valid
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  */
 protected function checkValue(AttributeInterface $attribute, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'filter', 'metric', gettype($data));
     }
     if (!array_key_exists('data', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'data', 'filter', 'metric', print_r($data, true));
     }
     if (!array_key_exists('unit', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'unit', 'filter', 'metric', print_r($data, true));
     }
     if (null !== $data['data'] && !is_numeric($data['data'])) {
         throw InvalidArgumentException::arrayNumericKeyExpected($attribute->getCode(), 'data', 'filter', 'metric', gettype($data['data']));
     }
     if (!is_string($data['unit'])) {
         throw InvalidArgumentException::arrayStringKeyExpected($attribute->getCode(), 'unit', 'filter', 'metric', gettype($data['unit']));
     }
     if (!array_key_exists($data['unit'], $this->measureManager->getUnitSymbolsForFamily($attribute->getMetricFamily()))) {
         throw InvalidArgumentException::arrayInvalidKey($attribute->getCode(), 'unit', sprintf('The unit does not exist in the attribute\'s family "%s"', $attribute->getMetricFamily()), 'filter', 'metric', $data['unit']);
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:27,代码来源:MetricFilter.php

示例10: checkData

 /**
  * Check if data are valid
  * "data": doesn't need value
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  *
  * @return mixed
  */
 protected function checkData(AttributeInterface $attribute, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'remover', 'prices collection', gettype($data));
     }
     foreach ($data as $price) {
         if (!is_array($price)) {
             throw InvalidArgumentException::arrayOfArraysExpected($attribute->getCode(), 'remover', 'prices collection', gettype($data));
         }
         if (!array_key_exists('data', $price)) {
             throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'data', 'remover', 'prices collection', print_r($data, true));
         }
         if (!array_key_exists('currency', $price)) {
             throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'currency', 'remover', 'prices collection', print_r($data, true));
         }
         if (!in_array($price['currency'], $this->currencyManager->getActiveCodes())) {
             throw InvalidArgumentException::arrayInvalidKey($attribute->getCode(), 'currency', 'The currency does not exist', 'remover', 'prices collection', $price['currency']);
         }
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:29,代码来源:PriceCollectionAttributeRemover.php


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