コード例 #1
0
 /**
  * Check if value is valid
  *
  * @param string $field
  * @param mixed  $values
  */
 protected function checkValue($field, $values)
 {
     FieldFilterHelper::checkArray($field, $values, 'options');
     foreach ($values as $value) {
         FieldFilterHelper::checkIdentifier($field, $value, 'options');
     }
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function getFilter($code)
 {
     $attribute = $this->attributeRepository->findOneBy(['code' => FieldFilterHelper::getCode($code)]);
     if (null !== $attribute) {
         return $this->getAttributeFilter($attribute);
     }
     return $this->getFieldFilter($code);
 }
コード例 #3
0
 /**
  * {@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, FieldFilterHelper::getCode($field));
     $this->qb->field($field)->equals($value);
     return $this;
 }
コード例 #4
0
 /**
  * {@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;
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function addFilter($field, $operator, $value, array $context = [])
 {
     $attribute = $this->attributeRepository->findOneBy(['code' => FieldFilterHelper::getCode($field)]);
     if ($attribute !== null) {
         $filter = $this->filterRegistry->getAttributeFilter($attribute);
     } else {
         $filter = $this->filterRegistry->getFieldFilter($field);
     }
     if ($filter === null) {
         throw new \LogicException(sprintf('Filter on field "%s" is not supported', $field));
     }
     if ($filter->supportsOperator($operator) === false) {
         throw new \LogicException(sprintf('Filter on field "%s" doesn\'t provide operator "%s"', $field, $operator));
     }
     $context = $this->getFinalContext($context);
     if ($attribute !== null) {
         $context['field'] = $field;
         $this->addAttributeFilter($filter, $attribute, $operator, $value, $context);
     } else {
         $this->addFieldFilter($filter, $field, $operator, $value, $context);
     }
     return $this;
 }