本文整理汇总了PHP中controller::init方法的典型用法代码示例。如果您正苦于以下问题:PHP controller::init方法的具体用法?PHP controller::init怎么用?PHP controller::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类controller
的用法示例。
在下文中一共展示了controller::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bootstrap
public static function bootstrap()
{
if (!empty($_GET['kos_path'])) {
// TODO: This needs escaping
$path = explode('/', $_GET['kos_path']);
unset($_GET['kos_path']);
} else {
$path = array();
}
// Set the controller
if (count($path) > 0) {
self::$controller = array_shift($path);
}
// Set the method
if (count($path) > 0) {
self::$method = array_shift($path);
}
// Set the method parameters
while (count($path) > 0) {
$param_key = array_shift($path);
if (!($param_value = array_shift($path))) {
$param_value = true;
}
self::$method_parameters[$param_key] = $param_value;
}
// Set the include dir
self::$include_dir = './';
// Include the required core classes, but don't instantiate them
self::include_class('kos/config');
self::include_class('kos/model');
self::include_class('kos/controller');
// Controller init
if (method_exists('controller', 'init')) {
controller::init();
}
// Load up the controller class and call the correct method
if (!self::controller(self::$controller)) {
self::fatal_error('Error loading the controller');
}
$controller_class = self::$controller . '_controller';
$method = self::$method;
// Call the controller's init method
if (method_exists($controller_class, 'init')) {
$controller_class::init();
}
// Call the controller method that was requested (or index)
if (method_exists($controller_class, $method)) {
$controller_class::$method();
} else {
self::fatal_error('Error loading class method');
}
}