1 | <?php namespace Cerbero\Workflow\Console\Commands; |
||
5 | class CreateWorkflowCommand extends WorkflowGeneratorCommand { |
||
6 | |||
7 | use AttachesPipesTrait; |
||
8 | |||
9 | /** |
||
10 | * The console command name. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $name = 'workflow:create'; |
||
15 | |||
16 | /** |
||
17 | * The console command description. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $description = 'Create a new workflow'; |
||
22 | |||
23 | /** |
||
24 | * @author Andrea Marco Sartori |
||
25 | * @var string $type Type of class to generate. |
||
26 | */ |
||
27 | protected $type = 'Pipe'; |
||
28 | |||
29 | /** |
||
30 | * Execute the console command. |
||
31 | * |
||
32 | * @return mixed |
||
33 | */ |
||
34 | public function fire() |
||
35 | { |
||
36 | $this->inflector->of($name = $this->getWorkflowName()); |
||
37 | |||
38 | if($this->pipelines->exists($name)) |
||
39 | { |
||
40 | return $this->error("The workflow [$name] already exists."); |
||
41 | } |
||
42 | |||
43 | $this->generateAllNeededFiles(); |
||
44 | |||
45 | $this->pipelines->store($name, $this->getNamespacedPipesByOption('attach')); |
||
46 | |||
47 | $this->info('Workflow created successfully.'); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Generate all the needed files. |
||
52 | * |
||
53 | * @author Andrea Marco Sartori |
||
54 | * @return void |
||
55 | */ |
||
56 | protected function generateAllNeededFiles() |
||
66 | |||
67 | /** |
||
68 | * Settle the pipeline repository if it does not exist. |
||
69 | * |
||
70 | * @author Andrea Marco Sartori |
||
71 | * @return void |
||
72 | */ |
||
73 | protected function settleRepositoryIfNotExists() |
||
82 | |||
83 | /** |
||
84 | * Create the job to handle. |
||
85 | * |
||
86 | * @author Andrea Marco Sartori |
||
87 | * @return void |
||
88 | */ |
||
89 | protected function generateJob() |
||
95 | |||
96 | /** |
||
97 | * Create the request if unguard is not set. |
||
98 | * |
||
99 | * @author Andrea Marco Sartori |
||
100 | * @return void |
||
101 | */ |
||
102 | protected function generateRequestIfGuarded() |
||
111 | |||
112 | /** |
||
113 | * Get the console command options. |
||
114 | * |
||
115 | * @return array |
||
116 | */ |
||
117 | protected function getOptions() |
||
124 | |||
125 | } |
||
126 |