Jump to content

Override and calling parent of parent


Recommended Posts

Hello,

I want to override controller function, in such a  way, that entire function is overridden and I don't won't call source function (so it is "omitted") . But problem is that source function is calling its parent e.g.:

Controller function:

public function postProcess()
    {

...

parent::postProcess();

...

}

in my overriden function I want to have same code with some modification. So I don't want to call parent but parent of parent, so I want to call something like parent::parent::postProcess(); instead of parent::postProcess();. Is is possible?

Thx for any help.

 

 

 

Link to comment
Share on other sites

Yes it ispossible just call it with original parent class. 

So not parent::parent::postProcess();  but Your ParentClass::postProcess();

For example if your override class is for Admin Carriers controller you have

in override class AdminCarriersController extends AdminCarriersControllerCore

and parent is:  class AdminCarriersControllerCore extends AdminController

 

So in AdminCarriersController override you would call AdminController::postProcess(); 

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...