vendor\project-biz\database-bundle\src\Database\Criteria\CriteriaComparison.php line 8

Open in your IDE?
  1. <?php
  2. namespace ProjectBiz\DatabaseBundle\Database\Criteria;
  3. use Doctrine\DBAL\Query\QueryBuilder;
  4. use ProjectBiz\PortalBundle\Exceptions\PortalException;
  5. class CriteriaComparison implements CriteriaBuilderInterface\JsonSerializable
  6. {
  7.     const msgNotSerializable 'Die Operanden können nicht serialisiert werden.';
  8.     private $operator;
  9.     private $left;
  10.     private $right;
  11.     public function __construct($operatorCriteriaBuilderInterface $leftCriteriaBuilderInterface $right)
  12.     {
  13.         $this->operator $operator;
  14.         $this->left     $left;
  15.         $this->right    $right;
  16.     }
  17.     public function buildCriteria(QueryBuilder $builder, array $columnMap$processedView$mt_name 'mt')
  18.     {
  19.         return $builder->expr()->comparison(
  20.             $this->left->buildCriteria($builder$columnMap$processedView$mt_name),
  21.             $this->operator,
  22.             $this->right->buildCriteria($builder$columnMap$processedView$mt_name)
  23.         );
  24.     }
  25.     /**
  26.      * (PHP 5 &gt;= 5.4.0)<br/>
  27.      * Specify data which should be serialized to JSON
  28.      * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
  29.      * @return mixed data which can be serialized by <b>json_encode</b>,
  30.      * which is a value of any type other than a resource.
  31.      */
  32.     public function jsonSerialize()
  33.     {
  34.         if (
  35.             ($this->left instanceof \JsonSerializable) && ($this->right instanceof \JsonSerializable)
  36.         ) {
  37.             return [
  38.                 'type'     => "comparison",
  39.                 'operator' => $this->operator,
  40.                 'left'     => $this->left->jsonSerialize(),
  41.                 'right'    => $this->right->jsonSerialize()
  42.             ];
  43.         } else {
  44.             throw new PortalException(self::msgNotSerializable);
  45.         }
  46.     }
  47. }