1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the ModularBundle project. |
||
5 | * |
||
6 | * (c) Anthonius Munthi <https://itstoni.com> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | declare(strict_types=1); |
||
13 | |||
14 | namespace Doyo\Bundle\Modular\Application; |
||
15 | |||
16 | use Doctrine\Inflector\InflectorFactory; |
||
17 | use ReflectionClass; |
||
18 | |||
19 | trait ModuleTrait |
||
20 | { |
||
21 | protected string $name; |
||
22 | protected string $basePath; |
||
23 | protected string $namespace; |
||
24 | |||
25 | public function boot(): void |
||
26 | { |
||
27 | $inflector = InflectorFactory::create()->build(); |
||
28 | $r = new ReflectionClass(__CLASS__); |
||
29 | |||
30 | $className = str_replace('Module', '', $r->getShortName()); |
||
31 | $this->name = $inflector->tableize($className); |
||
32 | $this->basePath = \dirname($r->getFileName()); |
||
33 | $this->namespace = $r->getNamespaceName(); |
||
34 | } |
||
35 | |||
36 | public function getName(): string |
||
37 | { |
||
38 | return $this->name; |
||
39 | } |
||
40 | |||
41 | public function getBasePath(): string |
||
42 | { |
||
43 | return $this->basePath; |
||
44 | } |
||
45 | |||
46 | public function getNamespace(): string |
||
47 | { |
||
48 | return $this->namespace; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return array<array-key,string|class-string> |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
53 | * @codeCoverageIgnore |
||
54 | */ |
||
55 | public function getResolveTargetEntities(): array |
||
56 | { |
||
57 | return []; |
||
58 | } |
||
59 | } |
||
60 |