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.
  */
 protected function alter_query(Query $query, array $conditions)
 {
     $query->own->similar_site->similar_language;
     if (isset($conditions['nid'])) {
         $query->filter_by_nid($conditions['nid']);
     } else {
         if (isset($conditions['slug'])) {
             $query->filter_by_slug($conditions['slug']);
         }
     }
     if ($this->returns == self::RETURNS_MANY) {
         $query->filter_by_is_online(true);
     }
     return parent::alter_query($query, $conditions)->order('created_at DESC');
 }