当前位置: 首页>>代码示例>>PHP>>正文


PHP X2Model::_modelNames方法代码示例

本文整理汇总了PHP中X2Model::_modelNames方法的典型用法代码示例。如果您正苦于以下问题:PHP X2Model::_modelNames方法的具体用法?PHP X2Model::_modelNames怎么用?PHP X2Model::_modelNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在X2Model的用法示例。


在下文中一共展示了X2Model::_modelNames方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getModelNames

 /**
  * Retrieves a list of model names.
  *
  * Obtains model names as an associative array with model names as the keys
  * and human-readable model names as their values. This is used in place of
  * {@link getDisplayedModelNamesList()} (formerly Admin::getModelList) where
  * specifying values for {@link modelName}, because the value of that should
  * ALWAYS be the name of the actual class, and {@link X2Model::getModelName()}
  * is guaranteed to return a class name (or false, if the class does not
  * exist).
  *
  * @param null|CDbCriteria $criteria if not null, will be used to query modules table. 
  *  Specifying a CDbCriteria will bypass caching.
  * @return array module titles indexed by associated model class names
  */
 public static function getModelNames($criteria = null)
 {
     if ($criteria !== null || !isset(self::$_modelNames)) {
         $modelNames = array();
         if ($criteria === null) {
             $modules = self::getModules();
         } else {
             $criteria->addColumnCondition(array('visible' => 1, 'editable' => true), 'AND', 'OR');
             $modules = X2Model::model('Modules')->findAll($criteria);
         }
         foreach ($modules as $module) {
             if ($modelName = X2Model::getModelName($module->name)) {
                 $modelNames[$modelName] = Yii::t('app', $module->title);
             } else {
                 // Shouldn't happen since getModelName uses class_exists
                 $modelNames[ucfirst($module->name)] = Yii::t('app', $module->title);
             }
         }
         asort($modelNames);
         if ($criteria !== null) {
             return $modelNames;
         } else {
             self::$_modelNames = $modelNames;
         }
     }
     return self::$_modelNames;
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:42,代码来源:X2Model.php


注:本文中的X2Model::_modelNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。