Jump to content

Difference between admin and front controller


jack2684

Recommended Posts

I writing a new controller for myself. I notice that in admin contollers, there is a method like this,

public function __construct()

which seems override the __construct() method in AdminControllerCore. While in the front controllers, there is no such method. 

 

Why the admincontroller needs to override the __construct()? Is it some kind of security issue or something else? Can we just write the code in the init() method instead of __construct()?

Edited by jack2684 (see edit history)
Link to comment
Share on other sites

it depends on what your admin controller needs to do.  For example, if you are displaying a list of data from the database (like customers or orders), then you would use __construct to define where the data would be pulled from.

Can I implement those thing in "public function init()"?

Link to comment
Share on other sites

Can I implement those thing in "public function init()"?

in my opinion you can, and this is correct function for such things.

__construction it's a constructor ;)

The "__construct" was introduced in PHP5 and it is the right way to define your, well, constructors (in PHP4 you used the name of the class for a constructor). You are not required to define a constructor in your class, but if you wish to pass any parameters on object construction then you need one.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...