how redirect in bootstrap

i need to make redirection into install page when db schema is not available. it works the way below but it triggers only after action was fired which is not desired.





final class MyLibraryBootstrap implements BootstrapInterface

{


	public function bootstrap($app)

	{


try {

//check db fails . . .


			if ($app->db->getTableSchema('{{%sometbl}}') == null) {

				

				Event::on('\frontend\components\Controller', Controller::EVENT_AFTER_ACTION, function($e) {

					/* @var $e \yii\base\ActionEvent */

					$r = new \yii\web\Response();

					$r->redirect(['install/test']);

					$e->result = $r;

					$e->handled = true;

				});




.....



thanks in advance.

nevermind. went for raw way. looks ok




                        if ($app->db->getTableSchema('{{%sometbl}}') == null) {


				Event::on('\frontend\components\Controller', Controller::EVENT_BEFORE_ACTION, function($e) {

					header('Location: '. Url::toRoute(['install/test'])); die;

				});