Search code examples
phpyii2maintenance-mode

Yii2 Dynamic Maintenance Mode


I've used the following library in my Yii2 project: Click here

I've set it up and tested it and it works great. But now I want to make it dynamic as in if an admin clicks on a toggle switch the website should go into maintenance mode. To make it happen all I need to do is to make the enabled variable true which is used in Maintenance class of this library.

But my question is how can I link my toggle switch to that variable.

Thanks in advance!


Solution

  • You can access to application's components like below:

    Yii::$app->componentName
    

    So, with this component you can access it like below:

    Yii::$app->maintenanceMode->enable=FALSE;