Permalink
Browse files

fix renderLayout and update deprecated and outdated code

  • Loading branch information...
dereuromark committed Sep 12, 2013
1 parent a980fd9 commit a796b26f13ed71632378019afcc00feaa778fb64
Showing with 42 additions and 59 deletions.
  1. +1 −1 lib/Cake/Console/Templates/default/actions/controller_actions.ctp
  2. +1 −1 lib/Cake/Controller/Component/SecurityComponent.php
  3. +4 −4 lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php
  4. +5 −5 lib/Cake/Test/Case/View/ViewTest.php
  5. +1 −1 lib/Cake/Test/bake_compare/Controller/ActionsUsingSessions.ctp
  6. +1 −1 lib/Cake/Test/bake_compare/Controller/ActionsWithNoSessions.ctp
  7. +0 −2 lib/Cake/Test/test_app/Controller/TestsAppsController.php
  8. +0 −2 lib/Cake/Test/test_app/Controller/TestsAppsPostsController.php
  9. +0 −7 lib/Cake/Test/test_app/Model/Comment.php
  10. +0 −2 lib/Cake/Test/test_app/Model/PersisterOne.php
  11. +0 −2 lib/Cake/Test/test_app/Model/PersisterTwo.php
  12. +0 −2 lib/Cake/Test/test_app/Model/Post.php
  13. +1 −1 lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/Component/OtherComponent.php
  14. +3 −3 lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/Component/TestPluginComponent.php
  15. +2 −2 lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/Component/TestPluginOtherComponent.php
  16. +0 −2 lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/TestsController.php
  17. +1 −1 lib/Cake/Test/test_app/Plugin/TestPlugin/View/Elements/translate.ctp
  18. +1 −1 lib/Cake/Test/test_app/Plugin/TestPlugin/View/Layouts/Emails/text/plug_default.ctp
  19. +1 −1 lib/Cake/Test/test_app/View/Layouts/Emails/html/default.ctp
  20. +1 −1 lib/Cake/Test/test_app/View/Layouts/Emails/html/japanese.ctp
  21. +1 −1 lib/Cake/Test/test_app/View/Layouts/Emails/html/thin.ctp
  22. +1 −1 lib/Cake/Test/test_app/View/Layouts/Emails/text/default.ctp
  23. +1 −1 lib/Cake/Test/test_app/View/Layouts/Emails/text/japanese.ctp
  24. +1 −1 lib/Cake/Test/test_app/View/Layouts/ajax.ctp
  25. +1 −1 lib/Cake/Test/test_app/View/Layouts/ajax2.ctp
  26. +1 −1 lib/Cake/Test/test_app/View/Layouts/cache_empty_sections.ctp
  27. +1 −1 lib/Cake/Test/test_app/View/Layouts/cache_layout.ctp
  28. +1 −1 lib/Cake/Test/test_app/View/Layouts/default.ctp
  29. +1 −1 lib/Cake/Test/test_app/View/Layouts/js/default.ctp
  30. +1 −1 lib/Cake/Test/test_app/View/Layouts/json/default.ctp
  31. +1 −1 lib/Cake/Test/test_app/View/Layouts/multi_cache.ctp
  32. +4 −4 lib/Cake/Test/test_app/View/Layouts/rss/default.ctp
  33. +1 −1 lib/Cake/Test/test_app/View/Layouts/xml/default.ctp
  34. +1 −1 lib/Cake/Test/test_app/View/Themed/TestTheme/Layouts/default.ctp
  35. +2 −0 lib/Cake/View/View.php
@@ -93,7 +93,7 @@
if (!$this-><?php echo $currentModelName; ?>->exists($id)) {
throw new NotFoundException(__('Invalid <?php echo strtolower($singularHumanName); ?>'));
}
- if ($this->request->is('post') || $this->request->is('put')) {
+ if ($this->request->is(array('post', 'put'))) {
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'));
@@ -226,7 +226,7 @@ public function startup(Controller $controller) {
$this->_secureRequired($controller);
$this->_authRequired($controller);
- $isPost = ($this->request->is('post') || $this->request->is('put'));
+ $isPost = $this->request->is(array('post', 'put'));
$isNotRequestAction = (
!isset($controller->request->params['requested']) ||
$controller->request->params['requested'] != 1
@@ -1188,7 +1188,7 @@ public function testCsrfNonceConsumption() {
$this->Controller->request = $this->getMock('CakeRequest', array('is'));
$this->Controller->request->expects($this->once())->method('is')
- ->with('post')
+ ->with(array('post', 'put'))
->will($this->returnValue(true));
$this->Controller->request->params['action'] = 'index';
@@ -1240,7 +1240,7 @@ public function testCsrfBlackHoleOnKeyMismatch() {
$this->Controller->request = $this->getMock('CakeRequest', array('is'));
$this->Controller->request->expects($this->once())->method('is')
- ->with('post')
+ ->with(array('post', 'put'))
->will($this->returnValue(true));
$this->Controller->request->params['action'] = 'index';
@@ -1270,7 +1270,7 @@ public function testCsrfBlackHoleOnExpiredKey() {
$this->Controller->request = $this->getMock('CakeRequest', array('is'));
$this->Controller->request->expects($this->once())->method('is')
- ->with('post')
+ ->with(array('post', 'put'))
->will($this->returnValue(true));
$this->Controller->request->params['action'] = 'index';
@@ -1326,7 +1326,7 @@ public function testCsrfNotUseOnceValidationLeavingToken() {
$this->Controller->request = $this->getMock('CakeRequest', array('is'));
$this->Controller->request->expects($this->once())->method('is')
- ->with('post')
+ ->with(array('post', 'put'))
->will($this->returnValue(true));
$this->Controller->request->params['action'] = 'index';
@@ -184,11 +184,11 @@ public function scripts() {
}
/**
- * TestAfterHelper class
+ * TestBeforeAfterHelper class
*
* @package Cake.Test.Case.View
*/
-class TestAfterHelper extends Helper {
+class TestBeforeAfterHelper extends Helper {
/**
* property property
@@ -949,10 +949,10 @@ public function testHelperCallbackTriggering() {
* @return void
*/
public function testBeforeLayout() {
- $this->PostsController->helpers = array('Session', 'TestAfter', 'Html');
+ $this->PostsController->helpers = array('Session', 'TestBeforeAfter', 'Html');
$View = new View($this->PostsController);
$View->render('index');
- $this->assertEquals('Valuation', $View->Helpers->TestAfter->property);
+ $this->assertEquals('Valuation', $View->Helpers->TestBeforeAfter->property);
}
/**
@@ -961,7 +961,7 @@ public function testBeforeLayout() {
* @return void
*/
public function testAfterLayout() {
- $this->PostsController->helpers = array('Session', 'TestAfter', 'Html');
+ $this->PostsController->helpers = array('Session', 'TestBeforeAfter', 'Html');
$this->PostsController->set('variable', 'values');
$View = new View($this->PostsController);
@@ -54,7 +54,7 @@
if (!$this->BakeArticle->exists($id)) {
throw new NotFoundException(__('Invalid bake article'));
}
- if ($this->request->is('post') || $this->request->is('put')) {
+ if ($this->request->is(array('post', 'put'))) {
if ($this->BakeArticle->save($this->request->data)) {
$this->Session->setFlash(__('The bake article has been saved.'));
return $this->redirect(array('action' => 'index'));
@@ -51,7 +51,7 @@
if (!$this->BakeArticle->exists($id)) {
throw new NotFoundException(__('Invalid bake article'));
}
- if ($this->request->is('post') || $this->request->is('put')) {
+ if ($this->request->is(array('post', 'put'))) {
if ($this->BakeArticle->save($this->request->data)) {
return $this->flash(__('The bake article has been saved.'), array('action' => 'index'));
}
@@ -25,8 +25,6 @@
*/
class TestsAppsController extends AppController {
- public $name = 'TestsApps';
-
public $uses = array();
public $components = array('RequestHandler');
@@ -25,8 +25,6 @@
*/
class TestsAppsPostsController extends AppController {
- public $name = 'TestsAppsPosts';
-
public $uses = array('Post');
public $viewPath = 'TestsApps';
@@ -34,11 +34,4 @@ class Comment extends AppModel {
*/
public $useTable = 'comments';
-/**
- * Model name
- *
- * @var string
- */
- public $name = 'Comment';
-
}
@@ -29,8 +29,6 @@ class PersisterOne extends AppModel {
public $useTable = 'posts';
- public $name = 'PersisterOne';
-
public $actsAs = array('PersisterOneBehavior', 'TestPlugin.TestPluginPersisterOne');
public $hasMany = array('Comment', 'TestPlugin.TestPluginComment');
@@ -29,8 +29,6 @@ class PersisterTwo extends AppModel {
public $useTable = 'posts';
- public $name = 'PersisterTwo';
-
public $actsAs = array('PersisterOneBehavior', 'TestPlugin.TestPluginPersisterOne');
public $hasMany = array('Comment', 'TestPlugin.TestPluginComment');
@@ -29,6 +29,4 @@ class Post extends AppModel {
public $useTable = 'posts';
- public $name = 'Post';
-
}
@@ -23,5 +23,5 @@
*
* @package Cake.Test.TestApp.Plugin.TestPlugin.Controller.Component
*/
-class OtherComponent extends Object {
+class OtherComponent extends Component {
}
@@ -19,12 +19,12 @@
*/
/**
- * Class TestPluginComponentComponent
+ * Class TestPluginComponent
*
* @package Cake.Test.TestApp.Plugin.TestPlugin.Controller.Component
*/
-class TestPluginComponentComponent extends Object {
+class TestPluginComponent extends Component {
- public $components = array('TestPlugin.TestPluginOtherComponent');
+ public $components = array('TestPlugin.TestPluginOther');
}
@@ -19,9 +19,9 @@
*/
/**
- * Class TestPluginOtherComponentComponent
+ * Class TestPluginOtherComponent
*
* @package Cake.Test.TestApp.Plugin.TestPlugin.Controller.Component
*/
-class TestPluginOtherComponentComponent extends Object {
+class TestPluginOtherComponent extends Component {
}
@@ -25,8 +25,6 @@
*/
class TestsController extends TestPluginAppController {
- public $name = 'Tests';
-
public $uses = array();
public $helpers = array('TestPlugin.OtherHelper', 'Html');
@@ -1 +1 @@
-<?php __('This is a translatable string'); ?>
+<?php echo __('This is a translatable string'); ?>
@@ -1,4 +1,4 @@
-<?php echo $content_for_layout; ?>
+<?php echo $this->fetch('content'); ?>
This email was sent using the TestPlugin.
@@ -6,7 +6,7 @@
</head>
<body>
- <?php echo $content_for_layout; ?>
+ <?php echo $this->fetch('content'); ?>
<p>This email was sent using the <a href="http://cakephp.org">CakePHP Framework</a></p>
</body>
@@ -6,7 +6,7 @@
</head>
<body>
- <?php echo $content_for_layout; ?>
+ <?php echo $this->fetch('content'); ?>
<p>このメールは <a href="http://cakephp.org">CakePHP Framework</a> を利用して送信しました。</p>
</body>
@@ -6,7 +6,7 @@
</head>
<body>
- <?php echo $content_for_layout; ?>
+ <?php echo $this->fetch('content'); ?>
<p>This email was sent using the CakePHP Framework</p>
</body>
@@ -1,4 +1,4 @@
-<?php echo $content_for_layout; ?>
+<?php echo $this->fetch('content'); ?>
This email was sent using the CakePHP Framework, http://cakephp.org.
@@ -1,4 +1,4 @@
-<?php echo $content_for_layout; ?>
+<?php echo $this->fetch('content'); ?>
CakePHP Framework を使って送信したメールです。 http://cakephp.org.
@@ -1 +1 @@
-<?php echo $content_for_layout; ?>
+<?php echo $this->fetch('content'); ?>
@@ -1,2 +1,2 @@
Ajax!
-<?php echo $content_for_layout; ?>
+<?php echo $this->fetch('content'); ?>
@@ -7,7 +7,7 @@
<body>
<!--nocache--><?php $x++; ?><!--/nocache-->
<!--nocache--><?php $x++; ?><!--/nocache-->
- <?php echo $content_for_layout; ?>
+ <?php echo $this->fetch('content'); ?>
<!--nocache--><?php echo 'cached count is: ' . $x; ?><!--/nocache-->
</body>
</html>
@@ -3,7 +3,7 @@
<?php echo microtime(); ?>
<!--/nocache-->
-<?php echo $content_for_layout; ?>
+<?php echo $this->fetch('content'); ?>
<?php echo $superman; ?>
@@ -27,7 +27,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
</div>
<div id="content">
- <?php echo $content_for_layout; ?>
+ <?php echo $this->fetch('content'); ?>
</div>
<div id="footer">
@@ -1,2 +1,2 @@
<?php echo $scripts_for_layout; ?>
-<script type="text/javascript"><?php echo $content_for_layout; ?></script>
+<script type="text/javascript"><?php echo $this->fetch('content'); ?></script>
@@ -1 +1 @@
-<?php echo $content_for_layout; ?>
+<?php echo $this->fetch('content'); ?>
@@ -8,7 +8,7 @@
<p>C. Layout After Test Element But Before Content</p>
<?php $this->log('3. layout after test element but before content') ?>
<!--/nocache-->
-<?php echo $content_for_layout; ?>
+<?php echo $this->fetch('content'); ?>
<!--nocache-->
<p>E. Layout After Content</p>
<?php $this->log('5. layout after content') ?>
@@ -1,5 +1,5 @@
<?php
-echo $rss->header();
+echo $this->Rss->header();
if (!isset($channel)) {
$channel = array();
@@ -8,9 +8,9 @@ if (!isset($channel['title'])) {
$channel['title'] = $title_for_layout;
}
-echo $rss->document(
- $rss->channel(
- array(), $channel, $content_for_layout
+echo $this->Rss->document(
+ $this->Rss->channel(
+ array(), $channel, $this->fetch('content')
)
);
@@ -1,2 +1,2 @@
<?php echo '<?xml version="1.0" encoding="' . Configure::read('App.encoding') . '"?>'; ?>
-<?php echo $content_for_layout; ?>
+<?php echo $this->fetch('content'); ?>
@@ -1,2 +1,2 @@
default test_theme layout
-<?php echo $content_for_layout ?>
+<?php echo $this->fetch('content') ?>
View
@@ -504,6 +504,8 @@ public function renderLayout($content, $layout = null) {
if (empty($content)) {
$content = $this->Blocks->get('content');
+ } else {
+ $this->Blocks->set('content', $content);
}
$this->getEventManager()->dispatch(new CakeEvent('View.beforeLayout', $this, array($layoutFileName)));

0 comments on commit a796b26

Please sign in to comment.