This Hook used to register helper.
Step1: Register Call call back. See below format:
App::Module('Hook')
->setHookName("Helper")
->setAction("register_helper")
->Register(Call Back Class Name, Call Back Function Name);
Name |
Type |
Description |
---|---|---|
Call Back Class Name |
Mandatory |
Class Name of call back function |
Call Back Function Name |
Mandatory |
Call back function |
Step 2: Register resource in Call back function:
In call back function we return an array with Helper information like below
$srcpaths[] = array(
'type'=>Name,
"'path"=>Path
);
Name |
Type |
Description |
---|---|---|
Name |
Mandatory |
Name of the helper |
Path |
Mandatory |
File path |
Call a helper:
We call a component helper like bellow:
App::Component(ComopnentName)->Helper(HelperName);
following example:
App::Component('appStore')->Helper('Data')->getPrice();
See below example:
class Component_Appstore_Register extends appRain_Base_Component
{
public function init(){
App::Module('Hook')
->setHookName('Helper')
->setAction("register_helper")
->Register(get_class($this),"register_helper");
}
public function register_helper()
{
$srcpaths = Array();
$srcpaths[] = array(
'name'=>'Data',
'path'=>$this->attachMyPath('helpers/data.php')
);
return $srcpaths;
}
}