本文整理匯總了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]);
}