Kohana v3.3.0
This commit is contained in:
50
system/classes/Kohana/Controller/Template.php
Normal file
50
system/classes/Kohana/Controller/Template.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php defined('SYSPATH') OR die('No direct script access.');
|
||||
/**
|
||||
* Abstract controller class for automatic templating.
|
||||
*
|
||||
* @package Kohana
|
||||
* @category Controller
|
||||
* @author Kohana Team
|
||||
* @copyright (c) 2008-2012 Kohana Team
|
||||
* @license http://kohanaframework.org/license
|
||||
*/
|
||||
abstract class Kohana_Controller_Template extends Controller {
|
||||
|
||||
/**
|
||||
* @var View page template
|
||||
*/
|
||||
public $template = 'template';
|
||||
|
||||
/**
|
||||
* @var boolean auto render template
|
||||
**/
|
||||
public $auto_render = TRUE;
|
||||
|
||||
/**
|
||||
* Loads the template [View] object.
|
||||
*/
|
||||
public function before()
|
||||
{
|
||||
parent::before();
|
||||
|
||||
if ($this->auto_render === TRUE)
|
||||
{
|
||||
// Load the template
|
||||
$this->template = View::factory($this->template);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the template [View] as the request response.
|
||||
*/
|
||||
public function after()
|
||||
{
|
||||
if ($this->auto_render === TRUE)
|
||||
{
|
||||
$this->response->body($this->template->render());
|
||||
}
|
||||
|
||||
parent::after();
|
||||
}
|
||||
|
||||
} // End Controller_Template
|
Reference in New Issue
Block a user