Jump to content

Overriding controller - am I doing this right?


Recommended Posts

PS 1.6

 

I'm overriding ContactControllerCore in /controllers/front/ContactController.php.

 

To do this, I created a file in /override/controllers/front/ContactController.php with the below code. 

 

There are additional functions in the ContactControllerCore class that I did NOT copy over to the override. Is that ok? I'm running into some strange behavior that leads me to guess that the rest of the functions in the ContactControllerCore class are not being loaded if I only include one function of the class as below.



<?php


class ContactController extends ContactControllerCore
{


    public function postProcess()
    {
        // my replaced function here
    }


}


 

Link to comment
Share on other sites

the structure is correct.  You do not need to override the other functions, unless you actually need to perform different behavior in those functions.

 

What you might be missing is parent::postProcess().  If you exclude this, than nothing in the core class postProcess function will execute.

    public function postProcess()
    {
        parent::postProcess();

        // my replaced function here
    }
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...