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


PHP Exception\InvalidArgumentException类代码示例

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


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

示例1: addAttributeFilter

 /**
  * {@inheritdoc}
  */
 public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = [])
 {
     try {
         $options = $this->resolver->resolve($options);
     } catch (\Exception $e) {
         throw InvalidArgumentException::expectedFromPreviousException($e, $attribute->getCode(), 'filter', 'options');
     }
     $this->checkLocaleAndScope($attribute, $locale, $scope, 'options');
     if (Operators::IS_EMPTY !== $operator && Operators::IS_NOT_EMPTY !== $operator) {
         $this->checkValue($options['field'], $value);
     }
     $joinAlias = $this->getUniqueAlias('filter' . $attribute->getCode());
     $joinAliasOpt = $this->getUniqueAlias('filterO' . $attribute->getCode());
     $backendField = sprintf('%s.%s', $joinAliasOpt, 'id');
     if (Operators::IS_EMPTY === $operator || Operators::IS_NOT_EMPTY === $operator) {
         $this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope));
         $this->qb->leftJoin($joinAlias . '.' . $attribute->getBackendType(), $joinAliasOpt)->andWhere($this->prepareCriteriaCondition($backendField, $operator, null));
     } else {
         if (FieldFilterHelper::getProperty($options['field']) === FieldFilterHelper::CODE_PROPERTY) {
             $value = $this->objectIdResolver->getIdsFromCodes('option', $value, $attribute);
         }
         $this->qb->innerJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope))->innerJoin($joinAlias . '.' . $attribute->getBackendType(), $joinAliasOpt, 'WITH', $this->prepareCriteriaCondition($backendField, $operator, $value));
         if (Operators::NOT_IN_LIST === $operator) {
             $this->qb->andWhere($this->qb->expr()->notIn($this->qb->getRootAlias() . '.id', $this->getNotInSubquery($attribute, $locale, $scope, $value)));
         }
     }
     return $this;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:31,代码来源:OptionsFilter.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:

 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

示例4: addAttributeFilter

 /**
  * {@inheritdoc}
  */
 public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = [])
 {
     try {
         $options = $this->resolver->resolve($options);
     } catch (\Exception $e) {
         throw InvalidArgumentException::expectedFromPreviousException($e, $attribute->getCode(), 'filter', 'option');
     }
     $this->checkLocaleAndScope($attribute, $locale, $scope, 'option');
     $field = $options['field'];
     if (Operators::IS_EMPTY !== $operator) {
         $this->checkValue($field, $value);
     }
     $joinAlias = $this->getUniqueAlias('filter' . $attribute->getCode(), true);
     // prepare join value condition
     $optionAlias = $joinAlias . '.option';
     if (Operators::IS_EMPTY === $operator) {
         $this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope));
         $this->qb->andWhere($this->qb->expr()->isNull($optionAlias));
     } else {
         // inner join to value
         $condition = $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope);
         if (FieldFilterHelper::getProperty($field) === FieldFilterHelper::CODE_PROPERTY) {
             $value = $this->objectIdResolver->getIdsFromCodes('option', $value, $attribute);
         }
         $condition .= ' AND ( ' . $this->qb->expr()->in($optionAlias, $value) . ' ) ';
         $this->qb->innerJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
     }
     return $this;
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:32,代码来源:OptionFilter.php

示例5:

 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

示例6:

 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

示例7: checkLocaleAndScope

 /**
  * Check locale and scope are valid
  *
  * @param AttributeInterface $attribute
  * @param string             $locale
  * @param string             $scope
  * @param string             $type
  *
  * @throws InvalidArgumentException
  */
 protected function checkLocaleAndScope(AttributeInterface $attribute, $locale, $scope, $type)
 {
     try {
         $this->attrValidatorHelper->validateLocale($attribute, $locale);
         $this->attrValidatorHelper->validateScope($attribute, $scope);
     } catch (\LogicException $e) {
         throw InvalidArgumentException::expectedFromPreviousException($e, $attribute->getCode(), 'setter', $type);
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:19,代码来源:AbstractAttributeRemover.php

示例8: addFieldFilter

 /**
  * {@inheritdoc}
  */
 public function addFieldFilter($field, $operator, $value, $locale = null, $scope = null, $options = [])
 {
     if (!is_bool($value)) {
         throw InvalidArgumentException::booleanExpected($field, 'filter', 'boolean', gettype($value));
     }
     $field = sprintf('%s.%s', ProductQueryUtility::NORMALIZED_FIELD, $field);
     $this->applyFilter($field, $operator, $value);
     return $this;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:12,代码来源:BooleanFilter.php

示例9: checkValue

 /**
  * Check if value is valid
  *
  * @param string      $field
  * @param mixed       $value
  * @param string|null $locale
  * @param string|null $scope
  */
 protected function checkValue($field, $value, $locale, $scope)
 {
     if (!is_numeric($value)) {
         throw InvalidArgumentException::numericExpected($field, 'filter', 'completeness', gettype($value));
     }
     if (null === $locale || null === $scope) {
         throw InvalidArgumentException::localeAndScopeExpected($field, 'filter', 'completeness');
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:17,代码来源:CompletenessFilter.php

示例10: checkData

 /**
  * Check if data is valid
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  */
 protected function checkData(AttributeInterface $attribute, $data)
 {
     if (null === $data) {
         return;
     }
     if (!is_string($data)) {
         throw InvalidArgumentException::stringExpected($attribute->getCode(), 'setter', 'reference data', gettype($data));
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:15,代码来源:ReferenceDataSetter.php

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

示例12:

 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

示例13: addFieldFilter

 /**
  * {@inheritdoc}
  */
 public function addFieldFilter($field, $operator, $value, $locale = null, $scope = null, $options = [])
 {
     if (!is_bool($value)) {
         throw InvalidArgumentException::booleanExpected($field, 'filter', 'boolean', gettype($value));
     }
     $field = current($this->qb->getRootAliases()) . '.' . FieldFilterHelper::getCode($field);
     $condition = $this->prepareCriteriaCondition($field, $operator, $value);
     $this->qb->andWhere($condition);
     return $this;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:13,代码来源:BooleanFilter.php

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

示例15:

 function it_throws_an_exception_when_scope_is_expected_but_not_existing($attrValidatorHelper, AttributeInterface $attribute)
 {
     $e = new \LogicException('Attribute "attributeCode" expects an existing scope, "ecommerce" given.');
     $attribute->getCode()->willReturn('attributeCode');
     $attribute->isLocalizable()->willReturn(false);
     $attribute->isScopable()->willReturn(true);
     $attrValidatorHelper->validateLocale($attribute, null)->shouldBeCalled();
     $attrValidatorHelper->validateScope($attribute, 'ecommerce')->willThrow($e);
     $this->shouldThrow(InvalidArgumentException::expectedFromPreviousException($e, 'attributeCode', 'copier', 'concrete'))->during('testLocaleAndScope', [$attribute, null, 'ecommerce']);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:10,代码来源:AbstractAttributeCopierSpec.php


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