I have api module in Yii2 app. Before any reuqest I need to check did user send language in post or get request. If user did not send language then throw exception with 422 code.
I have module Api.php. I should configure only for this module.
I have api module in Yii2 app. Before any reuqest I need to check did user send language in post or get request. If user did not send language then throw exception with 422 code.
I have module Api.php. I should configure only for this module.
Copyright © 2021 Jogjafile Inc.
Create behavior BeforeActionValidator, then create method beforeAction inside create validation rule with HttpException. Here is example:
And then attach this behavior to config file. In your module.
If you want you can add other events. Like AFTER_REQUEST