Codebench — A benchmarking module.
Class declared in MODPATH/codebench/classes/controller/codebench.php on line 11.
boolean
$auto_renderauto render template
Request
$requestRequest that created the controller
Response
$responseThe response that will be returned from controller
$templatepublic function action_index($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());
}
return parent::after();
}
Loads the template View object.
public function before()
{
if ($this->auto_render === TRUE)
{
// Load the template
$this->template = View::factory($this->template);
}
return parent::before();
}
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;
}