40
40
* and then inserted into the selected layout. This also means you can pass data from the view to the
41
41
* layout using `$this->set()`
42
42
*
43
- * Since 2.1, the base View class also includes support for themes by default. Theme views are regular
44
- * view files that can provide unique HTML and static assets. If theme views are not found for the
45
- * current view the default app view files will be used. You can set `$this->theme = 'Mytheme'`
46
- * in your Controller to use the Themes.
47
- *
48
- * Example of theme path with `$this->theme = 'SuperHot';` Would be `Plugin/SuperHot/Template/Posts`
43
+ * View class supports using plugins as themes. You can set
44
+ * `$this->theme = 'SuperHot'` in your Controller to use plugin `SuperHot` as a
45
+ * theme. Eg. If current action is Posts::index() then View class will look for
46
+ * template file `plugins/SuperHot/Template/Posts/index.ctp`. If a theme template
47
+ * is not found for the current action the default app template file is used.
49
48
*
50
49
* @property \Cake\View\Helper\CacheHelper $Cache
51
50
* @property \Cake\View\Helper\FormHelper $Form
@@ -69,21 +68,20 @@ class View {
69
68
/**
70
69
* Helpers collection
71
70
*
72
- * @var Cake\View\HelperRegistry
71
+ * @var \ Cake\View\HelperRegistry
73
72
*/
74
73
protected $ _helpers ;
75
74
76
75
/**
77
76
* ViewBlock instance.
78
77
*
79
- * @var ViewBlock
78
+ * @var \Cake\View\ ViewBlock
80
79
*/
81
80
public $ Blocks ;
82
81
83
82
/**
84
83
* The name of the plugin.
85
84
*
86
- * @link http://manual.cakephp.org/chapter/plugins
87
85
* @var string
88
86
*/
89
87
public $ plugin = null ;
@@ -251,13 +249,6 @@ class View {
251
249
'layoutPath ' , 'viewPath ' , 'plugin ' , 'passedArgs ' , 'cacheAction '
252
250
);
253
251
254
- /**
255
- * Scripts (and/or other <head /> tags) for the layout.
256
- *
257
- * @var array
258
- */
259
- protected $ _scripts = array ();
260
-
261
252
/**
262
253
* Holds an array of paths.
263
254
*
@@ -465,21 +456,6 @@ public function render($view = null, $layout = null) {
465
456
* Renders a layout. Returns output from _render(). Returns false on error.
466
457
* Several variables are created for use in layout.
467
458
*
468
- * - `title_for_layout` - A backwards compatible place holder, you should set this value if you want more control.
469
- * - `content_for_layout` - contains rendered view file
470
- * - `scripts_for_layout` - Contains content added with addScript() as well as any content in
471
- * the 'meta', 'css', and 'script' blocks. They are appended in that order.
472
- *
473
- * Deprecated features:
474
- *
475
- * - `$scripts_for_layout` is deprecated and will be removed in CakePHP 3.0.
476
- * Use the block features instead. `meta`, `css` and `script` will be populated
477
- * by the matching methods on HtmlHelper.
478
- * - `$title_for_layout` is deprecated and will be removed in CakePHP 3.0.
479
- * Use the `title` block instead.
480
- * - `$content_for_layout` is deprecated and will be removed in CakePHP 3.0.
481
- * Use the `content` block instead.
482
- *
483
459
* @param string $content Content to render in a view, wrapped by the surrounding layout.
484
460
* @param string $layout Layout name
485
461
* @return mixed Rendered output, or false on error
@@ -498,24 +474,11 @@ public function renderLayout($content, $layout = null) {
498
474
}
499
475
$ this ->eventManager ()->dispatch (new Event ('View.beforeLayout ' , $ this , array ($ layoutFileName )));
500
476
501
- $ scripts = implode ("\n\t" , $ this ->_scripts );
502
- $ scripts .= $ this ->Blocks ->get ('meta ' ) . $ this ->Blocks ->get ('css ' ) . $ this ->Blocks ->get ('script ' );
503
-
504
- $ this ->viewVars = array_merge ($ this ->viewVars , array (
505
- 'content_for_layout ' => $ content ,
506
- 'scripts_for_layout ' => $ scripts ,
507
- ));
508
-
509
477
$ title = $ this ->Blocks ->get ('title ' );
510
478
if ($ title === '' ) {
511
- if (isset ($ this ->viewVars ['title_for_layout ' ])) {
512
- $ title = $ this ->viewVars ['title_for_layout ' ];
513
- } else {
514
- $ title = Inflector::humanize ($ this ->viewPath );
515
- }
479
+ $ title = Inflector::humanize ($ this ->viewPath );
480
+ $ this ->Blocks ->set ('title ' , $ title );
516
481
}
517
- $ this ->viewVars ['title_for_layout ' ] = $ title ;
518
- $ this ->Blocks ->set ('title ' , $ title );
519
482
520
483
$ this ->_currentType = static ::TYPE_LAYOUT ;
521
484
$ this ->Blocks ->set ('content ' , $ this ->_render ($ layoutFileName ));
@@ -564,17 +527,6 @@ public function getVars() {
564
527
return array_keys ($ this ->viewVars );
565
528
}
566
529
567
- /**
568
- * Returns the contents of the given View variable(s)
569
- *
570
- * @param string $var The view var you want the contents of.
571
- * @return mixed The content of the named var if its set, otherwise null.
572
- * @deprecated Will be removed in 3.0. Use View::get() instead.
573
- */
574
- public function getVar ($ var ) {
575
- return $ this ->get ($ var );
576
- }
577
-
578
530
/**
579
531
* Returns the contents of the given View variable.
580
532
*
@@ -765,30 +717,6 @@ public function __get($name) {
765
717
return $ this ->{$ name };
766
718
}
767
719
768
- /**
769
- * Magic accessor for deprecated attributes.
770
- *
771
- * @param string $name Name of the attribute to set.
772
- * @param mixed $value Value of the attribute to set.
773
- * @return void
774
- */
775
- public function __set ($ name , $ value ) {
776
- $ this ->{$ name } = $ value ;
777
- }
778
-
779
- /**
780
- * Magic isset check for deprecated attributes.
781
- *
782
- * @param string $name Name of the attribute to check.
783
- * @return bool
784
- */
785
- public function __isset ($ name ) {
786
- if (isset ($ this ->{$ name })) {
787
- return true ;
788
- }
789
- return false ;
790
- }
791
-
792
720
/**
793
721
* Interact with the HelperRegistry to load all the helpers.
794
722
*
0 commit comments