@@ -37,22 +37,31 @@ class Bootstrap implements \yii\base\BootstrapInterface
37
37
*/
38
38
public function bootstrap ($ app )
39
39
{
40
- /** @var $module Module */
41
- if ($ app ->hasModule ('oauth2 ' ) && ($ module = $ app ->getModule ('oauth2 ' )) instanceof Module) {
42
- $ this ->_modelMap = array_merge ($ this ->_modelMap , $ module ->modelMap );
43
- foreach ($ this ->_modelMap as $ name => $ definition ) {
44
- \Yii::$ container ->set ("filsh \\yii2 \\oauth2server \\models \\" . $ name , $ definition );
45
- $ module ->modelMap [$ name ] = is_array ($ definition ) ? $ definition ['class ' ] : $ definition ;
40
+ $ module_list = array_keys ($ app ->getModules ());
41
+ $ module_oauth = [];
42
+ foreach ($ module_list as $ item ) {
43
+ if (strpos ($ item ,'oauth ' )===0 ) {
44
+ $ module_oauth [] = $ item ;
46
45
}
46
+ }
47
+ foreach ($ module_oauth as $ oauth_name ) {
48
+ /** @var $module Module */
49
+ if ($ app ->hasModule ($ oauth_name ) && ($ module = $ app ->getModule ($ oauth_name )) instanceof Module) {
50
+ $ this ->_modelMap = array_merge ($ this ->_modelMap , $ module ->modelMap );
51
+ foreach ($ this ->_modelMap as $ name => $ definition ) {
52
+ \Yii::$ container ->set ("filsh \\yii2 \\oauth2server \\models \\" . $ name , $ definition );
53
+ $ module ->modelMap [$ name ] = is_array ($ definition ) ? $ definition ['class ' ] : $ definition ;
54
+ }
47
55
48
- $ this ->_storageMap = array_merge ($ this ->_storageMap , $ module ->storageMap );
49
- foreach ($ this ->_storageMap as $ name => $ definition ) {
50
- \Yii::$ container ->set ($ name , $ definition );
51
- $ module ->storageMap [$ name ] = is_array ($ definition ) ? $ definition ['class ' ] : $ definition ;
52
- }
56
+ $ this ->_storageMap = array_merge ($ this ->_storageMap , $ module ->storageMap );
57
+ foreach ($ this ->_storageMap as $ name => $ definition ) {
58
+ \Yii::$ container ->set ($ name , $ definition );
59
+ $ module ->storageMap [$ name ] = is_array ($ definition ) ? $ definition ['class ' ] : $ definition ;
60
+ }
53
61
54
- if ($ app instanceof \yii \console \Application) {
55
- $ module ->controllerNamespace = 'filsh\yii2\oauth2server\commands ' ;
62
+ if ($ app instanceof \yii \console \Application) {
63
+ $ module ->controllerNamespace = 'filsh\yii2\oauth2server\commands ' ;
64
+ }
56
65
}
57
66
}
58
67
}
0 commit comments