当前位置: 首页>>代码示例>>PHP>>正文


PHP Controller_Base::init方法代码示例

本文整理汇总了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);
 }
开发者ID:zhangxinvip,项目名称:YafUse,代码行数:7,代码来源:Main.php

示例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/');
 }
开发者ID:zhangxinvip,项目名称:YafUse,代码行数:6,代码来源:Index.php


注:本文中的Controller_Base::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。