本文整理汇总了PHP中Template_Controller::before方法的典型用法代码示例。如果您正苦于以下问题:PHP Template_Controller::before方法的具体用法?PHP Template_Controller::before怎么用?PHP Template_Controller::before使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template_Controller
的用法示例。
在下文中一共展示了Template_Controller::before方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
/**
* Overload to reroute to view-action if a gallery is defined
*/
public function before()
{
parent::before();
if ($galleri = $this->request->param('galleri')) {
$this->request->action = 'view';
}
}
示例2: before
public function before()
{
parent::before();
$param = $this->request->param('forum');
$forum = Model_Forum::factory($param)->load();
try {
if (!$forum->loaded()) {
throw new Kohana_Exception('Forumet :forum existerar inte.', array(':forum' => $param));
}
$roles = $forum->roles->as_array(NULL, 'name');
if (!$this->auth->has_roles($roles)) {
throw new Kohana_Exception('Du måste vara inloggad för att ha tillgång till forum/:forum.', array(':forum' => $forum->name));
}
} catch (Kohana_Exception $e) {
$this->message_add($e->getMessage(), 'error');
$this->request->redirect('forum');
}
// Save forum for later use
$this->_forum = $forum;
// REST-thingy
switch (Request::$method) {
case 'POST':
$this->request->action = 'create';
break;
case 'DELETE':
$this->request->action = 'delete';
break;
}
}
示例3: before
public function before()
{
// For nagivation active link show
$path = $this->request->param('path');
$this->request->controller = substr($path, strpos($path, '/'));
parent::before();
}
示例4: before
public function before()
{
parent::before();
// Automatically set request status
$status = $this->request->param('status', 500);
if (isset(Request::$messages[$status])) {
$this->request->status = $status;
}
// View variables
$this->template->title = __(Request::$messages[$this->request->status]);
}