1

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?

1 Answer 1

2

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()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.