PHP Class Kohana_Controller, kohana-twig

It adds hooks to the construct, before and after methods. example to execute functions instead of the current action: To go along before/after the action is called:
Author: Chema ([email protected])
显示文件 Open project: jonathangeiger/kohana-twig Class Usage Examples

Public Properties

Property Type Description
$__context Standalone context
$request Request that created the controller
$response The response that will be returned from controller

Protected Properties

Property Type Description
$_auto_render Auto-render template after controller method returns
$_environment Twig_Environment
$_template_path Template path that points to the action view

Public Methods

Method Description
__construct ( Request $request, Response $response ) : void Creates a new controller instance. Each controller must be constructed with the request object that created it.
__get ( mixed $key ) : array Have a standalone action context. A context should not be within a template because not all request require a template, thus, we allow the controller to handle the context for later manipulation. We use magic methods to manipulate the data:
__set ( string $key, mixed $value ) : mixed Have a standalone action context. A context should not be within a template because not all request require a template, thus, we allow the controller to handle the context for later manipulation. We use magic methods to manipulate the data:
after ( ) : void Renders the template if necessary
before ( ) : void Before the action gets executed we need run a few processes.

Protected Methods

Method Description
_set_template_path ( string $path, string $file, string $extension = "html" ) : boolean Load the path that points to the view (if applicable).

Method Details

__construct() public method

Creates a new controller instance. Each controller must be constructed with the request object that created it.
public __construct ( Request $request, Response $response ) : void
$request Request Request that created the controller
$response Response The request's response
return void

__get() public method

class Controller_Object{ public function action_index() { Setter $this->var1 = "test"; $this->var2 = array( 'k1' => 'v1', 'k2' => 'v2', 'k3' => 'v3', ); } }
public __get ( mixed $key ) : array
$key mixed
return array

__set() public method

class Controller_Object{ public function action_index() { Getter $var1 = $this->var1; modify the var1 $this->var1 = $var1; } }
public __set ( string $key, mixed $value ) : mixed
$key string
$value mixed
return mixed

_set_template_path() protected method

We return a bool so that the method can be reused even if there's the need to extend the method
protected _set_template_path ( string $path, string $file, string $extension = "html" ) : boolean
$path string Directory path
$file string File name
$extension string File Extension
return boolean This boolean determines whether the file exists or not

after() public method

Renders the template if necessary
public after ( ) : void
return void

before() public method

Before the action gets executed we need run a few processes.
public before ( ) : void
return void

Property Details

$__context public_oe property

Standalone context
public $__context

$_auto_render protected_oe property

Auto-render template after controller method returns
protected $_auto_render

$_environment protected_oe property

protected Twig_Environment $_environment
return Twig_Environment

$_template_path protected_oe property

Template path that points to the action view
protected $_template_path

$request public_oe property

Request that created the controller
public $request

$response public_oe property

The response that will be returned from controller
public $response