本文整理汇总了PHP中AbstractController::setModel方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractController::setModel方法的具体用法?PHP AbstractController::setModel怎么用?PHP AbstractController::setModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractController
的用法示例。
在下文中一共展示了AbstractController::setModel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setModel
/** Specify user model */
function setModel($model, $login_field = 'email', $password_field = 'password')
{
parent::setModel($model);
$this->login_field = $login_field;
$this->password_field = $password_field;
// Load model from session
if ($this->info && $this->recall("id")) {
if ($this->recall('class', false) == get_class($this->model)) {
$this->debug("Loading model from cache");
$this->model->set($this->info);
$this->model->dirty = array();
$this->model->id = $this->recall('id', null);
} else {
// Class changed, re-fetch data from database
$this->debug("Class changed, loading from database");
$this->model->tryLoad($this->recall('id'));
if (!$this->model->loaded()) {
$this->logout(false);
}
$this->memorizeModel();
}
}
$t = $this;
// If model is saved, update our cache too, but don't store password
$this->model->addHook('afterSave', function ($m) use($t) {
// after this model is saved, re-cache the info
$tmp = $m->get();
unset($tmp[$t->password_field]);
$t->memorize('info', $tmp);
});
$this->addEncryptionHook($this->model);
if (strtolower($this->api->page) == 'logout') {
$this->logout();
$this->api->redirect('/');
}
return $this->model;
}
示例2: setModel
/**
* Allows use of models. Define a model with fields:
* - rule
* - target
* - params (comma separated)
*
* and content of that model will be used to auto-fill routing
*/
function setModel($model)
{
$model = parent::setModel($model);
foreach ($model as $rule) {
$this->addRule($rule["rule"], $rule["target"], explode(",", $rule["params"]));
}
return $this;
}
示例3: setModel
function setModel($m)
{
parent::setModel($m);
$this->api->addHook('localizeString', $this);
$this->api->translation = $this;
}
示例4: setModel
function setModel($model, $login_field = 'email', $password_field = 'password')
{
parent::setModel($model);
$this->login_field = $login_field;
$this->password_field = $password_field;
return $this->model;
}
示例5: setModel
/**
* Allows use of models. Define a model with fields:
* - rule
* - target
* - params (comma separated).
*
* and content of that model will be used to auto-fill routing
*/
public function setModel($model)
{
/** @type Model $model */
$model = parent::setModel($model);
foreach ($model as $rule) {
$this->addRule($rule['rule'], $rule['target'], explode(',', $rule['params']));
}
// @todo Consider to return $model instead of $this like we do in setModel method of all other classes
return $this;
}
示例6: setModel
public function setModel($model)
{
$m = $this->add($model);
//If model is empty, load data from files
if (!$m->count()->getOne()) {
$m = $this->fillFromFile($m);
}
parent::setModel($m);
}