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


PHP InvalidArgumentException::expectedFromPreviousException方法代码示例

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


在下文中一共展示了InvalidArgumentException::expectedFromPreviousException方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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', 'string');
     }
     $this->checkLocaleAndScope($attribute, $locale, $scope, 'string');
     if (Operators::IS_EMPTY !== $operator && Operators::IS_NOT_EMPTY !== $operator) {
         $this->checkValue($options['field'], $value);
     }
     $joinAlias = $this->getUniqueAlias('filter' . $attribute->getCode());
     $backendField = sprintf('%s.%s', $joinAlias, $attribute->getBackendType());
     if (Operators::IS_EMPTY === $operator) {
         $this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope));
         $this->qb->andWhere($this->prepareCriteriaCondition($backendField, $operator, $value));
     } else {
         $condition = $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope);
         if (Operators::IS_NOT_EMPTY === $operator) {
             $condition .= sprintf('AND (%s AND %s)', $this->qb->expr()->isNotNull($backendField), $this->qb->expr()->neq($backendField, $this->qb->expr()->literal('')));
             $this->qb->innerJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
         } elseif (Operators::DOES_NOT_CONTAIN === $operator) {
             $whereCondition = $this->prepareCondition($backendField, $operator, $value) . ' OR ' . $this->prepareCondition($backendField, Operators::IS_NULL, null);
             $this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
             $this->qb->andWhere($whereCondition);
         } else {
             $condition .= ' AND ' . $this->prepareCondition($backendField, $operator, $value);
             $this->qb->innerJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
         }
     }
     return $this;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:35,代码来源:StringFilter.php

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

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

示例5:

 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

示例6: 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', 'string');
     }
     $this->checkLocaleAndScope($attribute, $locale, $scope, 'string');
     if (Operators::IS_EMPTY !== $operator && Operators::IS_NOT_EMPTY !== $operator) {
         $this->checkValue($options['field'], $value);
     }
     $field = ProductQueryUtility::getNormalizedValueFieldFromAttribute($attribute, $locale, $scope);
     $field = sprintf('%s.%s', ProductQueryUtility::NORMALIZED_FIELD, $field);
     $this->applyFilter($field, $operator, $value);
     return $this;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:19,代码来源:StringFilter.php

示例7: 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');
     if (Operators::IS_EMPTY !== $operator) {
         $this->checkValue($options['field'], $value);
         if (FieldFilterHelper::getProperty($options['field']) === FieldFilterHelper::CODE_PROPERTY) {
             $value = $this->objectIdResolver->getIdsFromCodes('option', $value, $attribute);
         }
     }
     $mongoField = sprintf('%s.%s.id', ProductQueryUtility::NORMALIZED_FIELD, ProductQueryUtility::getNormalizedValueFieldFromAttribute($attribute, $locale, $scope));
     $this->applyFilter($operator, $value, $mongoField, $options);
     return $this;
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:21,代码来源:OptionFilter.php

示例8: addAttributeFilter

 /**
  * {@inheritdoc}
  */
 public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = [])
 {
     try {
         $options = $this->optionsResolver->resolve($options);
     } catch (\Exception $e) {
         throw InvalidArgumentException::expectedFromPreviousException($e, $attribute->getCode(), 'filter', 'reference data simple select');
     }
     $this->checkLocaleAndScope($attribute, $locale, $scope, 'reference_data');
     if (Operators::IS_EMPTY !== $operator) {
         $field = $options['field'];
         $this->checkValue($field, $value);
         if (FieldFilterHelper::CODE_PROPERTY === FieldFilterHelper::getProperty($field)) {
             $value = $this->valueCodesToIds($attribute, $value);
         }
         $this->addNonEmptyFilter($attribute, $operator, $value, $locale, $scope);
     } else {
         $this->addEmptyFilter($attribute, $locale, $scope);
     }
     return $this;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:23,代码来源:ReferenceDataFilter.php

示例9:

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


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