Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Can't Extend Yii Class Because Of Private Attributes

$
0
0
I've already created a topic http://www.yiiframework.com/forum/index.php/topic/39867-how-to-get-json-decoded-postdelete-data/page__p__190948__fromsearch__1 where described problem with CHttpRequest and private $_restParams property. Shortly we can't extend CHttpRequest::getRestParams because $_restParams is private and getRestParams() won't work as you exptected in your child class.

But we have the same problem in the whole framework. In order to override 1 method that changes some private property you need to copy paste other that return this property.

For instance if you want to override CErrorHandler::handleException that changes $this->_error = .... you need to copy paste getError method in order to get correct _error.
If you want to use your own CController::setPageTitle then you need to copy getPageTitle, $_pageTitle is private.

So there's a question for yii team:
Of course this is clear that you want to reduce visibility and in general this good. But it is very likely that such components as CErrorHandler CWebApplication CController and others could be overriden. So maybe you should not be so critical with protected properties.

Viewing all articles
Browse latest Browse all 18717

Trending Articles