當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Pool::get_pools_from_pool_posts方法代碼示例

本文整理匯總了PHP中Pool::get_pools_from_pool_posts方法的典型用法代碼示例。如果您正苦於以下問題:PHP Pool::get_pools_from_pool_posts方法的具體用法?PHP Pool::get_pools_from_pool_posts怎麽用?PHP Pool::get_pools_from_pool_posts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pool的用法示例。


在下文中一共展示了Pool::get_pools_from_pool_posts方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: batch_api_data

 /**
  * MI: Accept "fake_sample_url" option, passed only in
  * post#index. It will set a flag that will be read by PostFileMethods::sample_url()
  */
 public static function batch_api_data(array $posts, $options = array())
 {
     self::$create_fake_sample_url = !empty($options['fake_sample_url']);
     foreach ($posts as $post) {
         $result['posts'][] = $post->api_attributes();
     }
     if (empty($options['exclude_pools'])) {
         $result['pools'] = $result['pool_posts'] = [];
         $pool_posts = Pool::get_pool_posts_from_posts($posts);
         $pools = Pool::get_pools_from_pool_posts($pool_posts);
         foreach ($pools as $p) {
             $result['pools'][] = $p->api_attributes();
         }
         foreach ($pool_posts as $pp) {
             $result['pool_posts'][] = $pp->api_attributes();
         }
     }
     if (empty($options['exclude_tags'])) {
         $result['tags'] = Tag::batch_get_tag_types_for_posts($posts);
     }
     if (!empty($options['user'])) {
         $user = $options['user'];
     } else {
         $user = current_user();
     }
     # Allow loading votes along with the posts.
     #
     # The post data is cachable and vote data isn't, so keep this data separate from the
     # main post data to make it easier to cache API output later.
     if (empty($options['exclude_votes'])) {
         $vote_map = array();
         if ($posts) {
             $post_ids = array();
             foreach ($posts as $p) {
                 $post_ids[] = $p->id;
             }
             if ($post_ids) {
                 $post_ids = implode(',', $post_ids);
                 $sql = sprintf("SELECT v.* FROM post_votes v WHERE v.user_id = %d AND v.post_id IN (%s)", $user->id, $post_ids);
                 $votes = PostVote::findBySql($sql);
                 foreach ($votes as $v) {
                     $vote_map[$v->post_id] = $v->score;
                 }
             }
         }
         $result['votes'] = $vote_map;
     }
     self::$create_fake_sample_url = false;
     return $result;
 }
開發者ID:JCQS04,項目名稱:myimouto,代碼行數:54,代碼來源:ApiMethods.php


注:本文中的Pool::get_pools_from_pool_posts方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。