gpt4 book ai didi

cakephp - 在 cakephp 2.0.2 中使用 shell 类的插件组件

转载 作者:行者123 更新时间:2023-12-04 18:19:56 28 4
gpt4 key购买 nike

我想使用我的 shell 类中的插件组件。我正在尝试使用:

App::import('Component', 'Myplugin.Mycomponent');
$this->Mycomponent =& new MycomponentComponent();

不幸的是,上述方法似乎失败了。

我收到一条错误消息,指出找不到 Component 类。

有什么建议我应该如何解决这个问题?

谢谢

最佳答案

你应该总是先看看测试用例!这样你会发现它们是通过这种方式手动包含的:

App::uses('ComponentCollection', 'Controller');
App::uses('AppleComponent', 'Myplugin.Controller/Component');


$Collection = new ComponentCollection();
$Apple = new AppleComponent($Collection);

边注:
如果您需要在 Controller 以外的地方使用组件而不是您做错了什么!
您应该将功能提取到模型或库中,并从组件和外壳中调用它

关于cakephp - 在 cakephp 2.0.2 中使用 shell 类的插件组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10880694/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com