Skip to content
Permalink
Browse files

Suggest methods that exist in deprecation warnings.

Deprecation warnings should not tell developers to do a thing that will
explode on them.

Refs #7468
  • Loading branch information...
markstory committed Sep 29, 2015
1 parent ef79994 commit 424c173ab87db8f30229e02d17047865d9faf82a
Showing with 17 additions and 3 deletions.
  1. +16 −3 src/Controller/Controller.php
  2. +1 −0 tests/TestCase/Controller/ControllerTest.php
@@ -355,12 +355,25 @@ public function __get($name)
*/
public function __set($name, $value)
{
if (in_array($name, ['layout', 'view', 'theme', 'autoLayout', 'viewPath', 'layoutPath'], true)) {
$deprecated = [
'layout' => 'layout',
'view' => 'template',
'theme' => 'theme',
'autoLayout' => 'autoLayout',
'viewPath' => 'templatePath',
'layoutPath' => 'layoutPath',
];
if (isset($deprecated[$name])) {
$method = $deprecated[$name];
trigger_error(
sprintf('Controller::$%s is deprecated. Use $this->viewBuilder()->%s() instead.', $name, $name),
sprintf(
'Controller::$%s is deprecated. Use $this->viewBuilder()->%s() instead.',
$name,
$method
),
E_USER_DEPRECATED
);
$this->viewBuilder()->{$name}($value);
$this->viewBuilder()->{$method}($value);
return;
}
@@ -987,6 +987,7 @@ public function testIsAction()
/**
* Test declared deprecated properties like $theme are properly passed to view.
*
* @return void
*/
public function testDeclaredDeprecatedProperty()

0 comments on commit 424c173

Please sign in to comment.
You can’t perform that action at this time.