2012-10-12 13 views
5
<?php 
class ReportsController extends CController 
{ 
    public function __call($name,$argument) 
    { 
     echo "test"; 
    } 

} 
?> 

यह मेरा Yii नियंत्रक वर्ग है और जब index.php?r=reports/test यूआरएल बुला यह के रूप में परीक्षण विधि नहीं है मौजूद है, लेकिन यह त्रुटि The system is unable to find the requested action test त्रुटि देता है __call विधि कॉल करने के है।iicall विधि yii नियंत्रक में मौजूद मौजूदा कार्य को कॉल करने का प्रयास करते समय निष्पादित नहीं किया गया है?

उत्तर

3

अपने नियंत्रक में लागू missingAction विधि,

के रूप में कहा @xdazz, यह जाँच करता है, तो विधि मौजूद है और अगर नहीं यह missingAction प्रणाली को बुलाती है ।

//This method is invoked when the controller cannot find the requested action. 

public function missingAction($actionID) 
{ 
    // Your code here 
} 
+0

मैंने कोशिश की और यह अच्छी तरह से काम करता है !!!!!!!!!!! धन्यवाद –

3

यह ढांचे के कार्यान्वयन के आधार पर है।

उदाहरण के लिए

, अगर ढांचे कोड की तरह लागू:

If (!method_exists($controller, $action)) { 
    throw new Exception("The system is unable to find the requested action $action"); 
} 
संबंधित मुद्दे

 संबंधित मुद्दे