Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
2430c10e
Unverified
Commit
2430c10e
authored
Jul 01, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create and register a command to delete modules
parent
5e31ce88
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
0 deletions
+91
-0
DeleteModuleCommand.php
Modules/Core/Console/DeleteModuleCommand.php
+89
-0
CoreServiceProvider.php
Modules/Core/Providers/CoreServiceProvider.php
+2
-0
No files found.
Modules/Core/Console/DeleteModuleCommand.php
0 → 100644
View file @
2430c10e
<?php
namespace
Modules\Core\Console
;
use
Illuminate\Console\Command
;
use
Illuminate\Filesystem\Filesystem
;
use
Symfony\Component\Console\Input\InputOption
;
use
Symfony\Component\Console\Input\InputArgument
;
class
DeleteModuleCommand
extends
Command
{
/**
* The console command name.
*
* @var string
*/
protected
$name
=
'asgard:delete:module'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'Delete a module and optionally its migrations'
;
/**
* @var Filesystem
*/
private
$finder
;
public
function
__construct
(
Filesystem
$finder
)
{
parent
::
__construct
();
$this
->
finder
=
$finder
;
}
/**
* Execute the console command.
*
* @return mixed
*/
public
function
fire
()
{
$module
=
$this
->
argument
(
'module'
);
$modulePath
=
config
(
'modules.paths.modules'
)
.
'/'
.
$module
;
if
(
$this
->
finder
->
exists
(
$modulePath
)
===
false
)
{
$this
->
error
(
'This module does not exist'
);
return
;
}
if
(
is_core_module
(
$module
)
===
true
)
{
$this
->
error
(
'You cannot remove a core module.'
);
return
;
}
if
(
$this
->
option
(
'migrations'
)
===
true
)
{
$this
->
call
(
'module:migrate-reset'
,
[
'module'
=>
$module
]);
}
$this
->
finder
->
deleteDirectory
(
$modulePath
);
$this
->
info
(
'Module successfully deleted'
);
}
/**
* Get the console command arguments.
*
* @return array
*/
protected
function
getArguments
()
{
return
[
[
'module'
,
InputArgument
::
REQUIRED
,
'The module name'
],
];
}
/**
* Get the console command options.
*
* @return array
*/
protected
function
getOptions
()
{
return
[
[
'migrations'
,
'm'
,
InputOption
::
VALUE_NONE
,
'Reset the module migrations'
,
null
],
];
}
}
Modules/Core/Providers/CoreServiceProvider.php
View file @
2430c10e
...
...
@@ -7,6 +7,7 @@ use Illuminate\Routing\Router;
use
Illuminate\Support\Facades\Blade
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\ServiceProvider
;
use
Modules\Core\Console\DeleteModuleCommand
;
use
Modules\Core\Console\DownloadModuleCommand
;
use
Modules\Core\Console\InstallCommand
;
use
Modules\Core\Console\PublishModuleAssetsCommand
;
...
...
@@ -110,6 +111,7 @@ class CoreServiceProvider extends ServiceProvider
PublishThemeAssetsCommand
::
class
,
PublishModuleAssetsCommand
::
class
,
DownloadModuleCommand
::
class
,
DeleteModuleCommand
::
class
,
]);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment