Ejemplo n.º 1
0
 /**
  * @dataProvider dataProviderForTestConstructorWithValidArguments
  *
  * @param string $type
  * @param string $key
  * @param mixed  $data
  */
 public function testConstructorWithValidArguments($type, $key, $data)
 {
     $this->testedObject = new Criteria($type, $key, $data);
     $this->assertInstanceOf(Criteria::class, $this->testedObject);
     $this->assertSame($type, $this->testedObject->getType());
     $this->assertSame($key, $this->testedObject->getKey());
     $this->assertSame($data, $this->testedObject->getValue());
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function execute($queryBuilder, Criteria $criteria)
 {
     if ($criteria->getType() !== self::$commandName) {
         return false;
     }
     /** @var QueryBuilder $queryBuilder */
     $aliases = $queryBuilder->getRootAliases();
     $columnName = $criteria->getKey();
     $preparedColumnName = reset($aliases) . '.' . $columnName;
     $paramLeft = ':' . $columnName . 'FilterByBetweenLeft';
     $paramRight = ':' . $columnName . 'FilterByBetweenRight';
     $queryBuilder->andWhere($queryBuilder->expr()->between($preparedColumnName, $paramLeft, $paramRight))->setParameters([$paramLeft => $criteria->getValue()[0], $paramRight => $criteria->getValue()[1]]);
     return true;
 }
Ejemplo n.º 3
0
 /**
  * @inheritdoc
  */
 public function execute($queryBuilder, Criteria $criteria)
 {
     if ($criteria->getType() !== self::$commandName) {
         return false;
     }
     /** @var QueryBuilder $queryBuilder */
     $queryBuilder->setMaxResults($criteria->getValue());
     return true;
 }
Ejemplo n.º 4
0
 /**
  * @inheritdoc
  */
 public function execute($queryBuilder, Criteria $criteria)
 {
     if ($criteria->getType() !== self::$commandName) {
         return false;
     }
     /** @var QueryBuilder $queryBuilder */
     $aliases = $queryBuilder->getRootAliases();
     $columnName = $criteria->getKey();
     $preparedColumnName = reset($aliases) . '.' . $columnName;
     $queryBuilder->addOrderBy($preparedColumnName, $criteria->getValue());
     return true;
 }
Ejemplo n.º 5
0
 /**
  * @inheritdoc
  */
 public function execute($queryBuilder, Criteria $criteria)
 {
     if ($criteria->getType() !== self::$commandName) {
         return false;
     }
     /** @var QueryBuilder $queryBuilder */
     $aliases = $queryBuilder->getRootAliases();
     $columnName = $criteria->getKey();
     $preparedColumnName = reset($aliases) . '.' . $columnName;
     $param = ':' . $columnName . 'FilterByMax';
     $queryBuilder->andWhere($queryBuilder->expr()->lte($preparedColumnName, $param))->setParameter($param, $criteria->getValue());
     return true;
 }