我尝试插入分页调用组件(http://bakery.cakephp.org/articles/Zaphod/2012/03/27/paginationrecall_for_cakephp_2_x http://bakery.cakephp.org/articles/Zaphod/2012/03/27/paginationrecall_for_cakephp_2_x), in
应用程序 -> 控制器 -> 组件 -> PaginationRecallComponent.php
用户控制器:
公共$组件=数组('PaginationRecall');
为什么我收到以下错误:
Strict (2048): Declaration of PaginationRecallComponent::initialize() should be compatible with Component::initialize(Controller $controller) [APP/Controller/Component/PaginationRecallComponent.php, line 46]
Code Context
App::load() - CORE/Cake/Core/App.php, line 567
App::load() - CORE/Cake/Core/App.php, line 567
spl_autoload_call - [internal], line ??
class_exists - [internal], line ??
ComponentCollection::load() - CORE/Cake/Controller/ComponentCollection.php, line 110
ComponentCollection::init() - CORE/Cake/Controller/ComponentCollection.php, line 53
Controller::constructClasses() - CORE/Cake/Controller/Controller.php, line 652
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 183
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 162
[main] - APP/webroot/index.php, line 97
CakePHP 2.4.2
您收到此错误是因为initialize
方法中的PaginationRecallComponent
类与其父类中的类不同。
如果你查看代码,你会发现Cake/Controller/Component.php
签名是:
public function initialize(Controller $controller)
而在PaginationRecallComponent
it is:
function initialize(&$controller)
在第一种情况下$controller
参数必须是一个实例Controller
,而在第二种情况下则没有这样的约束。要消除错误,您只需将此约束添加到initialize
的方法PaginationRecallComponent
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)