Kohana 3:
You can define a catch-all route in your bootstrap.php
before the Kohana::modules()
lines:
if (/* check if site is in under maintenance mode */) {
Route::set('defaulta', '(<id>)', array('id' => '.*'))
->defaults(array(
'controller' => 'errors',
'action' => 'maintenance',
));
}
Ya da aynı şeyi isteği ile karışıklık eşitlemek yapabilirsiniz:
if (/* check if site is in under maintenance mode */) {
echo Request::factory('errors/maintenance')
->execute()
->send_headers()
->response;
}
Kohana 2:
You would need to extend Controller
and handle the 'under maintenance' page display in the constructor (but you need to make sure all your controllers extend this controller class instead of the vanilla one):
abstract class Custom_Controller extends Controller {
public function __construct()
{
parent::__construct();
if (/* check if site is in under maintenance mode */) {
$page = new View('maintenance');
$page->render(TRUE);
exit;
}
}
}
Yoksa bile hooks
klasördeki bir dosyayı ekleyerek, bunu yapmak için kanca sistemi kullanabilir (size kanca sağlamak emin olun sizin config.php
):
Event::add('system.ready', 'check_maintenance_mode');
function check_maintenance_mode() {
if (/* check if site is in under maintenance mode */) {
Kohana::config_set('routes', array('_default' => 'errors/maintenance'));
}
}
Gördüğünüz gibi, bu çok esnek bir PHP çerçeve çünkü Kohana bölgesinde şeyler yapmak nasıl aslında birçok yolu vardır :)