Welcome Guest, Not a member yet? Register   Sign In
Abstract Classes
#1

[eluser]Unknown[/eluser]
In an attempt to port my Authentication class from my personal web system, I am hung up on the fact that I used an abstract class in my system. The class will need access to Session, Cookie, and Request (post) variables, as well as Database access.

Furthermore, I extend the Authentication class to essentially use different tables for drastically different types of members, with a possibly different username field names in the db.

This keeps the members of the 'administration' section separate from the members of the main website itself.
My administrators (myself) use an email/pass login, and my website users user a username/pass login, both tables will contain a username and an email field.

I was told to make these into Libraries, but I also heard that Libraries will soon be deprecated. What should I do?
#2

[eluser]danmontgomery[/eluser]
Libraries are not going to be deprecated... Plugins are removed in 2.0, however.
#3

[eluser]Unknown[/eluser]
Well I must have been misinformed.

So how should I go about this?

Can my abstract class be a new Library, should my extensions all be libraries as well?

How do I go about loading helpers and libraries that are required? Is that through the get_instance() function?

My apologies for being new, and much gratitude for your help.
#4

[eluser]danmontgomery[/eluser]
There's no good way to setup a base library class in the way that there is for core classes (MY_Controller, MY_Model, etc)... But you can either create an __autoload/spl_autoload_register(which many people do), or just include the base class at the top of each class file.

To load things automatically, they can go in config/autoload.php. You generally only want to autoload resources which are going to be used on every page load, which may or may not be applicable here. The other option is to extend the controller class (MY_Controller), and load the resources there. Then, only the controllers which extend MY_Controller (as opposed to Controller) will load those resources (also note the MY_ portion here is configurable in config.php). This is generally how people create login systems. Read about extending core classes in the user guide.




Theme © iAndrew 2016 - Forum software by © MyBB