Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
a4b02e6f
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
17
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yii2_fecshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a4b02e6f
编写于
8月 30, 2019
作者:
T
Terry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
extension services
上级
a2aaa3e9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
73 addition
and
0 deletion
+73
-0
services/Extension.php
services/Extension.php
+73
-0
未找到文件。
services/Extension.php
浏览文件 @
a4b02e6f
...
...
@@ -29,6 +29,9 @@ class Extension extends Service
const
STATUS_ENABLE
=
1
;
const
STATUS_DISABLE
=
2
;
const
TYPE_INSTALL
=
'installed'
;
const
TYPE_LOCAL_CREATED
=
'local_created'
;
protected
$warnings
;
protected
$_modelName
=
'\fecshop\models\mysqldb\Extension'
;
...
...
@@ -143,6 +146,53 @@ class Extension extends Service
return
true
;
}
//const TYPE_INSTALL = 'installed';
//const TYPE_LOCAL_CREATED = 'local_created';
// 本地后台初始化的应用
public
function
newLocalCreateInit
(
$param
)
{
$namespace
=
$param
[
'namespaces'
];
//$package = $param['package'];
//$name = $param['name'];
//$config_file_path = $param['config_file_path'];
//$version = $param['version'];
if
(
!
$namespace
)
{
Yii
::
$service
->
helper
->
errors
->
add
(
'namespace is empty'
);
return
false
;
}
// 查看namespace 是否存在
$modelOne
=
$this
->
_model
->
findOne
([
'namespace'
=>
$namespace
]);
if
(
$modelOne
[
'id'
])
{
Yii
::
$service
->
helper
->
errors
->
add
(
'this namespace is exist'
);
return
false
;
}
$config_file_path
=
'@addons/'
.
$param
[
'package'
]
.
'/'
.
$param
[
'addon_folder'
]
.
'/config.php'
;
$model
=
new
$this
->
_modelName
();
$model
[
'namespace'
]
=
$param
[
'namespaces'
];
$model
[
'package'
]
=
$param
[
'package'
];
$model
[
'folder'
]
=
$param
[
'addon_folder'
];
$model
[
'name'
]
=
$param
[
'addon_name'
];
$model
[
'version'
]
=
'1.0.0'
;
$model
[
'config_file_path'
]
=
$config_file_path
;
if
(
!
$model
->
validate
())
{
$errors
=
$model
->
errors
;
Yii
::
$service
->
helper
->
errors
->
addByModelErrors
(
$errors
);
return
false
;
}
$model
->
status
=
self
::
STATUS_ENABLE
;
$model
->
type
=
self
::
TYPE_LOCAL_CREATED
;
$model
->
created_at
=
time
();
$model
->
updated_at
=
time
();
$model
->
installed_status
=
self
::
INSTALLED_STATUS
;
$model
->
priority
=
1
;
return
$model
->
save
();
}
// 新安装的插件,进行初始化
public
function
newInstallInit
(
$param
)
{
...
...
@@ -172,6 +222,8 @@ class Extension extends Service
return
false
;
}
$model
->
status
=
self
::
STATUS_ENABLE
;
$model
->
type
=
self
::
TYPE_INSTALL
;
$model
->
created_at
=
time
();
$model
->
updated_at
=
time
();
$model
->
installed_status
=
self
::
INSTALL_INIT_STATUS
;
...
...
@@ -345,4 +397,25 @@ class Extension extends Service
return
true
;
}
/**
* @param $installConfig | array
* 进行应用的卸载
* 通过扩展配置中获取安装部分的配置,通过该函数执行安装。
*/
public
function
uninstallAddons
(
$unstallConfig
,
$modelOne
)
{
$uninstallOb
=
Yii
::
createObject
(
$unstallConfig
);
if
(
!
(
$uninstallOb
instanceof
\
fecshop\services\extension\UninstallInterface
))
{
Yii
::
$service
->
helper
->
errors
->
add
(
"Extension unstall file must implements interface `
\f
ecshop\services
\e
xtension\UninstallInterface`"
);
return
false
;
}
if
(
!
$uninstallOb
->
run
())
{
return
false
;
}
// 进行extension数据的删除
return
$modelOne
->
delete
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录