Skip to content

Instantly share code, notes, and snippets.

@atsu666
Created April 15, 2019 03:30
Show Gist options
  • Save atsu666/7c6ed4076f16cf361b9e198a5d57800e to your computer and use it in GitHub Desktop.
Save atsu666/7c6ed4076f16cf361b9e198a5d57800e to your computer and use it in GitHub Desktop.
php/ACMS/GET/Category/EntrySummary.php
function preBuildUnit()
{
$entryIds = array();
$blogIds = array();
$userIds = array();
$categoryIds = array();
foreach ($this->entries as $entry) {
if (!empty($entry['entry_id'])) $entryIds[] = $entry['entry_id'];
if (!empty($entry['entry_blog_id'])) $blogIds[] = $entry['entry_blog_id'];
if (!empty($entry['entry_user_id'])) $userIds[] = $entry['entry_user_id'];
if (!empty($entry['entry_category_id'])) $categoryIds[] = $entry['entry_category_id'];
}
// メイン画像のEagerLoading
if (!isset($this->_config['mainImageOn']) || $this->_config['mainImageOn'] === 'on') {
$this->eagerLoadingData['mainImage'] = Tpl::eagerLoadMainImage($this->entries);
}
// フルテキストのEagerLoading
if (!isset($this->_config['fullTextOn']) || $this->_config['fullTextOn'] === 'on') {
$this->eagerLoadingData['fullText'] = Tpl::eagerLoadFullText($entryIds);
}
// タグのEagerLoading
$this->eagerLoadingData['tag'] = Tpl::eagerLoadTag($entryIds);
// エントリーフィールドのEagerLoading
if (!isset($this->_config['entryFieldOn']) || $this->_config['entryFieldOn'] === 'on') {
$this->eagerLoadingData['entryField'] = eagerLoadField($entryIds, 'eid');
}
// ユーザーフィールドのEagerLoading
if (isset($this->_config['userInfoOn']) && $this->_config['userInfoOn'] === 'on') {
$this->eagerLoadingData['userField'] = eagerLoadField($userIds, 'uid');
}
// ブログフィールドのEagerLoading
if (isset($this->_config['blogInfoOn']) && $this->_config['blogInfoOn'] === 'on') {
$this->eagerLoadingData['blogField'] = eagerLoadField($blogIds, 'bid');
}
// カテゴリーフィールドのEagerLoading
if (isset($this->_config['categoryInfoOn']) && $this->_config['categoryInfoOn'] === 'on') {
$this->eagerLoadingData['categoryField'] = eagerLoadField($categoryIds, 'cid');
}
// サブカテゴリーのEagerLoading
if (isset($this->_config['categoryInfoOn']) && $this->_config['categoryInfoOn'] === 'on') {
$this->eagerLoadingData['subCategory'] = eagerLoadSubCategories($entryIds);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment