mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Corrected the use of View class instance.
It looks like the way you where coding it was to be used as a Singleton. In Controller::render() I am setting all View() attributed by pass reference. I do not think it will effect other parts of the system. You can see why I did this by uncommenting the print_r function in View::render(). Reload url in browser. Then in Controller::render() remove the & from: $view->autoRender =& $this->autoRender; This is the only one that seems to cause array to print. This may also caused in the Router::connect(). Look at this if you get time. I noticed that each setting in the conf/routes.php file calls outer::connect(); Tee profiler show this happening 6 times on current install from trunk Router::parse() is called 2 times. We really need to get some good unit test in place. Also speeded things up a little. Profiler test: Before changes on default install from trunk Between: Total Request Time: 13013.4 Milliseconds Total Request Time: 13065.84 Milliseconds 28 files After changes Between: Total Request Time: 10230.99 Milliseconds Total Request Time: 10511.59 Milliseconds 27 files git-svn-id: https://svn.cakephp.org/repo/trunk/cake@304 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
cad49da852
commit
301731fb1a
3 changed files with 31 additions and 23 deletions
|
@ -279,25 +279,25 @@ class Controller extends Object
|
|||
|
||||
function render($action=null, $layout=null, $file=null)
|
||||
{
|
||||
$v = new View();
|
||||
$v->_viewVars = $this->_viewVars;
|
||||
$v->action = $this->action;
|
||||
$v->autoLayout = $this->autoLayout;
|
||||
$v->autoRender = $this->autoRender;
|
||||
$v->base = $this->base;
|
||||
$v->helpers = $this->helpers;
|
||||
$v->here = $this->here;
|
||||
$v->layout = $this->layout;
|
||||
$v->models = $this->models;
|
||||
$v->name = $this->name;
|
||||
$v->pageTitle = $this->pageTitle;
|
||||
$v->parent = $this->parent;
|
||||
$v->viewPath = $this->viewPath;
|
||||
|
||||
$v->params = $this->params;
|
||||
$v->data = $this->data;
|
||||
//$this->view = $v;
|
||||
return $v->render($action, $layout, $file);
|
||||
|
||||
$view =& View::getInstance();
|
||||
$view->_viewVars =& $this->_viewVars;
|
||||
$view->action =& $this->action;
|
||||
$view->autoLayout =& $this->autoLayout;
|
||||
$view->autoRender =& $this->autoRender;
|
||||
$view->base =& $this->base;
|
||||
$view->helpers =& $this->helpers;
|
||||
$view->here =& $this->here;
|
||||
$view->layout =& $this->layout;
|
||||
$view->models =& $this->models;
|
||||
$view->name =& $this->name;
|
||||
$view->pageTitle =& $this->pageTitle;
|
||||
$view->parent =& $this->parent;
|
||||
$view->viewPath =& $this->viewPath;
|
||||
$view->params =& $this->params;
|
||||
$view->data =& $this->data;
|
||||
|
||||
return $view->render($action, $layout, $file);
|
||||
}
|
||||
|
||||
function missingController()
|
||||
|
@ -359,4 +359,4 @@ class Controller extends Object
|
|||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
|
@ -150,7 +150,7 @@ class Dispatcher extends Object
|
|||
$controller->params = $params;
|
||||
$controller->action = $params['action'];
|
||||
$controller->data = empty($params['data'])? null: $params['data'];
|
||||
//$controller->passed_args = empty($params['pass'])? null: $params['pass'];
|
||||
$controller->passed_args = empty($params['pass'])? null: $params['pass'];
|
||||
|
||||
// EXECUTE THE REQUESTED ACTION
|
||||
call_user_func_array(array(&$controller, $params['action']), empty($params['pass'])? null: $params['pass']);
|
||||
|
|
|
@ -155,13 +155,16 @@ class View extends Object
|
|||
var $hasRendered = null;
|
||||
|
||||
var $modelsLoaded = false;
|
||||
|
||||
function View(){
|
||||
}
|
||||
|
||||
function getInstance()
|
||||
{
|
||||
static $instance;
|
||||
if (!isset($instance))
|
||||
{
|
||||
$instance = array(new View());
|
||||
$instance[0] =& new View();
|
||||
}
|
||||
return $instance[0];
|
||||
}
|
||||
|
@ -195,6 +198,8 @@ class View extends Object
|
|||
*/
|
||||
function render($action=null, $layout=null, $file=null)
|
||||
{
|
||||
|
||||
|
||||
if ($this->modelsLoaded!==true)
|
||||
{
|
||||
foreach ($this->models as $modelName => $model)
|
||||
|
@ -202,9 +207,12 @@ class View extends Object
|
|||
$this->$modelName = $model;
|
||||
}
|
||||
}
|
||||
|
||||
// What is reason for these being the same?
|
||||
if (isset($this->hasRendered) && $this->hasRendered)
|
||||
{
|
||||
//echo "<pre>";
|
||||
//print_r($this);
|
||||
//echo "</pre>";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue