@@ -23,6 +23,8 @@ class Administer extends Service
23
23
// 卸载应用,是否删除掉应用的文件夹
24
24
public $ uninstallRemoveFile = true ;
25
25
26
+ public $ currentNamespace ;
27
+
26
28
/**
27
29
* 1.插件的安装
28
30
* @param $extension_name | string , 插件名称(唯一)
@@ -39,6 +41,7 @@ public function install($extension_namespace, $forceInstall=false)
39
41
40
42
return false ;
41
43
}
44
+ $ this ->currentNamespace = $ extension_namespace ;
42
45
// 插件已经安装
43
46
$ installed_status = $ modelOne ['installed_status ' ];
44
47
if (!$ forceInstall && Yii::$ service ->extension ->isInstalledStatus ($ installed_status )) {
@@ -93,7 +96,7 @@ public function testInstall($extension_namespace, $forceInstall=false)
93
96
94
97
return false ;
95
98
}
96
-
99
+ $ this -> currentNamespace = $ extension_namespace ;
97
100
// 通过数据库找到应用的配置文件路径
98
101
$ extensionConfigFile = Yii::getAlias ($ modelOne ['config_file_path ' ]);
99
102
if (!file_exists ($ extensionConfigFile )) {
@@ -144,6 +147,7 @@ public function upgrade($extension_namespace)
144
147
145
148
return false ;
146
149
}
150
+ $ this ->currentNamespace = $ extension_namespace ;
147
151
// 插件如果没有安装
148
152
$ installed_status = $ modelOne ['installed_status ' ];
149
153
if (!Yii::$ service ->extension ->isInstalledStatus ($ installed_status )) {
@@ -369,13 +373,30 @@ protected function installDbData($modelOne)
369
373
370
374
371
375
// theme文件进行copy到@app/theme/base/addons 下面。
372
- protected function copyThemeFile ($ modelOne )
376
+ protected function copyThemeFile ($ sourcePath )
373
377
{
378
+ if (!$ this ->currentNamespace ) {
379
+ Yii::$ service ->helper ->errors ->add ('copyThemeFile: current extension: {namespace} is not exist ' , ['namespace ' =>$ this ->currentNamespace ]);
380
+
381
+ return false ;
382
+ }
383
+ $ targetPath = Yii::getAlias ('@appimage/common/addons/ ' .$ this ->currentNamespace );
374
384
375
-
376
-
385
+ Yii::$ service ->helper ->copyDirImage ($ sourcePath , $ targetPath );
377
386
378
387
}
379
388
380
-
389
+ // theme文件进行copy到@app/theme/base/addons 下面。
390
+ protected function removeThemeFile ()
391
+ {
392
+ if (!$ this ->currentNamespace ) {
393
+ Yii::$ service ->helper ->errors ->add ('copyThemeFile: current extension: {namespace} is not exist ' , ['namespace ' =>$ this ->currentNamespace ]);
394
+
395
+ return false ;
396
+ }
397
+ $ sourcePath = Yii::getAlias ('@appimage/common/addons/ ' .$ this ->currentNamespace );
398
+ Yii::$ service ->helper ->deleteDir ($ sourcePath );
399
+
400
+ return true ;
401
+ }
381
402
}
0 commit comments