當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。