Kohana 3 : You can define a catch-all route in bootstrap.phpfront of the lines Kohana::modules():
if () {
Route::set('defaulta', '(<id>)', array('id' => '.*'))
->defaults(array(
'controller' => 'errors',
'action' => 'maintenance',
));
}
Or you may even be asked to do the same:
if () {
echo Request::factory('errors/maintenance')
->execute()
->send_headers()
->response;
}
Kohana 2 : You will need to expand Controllerand process the display of the page "for maintenance" in the constructor (but you must make sure that all your controllers extend this controller class instead of vanilla):
abstract class Custom_Controller extends Controller {
public function __construct()
{
parent::__construct();
if () {
$page = new View('maintenance');
$page->render(TRUE);
exit;
}
}
}
Or you can even use the hook system to do this by adding the file to your folder hooks(make sure you turn on hooks in config.php):
Event::add('system.ready', 'check_maintenance_mode');
function check_maintenance_mode() {
if () {
Kohana::config_set('routes', array('_default' => 'errors/maintenance'));
}
}
As you can see, there are actually many ways to do things in Cohan, because it is a very flexible PHP framework :)
source
share