Reputation: 853
I want to make a modular Controller by separating Actions in different class.
The problem is some of the actions are calling a private function of the controler.
Controller :
class ApiController extends Controller
{
public function actions()
{
return array(
'index'=>'application.controllers.api.IndexAction',
);
}
..........
private function _sendResponse($status = 200, $body = '', $content_type = 'text/html')
{
// some code
}
}
In IndexAction.php I tried like this, but doesn't work :
class IndexAction extends CAction
{
public function run()
{
$this->getController()->_sendResponse(204); //this error
}
}
the exception is
ApiController and its behaviors do not have a method or closure named "_sendResponse".
Is this possible what i'm trying to do?
am I missing something here?
Upvotes: 1
Views: 673
Reputation: 36
I looks like you try to access a private Method out of the Scope of your Class. Not even Classes that inherit can access a private Method.
Try public function _sendResponse()
Upvotes: 2