本文整理汇总了PHP中core\View::setView方法的典型用法代码示例。如果您正苦于以下问题:PHP View::setView方法的具体用法?PHP View::setView怎么用?PHP View::setView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core\View
的用法示例。
在下文中一共展示了View::setView方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadController
/**
* Load controller
*
* @param array $cmv array('controller' => '', 'method' => '', 'vars' => array())
*/
private function loadController($cmv)
{
//if we have nothing to do, then quit
if (empty($cmv) or empty($cmv['controller']) or empty($cmv['method'])) {
trigger_error('Not call controller->method', E_USER_ERROR);
exit;
}
if (!is_array($cmv['controller'])) {
$cmv['controller'] = array($cmv['controller']);
}
self::$controller = implode("\\", $cmv['controller']);
self::$method = $cmv['method'];
$this->view->setView(self::$controller . DS . self::$method);
//add controllers folder to begin and uppercase first letter class name
array_unshift($cmv['controller'], 'controllers');
end($cmv['controller']);
$cmv['controller'][key($cmv['controller'])] = ucfirst($cmv['controller'][key($cmv['controller'])]);
$cmv['controller'] = "\\" . implode("\\", $cmv['controller']);
$controller = new $cmv['controller']($this->config, $this->router, $this->view);
if (method_exists($controller, 'beforeMethod')) {
Debug::timer('beforeMethod');
$controller->beforeMethod();
Debug::timer('beforeMethod');
}
if (is_callable(array($controller, $cmv['method']), true)) {
Debug::timer('Controller logic');
call_user_func_array(array($controller, $cmv['method']), $cmv['vars']);
Debug::timer('Controller logic');
}
if (method_exists($controller, 'afterMethod')) {
Debug::timer('afterMethod');
$controller->afterMethod();
Debug::timer('afterMethod');
}
}