当前位置: 首页>>代码示例>>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;未经允许,请勿转载。