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


PHP AssetFileModel::populateModels方法代碼示例

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


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

示例1: _getThumbnails

 /**
  * Returns an array of all embedded assets thumbnails, indexed by the asset file models ID.
  * This method is used to inject the asset thumbnails into the CP front-end. Since embedded asset files are stored
  * as JSON files, there's no supported way of setting the thumbnail on the front-end for these files. The
  * alternative is to pass a list of these thumbnails to the front-end, and use JS to patch them on-top of the
  * elements system.
  *
  * @return array
  */
 private function _getThumbnails()
 {
     // TODO Redo this using the elements API so it's not depending on the DB schema
     // Escape for using in LIKE clause
     // See: http://www.yiiframework.com/doc/guide/1.1/en/database.query-builder
     $prefix = strtr(self::getFileNamePrefix(), array('%' => '\\%', '_' => '\\_'));
     $results = craft()->db->createCommand()->select('assetfiles.*')->from('assetfiles assetfiles')->where(array('like', 'assetfiles.filename', $prefix . '%.json'))->queryAll();
     $assets = AssetFileModel::populateModels($results, 'id');
     $thumbnails = array();
     foreach ($assets as $id => $asset) {
         $embed = craft()->embeddedAssets->getEmbeddedAsset($asset);
         if ($embed) {
             $thumbnails[$id] = $embed->thumbnailUrl;
         }
     }
     return $thumbnails;
 }
開發者ID:jonleesmith,項目名稱:jonleesmith,代碼行數:26,代碼來源:EmbeddedAssetsPlugin.php

示例2: getFilesBySourceId

 /**
  * Returns all top-level files in a source.
  *
  * @param int         $sourceId
  * @param string|null $indexBy
  *
  * @return array
  */
 public function getFilesBySourceId($sourceId, $indexBy = null)
 {
     $files = craft()->db->createCommand()->select('fi.*')->from('assetfiles fi')->join('assetfolders fo', 'fo.id = fi.folderId')->where('fo.sourceId = :sourceId', array(':sourceId' => $sourceId))->order('fi.filename')->queryAll();
     return AssetFileModel::populateModels($files, $indexBy);
 }
開發者ID:kant312,項目名稱:sop,代碼行數:13,代碼來源:AssetsService.php


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