Example #1
0
 /**
  * Alters the query to search for records from the same constructor, a similar site and a
  * similar language.
  *
  * The method also alters the query if the `nid` or `slug` conditions are defined.
  *
  * Finaly if the return type is RETURN_MANY the query is altered to search for online nodes
  * only.
  *
  * @see BriskView.ActiveRecordProvider::alter_query()
  */
 protected function alter_query(Query $query, array $conditions)
 {
     static $mapping = ['uid', 'constructor', 'username', 'language'];
     foreach ($mapping as $property) {
         if (!isset($conditions[$property])) {
             continue;
         }
         $filter = 'filter_by_' . $property;
         $query->{$filter}($conditions[$property]);
     }
     if ($this->returns == self::RETURNS_MANY) {
         $query->filter_by_is_activated(true);
     }
     return parent::alter_query($query, $conditions)->order('created_at DESC');
 }