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


PHP Admin::introspectModel方法代码示例

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


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

示例1: beforeFilter

 /**
  * Introspect ACL models and make them available.
  */
 public function beforeFilter()
 {
     parent::beforeFilter();
     $this->Aco = Admin::introspectModel('Admin.ControlObject');
     $this->Aro = Admin::introspectModel('Admin.RequestObject');
     $this->Permission = Admin::introspectModel('Admin.ObjectPermission');
     $this->Permission->cacheQueries = false;
 }
开发者ID:johnulist,项目名称:admin-1,代码行数:11,代码来源:AclController.php

示例2: isAuthorized

 /**
  * Validate the user is authorized.
  *
  * @param array $user
  * @return bool
  * @throws ForbiddenException
  * @throws UnauthorizedException
  */
 public function isAuthorized($user = null)
 {
     if (!$user) {
         throw new ForbiddenException(__d('admin', 'Invalid User'));
     }
     $aro = Admin::introspectModel('Admin.RequestObject');
     if ($aro->isAdmin($user['id'])) {
         if (!$this->Session->read('Admin.crud')) {
             $this->Session->write('Admin.crud', $aro->getCrudPermissions($user['id']));
         }
         return true;
     }
     throw new UnauthorizedException(__d('admin', 'Insufficient Access Permissions'));
 }
开发者ID:johnulist,项目名称:admin-1,代码行数:22,代码来源:AdminAppController.php

示例3: index

 /**
  * List out all models and plugins.
  */
 public function index()
 {
     $plugins = Admin::getModels();
     $counts = array();
     // Gather record counts
     foreach ($plugins as $plugin) {
         foreach ($plugin['models'] as $model) {
             if ($model['installed']) {
                 $object = Admin::introspectModel($model['class']);
                 if ($object->hasMethod('getCount')) {
                     $count = $object->getCount();
                 } else {
                     $count = $object->find('count', array('cache' => array($model['class'], 'count'), 'cacheExpires' => '+24 hours'));
                 }
                 $counts[$model['class']] = $count;
             }
         }
     }
     $this->set('plugins', $plugins);
     $this->set('counts', $counts);
 }
开发者ID:duyhn,项目名称:learnlaw,代码行数:24,代码来源:AdminController.php

示例4: admin_delete

 /**
  * Admin override for Forum model delete action.
  * Provides support for moving topics and forums to a new forum.
  *
  * @param int $id
  * @throws NotFoundException
  */
 public function admin_delete($id)
 {
     $this->Model = Admin::introspectModel('Forum.Forum');
     $this->Model->id = $id;
     $result = $this->AdminToolbar->getRecordById($this->Model, $id);
     if (!$result) {
         throw new NotFoundException(__d('admin', '%s Not Found', $this->Model->singularName));
     }
     if ($this->request->is('post')) {
         if ($this->Model->delete($id, true)) {
             $this->Forum->Topic->moveAll($id, $this->request->data['Forum']['move_topics']);
             $this->Forum->moveAll($id, $this->request->data['Forum']['move_forums']);
             $this->AdminToolbar->logAction(ActionLog::DELETE, $this->Model, $id);
             $this->AdminToolbar->setFlashMessage(__d('admin', 'Successfully deleted %s with ID %s', array(mb_strtolower($this->Model->singularName), $id)));
             $this->AdminToolbar->redirectAfter($this->Model);
         } else {
             $this->AdminToolbar->setFlashMessage(__d('admin', 'Failed to delete %s with ID %s', array(mb_strtolower($this->Model->singularName), $id)), 'error');
         }
     }
     // Get tree excluding this record
     $forums = $this->Model->generateTreeList(array('Forum.id !=' => $id), null, null, ' -- ');
     $this->set('result', $result);
     $this->set('moveTopics', $forums);
     $this->set('moveForums', $forums);
 }
开发者ID:loganbest,项目名称:forum,代码行数:32,代码来源:StationsController.php

示例5: getPluginModels

 /**
  * Return a list of all models within a plugin.
  *
  * @param string $plugin
  * @return array
  */
 public static function getPluginModels($plugin)
 {
     return self::cache(array(__METHOD__, $plugin), function () use($plugin) {
         $search = 'Model';
         $core = Configure::read('Admin.coreName') ?: 'Core';
         if ($plugin !== $core) {
             $search = $plugin . '.' . $search;
         }
         // Fetch models and filter out AppModel's
         $models = array_filter(App::objects($search), function ($value) {
             return mb_strpos($value, 'AppModel') === false;
         });
         // Filter out models that don't connect to the database or are admin disabled
         $map = array();
         $ignore = Configure::read('Admin.ignoreModels');
         foreach ($models as $model) {
             list($plugin, $model, $id, $class) = Admin::parseName($plugin . '.' . $model);
             if (in_array($id, $ignore)) {
                 continue;
             }
             $object = Admin::introspectModel($id);
             if (!$object) {
                 continue;
             }
             $map[] = array_merge($object->admin, array('id' => $id, 'title' => $object->pluralName, 'alias' => $model, 'class' => $class, 'url' => Inflector::underscore($id), 'installed' => Admin::isModelInstalled($id), 'group' => $object->useDbConfig));
         }
         return $map;
     });
 }
开发者ID:johnulist,项目名称:admin-1,代码行数:35,代码来源:Admin.php

示例6: beforeFilter

 /**
  * Before filter.
  */
 public function beforeFilter()
 {
     parent::beforeFilter();
     $this->Model = Admin::introspectModel('Admin.ActionLog');
 }
开发者ID:johnulist,项目名称:admin-1,代码行数:8,代码来源:LogsController.php

示例7: introspect

 /**
  * Return a modified model object.
  *
  * @param string $model
  * @return Model
  */
 public function introspect($model)
 {
     return Admin::introspectModel($model);
 }
开发者ID:johnulist,项目名称:admin-1,代码行数:10,代码来源:AdminHelper.php

示例8: setHabtmData

 /**
  * Set hasAndBelongsToMany data for forms. This allows for saving of associated data.
  *
  * @param Model $model
  */
 public function setHabtmData(Model $model)
 {
     foreach ($model->hasAndBelongsToMany as $assoc) {
         if (!$assoc['showInForm']) {
             continue;
         }
         $object = Admin::introspectModel($assoc['className']);
         $variable = Inflector::variable(Inflector::pluralize(preg_replace('/(?:_id)$/', '', $assoc['associationForeignKey'])));
         $this->Controller->set($variable, $this->getRecordList($object));
     }
 }
开发者ID:johnulist,项目名称:admin-1,代码行数:16,代码来源:AdminToolbarComponent.php

示例9: beforeFilter

 /**
  * Before filter.
  */
 public function beforeFilter()
 {
     parent::beforeFilter();
     // Introspect model
     if (isset($this->params['model'])) {
         $this->Model = Admin::introspectModel($this->params['model']);
         if (!$this->Model) {
             throw new ForbiddenException(__d('admin', 'Invalid Model'));
         }
     }
     // Parse request and set null fields to null
     if ($data = $this->request->data) {
         foreach ($data as $model => $fields) {
             foreach ($fields as $key => $value) {
                 if (mb_substr($key, -5) === '_null' && $value) {
                     $data[$model][str_replace('_null', '', $key)] = null;
                 }
             }
         }
         $this->request->data = $data;
     }
     // Don't validate post since data changes constantly
     $this->Security->validatePost = false;
 }
开发者ID:duyhn,项目名称:learnlaw,代码行数:27,代码来源:CrudController.php


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