コード例 #1
0
ファイル: provider.php プロジェクト: icybee/module-nodes
 /**
  * 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');
 }
コード例 #2
0
ファイル: provider.php プロジェクト: icybee/module-users
 /**
  * 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');
 }