public function andSearchCriteria($restrictedStates = array(), $options = array())
    {
        if (true === is_array($restrictedStates) && 0 < count($restrictedStates) && false === in_array('all', $restrictedStates)) {
            $this->andStateIsIn($restrictedStates);
        }

        if (false === is_array($options)) {
            $options = array();
        }

        if (true === array_key_exists('beforePubdateField', $options)) {
            $date = new \DateTime();
            $suffix = $this->getSuffix();
            $this->andWhere($this->getAlias().'._modified < :date'.$suffix)
                    ->setParameter('date'.$suffix, $date->setTimestamp($options['beforePubdateField']));
        }

        if (true === array_key_exists('afterPubdateField', $options)) {
            $date = new \DateTime();
            $suffix = $this->getSuffix();
            $this->andWhere($this->getAlias().'._modified > :date'.$suffix)
                    ->setParameter('date'.$suffix, $date->setTimestamp($options['afterPubdateField']));
        }

        if (true === array_key_exists('searchField', $options)) {
            $this->andWhere($this->expr()->like($this->getAlias().'._title', $this->expr()->literal('%'.$options['searchField'].'%')));
        }

        return $this;
    }
public function andSearchCriteria($restrictedStates = array(), $options = array())
    {
        if (true === is_array($restrictedStates) && 0 < count($restrictedStates) && false === in_array('all', $restrictedStates)) {
            $this->andStateIsIn($restrictedStates);
        }

        if (false === is_array($options)) {
            $options = array();
        }

        if (true === array_key_exists('beforePubdateField', $options)) {
            $date = new \DateTime();
            $suffix = $this->getSuffix();
            $this->andWhere($this->getAlias().'._modified < :date'.$suffix)
                    ->setParameter('date'.$suffix, $date->setTimestamp($options['beforePubdateField']));
        }

        if (true === array_key_exists('afterPubdateField', $options)) {
            $date = new \DateTime();
            $suffix = $this->getSuffix();
            $this->andWhere($this->getAlias().'._modified > :date'.$suffix)
                    ->setParameter('date'.$suffix, $date->setTimestamp($options['afterPubdateField']));
        }

        if (true === array_key_exists('searchField', $options)) {
            $this->andWhere($this->expr()->like($this->getAlias().'._title', $this->expr()->literal('%'.$options['searchField'].'%')));
        }

        return $this;
    }
public function andSearchCriteria ( $ restrictedStates = array ( ) , $ options = array ( ) ) { if ( true === is_array ( $ restrictedStates ) && 0 < count ( $ restrictedStates ) && false === in_array ( 'all' , $ restrictedStates ) ) { $ this -> andStateIsIn ( $ restrictedStates ) ; } if ( false === is_array ( $ options ) ) { $ options = array ( ) ; } if ( true === array_key_exists ( 'beforePubdateField' , $ options ) ) { $ date = new \ DateTime ( ) ; $ suffix = $ this -> getSuffix ( ) ; $ this -> andWhere ( $ this -> getAlias ( ) . '._modified < :date' . $ suffix ) -> setParameter ( 'date' . $ suffix , $ date -> setTimestamp ( $ options [ 'beforePubdateField' ] ) ) ; } if ( true === array_key_exists ( 'afterPubdateField' , $ options ) ) { $ date = new \ DateTime ( ) ; $ suffix = $ this -> getSuffix ( ) ; $ this -> andWhere ( $ this -> getAlias ( ) . '._modified > :date' . $ suffix ) -> setParameter ( 'date' . $ suffix , $ date -> setTimestamp ( $ options [ 'afterPubdateField' ] ) ) ; } if ( true === array_key_exists ( 'searchField' , $ options ) ) { $ this -> andWhere ( $ this -> expr ( ) -> like ( $ this -> getAlias ( ) . '._title' , $ this -> expr ( ) -> literal ( '%' . $ options [ 'searchField' ] . '%' ) ) ) ; } return $ this ; }
Add query part to select page matching provided criteria.

@param  integer|integer[]    $restrictedStates   Optional, limit to pages having provided states, empty by default.
@param  string[]             $options            Optional, the search criteria:
* 'beforePubdateField'  => timestamp against page._modified,
* 'afterPubdateField'   => timestamp against page._modified,
* 'searchField'         => string to search for title

@return PageQueryBuilder
Add query part to select page matching provided criteria .