我有同样的问题 - 我需要从内部控制器和命令调用操作
我说的是同样的问题,因为它实际上是一样的——你有需要从控制台调用的操作,也可以从控制器调用它。
If you need to call an action(command) as a part of controller action, then i think you need to modify this solution a little. 或者我的解决方案对你来说足够了吗?
所以这是我的解决方案:
首先按照http://www.yiichina.net/doc/guide/1.1/en/basics.controller#action中的说明创建动作
class NotifyUnsharedItemsAction extends CAction
{
    public function run()
    {
        echo "ok";
    }
}
然后像往常一样加载控制器动作:
class TestController extends Controller
{
    public function actions() {
        return array(
            'notifyUnsharedItems'=>'application.controllers.actions.NotifyUnsharedItemsAction',
    );
}
在命令中,我以这种方式运行操作:
class NotifyUnsharedItemsCommand extends CConsoleCommand
{
    public function run($args)
    {
        $action = Yii::createComponent('application.controllers.actions.NotifyUnsharedItemsAction',$this,'notify');
        $action->run();
    }
}