1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
3 * Kohana Controller class. The controller class must be extended to work
4 * properly, so this class is defined as abstract.
6 * $Id: Controller.php 3917 2009-01-21 03:06:22Z zombor $
10 * @copyright (c) 2007-2008 Kohana Team
11 * @license http://kohanaphp.com/license.html
13 abstract class Controller
{
15 // Allow all controllers to run in production by default
16 const ALLOW_PRODUCTION
= TRUE;
19 * Loads URI, and Input into this controller.
23 public function __construct()
25 if (Kohana
::$instance == NULL)
27 // Set the instance to the first controller loaded
28 Kohana
::$instance = $this;
31 // URI should always be available
32 $this->uri
= URI
::instance();
34 // Input should always be available
35 $this->input
= Input
::instance();
39 * Handles methods that do not exist.
41 * @param string method name
42 * @param array arguments
45 public function __call($method, $args)
47 // Default to showing a 404 page
48 Event
::run('system.404');
52 * Includes a View within the controller scope.
54 * @param string view filename
55 * @param array array of view variables
58 public function _kohana_load_view($kohana_view_filename, $kohana_input_data)
60 if ($kohana_view_filename == '')
66 // Import the view variables to local namespace
67 extract($kohana_input_data, EXTR_SKIP
);
71 // Views are straight HTML pages with embedded PHP, so importing them
72 // this way insures that $this can be accessed as if the user was in
73 // the controller, which gives the easiest access to libraries in views
74 include $kohana_view_filename;
78 // Display the exception using its internal __toString method
82 // Fetch the output and close the buffer
83 return ob_get_clean();
86 } // End Controller Class