Jump to content

Extend create method


Tomascrespo

Recommended Posts

Hi, using Prestashop 1.6 I'm developing a module (A) that depends on other module (B).

I want to call a function, A::myFunction(), when one object of module B is created.

As far as I know, Prestashop ObjectModel use CRUD actions, so... Could I extend the create method of a module B object class?

I mean something like:

class ModuleAClassModel extends ModuleBClassModel 
	public function create() {
		myFunction();
		parent:create();
}

 

What I really want is to be warned when a module B object is created, to make some actions.

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

Just create a constructor function in the B class & throw the error in the constructor function. 

& Override the constructor function in the class A (Which extends the Class B). So if anyone will create the direct object of the B class, System will get the error. 

We hope, It will solve your problem.

 

 

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