Codebench — A benchmarking module.
Class declared in MODPATH/codebench/classes/controller/codebench.php on line 11.
boolean
$auto_renderlink to thisauto render template
Request
$requestlink to thisRequest that created the controller
Response
$responselink to thisThe response that will be returned from controller
$templatelink to this
public
function
action_index()
{
$class
=
$this
->request->param(
'class'
);
// Convert submitted class name to URI segment
if
(isset(
$_POST
[
'class'
]))
{
$this
->request->redirect(
'codebench/'
.trim(
$_POST
[
'class'
]));
}
// Pass the class name on to the view
$this
->template->
class
= (string)
$class
;
// Try to load the class, then run it
if
(Kohana::auto_load(
$class
) === TRUE)
{
$codebench
=
new
$class
;
$this
->template->codebench =
$codebench
->run();
}
}
Assigns the template View as the request response.
public
function
after()
{
if
(
$this
->auto_render === TRUE)
{
$this
->response->body(
$this
->template->render());
}
parent::after();
}
Loads the template View object.
public
function
before()
{
parent::before();
if
(
$this
->auto_render === TRUE)
{
// Load the template
$this
->template = View::factory(
$this
->template);
}
}
Creates a new controller instance. Each controller must be constructed with the request object that created it.
Request
$request
required - Request that created the controllerResponse
$response
required - The request's responsevoid
public
function
__construct(Request
$request
, Response
$response
)
{
// Assign the request to the controller
$this
->request =
$request
;
// Assign a response to the controller
$this
->response =
$response
;
}