Hook is a method that help to register resource in appRain core. After registering a hook the target resource become a part of it until we deactivate the component.
In first step we register a hook name with a call back function. See below format to register a hook
App::Module('Hook')
->setHookName(Hook Name)
->setAction(Action Name)
->Register(Class Name,Call Back Function);
A hook function must call in init() event of a component.
Name |
Type |
Description |
---|---|---|
Hook Name |
Mandatory |
Name of the Hook Type. |
Action Name |
Mandatory |
Action Name of desired hook |
Class Name |
Mandatory |
Class Name of the Call Back Hook. |
Class Back Function |
Mandatory |
Function Name of the call back. |
In this step we work in registered call back function to add resource. Each Hook has separate method to load resource. See below example to load an model:
class Component_Appstore_Register extends appRain_Base_Component
{
public function register_model()
{
$srcpaths = Array();
$srcpaths[] = array(
'name'=>'Item',
'model_path'=>$this->attachMyPath('models')
);
$srcpaths[] = array(
'name'=>'Order',
'model_path'=>$this->attachMyPath('models')
);
return $srcpaths;
}
}
See also: ACL,Addon, CategorySet, Controller, Helper, InformationSet, Model, Sitemenu, Sitesettings, UI, URIManager, Admin Notice