Skip to content

Commit

Permalink
Fix deprecation warning text in ViewVarsTrait.
Browse files Browse the repository at this point in the history
Don't suggest method names that will fail.

Refs #7468
  • Loading branch information
markstory committed Sep 29, 2015
1 parent c9642e6 commit 4ec895b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/View/ViewVarsTrait.php
Expand Up @@ -86,15 +86,22 @@ public function createView($viewClass = null)
$viewOptions[$option] = $this->{$option};
}
}
$deprecatedOptions = ['layout', 'view', 'theme', 'autoLayout', 'viewPath', 'layoutPath'];
foreach ($deprecatedOptions as $option) {
if (property_exists($this, $option)) {
$method = $option === 'viewPath' ? 'templatePath' : $option;
$builder->{$method}($this->{$option});

$deprecatedOptions = [
'layout' => 'layout',
'view' => 'template',
'theme' => 'theme',
'autoLayout' => 'autoLayout',
'viewPath' => 'templatePath',
'layoutPath' => 'layoutPath',
];
foreach ($deprecatedOptions as $old => $new) {
if (property_exists($this, $old)) {
$builder->{$new}($this->{$old});
trigger_error(sprintf(
'Property $%s is deprecated. Use $this->viewBuilder()->%s() instead in beforeRender().',
$option,
$method
$old,
$new
), E_USER_DEPRECATED);
}
}
Expand Down

0 comments on commit 4ec895b

Please sign in to comment.