提交 2e6542a9 编写于 作者: T Terry

应用插件部分

上级 b3d5efd5
...@@ -23,6 +23,8 @@ class Administer extends Service ...@@ -23,6 +23,8 @@ class Administer extends Service
// 卸载应用,是否删除掉应用的文件夹 // 卸载应用,是否删除掉应用的文件夹
public $uninstallRemoveFile = true; public $uninstallRemoveFile = true;
public $currentNamespace;
/** /**
* 1.插件的安装 * 1.插件的安装
* @param $extension_name | string , 插件名称(唯一) * @param $extension_name | string , 插件名称(唯一)
...@@ -39,6 +41,7 @@ class Administer extends Service ...@@ -39,6 +41,7 @@ class Administer extends Service
return false; return false;
} }
$this->currentNamespace = $extension_namespace;
// 插件已经安装 // 插件已经安装
$installed_status = $modelOne['installed_status']; $installed_status = $modelOne['installed_status'];
if (!$forceInstall && Yii::$service->extension->isInstalledStatus($installed_status)) { if (!$forceInstall && Yii::$service->extension->isInstalledStatus($installed_status)) {
...@@ -93,7 +96,7 @@ class Administer extends Service ...@@ -93,7 +96,7 @@ class Administer extends Service
return false; return false;
} }
$this->currentNamespace = $extension_namespace;
// 通过数据库找到应用的配置文件路径 // 通过数据库找到应用的配置文件路径
$extensionConfigFile = Yii::getAlias($modelOne['config_file_path']); $extensionConfigFile = Yii::getAlias($modelOne['config_file_path']);
if (!file_exists($extensionConfigFile)) { if (!file_exists($extensionConfigFile)) {
...@@ -144,6 +147,7 @@ class Administer extends Service ...@@ -144,6 +147,7 @@ class Administer extends Service
return false; return false;
} }
$this->currentNamespace = $extension_namespace;
// 插件如果没有安装 // 插件如果没有安装
$installed_status = $modelOne['installed_status']; $installed_status = $modelOne['installed_status'];
if (!Yii::$service->extension->isInstalledStatus($installed_status)) { if (!Yii::$service->extension->isInstalledStatus($installed_status)) {
...@@ -369,13 +373,30 @@ class Administer extends Service ...@@ -369,13 +373,30 @@ class Administer extends Service
// theme文件进行copy到@app/theme/base/addons 下面。 // theme文件进行copy到@app/theme/base/addons 下面。
protected function copyThemeFile($modelOne) protected function copyThemeFile($sourcePath)
{ {
if (!$this->currentNamespace) {
Yii::$service->helper->errors->add('copyThemeFile: current extension: {namespace} is not exist', ['namespace' =>$this->currentNamespace ]);
return false;
}
$targetPath = Yii::getAlias('@appimage/common/addons/'.$this->currentNamespace);
Yii::$service->helper->copyDirImage($sourcePath, $targetPath);
} }
// theme文件进行copy到@app/theme/base/addons 下面。
protected function removeThemeFile()
{
if (!$this->currentNamespace) {
Yii::$service->helper->errors->add('copyThemeFile: current extension: {namespace} is not exist', ['namespace' =>$this->currentNamespace ]);
return false;
}
$sourcePath = Yii::getAlias('@appimage/common/addons/'.$this->currentNamespace);
Yii::$service->helper->deleteDir($sourcePath);
return true;
}
} }
...@@ -98,16 +98,14 @@ class Install implements \fecshop\services\extension\InstallInterface ...@@ -98,16 +98,14 @@ class Install implements \fecshop\services\extension\InstallInterface
} }
/** /**
* 复制图片文件到appimage,如果存在,则会被强制覆盖 * 复制图片文件到appimage/common/addons/{namespace},如果存在,则会被强制覆盖
* 模板应用一般会用到改函数
*/ */
public function copyImageFile() public function copyImageFile()
{ {
/* /*
$sourcePath = Yii::getAlias('@<?= $namespaces ?>/app/appimage'); $sourcePath = Yii::getAlias('@<?= $namespaces ?>/app/appimage/common/addons/<?= $namespaces ?>');
$targetPath = Yii::getAlias('@appimage');
// 只复制产品文件到appimage,其他的文件将会被过滤掉。(安全) Yii::$service->extension->administer->copyThemeFile($sourcePath);
Yii::$service->helper->copyDirImage($sourcePath, $targetPath);
*/ */
return true; return true;
} }
......
...@@ -48,8 +48,7 @@ class Uninstall implements \fecshop\services\extension\UninstallInterface ...@@ -48,8 +48,7 @@ class Uninstall implements \fecshop\services\extension\UninstallInterface
public function removeImageFile() public function removeImageFile()
{ {
/* /*
$targetPath = Yii::getAlias('@appimage/common/appfront/media/fect/xxxxxxxxx'); return Yii::$service->extension->administer->removeThemeFile();
Yii::$service->helper->deleteDir($targetPath);
*/ */
return true; return true;
......
...@@ -77,21 +77,17 @@ class Upgrade implements \fecshop\services\extension\UpgradeInterface ...@@ -77,21 +77,17 @@ class Upgrade implements \fecshop\services\extension\UpgradeInterface
} }
/** /**
* 复制图片文件到appimage,如果存在,则会被强制覆盖 * 复制图片文件到appimage/common/addons/{namespace},如果存在,则会被强制覆盖
* 如果更新的版本中有新增的图片,可以执行copy image
*/ */
public function copyImageFile() public function copyImageFile()
{ {
/* /*
$sourcePath = Yii::getAlias('@<?= $namespaces ?>/app/appimage'); $sourcePath = Yii::getAlias('@<?= $namespaces ?>/app/appimage/common/addons/<?= $namespaces ?>');
$targetPath = Yii::getAlias('@appimage');
// 只复制产品文件到appimage,其他的文件将会被过滤掉。(安全) Yii::$service->extension->administer->copyThemeFile($sourcePath);
Yii::$service->helper->copyDirImage($sourcePath, $targetPath);
*/ */
return true; return true;
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册