|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: arthur |
|
5
|
|
|
* Date: 09.03.19 |
|
6
|
|
|
* Time: 21:51. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Foundation\Core; |
|
10
|
|
|
|
|
11
|
|
|
use Foundation\Abstracts\Events\Event; |
|
12
|
|
|
use Foundation\Abstracts\Jobs\Job; |
|
13
|
|
|
use Foundation\Abstracts\Listeners\Listener; |
|
14
|
|
|
use Foundation\Abstracts\Middleware\Middleware; |
|
15
|
|
|
use Foundation\Abstracts\Observers\Observer; |
|
16
|
|
|
use Foundation\Abstracts\Policies\Policy; |
|
17
|
|
|
use Foundation\Abstracts\Services\Service; |
|
18
|
|
|
use Illuminate\Console\Command; |
|
19
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
20
|
|
|
use Illuminate\Database\Migrations\Migration; |
|
21
|
|
|
use Illuminate\Database\Seeder; |
|
22
|
|
|
use Illuminate\Foundation\Testing\TestCase; |
|
23
|
|
|
use Illuminate\Http\Request; |
|
24
|
|
|
use Illuminate\Http\Resources\Json\JsonResource; |
|
25
|
|
|
use Illuminate\Notifications\Notification; |
|
26
|
|
|
use Illuminate\Routing\Controller; |
|
27
|
|
|
use Illuminate\Support\ServiceProvider; |
|
28
|
|
|
use Illuminate\Validation\Rule; |
|
29
|
|
|
|
|
30
|
|
|
final class Module |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* @var string |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $name; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $path; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* LarapiModule constructor. |
|
44
|
|
|
* @param $name |
|
45
|
102 |
|
*/ |
|
46
|
|
|
public function __construct(string $name, string $path) |
|
47
|
102 |
|
{ |
|
48
|
102 |
|
$this->name = $name; |
|
49
|
102 |
|
$this->path = $path; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return string |
|
54
|
102 |
|
*/ |
|
55
|
|
|
public function getName(): string |
|
56
|
102 |
|
{ |
|
57
|
|
|
return $this->name; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return string |
|
62
|
102 |
|
*/ |
|
63
|
|
|
public function getPath(): string |
|
64
|
102 |
|
{ |
|
65
|
|
|
return $this->path; |
|
66
|
|
|
} |
|
67
|
1 |
|
|
|
68
|
|
|
public function getListeners() |
|
69
|
1 |
|
{ |
|
70
|
|
|
return new Resource('listeners', '/Listeners', $this, Listener::class); |
|
71
|
|
|
} |
|
72
|
102 |
|
|
|
73
|
|
|
public function getConfigs() |
|
74
|
102 |
|
{ |
|
75
|
|
|
return new Resource('configs', '/Config', $this); |
|
76
|
|
|
} |
|
77
|
102 |
|
|
|
78
|
|
|
public function getFactories() |
|
79
|
102 |
|
{ |
|
80
|
|
|
return new Resource('factories', '/Database/factories', $this); |
|
81
|
|
|
} |
|
82
|
102 |
|
|
|
83
|
|
|
public function getEvents() |
|
84
|
102 |
|
{ |
|
85
|
|
|
return new Resource('events', '/Events', $this, Event::class); |
|
86
|
|
|
} |
|
87
|
102 |
|
|
|
88
|
|
|
public function getRoutes() |
|
89
|
102 |
|
{ |
|
90
|
|
|
return new Resource('routes', '/Routes', $this); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function getServices() |
|
94
|
|
|
{ |
|
95
|
|
|
return new Resource('services', '/Services', $this, Service::class); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function getPolicies() |
|
99
|
|
|
{ |
|
100
|
|
|
return new Resource('policies', '/Policies', $this, Policy::class); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
public function getPermissions() |
|
104
|
|
|
{ |
|
105
|
|
|
return new Resource('permissions', '/Permissions', $this); |
|
106
|
|
|
} |
|
107
|
102 |
|
|
|
108
|
|
|
public function getTransformers() |
|
109
|
102 |
|
{ |
|
110
|
|
|
return new Resource('transformers', '/Transformers', $this, JsonResource::class); |
|
111
|
|
|
} |
|
112
|
102 |
|
|
|
113
|
|
|
public function getServiceProviders() |
|
114
|
102 |
|
{ |
|
115
|
|
|
return new Resource('providers', '/Providers', $this, ServiceProvider::class); |
|
116
|
|
|
} |
|
117
|
102 |
|
|
|
118
|
|
|
public function getMigrations() |
|
119
|
102 |
|
{ |
|
120
|
|
|
return new Resource('migrations', '/Database/Migrations', $this, Migration::class); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
public function getModels() |
|
124
|
|
|
{ |
|
125
|
|
|
return new Resource('models', '/Entities', $this, Model::class); |
|
126
|
|
|
} |
|
127
|
102 |
|
|
|
128
|
|
|
public function getObservers() |
|
129
|
102 |
|
{ |
|
130
|
|
|
return new Resource('observers', '/Observers', $this, Observer::class); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
public function getSeeders() |
|
134
|
|
|
{ |
|
135
|
|
|
return new Resource('seeders', '/Database/Seeders', $this, Seeder::class); |
|
136
|
|
|
} |
|
137
|
1 |
|
|
|
138
|
|
|
public function getRequests() |
|
139
|
1 |
|
{ |
|
140
|
|
|
return new Resource('requests', '/Http/Requests', $this, Request::class); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
public function getRules() |
|
144
|
|
|
{ |
|
145
|
|
|
return new Resource('rules', '/Rules', $this, Rule::class); |
|
146
|
|
|
} |
|
147
|
102 |
|
|
|
148
|
|
|
public function getMiddleWare() |
|
149
|
102 |
|
{ |
|
150
|
|
|
return new Resource('middleware', '/Http/Middleware', $this, MiddleWare::class); |
|
151
|
|
|
} |
|
152
|
1 |
|
|
|
153
|
|
|
public function getTests() |
|
154
|
1 |
|
{ |
|
155
|
|
|
return new Resource('tests', '/Tests', $this, TestCase::class); |
|
156
|
|
|
} |
|
157
|
102 |
|
|
|
158
|
|
|
public function getCommands() |
|
159
|
102 |
|
{ |
|
160
|
|
|
return new Resource('commands', '/Console', $this, Command::class); |
|
161
|
|
|
} |
|
162
|
1 |
|
|
|
163
|
|
|
public function getNotifications() |
|
164
|
1 |
|
{ |
|
165
|
|
|
return new Resource('notifications', '/Notifications', $this, Notification::class); |
|
166
|
|
|
} |
|
167
|
102 |
|
|
|
168
|
|
|
public function getControllers() |
|
169
|
102 |
|
{ |
|
170
|
|
|
return new Resource('controllers', '/Http/Controllers', $this, Controller::class); |
|
171
|
|
|
} |
|
172
|
102 |
|
|
|
173
|
|
|
public function getJobs() |
|
174
|
102 |
|
{ |
|
175
|
|
|
return new Resource('jobs', '/Jobs', $this, Job::class); |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
public function getNamespace(): string |
|
179
|
|
|
{ |
|
180
|
|
|
return 'Modules' . '\\' . $this->getName(); |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
public function getMainModel() |
|
184
|
|
|
{ |
|
185
|
|
|
return $this->getModels()->getClassByName($this->getName()); |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
public function exists(): bool |
|
189
|
|
|
{ |
|
190
|
|
|
return file_exists($this->getPath()); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
public function doesNotExist() |
|
194
|
|
|
{ |
|
195
|
|
|
return !$this->exists(); |
|
196
|
|
|
} |
|
197
|
|
|
} |
|
198
|
|
|
|