pclib  2.3.2
Lightweight PHP framework
Public Member Functions | Data Fields | Protected Attributes
Controller Class Reference

Base class for any application controller. More...

Inheritance diagram for Controller:
BaseObject

Public Member Functions

 init ()
 Called before every action. More...
 
 run ($action)
 Call action method of the controller, feeding it with required parameters. More...
 
 redirect ($route)
 Redirect to $route.
 
 model ($tableName, $id=null)
 Return model for table $tableName.
 
 selection ($from=null)
 Return orm class.
 
- Public Member Functions inherited from BaseObject
 loadDefaults ($className=null)
 Load default parameters of class $className into object instance.
 
 setProperties (array $defaults)
 Set public properties of object from the array. More...
 
 addEvent ($name, $callback)
 Add event handler to $object->$name property. More...
 
 toArray ()
 Convert object to array. More...
 

Data Fields

 $ACTION_POSTFIX = 'Action'
 Each action method name must have following postfix. More...
 
 $name
 Name of the controller without postfix. More...
 
 $action
 Name of the called action without postfix. More...
 
 $onInit
 Occurs when Controller is initialized. More...
 
- Data Fields inherited from BaseObject
 $onNewInstance
 Occurs when new instance of the class is created. More...
 
 $onMissingMethod
 Occurs when called method does not exist. More...
 
 $serviceLocator
 var function() Return service object when requested with service(). More...
 

Protected Attributes

 $app
 var App Link to application
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseObject
static defaults ()
 Set or retireve default parameters of the object. More...
 
- Protected Member Functions inherited from BaseObject
 fireEvent ($name, array $args=array())
 Run all event handlers in $object->$name property. More...
 
 service ($service, $default=null)
 Try acquire $service and load it into property $this->$service. More...
 

Detailed Description

Base class for any application controller.

Define your controller, say 'products', in file controllers/ProductsController.php like class ProductsController extends Controller. Now you can define actions such as: function editAction() { ... return 'your html'; } It will be called on url '?r=products/edit'.

See also
App::run()

Member Function Documentation

init ( )

Called before every action.

Override for controller's setup, testing access permissions, etc.

run (   $action)

Call action method of the controller, feeding it with required parameters.

Parameters
Action$actioncalled action.

Field Documentation

$action

Name of the called action without postfix.

$ACTION_POSTFIX = 'Action'

Each action method name must have following postfix.

Only action methods are callable by sending request from user browser.

$name

Name of the controller without postfix.

$onInit

Occurs when Controller is initialized.


The documentation for this class was generated from the following file: