/** * 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'); }
/** * @return ActiveRecord|array[ActiveRecord]|null If the view's type is "view" the method returns an * ActiveRecord, or null if no record matching the conditions could be found, otherwise the * method returns an array of ActiveRecord. * * @see BriskView.ActiveRecordProvider::extract_result() */ protected function extract_result(Query $query) { if ($this->returns == self::RETURNS_ONE) { return $query->one; } return parent::extract_result($query); }