Jump to content

Call ModuleAdminController public function from other module controller


Recommended Posts

I'm developing a module integration with an existing module.

Existing module has a ModuleAdminController with a public function like:

class AdminExistingModuleController extends ModuleAdminController
{

	public function functionA(){
		.
		.
		.
	}

}

 

Then, I'm developing a module, which has a front controller like this:

include_once _PS_MODULE_DIR_ . 'existingModule/controllers/admin/AdminExistingModuleController.php';
class DevelopingModuleFrontController extends ModuleFrontController
{
    public function postProcess()
    {
        $controller=new AdminExistingModuleController();
        $result=$controller->functionA();
        
        exit($result);
    }

}

 

So, I need to call functionA() from DevelopingModuleFrontController.

The code doesn't work giving a exception :

Quote

ContextErrorException

Notice: Trying to get property 'id' of non-object

in AdminController.php line 451

at AdminControllerCore->__construct()in AdminExistingModuleController.php line 187

 

How I can achive this?

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