コード例 #1
0
ファイル: StringFilter.php プロジェクト: sylius/grid
 /**
  * @param ExpressionBuilderInterface $expressionBuilder
  * @param string $type
  * @param string $field
  * @param mixed $value
  *
  * @return ExpressionBuilderInterface
  */
 private function getExpression(ExpressionBuilderInterface $expressionBuilder, $type, $field, $value)
 {
     switch ($type) {
         case self::TYPE_EQUAL:
             return $expressionBuilder->equals($field, $value);
         case self::TYPE_EMPTY:
             return $expressionBuilder->isNull($field);
         case self::TYPE_NOT_EMPTY:
             return $expressionBuilder->isNotNull($field);
         case self::TYPE_CONTAINS:
             return $expressionBuilder->like($field, '%' . $value . '%');
         case self::TYPE_NOT_CONTAINS:
             return $expressionBuilder->notLike($field, '%' . $value . '%');
         case self::TYPE_STARTS_WITH:
             return $expressionBuilder->like($field, $value . '%');
         case self::TYPE_ENDS_WITH:
             return $expressionBuilder->like($field, '%' . $value);
         case self::TYPE_IN:
             return $expressionBuilder->in($field, array_map('trim', explode(',', $value)));
         case self::TYPE_NOT_IN:
             return $expressionBuilder->notIn($field, array_map('trim', explode(',', $value)));
         default:
             throw new \InvalidArgumentException(sprintf('Could not get an expression for type "%s"!', $type));
     }
 }
コード例 #2
0
ファイル: StringFilter.php プロジェクト: ahmadrabie/Sylius
 /**
  * @param string $type
  * @param string $field
  * @param mixed  $value
  */
 private function getExpression(ExpressionBuilderInterface $expressionBuilder, $type, $field, $value)
 {
     switch ($type) {
         case self::TYPE_EQUAL:
             return $expressionBuilder->equals($field, $value);
             break;
         case self::TYPE_EMPTY:
             return $expressionBuilder->isNull($field);
             break;
         case self::TYPE_NOT_EMPTY:
             return $expressionBuilder->isNotNull($field);
             break;
         case self::TYPE_CONTAINS:
             return $expressionBuilder->like($field, '%' . $value . '%');
             break;
         case self::TYPE_NOT_CONTAINS:
             return $expressionBuilder->notLike($field, '%' . $value . '%');
             break;
         case self::TYPE_STARTS_WITH:
             return $expressionBuilder->like($field, $value . '%');
             break;
         case self::TYPE_ENDS_WITH:
             return $expressionBuilder->like($field, '%' . $value);
             break;
         case self::TYPE_IN:
             return $expressionBuilder->in($field, array_map('trim', explode(',', $value)));
             break;
         case self::TYPE_NOT_IN:
             return $expressionBuilder->notIn($field, array_map('trim', explode(',', $value)));
             break;
     }
 }