本文整理汇总了PHP中Controller_Base::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller_Base::init方法的具体用法?PHP Controller_Base::init怎么用?PHP Controller_Base::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller_Base
的用法示例。
在下文中一共展示了Controller_Base::init方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* init: check if user is logged in
*
* if not: redirect to login
*/
public function init()
{
// call parent before first
parent::init();
// only check if the controller is not auth
if (Request::initial()->controller() != 'Auth') {
// url to loginpage
$url = URL::to('Auth@login');
// init identity
$identity = Identity::instance();
//revert identity to original user (maybe assume was called somewhere else)
$identity->revert();
// check authentication
if (!$identity->authenticated()) {
// if user is not allready authenticated, redirect to login page
$this->redirect($url);
} else {
$website = Website::instance();
// else: initialise acl
Acl::init($identity, new Model_Rights($website->websites()));
// set current environment
Acl::environment($website->id());
// if user is not entitled to access backend
if (!Acl::instance()->allowed('Backend', 'access')) {
$this->redirect($url);
}
// if user is not entitled to access controller
if (!Acl::instance()->allowed(Request::initial()->controller(), 'access')) {
$this->redirect($url);
}
}
}
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:38,代码来源:Auth.php
示例2: init
public function init()
{
parent::init();
$this->_layout = new LayoutPlugin('layout.html');
$this->dispatcher = Yaf_Registry::get("dispatcher");
$this->dispatcher->registerPlugin($this->_layout);
}
示例3: init
public function init()
{
parent::init();
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:4,代码来源:Manager.php
示例4: init
public function init()
{
parent::init();
//使用layout页面布局
$this->_layout = new LayoutPlugin('layout.html', APP_PATH . '/views/layout/');
}