1 | <?php namespace Cerbero\Workflow\Console\Commands; |
||
5 | class DeleteWorkflowCommand extends WorkflowGeneratorCommand { |
||
6 | |||
7 | use DeleteIfForcedTrait; |
||
8 | |||
9 | /** |
||
10 | * The console command name. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $name = 'workflow:delete'; |
||
15 | |||
16 | /** |
||
17 | * The console command description. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $description = 'Delete an existing workflow'; |
||
22 | |||
23 | /** |
||
24 | * Execute the console command. |
||
25 | * |
||
26 | * @return mixed |
||
27 | */ |
||
28 | public function fire() |
||
29 | { |
||
30 | $this->inflector->of($name = $this->getWorkflowName()); |
||
31 | |||
32 | if( ! $this->pipelines->exists($name)) |
||
33 | { |
||
34 | return $this->error("The workflow [$name] does not exist."); |
||
35 | } |
||
36 | |||
37 | $this->deleteAllFilesOfWorkflowIfForced($name); |
||
38 | |||
39 | $this->pipelines->destroy($name); |
||
40 | |||
41 | $this->info('Workflow deleted successfully.'); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Delete all the generated files of the given workflow if forced. |
||
46 | * |
||
47 | * @author Andrea Marco Sartori |
||
48 | * @param string $workflow |
||
49 | * @return void |
||
50 | */ |
||
51 | protected function deleteAllFilesOfWorkflowIfForced($workflow) |
||
61 | |||
62 | /** |
||
63 | * Get the console command options. |
||
64 | * |
||
65 | * @return array |
||
66 | */ |
||
67 | protected function getOptions() |
||
73 | |||
74 | } |
||
75 |