本文整理汇总了PHP中Routes::getController方法的典型用法代码示例。如果您正苦于以下问题:PHP Routes::getController方法的具体用法?PHP Routes::getController怎么用?PHP Routes::getController使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Routes
的用法示例。
在下文中一共展示了Routes::getController方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public static function render($vars, $displayContents = true)
{
// Get Templating Vars
extract($vars, EXTR_SKIP);
// Include Helper Functions
require(BASEPATH.'/app/helpers/template.php');
// Render View File
ob_start();
include(BASEPATH.'/app/views/'.Routes::getController().'/'.Routes::getMethod().'.php');
$contents = ob_get_contents();
ob_end_clean();
// Render Layout File
ob_start();
include(BASEPATH.'/app/views/layouts/'.Routes::getController().'.php');
$view = ob_get_contents();
ob_end_clean();
foreach($templates as $key => $value)
$view = str_ireplace($key, $value, $view);
// Render View
if ($displayContents)
print $view;
return $view;
}
示例2: render
public function render()
{
// Get Template and Page
if (!file_exists(BASEPATH.'/app/views/'.Routes::getController().'/'.Routes::getMethod().'.php'))
trigger_error('View file "'.Routes::getController().'/'.Routes::getMethod().'.php" was not found.');
Template::render($this->vars, true);
}
示例3: initiateController
public function initiateController()
{
if ($_SERVER['SCRIPT_FILENAME'] == './scripts/db.php') {
return false;
}
$route = new Routes($this->uriSegment('whole'));
$controller_class = $route->getController() . '_controller';
$action = $route->getAction();
if (class_exists($controller_class) && !empty($action)) {
$controller = new $controller_class();
$controller->setParams($route->getParams($controller));
$controller->setRequest($route->getRequest());
$controller->{$action}();
} else {
echo 'contorller: ' . $controller_class . ' action: ' . $action . '<br/>';
die("404 - dont know what you're looking for");
}
}