In order to control data structures, functions, flow and views AbanteCart utilize utilizes hooks placed in various parts of the code in core, storefront and admin. Each hook will have a unique name.
To call a hook you must use extensions api object. It is stored in the registry as an extensions and since all classes can use registry properties as their own you can use $this->extensions To have an extensions api hook an object of class “ClassName” method call, you do:
Code Block | ||||
---|---|---|---|---|
| ||||
$this->extensions->hkMethodName($object, $param1, $param2); |
...
- Extension::beforeClassNameMethodName() - use it to update/change parameters passed to the method
- Extension::aroundClassNameMethodNameoverrideClassNameMethodName() - use it to forbid the original method call
- ClassName::methodName()
- Extension::onClassNameMethodName() - use it to change return data
- Extension::afterClassNameMethodName() - use it to run some functions after the method is executed
Some of the hooks may seem very similar, but they help to serve different purposes.
Extension automatically has access to the current controller object (class instance) loaded during the hooking process. Current The current controller instance used in the extension class will be available via $this->baseObject and provides access to all public methods and properties in the extended controller. This also includes access to global structures. Refer to the developer’s manual for global data structures and controller public methods and properties.
Note |
---|
The state of the extended controller instance can be different depending on the hook location and stage of execution. |
...