The Yaf_Bootstrap_Abstract class

The Yaf_Bootstrap_Abstract class

(No version information available, might only be in Git)

簡介

Bootstrap是用來在Application執行(run)之前做一些初始化工作的機制.

你可以通過繼承Yaf_Bootstrap_Abstract 來定義自己的Bootstrap類.

在Bootstrap類中所有以"_init"開頭的公有的方法, 都會被按照定義順序依次在Yaf_Application::bootstrap() 被呼叫的時刻呼叫.

範例

示例 #1 Bootstrap example

<?php
   
/* bootstrap class should be defined under ./application/Bootstrap.php */
   
class Bootstrap extends Yaf_Bootstrap_Abstract {
        public function 
_initConfig(Yaf_Dispatcher $dispatcher) {
            
var_dump(__METHOD__);
        }
        public function 
_initPlugin(Yaf_Dispatcher $dispatcher) {
            
var_dump(__METHOD__);
        }
   }

   
$config = array(
       
"application" => array(
           
"directory" => dirname(__FILE__) . "/application/",
       ),
   );
 
   
$app = new Yaf_Application($config);
   
$app->bootstrap();
?>

以上例程的輸出類似於:

string(22) "Bootstrap::_initConfig"
string(22) "Bootstrap::_initPlugin"

類摘要

abstract class Yaf_Bootstrap_Abstract {
/* 屬性 */
/* 方法 */
}

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *