Controller

Navigation:  Components > Hook >

Controller

Previous pageReturn to chapter overviewNext page

This Hook used to register Controller.
 
Step1: Register Call call back. See below format:
 
App::Module('Hook')

   ->setHookName("Controller")

   ->setAction("register_controller")

   ->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 Controller information like below
 

$srcpaths[] = array(

   'type'=>Name,

   "'path"=>Path

);
 
 

Name

Type

Description

Name

Mandatory

Name of the controller

Path

Mandatory

File path

 

Work with templates:

Each controller must have a folder in same path with the name of controller for Action Template. For example:

 

Controller path

/component/testcomponent/controller/testcomponent.php

template path

/component/testcomponent/controller/testcomponent/(*).phtml

 
 
See below example:
 
class Component_Appstore_Register extends appRain_Base_Component
{
   public function init(){
 
       App::Module('Hook')
           ->setHookName('Controller')
           ->setAction("register_controller")
           ->Register(get_class($this),"register_controller");
 
   }
 
   public function register_controller()
   {
       $srcpaths = Array();
       $srcpaths[] =   array(
          'name'=>'appStore',
          'controller_path'=>$this->attachMyPath('controllers')
       );
       $srcpaths[] =   array(
          'name'=>'manageStore',
          'controller_path'=>$this->attachMyPath('controllers')
       );
      return $srcpaths;
   }
}