本文整理汇总了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;
}
示例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'));
}
示例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);
}
示例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);
}
示例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;
});
}
示例6: beforeFilter
/**
* Before filter.
*/
public function beforeFilter()
{
parent::beforeFilter();
$this->Model = Admin::introspectModel('Admin.ActionLog');
}
示例7: introspect
/**
* Return a modified model object.
*
* @param string $model
* @return Model
*/
public function introspect($model)
{
return Admin::introspectModel($model);
}
示例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));
}
}
示例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;
}