Template.php 880 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Abstract controller class for automatic templating.
  4. *
  5. * @package Kohana
  6. * @category Controller
  7. * @author Kohana Team
  8. * @copyright (c) Kohana Team
  9. * @license https://koseven.ga/LICENSE.md
  10. */
  11. abstract class Kohana_Controller_Template extends Controller {
  12. /**
  13. * @var View page template
  14. */
  15. public $template = 'template';
  16. /**
  17. * @var boolean auto render template
  18. **/
  19. public $auto_render = TRUE;
  20. /**
  21. * Loads the template [View] object.
  22. */
  23. public function before()
  24. {
  25. parent::before();
  26. if ($this->auto_render === TRUE)
  27. {
  28. // Load the template
  29. $this->template = View::factory($this->template);
  30. }
  31. }
  32. /**
  33. * Assigns the template [View] as the request response.
  34. */
  35. public function after()
  36. {
  37. if ($this->auto_render === TRUE)
  38. {
  39. $this->response->body($this->template->render());
  40. }
  41. parent::after();
  42. }
  43. }