CakePHP 在 Shell 及其任务之间共享代码
我想知道是否可以在 Shell 及其任务之间共享代码(函数和变量)。例如,假设我有以下内容:
Class MyShell extends Shell{
var $tasks = array('MyTask');
var $someVariable;
function someFunction(){}
}
然后在我的任务中:
class MyTask extends Shell {
//somehow access the someFunction() and $someVariable in here
}
这可能吗?还有,不管是不是,这不是推荐的蛋糕做法吗?谢谢你!
I'm wondering if it's possible to share code (functions and variables) between a Shell and its Tasks. For example, say I have the following:
Class MyShell extends Shell{
var $tasks = array('MyTask');
var $someVariable;
function someFunction(){}
}
and then in my tasks:
class MyTask extends Shell {
//somehow access the someFunction() and $someVariable in here
}
Is this possible? Also, whether it is or isnt, is this not the recommended cake way? Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么为什么不使用任务来扩展 shell 类,就像这样呢?
Then why not extend the shell class with the task, like this?