cakephp/cakephp — pull request #2986 by sam-at-github (2014-03-10 05:04:10+00:00)
Title: Controller view vars. Refs #2970.

Rewrite of the way Controller passes View vars to view on construction. Refs #2970.

Controller used to store a bunch of variables that were only used by the view. This has been deprecated. Instead Controller::setViewOption(,) is used. Controller will pass these variables over to View on construction. The method Controller::getViewObject() is the factory method that creates the view passing in these stashed variables. If you want to the stashed variables passed over you have to use this factory method - which is now public. Controller does not provide defaults for variables that clearly are nothing to do with the Controller. However, there are still a few view options that Controller does set, when creating a View. These are currently name, plugin, passedArgs, helpers. In review, the following lists the variables that used to be passed from controller to view and how the passing has changed:

* viewVars not passed, now a formal param to View::__contruct()
* autoLayout not passed at all anymore
* ext not passed at all anymore
* helpers controller and view
* view view only - set via setViewOption()
* layout view only - set via setViewOption()
* name controller and view
* theme view only - set via setViewOption()
* layoutPath view only - set via setViewOption()
* viewPath view only - set via setViewOption()
* request not passed, now a formal param to View::__contruct()
* plugin controller and view
* passedArgs controller and view
* cacheAction view only - set via setViewOption()

Note. The old View constructor:

public function __construct(Controller $controller = null) {

The new View constructor:

public function __construct(Array $viewOptions, Array $viewVars, EventManager $eventManager = null, Request $request = null, Response $response = null) {