我已经从Cakephp3 v3升级到v3.3(使用Composer),我收到以下错误:
Deprecated (16384): Property $theme is deprecated.
Use $this->viewBuilder()->theme() instead in beforeRender().
[CORE/src/View/ViewVarsTrait.php, line 103]
但我无法在我的文件中找到使用 $ theme 的文件。我在所有文件中搜索了关键字 $ theme 和 beforeRender ,没有相关结果。
此错误显示在我的所有页面中,因此它必须是每个页面中包含的某个文件。
我已经在google上搜索过这个问题,也没有相关结果。
还有其他人有这个问题吗?
完整错误堆栈:
$viewClass = null
$builder = object(Cake\View\ViewBuilder) {
[protected] _templatePath => 'Users'
[protected] _template => 'login'
[protected] _plugin => null
[protected] _theme => 'Orange'
[protected] _layout => null
[protected] _autoLayout => null
[protected] _layoutPath => null
[protected] _name => null
[protected] _className => null
[protected] _options => []
[protected] _helpers => []
}
$validViewOptions = [
(int) 0 => 'passedArgs'
]
$viewOptions = [
'passedArgs' => []
]
$option = 'passedArgs'
$this = object(App\Controller\UsersController) {
theme => 'Orange'
name => 'Users'
helpers => []
request => object(Cake\Network\Request) {}
response => object(Cake\Network\Response) {}
paginate => []
autoRender => false
components => []
View => null
plugin => null
passedArgs => []
modelClass => 'Users'
viewClass => null
viewVars => []
Flash => object(Cake\Controller\Component\FlashComponent) {}
Auth => object(Cake\Controller\Component\AuthComponent) {}
[protected] _responseClass => 'Cake\Network\Response'
[protected] _components => object(Cake\Controller\ComponentRegistry) {}
[protected] _validViewOptions => [
(int) 0 => 'passedArgs'
]
[protected] _eventManager => object(Cake\Event\EventManager) {}
[protected] _eventClass => '\Cake\Event\Event'
[protected] _tableLocator => object(Cake\ORM\Locator\TableLocator) {}
[protected] _modelFactories => [
'Table' => [
[maximum depth reached]
]
]
[protected] _modelType => 'Table'
[protected] _viewBuilder => object(Cake\View\ViewBuilder) {}
}
$deprecatedOptions = [
'layout' => 'layout',
'view' => 'template',
'theme' => 'theme',
'autoLayout' => 'autoLayout',
'viewPath' => 'templatePath',
'layoutPath' => 'layoutPath'
]
$new = 'theme'
$old = 'theme'
Cake\Controller\Controller::createView() - CORE/src/View/ViewVarsTrait.php, line 103
Cake\Controller\Controller::render() - CORE/src/Controller/Controller.php, line 616
Cake\Http\ActionDispatcher::_invoke() - CORE/src/Http/ActionDispatcher.php, line 131
Cake\Http\ActionDispatcher::dispatch() - CORE/src/Http/ActionDispatcher.php, line 99
Cake\Routing\Dispatcher::dispatch() - CORE/src/Routing/Dispatcher.php, line 65
[main] - ROOT/webroot/index.php, line 21

答案 0 :(得分:0)
事实证明,在AppController中,需要将自定义主题(在我的情况下为Orange)声明为:
public function beforeRender(Event $event)
{
$this->viewBuilder()->theme('Orange');
}
而不喜欢
public $theme = 'Orange';
非常感谢@arilia帮我解决这个问题。