मैं एक ही समस्या थी - मैं अंदर नियंत्रक से और आदेश से
मैं एक ही समस्या कहा कार्रवाई कॉल करने की आवश्यकता है क्योंकि यह वास्तव में एक ही - आप कार्रवाई है जो आप कंसोल से कहते हैं, और नियंत्रक से भी यह कॉल करने की आवश्यकता है ।
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";
}
}
तो नियंत्रक में कार्रवाई के रूप में usuall भरी हुई है में कहा::
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();
}
}
आप इसे कमांड क्यों नहीं चाहते हैं और नियंत्रक नहीं? – Puigcerber
यह एक नमूना कोड है। मैंने अभी उल्लेख किया है कि मुझे वेब एक्शन में कमांड एक्शन चलाने की ज़रूरत है। – JahangirAhmad
लेकिन कमांड का उद्देश्य ऑफ़लाइन कार्यों को चलाने के लिए है, इसलिए जू इसे क्रॉन नौकरी के साथ उपयोग कर सकते हैं। – Puigcerber