同じ問題がありました-コントローラー内とコマンドからアクションを呼び出す必要があります
実際には同じなので、同じ問題を言いました-コンソールから呼び出す必要があるアクションがあり、コントローラーからも呼び出す必要があります。
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();
}
}