本文整理汇总了PHP中bootstrap::pre_render方法的典型用法代码示例。如果您正苦于以下问题:PHP bootstrap::pre_render方法的具体用法?PHP bootstrap::pre_render怎么用?PHP bootstrap::pre_render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bootstrap
的用法示例。
在下文中一共展示了bootstrap::pre_render方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public static function process($options = [])
{
// start buffering
helper_ob::start(true);
$controller_class = self::$settings['mvc']['controller_class'];
// if we are handling error message and controller class has not been loaded
if ($controller_class == 'controller_error' && error_base::$flag_error_already && !class_exists('controller_error')) {
require './controller/error.php';
}
$controller = new $controller_class();
// processing options
if (!empty($options)) {
foreach ($options as $k => $v) {
$controller->{$k} = $v;
}
}
// put action into controller
$controller->action = ['code' => self::$settings['mvc']['controller_action_code'], 'full' => self::$settings['mvc']['controller_action']];
// check ACL
if ($controller_class != 'controller_error') {
helper_acl::merge_data_with_db($controller, self::$settings['mvc']['controller_class']);
if (helper_acl::can_be_executed($controller, true) == false) {
throw new Exception('Permission denied!', -1);
}
} else {
// important to unset controller data
application::set('controller', null);
}
// auto populating input property in controller
if (!empty(self::$settings['application']['controller']['input'])) {
$controller->input = request::input(null, true, true);
}
// init method
if (method_exists($controller, 'init')) {
call_user_func(array($controller, 'init'));
}
// check if action exists
if (!method_exists($controller, $controller->action['full'])) {
throw new Exception('Action does not exists!');
}
// calling action
echo call_user_func(array($controller, $controller->action['full']));
// auto rendering view only if view exists, processing extension order as specified in .ini file
$temp_reflection_obj = new ReflectionClass($controller);
$controller_dir = pathinfo($temp_reflection_obj->getFileName(), PATHINFO_DIRNAME) . '/';
$controller_file = end(self::$settings['mvc']['controllers']);
$view = self::$settings['mvc']['controller_view'];
$flag_view_found = false;
if (!empty($view)) {
$extensions = explode(',', isset(self::$settings['application']['view']['extension']) ? self::$settings['application']['view']['extension'] : 'html');
foreach ($extensions as $extension) {
$file = $controller_dir . $controller_file . '.' . $view . '.' . $extension;
if (file_exists($file)) {
$controller = new view($controller, $file, $extension);
$flag_view_found = true;
break;
}
}
// if views are mandatory
if (!empty(self::$settings['application']['view']['mandatory']) && !$flag_view_found) {
throw new Exception('View ' . $view . ' does not exists!');
}
}
// autoloading media files
layout::include_media($controller_dir, $controller_file, $view, $controller_class);
// appending view after controllers output
$controller->view = ($controller->view ?? '') . helper_ob::clean();
// if we have to render debug toolbar
if (debug::$toolbar) {
helper_ob::start();
}
// call pre rendering method in bootstrap
bootstrap::pre_render();
// rendering layout
$__skip_layout = application::get('flag.global.__skip_layout');
if (!empty(self::$settings['mvc']['controller_layout']) && empty($__skip_layout)) {
helper_ob::start();
if (file_exists(self::$settings['mvc']['controller_layout_file'])) {
$controller = new layout($controller, self::$settings['mvc']['controller_layout_file'], self::$settings['mvc']['controller_layout_extension']);
}
// session expiry dialog before replaces
session::expiry_dialog();
// buffer output and handling javascript files, chicken and egg problem
$from = ['<!-- [numbers: messages] -->', '<!-- [numbers: title] -->', '<!-- [numbers: document title] -->', '<!-- [numbers: actions] -->', '<!-- [numbers: breadcrumbs] -->', '<!-- [numbers: javascript links] -->', '<!-- [numbers: javascript data] -->', '<!-- [numbers: css links] -->', '<!-- [numbers: layout onload] -->', '<!-- [numbers: layout onhtml] -->'];
$to = [layout::render_messages(), layout::render_title(), layout::render_document_title(), layout::render_actions(), layout::render_breadcrumbs(), layout::render_js(), layout::render_js_data(), layout::render_css(), layout::render_onload(), layout::$onhtml];
echo str_replace($from, $to, helper_ob::clean());
} else {
echo $controller->view;
}
// ajax calls that has not been processed by application
if (application::get('flag.global.__ajax')) {
layout::render_as(['success' => false, 'error' => [i18n(null, 'Could not process ajax call!')]], 'application/json');
}
}