How to crawl in the script before execution begins in Yii2?

Need to block access to the site.
A sign in the database, active or not(he he exhibited under his alias from another location), and if not, you need to terminate the script and display a message. Ie this should be done after loading configuration, to check the record in database and close it. And this should happen on all pages.

Where can you prescribe? In some base controller?
July 2nd 19 at 18:02
2 answers
July 2nd 19 at 18:04
Solution
You can implement this functionality using the mechanism application bootstrapping
What you need. Thank you. - Christiana_Bernhard86 commented on July 2nd 19 at 18:07
July 2nd 19 at 18:06
The catchAll route
Sometimes you need to temporarily put the app in maintenance mode and one to display an informational message for all queries. There are many options to implement this task. But one of the easiest is to use the properties of yii\web\Application::catchAll, such as:

[
 // ...
 'catchAll' => ['site/offline'],
];

In this case, the action site/offline will handle all incoming requests.

The catchAll property should take an array whose first element determines the route, and the other elements (key and value) define the parameters passed to the action.
after the script continues to work - Christiana_Bernhard86 commented on July 2nd 19 at 18:09
What prevents this action to verify the symptom in the database and trigger the necessary actions after audits?
In the end you can override UrlManager class in which to add
protected function beforeParseRequest()
{
//here check sign in the database
return true or false
}
and override the function
public function parseRequest($request)
{
if($this->beforeParseRequest()) {
return parent::parseRequest($request)
} else {
//actions in the case of a closed site
}
} - Christiana_Bernhard86 commented on July 2nd 19 at 18:12

Find more questions by tags Yii