本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Exception\InvalidArgumentException::arrayOfArraysExpected方法的典型用法代码示例。如果您正苦于以下问题:PHP InvalidArgumentException::arrayOfArraysExpected方法的具体用法?PHP InvalidArgumentException::arrayOfArraysExpected怎么用?PHP InvalidArgumentException::arrayOfArraysExpected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Exception\InvalidArgumentException
的用法示例。
在下文中一共展示了InvalidArgumentException::arrayOfArraysExpected方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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(), 'setter', 'prices collection', gettype($data));
}
foreach ($data as $price) {
if (!is_array($price)) {
throw InvalidArgumentException::arrayOfArraysExpected($attribute->getCode(), 'setter', 'prices collection', gettype($data));
}
if (!array_key_exists('data', $price)) {
throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'data', 'setter', 'prices collection', print_r($data, true));
}
if (!array_key_exists('currency', $price)) {
throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'currency', 'setter', 'prices collection', print_r($data, true));
}
}
}
示例2: 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(), 'setter', 'prices collection', gettype($data));
}
foreach ($data as $price) {
if (!is_array($price)) {
throw InvalidArgumentException::arrayOfArraysExpected($attribute->getCode(), 'setter', 'prices collection', gettype($data));
}
if (!array_key_exists('data', $price)) {
throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'data', 'setter', 'prices collection', print_r($data, true));
}
if (!array_key_exists('currency', $price)) {
throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'currency', 'setter', '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', 'setter', 'prices collection', $price['currency']);
}
}
}
示例3: gettype
function it_throws_an_error_if_attribute_data_does_not_contain_an_array(AttributeInterface $attribute, ProductInterface $product)
{
$attribute->getCode()->willReturn('attributeCode');
$data = ['not an array'];
$this->shouldThrow(InvalidArgumentException::arrayOfArraysExpected('attributeCode', 'setter', 'prices collection', gettype($data)))->during('setAttributeData', [$product, $attribute, $data, ['locale' => 'fr_FR', 'scope' => 'mobile']]);
}
示例4: gettype
function it_throws_an_error_if_data_does_not_contain_an_array(AttributeInterface $attribute)
{
$attribute->getCode()->willReturn('attributeCode');
$data = ['not an array'];
$this->shouldThrow(InvalidArgumentException::arrayOfArraysExpected('attributeCode', 'setter', 'prices collection', gettype($data)))->during('setValue', [[], $attribute, $data, 'fr_FR', 'mobile']);
}