切换导航条
此项目
正在载入...
登录
何书鹏
/
recruit
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
Karson
6 years ago
提交者
Gitee
6 years ago
提交
ebf38b470c31cf5fc517754490260026aa7c4c7f
2 个父辈
1390a5f1
b0cfaed5
!138 增加插件资源移动命令
Merge pull request !138 from 道阻且长/master
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
66 行增加
和
5 行删除
application/admin/command/Addon.php
application/admin/command/Addon.php
查看文件 @
ebf38b4
...
...
@@ -21,7 +21,7 @@ class Addon extends Command
$this
->
setName
(
'addon'
)
->
addOption
(
'name'
,
'a'
,
Option
::
VALUE_REQUIRED
,
'addon name'
,
null
)
->
addOption
(
'action'
,
'c'
,
Option
::
VALUE_REQUIRED
,
'action(create/enable/disable/install/uninstall/refresh/upgrade/package)'
,
'create'
)
->
addOption
(
'action'
,
'c'
,
Option
::
VALUE_REQUIRED
,
'action(create/enable/disable/install/uninstall/refresh/upgrade/package
/move
)'
,
'create'
)
->
addOption
(
'force'
,
'f'
,
Option
::
VALUE_OPTIONAL
,
'force override'
,
null
)
->
addOption
(
'release'
,
'r'
,
Option
::
VALUE_OPTIONAL
,
'addon release version'
,
null
)
->
addOption
(
'uid'
,
'u'
,
Option
::
VALUE_OPTIONAL
,
'fastadmin uid'
,
null
)
...
...
@@ -51,7 +51,7 @@ class Addon extends Command
if
(
!
$name
)
{
throw
new
Exception
(
'Addon name could not be empty'
);
}
if
(
!
$action
||
!
in_array
(
$action
,
[
'create'
,
'disable'
,
'enable'
,
'install'
,
'uninstall'
,
'refresh'
,
'upgrade'
,
'package'
]))
{
if
(
!
$action
||
!
in_array
(
$action
,
[
'create'
,
'disable'
,
'enable'
,
'install'
,
'uninstall'
,
'refresh'
,
'upgrade'
,
'package'
,
'move'
]))
{
throw
new
Exception
(
'Please input correct action name'
);
}
...
...
@@ -253,8 +253,69 @@ class Addon extends Command
$zip
->
close
();
$output
->
info
(
"Package Successed!"
);
break
;
default
:
case
'move'
:
$movePath
=
[
'adminOnlySelfDir'
=>
[
'admin/behavior'
,
'admin/controller'
,
'admin/library'
,
'admin/model'
,
'admin/validate'
,
'admin/view'
],
'adminAllSubDir'
=>
[
'admin/lang'
],
'publicDir'
=>
[
'public/assets/addons'
,
'public/assets/js/backend'
]
];
$paths
=
[];
$appPath
=
str_replace
(
'/'
,
DS
,
APP_PATH
);
$rootPath
=
str_replace
(
'/'
,
DS
,
ROOT_PATH
);
foreach
(
$movePath
as
$k
=>
$items
)
{
switch
(
$k
)
{
case
'adminOnlySelfDir'
:
foreach
(
$items
as
$v
)
{
$v
=
str_replace
(
'/'
,
DS
,
$v
);
$oldPath
=
$appPath
.
$v
.
DS
.
$name
;
$newPath
=
$rootPath
.
"addons"
.
DS
.
$name
.
DS
.
"application"
.
DS
.
$v
.
DS
.
$name
;
$paths
[
$oldPath
]
=
$newPath
;
}
break
;
case
'adminAllSubDir'
:
foreach
(
$items
as
$v
)
{
$v
=
str_replace
(
'/'
,
DS
,
$v
);
$vPath
=
$appPath
.
$v
;
$list
=
scandir
(
$vPath
);
foreach
(
$list
as
$_v
)
{
if
(
!
in_array
(
$_v
,
[
'.'
,
'..'
])
&&
is_dir
(
$vPath
.
DS
.
$_v
))
{
$oldPath
=
$appPath
.
$v
.
DS
.
$_v
.
DS
.
$name
;
$newPath
=
$rootPath
.
"addons"
.
DS
.
$name
.
DS
.
"application"
.
DS
.
$v
.
DS
.
$_v
.
DS
.
$name
;
$paths
[
$oldPath
]
=
$newPath
;
}
}
}
break
;
case
'publicDir'
:
foreach
(
$items
as
$v
)
{
$v
=
str_replace
(
'/'
,
DS
,
$v
);
$oldPath
=
$rootPath
.
$v
.
DS
.
$name
;
$newPath
=
$rootPath
.
'addons'
.
DS
.
$name
.
DS
.
$v
.
DS
.
$name
;
$paths
[
$oldPath
]
=
$newPath
;
}
break
;
}
}
foreach
(
$paths
as
$oldPath
=>
$newPath
)
{
if
(
is_dir
(
$oldPath
))
{
if
(
$force
)
{
if
(
is_dir
(
$newPath
))
{
$list
=
scandir
(
$newPath
);
foreach
(
$list
as
$_v
)
{
if
(
!
in_array
(
$_v
,
[
'.'
,
'..'
]))
{
$file
=
$newPath
.
DS
.
$_v
;
@
chmod
(
$file
,
0777
);
@
unlink
(
$file
);
}
}
@
rmdir
(
$newPath
);
}
}
copydirs
(
$oldPath
,
$newPath
);
}
}
break
;
default
:
break
;
}
}
...
...
@@ -318,5 +379,5 @@ class Addon extends Command
{
return
__DIR__
.
'/Addon/stubs/'
.
$name
.
'.stub'
;
}
}
...
...
请
注册
或
登录
后发表评论