|
15 | 15 |
|
16 | 16 | final class NamespacesHelper |
17 | 17 | { |
18 | | - /** @var string */ |
19 | | - private $command; |
20 | | - |
21 | | - /** @var string */ |
22 | | - private $controller; |
23 | | - |
24 | | - /** @var string */ |
25 | | - private $entity; |
26 | | - |
27 | | - /** @var string */ |
28 | | - private $fixtures; |
29 | | - |
30 | | - /** @var string */ |
31 | | - private $form; |
32 | | - |
33 | | - /** @var string */ |
34 | | - private $functionalTest; |
35 | | - |
36 | | - /** @var string */ |
37 | | - private $repository; |
38 | | - |
39 | | - /** @var string */ |
40 | | - private $root; |
41 | | - |
42 | | - /** @var string */ |
43 | | - private $security; |
44 | | - |
45 | | - /** @var string */ |
46 | | - private $serializer; |
47 | | - |
48 | | - /** @var string */ |
49 | | - private $subscriber; |
50 | | - |
51 | | - /** @var string */ |
52 | | - private $twig; |
53 | | - |
54 | | - /** @var string */ |
55 | | - private $unitTest; |
56 | | - |
57 | | - /** @var string */ |
58 | | - private $validator; |
59 | | - |
60 | | - public function __construct( |
61 | | - string $root, |
62 | | - string $command = null, |
63 | | - string $controller = null, |
64 | | - string $entity = null, |
65 | | - string $fixtures = null, |
66 | | - string $form = null, |
67 | | - string $functionalTest = null, |
68 | | - string $repository = null, |
69 | | - string $security = null, |
70 | | - string $serializer = null, |
71 | | - string $subscriber = null, |
72 | | - string $twig = null, |
73 | | - string $unitTest = null, |
74 | | - string $validator = null |
75 | | - ) { |
76 | | - $this->root = $root; |
77 | | - $this->command = $command ?? 'Command\\'; |
78 | | - $this->controller = $controller ?? 'Controller\\'; |
79 | | - $this->entity = $entity ?? 'Entity\\'; |
80 | | - $this->fixtures = $fixtures ?? 'DataFixtures\\'; |
81 | | - $this->form = $form ?? 'Form\\'; |
82 | | - $this->functionalTest = $functionalTest ?? 'Tests\\'; |
83 | | - $this->repository = $repository ?? 'Repository\\'; |
84 | | - $this->security = $security ?? 'Security\\'; |
85 | | - $this->serializer = $serializer ?? 'Serializer\\'; |
86 | | - $this->subscriber = $subscriber ?? 'EventSubscriber\\'; |
87 | | - $this->twig = $twig ?? 'Twig\\'; |
88 | | - $this->unitTest = $unitTest ?? 'Tests\\'; |
89 | | - $this->validator = $validator ?? 'Validator\\'; |
| 18 | + /** @var string[] */ |
| 19 | + private $namespaces; |
| 20 | + |
| 21 | + public function __construct(array $namespaces = null) |
| 22 | + { |
| 23 | + $this->namespaces = $namespaces ?? []; |
90 | 24 | } |
91 | 25 |
|
92 | 26 | public function getCommandNamespace(): string |
93 | 27 | { |
94 | | - return $this->trim($this->command); |
| 28 | + return $this->trim($this->namespaces['command_namespace'] ?? 'Command\\'); |
95 | 29 | } |
96 | 30 |
|
97 | 31 | public function getControllerNamespace(): string |
98 | 32 | { |
99 | | - return $this->trim($this->controller); |
| 33 | + return $this->trim($this->namespaces['controller_namespace'] ?? 'Controller\\'); |
100 | 34 | } |
101 | 35 |
|
102 | 36 | public function getEntityNamespace(): string |
103 | 37 | { |
104 | | - return $this->trim($this->entity); |
| 38 | + return $this->trim($this->namespaces['entity_namespace'] ?? 'Entity\\'); |
105 | 39 | } |
106 | 40 |
|
107 | 41 | public function getFixturesNamespace(): string |
108 | 42 | { |
109 | | - return $this->trim($this->fixtures); |
| 43 | + return $this->trim($this->namespaces['fixtures_namespace'] ?? 'DataFixtures\\'); |
110 | 44 | } |
111 | 45 |
|
112 | 46 | public function getFormNamespace(): string |
113 | 47 | { |
114 | | - return $this->trim($this->form); |
| 48 | + return $this->trim($this->namespaces['form_namespace'] ?? 'Form\\'); |
115 | 49 | } |
116 | 50 |
|
117 | 51 | public function getFunctionalTestNamespace(): string |
118 | 52 | { |
119 | | - return $this->trim($this->functionalTest); |
| 53 | + return $this->trim($this->namespaces['functional_test_namespace'] ?? 'Tests\\'); |
120 | 54 | } |
121 | 55 |
|
122 | 56 | public function getRepositoryNamespace(): string |
123 | 57 | { |
124 | | - return $this->trim($this->repository); |
| 58 | + return $this->trim($this->namespaces['repository_namespace'] ?? 'Repository\\'); |
125 | 59 | } |
126 | 60 |
|
127 | 61 | public function getRootNamespace(): string |
128 | 62 | { |
129 | | - return $this->trim($this->root); |
| 63 | + return $this->trim($this->namespaces['root_namespace'] ?? 'App\\'); |
130 | 64 | } |
131 | 65 |
|
132 | 66 | public function getSecurityNamespace(): string |
133 | 67 | { |
134 | | - return $this->trim($this->security); |
| 68 | + return $this->trim($this->namespaces['security_namespace'] ?? 'Security\\'); |
135 | 69 | } |
136 | 70 |
|
137 | 71 | public function getSerializerNamespace(): string |
138 | 72 | { |
139 | | - return $this->trim($this->serializer); |
| 73 | + return $this->trim($this->namespaces['serializer_namespace'] ?? 'Serializer\\'); |
140 | 74 | } |
141 | 75 |
|
142 | 76 | public function getSubscriberNamespace(): string |
143 | 77 | { |
144 | | - return $this->trim($this->subscriber); |
| 78 | + return $this->trim($this->namespaces['subscriber_namespace'] ?? 'EventSubscriber\\'); |
145 | 79 | } |
146 | 80 |
|
147 | 81 | public function getTwigNamespace(): string |
148 | 82 | { |
149 | | - return $this->trim($this->twig); |
| 83 | + return $this->trim($this->namespaces['twig_namespace'] ?? 'Twig\\'); |
150 | 84 | } |
151 | 85 |
|
152 | 86 | public function getUnitTestNamespace(): string |
153 | 87 | { |
154 | | - return $this->trim($this->unitTest); |
| 88 | + return $this->trim($this->namespaces['unit_test_namespace'] ?? 'Tests\\'); |
155 | 89 | } |
156 | 90 |
|
157 | 91 | public function getValidatorNamespace(): string |
158 | 92 | { |
159 | | - return $this->trim($this->validator); |
| 93 | + return $this->trim($this->namespaces['validator_namespace'] ?? 'Validator\\'); |
160 | 94 | } |
161 | 95 |
|
162 | 96 | /** |
|
0 commit comments