1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- /**
- * Abstract controller class for automatic templating.
- *
- * @package Kohana
- * @category Controller
- * @author Kohana Team
- * @copyright (c) Kohana Team
- * @license https://koseven.ga/LICENSE.md
- */
- 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();
- }
- }
|