Welcome Guest, Not a member yet? Register   Sign In
Private methods are preventing me extending the CI_Email class
#1

[eluser]triplethree[/eluser]
Hi guys

I'm trying to extend the CI email library but I'm struggling as a number of the methods that I want to replace or call are private. Is there a way around this, or should I change the methods in the CI class to be protected / public?

Thanks in advanced.
#2

[eluser]toopay[/eluser]
There are several ways, but inefficient (like duplicate or play with constructor, in the original class). So if you really have to change those private function, changes several methods visibility obviously your best option.
#3

[eluser]Aken[/eluser]
There's nothing wrong with editing the system files if you want/need. Just need to remember that you made those changes if/when you upgrade.

I personally would copy the entire Email class into your own MY_Email.php, and then change the methods and add whatever you need. That way if you upgrade the system folder, your changes won't be overwritten. Then you just need to check the change logs to see if there have been any changes to the Email class so you can match/update.

This issue has been brought up on the Reactor core thing on BitBucket, so it will be addressed eventually. Who knows when, though.
#4

[eluser]WanWizard[/eluser]
In general, this approach sucks, and breaks lots of third-party libraries that depend on accessing core libraries to integrate themselfs with CI.

For those libraries you can't follow the usual approach of creating MY_Loader, MY_Model and the other MY's, as you'll end up with several third party libraries all needing to extend these core libraries. It's a merge nightmare waiting to happen, and it seriously tempered my enthusiasm for CI.
#5

[eluser]wiredesignz[/eluser]
None of CodeIgniter library methods should be private. If anything they should be protected methods so they can be extended freely but are unavailable outside of the class.

Another example of a problem introduced by the Reactor development team. They've seen @access marked private in the original class and given it no further thought.

@triplethree, Raise a bug report on the Reactor repository, they might get around to fixing it.
#6

[eluser]triplethree[/eluser]
Thanks for the replies guys! Personally I would have thought these methods should be protected or public as mentioned above. I'll log a bug and see what happens Smile I like the idea of duplicating the whole library to ease core upgrades later on.




Theme © iAndrew 2016 - Forum software by © MyBB