本文整理匯總了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;
}
示例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);
}