Cakephp3 - 找不到引发错误的 $theme 属性
Cakephp3 - Cant find $theme property that throws an error
我已经从 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
事实证明,在 AppController 中,自定义主题(在我的例子中是橙色)需要声明为:
public function beforeRender(Event $event)
{
$this->viewBuilder()->theme('Orange');
}
不喜欢
public $theme = 'Orange';
非常感谢@arilia 帮助我。
我已经从 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
事实证明,在 AppController 中,自定义主题(在我的例子中是橙色)需要声明为:
public function beforeRender(Event $event)
{
$this->viewBuilder()->theme('Orange');
}
不喜欢
public $theme = 'Orange';
非常感谢@arilia 帮助我。