Completed
Push — master ( 3bff69...1d4f77 )
by Craig
05:53
created
src/system/ThemeModule/Engine/Engine.php 1 patch
Braces   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
  * @see https://github.com/zikula/SpecTheme
46 46
  * Themes can define 'realms' which determine specific templates based on Request
47 47
  */
48
-class Engine
49
-{
48
+class Engine
49
+{
50 50
     /**
51 51
      * The instance of the currently active theme.
52 52
      *
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         ZikulaHttpKernelInterface $kernel,
100 100
         AssetFilter $filter,
101 101
         VariableApiInterface $variableApi
102
-    ) {
102
+    ) {
103 103
         $this->requestStack = $requestStack;
104 104
         $this->annotationReader = $annotationReader;
105 105
         $this->kernel = $kernel;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function getTheme(): ?AbstractTheme
149 149
     {
150
-        if (!isset($this->activeThemeBundle) && $this->kernel->getContainer()->getParameter('installed')) {
150
+        if (!isset($this->activeThemeBundle) && $this->kernel->getContainer()->getParameter('installed')) {
151 151
             $this->setActiveTheme();
152 152
         }
153 153
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     public function getRealm(): string
162 162
     {
163
-        if (!isset($this->realm)) {
163
+        if (!isset($this->realm)) {
164 164
             $this->setMatchingRealm();
165 165
         }
166 166
 
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
      * @throws ReflectionException
182 182
      * @api Core-2.0
183 183
      */
184
-    public function changeThemeByAnnotation(string $controllerClassName, string $method)
185
-    {
184
+    public function changeThemeByAnnotation(string $controllerClassName, string $method)
185
+    {
186 186
         $reflectionClass = new ReflectionClass($controllerClassName);
187 187
         $reflectionMethod = $reflectionClass->getMethod($method);
188 188
         $themeAnnotation = $this->annotationReader->getMethodAnnotation($reflectionMethod, Theme::class);
189
-        if (isset($themeAnnotation)) {
189
+        if (isset($themeAnnotation)) {
190 190
             // method annotations contain `@Theme` so set theme based on value
191 191
             $this->annotationValue = $themeAnnotation->value;
192
-            switch ($themeAnnotation->value) {
192
+            switch ($themeAnnotation->value) {
193 193
                 case 'admin':
194 194
                     $newThemeName = $this->variableApi->get('ZikulaAdminModule', 'admintheme', '');
195 195
                     break;
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
                 default:
206 206
                     $newThemeName = $themeAnnotation->value;
207 207
             }
208
-            if (!empty($newThemeName)) {
208
+            if (!empty($newThemeName)) {
209 209
                 $this->setActiveTheme($newThemeName);
210 210
 
211 211
                 return $newThemeName;
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
     public function positionIsAvailableInTheme(string $name): bool
219 219
     {
220 220
         $config = $this->getTheme()->getConfig();
221
-        if (empty($config)) {
221
+        if (empty($config)) {
222 222
             return true;
223 223
         }
224
-        foreach ($config as $realm => $definition) {
225
-            if (isset($definition['block']['positions'][$name])) {
224
+        foreach ($config as $realm => $definition) {
225
+            if (isset($definition['block']['positions'][$name])) {
226 226
                 return true;
227 227
             }
228 228
         }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
     {
246 246
         $themeConfig = $this->getTheme()->getConfig();
247 247
         // defining an admin realm overrides all other options for 'admin' annotated methods
248
-        if ('admin' === $this->annotationValue && isset($themeConfig['admin'])) {
248
+        if ('admin' === $this->annotationValue && isset($themeConfig['admin'])) {
249 249
             $this->realm = 'admin';
250 250
 
251 251
             return;
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
         $pathInfo = null;
254 254
         $requestAttributes = [];
255 255
         $request = $this->requestStack->getMasterRequest();
256
-        if (null !== $request) {
256
+        if (null !== $request) {
257 257
             $requestAttributes = $request->attributes->all();
258 258
             // match `/` for home realm
259
-            if (isset($requestAttributes['_route']) && 'home' === $requestAttributes['_route']) {
259
+            if (isset($requestAttributes['_route']) && 'home' === $requestAttributes['_route']) {
260 260
                 $this->realm = 'home';
261 261
 
262 262
                 return;
@@ -265,22 +265,22 @@  discard block
 block discarded – undo
265 265
         }
266 266
 
267 267
         unset($themeConfig['admin'], $themeConfig['home'], $themeConfig['master']); // remove to avoid scanning/matching in loop
268
-        foreach ($themeConfig as $realm => $config) {
269
-            if (!empty($config['pattern'])) {
268
+        foreach ($themeConfig as $realm => $config) {
269
+            if (!empty($config['pattern'])) {
270 270
                 $pattern = ';' . str_replace('/', '\\/', $config['pattern']) . ';i'; // delimiters are ; and i means case-insensitive
271 271
                 $valuesToMatch = [];
272
-                if (isset($pathInfo)) {
272
+                if (isset($pathInfo)) {
273 273
                     $valuesToMatch[] = $pathInfo; // e.g. /pages/display/welcome-to-pages-content-manager
274 274
                 }
275
-                if (isset($requestAttributes['_route'])) {
275
+                if (isset($requestAttributes['_route'])) {
276 276
                     $valuesToMatch[] = $requestAttributes['_route']; // e.g. zikulapagesmodule_user_display
277 277
                 }
278
-                if (isset($requestAttributes['_zkModule'])) {
278
+                if (isset($requestAttributes['_zkModule'])) {
279 279
                     $valuesToMatch[] = $requestAttributes['_zkModule']; // e.g. zikulapagesmodule
280 280
                 }
281
-                foreach ($valuesToMatch as $value) {
281
+                foreach ($valuesToMatch as $value) {
282 282
                     $match = preg_match($pattern, $value);
283
-                    if (1 === $match) {
283
+                    if (1 === $match) {
284 284
                         $this->realm = $realm;
285 285
 
286 286
                         return; // use first match and do not continue to attempt to match patterns
Please login to merge, or discard this patch.
src/system/ExtensionsModule/AbstractCoreTheme.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,6 +13,6 @@
 block discarded – undo
13 13
 
14 14
 namespace Zikula\ExtensionsModule;
15 15
 
16
-abstract class AbstractCoreTheme extends AbstractTheme
17
-{
16
+abstract class AbstractCoreTheme extends AbstractTheme
17
+{
18 18
 }
Please login to merge, or discard this patch.
src/system/ExtensionsModule/AbstractTheme.php 1 patch
Braces   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 use Twig\Environment;
20 20
 use Zikula\ExtensionsModule\Api\VariableApi;
21 21
 
22
-abstract class AbstractTheme extends AbstractExtension
23
-{
22
+abstract class AbstractTheme extends AbstractExtension
23
+{
24 24
     /**
25 25
      * @var array
26 26
      */
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
     /**
40 40
      * Load the theme configuration from the config/theme.yaml file.
41 41
      */
42
-    public function __construct()
43
-    {
42
+    public function __construct()
43
+    {
44 44
         $this->config = [];
45 45
 
46 46
         $configPath = $this->getConfigPath() . '/theme.yaml';
47
-        if (!file_exists($configPath)) {
47
+        if (!file_exists($configPath)) {
48 48
             return;
49 49
         }
50 50
 
51 51
         $this->config = Yaml::parse(file_get_contents($configPath));
52
-        if (!isset($this->config['master'])) {
52
+        if (!isset($this->config['master'])) {
53 53
             throw new InvalidConfigurationException('Core-2.0 themes must have a defined master realm.');
54 54
         }
55 55
     }
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
         string $blockContent,
89 89
         string $blockTitle
90 90
     ): string {
91
-        if (isset($this->config[$realm]['block']['positions'][$positionName])) {
91
+        if (isset($this->config[$realm]['block']['positions'][$positionName])) {
92 92
             $template = '@' . $this->name . '/' . $this->config[$realm]['block']['positions'][$positionName];
93
-        } else {
93
+        } else {
94 94
             // block position not defined, provide a default template
95 95
             $template = '@ZikulaThemeModule/Default/block.html.twig';
96 96
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function loadThemeVars(): void
128 128
     {
129
-        if ($this->getContainer()->has('zikula_core.common.theme.themevars')) {
129
+        if ($this->getContainer()->has('zikula_core.common.theme.themevars')) {
130 130
             $this->getContainer()->get('zikula_core.common.theme.themevars')->replace($this->getThemeVars());
131 131
         }
132 132
     }
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
     {
139 139
         $variableApi = $this->container->get(VariableApi::class);
140 140
         $dbVars = $variableApi->getAll($this->name);
141
-        if (empty($dbVars) && !is_array($dbVars)) {
141
+        if (empty($dbVars) && !is_array($dbVars)) {
142 142
             $dbVars = [];
143 143
         }
144 144
         $defaultVars = $this->getDefaultThemeVars();
145 145
         $combinedVars = array_merge($defaultVars, $dbVars);
146
-        if (array_keys($dbVars) !== array_keys($combinedVars)) {
146
+        if (array_keys($dbVars) !== array_keys($combinedVars)) {
147 147
             // First load of file or vars have been added to the YAML file.
148 148
             $variableApi->setAll($this->name, $combinedVars);
149 149
         }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     {
159 159
         $defaultVars = [];
160 160
         $themeVarsPath = $this->getConfigPath() . '/variables.yaml';
161
-        if (!file_exists($themeVarsPath)) {
161
+        if (!file_exists($themeVarsPath)) {
162 162
             return $defaultVars;
163 163
         }
164 164
 
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
         }*/
168 168
 
169 169
         $yamlVars = Yaml::parse(file_get_contents($themeVarsPath));
170
-        if (!is_array($yamlVars)) {
170
+        if (!is_array($yamlVars)) {
171 171
             $yamlVars = [];
172 172
         }
173
-        foreach ($yamlVars as $name => $definition) {
173
+        foreach ($yamlVars as $name => $definition) {
174 174
             $defaultVars[$name] = $definition['default_value'];
175 175
         }
176 176
 
Please login to merge, or discard this patch.
src/system/ExtensionsModule/AbstractModule.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
 
14 14
 namespace Zikula\ExtensionsModule;
15 15
 
16
-abstract class AbstractModule extends AbstractExtension
17
-{
16
+abstract class AbstractModule extends AbstractExtension
17
+{
18 18
     public function getNameType(): string
19 19
     {
20 20
         return 'Module';
Please login to merge, or discard this patch.
src/system/ExtensionsModule/Controller/ExtensionController.php 1 patch
Braces   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
  * Class ExtensionController
51 51
  * @Route("")
52 52
  */
53
-class ExtensionController extends AbstractController
54
-{
53
+class ExtensionController extends AbstractController
54
+{
55 55
     private const NEW_ROUTES_AVAIL = 'new.routes.avail';
56 56
 
57 57
     /**
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
         RouterInterface $router,
70 70
         int $pos = 1
71 71
     ): array {
72
-        if (!$this->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
72
+        if (!$this->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
73 73
             throw new AccessDeniedException();
74 74
         }
75 75
         $modulesJustInstalled = $request->query->get('justinstalled');
76
-        if (!empty($modulesJustInstalled)) {
76
+        if (!empty($modulesJustInstalled)) {
77 77
             // notify the event dispatcher that new routes are available (ids of modules just installed avail as args)
78 78
             $event = new GenericEvent(null, json_decode($modulesJustInstalled));
79 79
             $eventDispatcher->dispatch($event, self::NEW_ROUTES_AVAIL);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         $upgradedExtensions = [];
87 87
         $vetoEvent = new GenericEvent();
88 88
         $eventDispatcher->dispatch($vetoEvent, ExtensionEvents::REGENERATE_VETO);
89
-        if (1 === $pos && !$vetoEvent->isPropagationStopped()) {
89
+        if (1 === $pos && !$vetoEvent->isPropagationStopped()) {
90 90
             // regenerate the extension list only when viewing the first page
91 91
             $extensionsInFileSystem = $bundleSyncHelper->scanForBundles();
92 92
             $upgradedExtensions = $bundleSyncHelper->syncExtensions($extensionsInFileSystem);
@@ -121,19 +121,19 @@  discard block
 block discarded – undo
121 121
         ExtensionStateHelper $extensionStateHelper,
122 122
         CacheClearer $cacheClearer
123 123
     ): RedirectResponse {
124
-        if (!$this->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
124
+        if (!$this->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
125 125
             throw new AccessDeniedException();
126 126
         }
127 127
 
128
-        if (!$this->isCsrfTokenValid('activate-extension', $token)) {
128
+        if (!$this->isCsrfTokenValid('activate-extension', $token)) {
129 129
             throw new AccessDeniedException();
130 130
         }
131 131
 
132 132
         /** @var ExtensionEntity $extension */
133 133
         $extension = $extensionRepository->find($id);
134
-        if (Constant::STATE_NOTALLOWED === $extension->getState()) {
134
+        if (Constant::STATE_NOTALLOWED === $extension->getState()) {
135 135
             $this->addFlash('error', $this->trans('Error! Activation of %name% not allowed.', ['%name%' => $extension->getName()]));
136
-        } else {
136
+        } else {
137 137
             // Update state
138 138
             $extensionStateHelper->updateState($id, Constant::STATE_ACTIVE);
139 139
             $cacheClearer->clear('symfony');
@@ -157,21 +157,21 @@  discard block
 block discarded – undo
157 157
         ExtensionStateHelper $extensionStateHelper,
158 158
         CacheClearer $cacheClearer
159 159
     ): RedirectResponse {
160
-        if (!$this->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
160
+        if (!$this->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
161 161
             throw new AccessDeniedException();
162 162
         }
163 163
 
164
-        if (!$this->isCsrfTokenValid('deactivate-extension', $token)) {
164
+        if (!$this->isCsrfTokenValid('deactivate-extension', $token)) {
165 165
             throw new AccessDeniedException();
166 166
         }
167 167
         // @todo check if this is a theme and currently set as default or admin theme
168 168
 
169 169
         /** @var ExtensionEntity $extension */
170 170
         $extension = $extensionRepository->find($id);
171
-        if (null !== $extension) {
172
-            if (ZikulaKernel::isCoreExtension($extension->getName())) {
171
+        if (null !== $extension) {
172
+            if (ZikulaKernel::isCoreExtension($extension->getName())) {
173 173
                 $this->addFlash('error', $this->trans('Error! You cannot deactivate the %name%. It is required by the system.', ['%name%' => $extension->getName()]));
174
-            } else {
174
+            } else {
175 175
                 // Update state
176 176
                 $extensionStateHelper->updateState($id, Constant::STATE_INACTIVE);
177 177
                 $cacheClearer->clear('symfony');
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
         ExtensionEntity $extension,
199 199
         CacheClearer $cacheClearer,
200 200
         bool $forceDefaults = false
201
-    ) {
202
-        if (!$this->hasPermission('ZikulaExtensionsModule::modify', $extension->getName() . '::' . $extension->getId(), ACCESS_ADMIN)) {
201
+    ) {
202
+        if (!$this->hasPermission('ZikulaExtensionsModule::modify', $extension->getName() . '::' . $extension->getId(), ACCESS_ADMIN)) {
203 203
             throw new AccessDeniedException();
204 204
         }
205 205
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         $extensionBundle = $kernel->getBundle($extension->getName());
208 208
         $metaData = $extensionBundle->getMetaData()->getFilteredVersionInfoArray();
209 209
 
210
-        if ($forceDefaults) {
210
+        if ($forceDefaults) {
211 211
             $extension->setName($metaData['name']);
212 212
             $extension->setUrl($metaData['url']);
213 213
             $extension->setDescription($metaData['description']);
@@ -215,20 +215,20 @@  discard block
 block discarded – undo
215 215
 
216 216
         $form = $this->createForm(ExtensionModifyType::class, $extension);
217 217
         $form->handleRequest($request);
218
-        if ($form->isSubmitted() && $form->isValid()) {
219
-            if ($form->get('defaults')->isClicked()) {
218
+        if ($form->isSubmitted() && $form->isValid()) {
219
+            if ($form->get('defaults')->isClicked()) {
220 220
                 $this->addFlash('info', 'Default values reloaded. Save to confirm.');
221 221
 
222 222
                 return $this->redirectToRoute('zikulaextensionsmodule_extension_modify', ['id' => $extension->getId(), 'forceDefaults' => 1]);
223 223
             }
224
-            if ($form->get('save')->isClicked()) {
224
+            if ($form->get('save')->isClicked()) {
225 225
                 $em = $this->getDoctrine()->getManager();
226 226
                 $em->persist($extension);
227 227
                 $em->flush();
228 228
 
229 229
                 $cacheClearer->clear('symfony');
230 230
                 $this->addFlash('status', 'Done! Extension updated.');
231
-            } elseif ($form->get('cancel')->isClicked()) {
231
+            } elseif ($form->get('cancel')->isClicked()) {
232 232
                 $this->addFlash('status', 'Operation cancelled.');
233 233
             }
234 234
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      */
252 252
     public function compatibilityAction(ExtensionEntity $extension): array
253 253
     {
254
-        if (!$this->hasPermission('ZikulaExtensionsModule::', $extension->getName() . '::' . $extension->getId(), ACCESS_ADMIN)) {
254
+        if (!$this->hasPermission('ZikulaExtensionsModule::', $extension->getName() . '::' . $extension->getId(), ACCESS_ADMIN)) {
255 255
             throw new AccessDeniedException();
256 256
         }
257 257
 
@@ -280,17 +280,17 @@  discard block
 block discarded – undo
280 280
         ExtensionStateHelper $extensionStateHelper,
281 281
         ExtensionDependencyHelper $dependencyHelper,
282 282
         CacheClearer $cacheClearer
283
-    ) {
284
-        if (!$this->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
283
+    ) {
284
+        if (!$this->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
285 285
             throw new AccessDeniedException();
286 286
         }
287 287
 
288 288
         $id = $extension->getId();
289
-        if (!$this->isCsrfTokenValid('install-extension', $token)) {
289
+        if (!$this->isCsrfTokenValid('install-extension', $token)) {
290 290
             throw new AccessDeniedException();
291 291
         }
292 292
 
293
-        if (!$kernel->isBundle($extension->getName())) {
293
+        if (!$kernel->isBundle($extension->getName())) {
294 294
             $extensionStateHelper->updateState($id, Constant::STATE_TRANSITIONAL);
295 295
             $cacheClearer->clear('symfony');
296 296
 
@@ -302,28 +302,28 @@  discard block
 block discarded – undo
302 302
         ]);
303 303
         $hasNoUnsatisfiedDependencies = empty($unsatisfiedDependencies);
304 304
         $form->handleRequest($request);
305
-        if ($hasNoUnsatisfiedDependencies || ($form->isSubmitted() && $form->isValid())) {
306
-            if ($hasNoUnsatisfiedDependencies || $form->get('install')->isClicked()) {
305
+        if ($hasNoUnsatisfiedDependencies || ($form->isSubmitted() && $form->isValid())) {
306
+            if ($hasNoUnsatisfiedDependencies || $form->get('install')->isClicked()) {
307 307
                 $extensionsInstalled = [];
308 308
                 $data = $form->getData();
309
-                foreach ($data['dependencies'] as $dependencyId => $installSelected) {
310
-                    if (!$installSelected && MetaData::DEPENDENCY_REQUIRED !== $unsatisfiedDependencies[$dependencyId]->getStatus()) {
309
+                foreach ($data['dependencies'] as $dependencyId => $installSelected) {
310
+                    if (!$installSelected && MetaData::DEPENDENCY_REQUIRED !== $unsatisfiedDependencies[$dependencyId]->getStatus()) {
311 311
                         continue;
312 312
                     }
313 313
                     $dependencyExtensionEntity = $extensionRepository->get($unsatisfiedDependencies[$dependencyId]->getModname());
314
-                    if (isset($dependencyExtensionEntity)) {
315
-                        if (!$extensionHelper->install($dependencyExtensionEntity)) {
314
+                    if (isset($dependencyExtensionEntity)) {
315
+                        if (!$extensionHelper->install($dependencyExtensionEntity)) {
316 316
                             $this->addFlash('error', $this->trans('Failed to install dependency "%name%"!', ['%name%' => $dependencyExtensionEntity->getName()]));
317 317
 
318 318
                             return $this->redirectToRoute('zikulaextensionsmodule_extension_list');
319 319
                         }
320 320
                         $extensionsInstalled[] = $dependencyExtensionEntity->getId();
321 321
                         $this->addFlash('status', $this->trans('Installed dependency "%name%".', ['%name%' => $dependencyExtensionEntity->getName()]));
322
-                    } else {
322
+                    } else {
323 323
                         $this->addFlash('warning', $this->trans('Warning: could not install selected dependency "%name%".', ['%name%' => $unsatisfiedDependencies[$dependencyId]->getModname()]));
324 324
                     }
325 325
                 }
326
-                if ($extensionHelper->install($extension)) {
326
+                if ($extensionHelper->install($extension)) {
327 327
                     $this->addFlash('status', $this->trans('Done! Installed "%name%".', ['%name%' => $extension->getName()]));
328 328
                     $extensionsInstalled[] = $id;
329 329
                     $cacheClearer->clear('symfony');
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
                 $extensionStateHelper->updateState($id, Constant::STATE_UNINITIALISED);
334 334
                 $this->addFlash('error', $this->trans('Initialization of "%name%" failed!', ['%name%' => $extension->getName()]));
335 335
             }
336
-            if ($form->get('cancel')->isClicked()) {
336
+            if ($form->get('cancel')->isClicked()) {
337 337
                 $extensionStateHelper->updateState($id, Constant::STATE_UNINITIALISED);
338 338
                 $this->addFlash('status', 'Operation cancelled.');
339 339
             }
@@ -360,17 +360,17 @@  discard block
 block discarded – undo
360 360
         EventDispatcherInterface $eventDispatcher,
361 361
         string $extensions = null
362 362
     ): RedirectResponse {
363
-        if (!empty($extensions)) {
363
+        if (!empty($extensions)) {
364 364
             $extensions = json_decode($extensions);
365
-            foreach ($extensions as $extensionId) {
365
+            foreach ($extensions as $extensionId) {
366 366
                 /** @var ExtensionEntity $extensionEntity */
367 367
                 $extensionEntity = $extensionRepository->find($extensionId);
368
-                if (null === $extensionRepository) {
368
+                if (null === $extensionRepository) {
369 369
                     continue;
370 370
                 }
371 371
                 /** @var AbstractExtension $extensionBundle */
372 372
                 $extensionBundle = $kernel->getBundle($extensionEntity->getName());
373
-                if (null === $extensionBundle) {
373
+                if (null === $extensionBundle) {
374 374
                     continue;
375 375
                 }
376 376
                 $event = new ExtensionStateEvent($extensionBundle, $extensionEntity->toArray());
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
         array $dependencies
390 390
     ): array {
391 391
         $return = [];
392
-        foreach ($dependencies as $dependency) {
392
+        foreach ($dependencies as $dependency) {
393 393
             /** @var ExtensionEntity $dependencyExtension */
394 394
             $dependencyExtension = $extensionRepository->get($dependency->getModname());
395 395
             $return[$dependency->getId()] = null !== $dependencyExtension;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
         $token,
411 411
         ExtensionHelper $extensionHelper
412 412
     ): RedirectResponse {
413
-        if (!$this->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
413
+        if (!$this->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
414 414
             throw new AccessDeniedException();
415 415
         }
416 416
 
417
-        if (!$this->isCsrfTokenValid('upgrade-extension', $token)) {
417
+        if (!$this->isCsrfTokenValid('upgrade-extension', $token)) {
418 418
             throw new AccessDeniedException();
419 419
         }
420 420
 
421 421
         $result = $extensionHelper->upgrade($extension);
422
-        if ($result) {
422
+        if ($result) {
423 423
             $this->addFlash('status', $this->trans('%name% upgraded to new version and activated.', ['%name%' => $extension->getDisplayname()]));
424
-        } else {
424
+        } else {
425 425
             $this->addFlash('error', 'Extension upgrade failed!');
426 426
         }
427 427
 
@@ -448,19 +448,19 @@  discard block
 block discarded – undo
448 448
         ExtensionStateHelper $extensionStateHelper,
449 449
         ExtensionDependencyHelper $dependencyHelper,
450 450
         CacheClearer $cacheClearer
451
-    ) {
452
-        if (!$this->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
451
+    ) {
452
+        if (!$this->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
453 453
             throw new AccessDeniedException();
454 454
         }
455 455
 
456
-        if (!$this->isCsrfTokenValid('uninstall-extension', $token)) {
456
+        if (!$this->isCsrfTokenValid('uninstall-extension', $token)) {
457 457
             throw new AccessDeniedException();
458 458
         }
459 459
 
460
-        if (Constant::STATE_MISSING === $extension->getState()) {
460
+        if (Constant::STATE_MISSING === $extension->getState()) {
461 461
             throw new RuntimeException($this->trans('Error! The requested extension cannot be uninstalled because its files are missing!'));
462 462
         }
463
-        if (!$kernel->isBundle($extension->getName())) {
463
+        if (!$kernel->isBundle($extension->getName())) {
464 464
             $extensionStateHelper->updateState($extension->getId(), Constant::STATE_TRANSITIONAL);
465 465
             $cacheClearer->clear('symfony');
466 466
         }
@@ -474,10 +474,10 @@  discard block
 block discarded – undo
474 474
             ]),
475 475
         ]);
476 476
         $form->handleRequest($request);
477
-        if ($form->isSubmitted() && $form->isValid()) {
478
-            if ($form->get('delete')->isClicked()) {
477
+        if ($form->isSubmitted() && $form->isValid()) {
478
+            if ($form->get('delete')->isClicked()) {
479 479
                 // remove dependent extensions
480
-                if (!$extensionHelper->uninstallArray($requiredDependents)) {
480
+                if (!$extensionHelper->uninstallArray($requiredDependents)) {
481 481
                     $this->addFlash('error', 'Error: Could not uninstall dependent extensions.');
482 482
 
483 483
                     return $this->redirectToRoute('zikulaextensionsmodule_extension_list');
@@ -486,12 +486,12 @@  discard block
 block discarded – undo
486 486
                 $blockRepository->remove($blocks);
487 487
 
488 488
                 // remove the extension
489
-                if ($extensionHelper->uninstall($extension)) {
489
+                if ($extensionHelper->uninstall($extension)) {
490 490
                     $this->addFlash('status', 'Done! Uninstalled extension.');
491
-                } else {
491
+                } else {
492 492
                     $this->addFlash('error', 'Extension removal failed! (note: blocks and dependents may have been removed)');
493 493
                 }
494
-            } elseif ($form->get('cancel')->isClicked()) {
494
+            } elseif ($form->get('cancel')->isClicked()) {
495 495
                 $this->addFlash('status', 'Operation cancelled.');
496 496
             }
497 497
 
Please login to merge, or discard this patch.
src/system/ExtensionsModule/Event/ExtensionStateEvent.php 1 patch
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 /**
20 20
  * Class ExtensionStateEvent
21 21
  */
22
-class ExtensionStateEvent extends Event
23
-{
22
+class ExtensionStateEvent extends Event
23
+{
24 24
     /**
25 25
      * @var null|AbstractExtension The module instance. Null when Module object is not available
26 26
      */
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
      */
34 34
     private $info;
35 35
 
36
-    public function __construct(AbstractExtension $extension = null, array $info = null)
37
-    {
36
+    public function __construct(AbstractExtension $extension = null, array $info = null)
37
+    {
38 38
         $this->extension = $extension;
39 39
         $this->info = $info;
40 40
     }
Please login to merge, or discard this patch.
src/system/ExtensionsModule/Installer/AbstractExtensionInstaller.php 1 patch
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
         $this->name = $extension->getName();
78 78
     }
79 79
 
80
-    public function setContainer(ContainerInterface $container = null)
81
-    {
80
+    public function setContainer(ContainerInterface $container = null)
81
+    {
82 82
         $this->extensionName = $this->name; // for ExtensionVariablesTrait
83 83
         $this->container = $container;
84
-        if (null === $container) {
84
+        if (null === $container) {
85 85
             return;
86 86
         }
87 87
         $this->setTranslator($container->get('translator'));
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
     public function addFlash(string $type, string $message): void
97 97
     {
98 98
         $request = $this->container->get('request_stack')->getCurrentRequest();
99
-        if (null === $request) {
99
+        if (null === $request) {
100 100
             echo ucfirst($type) . ': ' . $message . "\n";
101 101
 
102 102
             return;
103 103
         }
104
-        if (!$request->hasSession()) {
104
+        if (!$request->hasSession()) {
105 105
             throw new LogicException('You can not use the addFlash method if sessions are disabled.');
106 106
         }
107 107
 
Please login to merge, or discard this patch.
src/system/ExtensionsModule/Installer/ExtensionInstallerInterface.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 /**
19 19
  * Interface ExtensionInstallerInterface
20 20
  */
21
-interface ExtensionInstallerInterface extends InstallerInterface
22
-{
21
+interface ExtensionInstallerInterface extends InstallerInterface
22
+{
23 23
     public function setExtension(AbstractExtension $extension): void;
24 24
 }
Please login to merge, or discard this patch.
src/system/ExtensionsModule/Helper/BundleSyncHelper.php 1 patch
Braces   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 /**
37 37
  * Helper functions for the extensions bundle
38 38
  */
39
-class BundleSyncHelper
40
-{
39
+class BundleSyncHelper
40
+{
41 41
     /**
42 42
      * @var ZikulaHttpKernelInterface
43 43
      */
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         BundlesSchemaHelper $bundlesSchemaHelper,
100 100
         ComposerValidationHelper $composerValidationHelper,
101 101
         SessionInterface $session
102
-    ) {
102
+    ) {
103 103
         $this->kernel = $kernel;
104 104
         $this->extensionRepository = $extensionRepository;
105 105
         $this->extensionVarRepository = $extensionVarRepository;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         // sync the extensions directory and the bundles table
121 121
         $this->bundlesSchemaHelper->load();
122 122
         $scanner = $this->bundlesSchemaHelper->getScanner();
123
-        foreach ($scanner->getInvalid() as $invalidName) {
123
+        foreach ($scanner->getInvalid() as $invalidName) {
124 124
             $this->session->getFlashBag()->add(
125 125
                 'warning',
126 126
                 $this->translator->trans(
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
         $bundles = [];
135 135
         $srcDir = $this->kernel->getProjectDir() . '/src/';
136 136
         /** @var MetaData $bundleMetaData */
137
-        foreach ($extensions as $name => $bundleMetaData) {
138
-            foreach ($bundleMetaData->getPsr4() as $ns => $path) {
137
+        foreach ($extensions as $name => $bundleMetaData) {
138
+            foreach ($bundleMetaData->getPsr4() as $ns => $path) {
139 139
                 $this->kernel->getAutoloader()->addPsr4($ns, $srcDir . $path);
140 140
             }
141 141
 
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
 
149 149
             $finder = new Finder();
150 150
             $finder->files()->in($bundle->getPath())->depth(0)->name('composer.json');
151
-            foreach ($finder as $splFileInfo) {
151
+            foreach ($finder as $splFileInfo) {
152 152
                 // there will only be one loop here
153 153
                 $this->composerValidationHelper->check($splFileInfo);
154
-                if ($this->composerValidationHelper->isValid()) {
154
+                if ($this->composerValidationHelper->isValid()) {
155 155
                     $bundles[$bundle->getName()] = $bundleVersionArray;
156 156
                     $bundles[$bundle->getName()]['oldnames'] = $bundleVersionArray['oldnames'] ?? '';
157
-                } else {
157
+                } else {
158 158
                     $this->session->getFlashBag()->add(
159 159
                         'error',
160 160
                         $this->translator->trans(
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
                             ['%extension%' => $bundle->getName()]
163 163
                         )
164 164
                     );
165
-                    foreach ($this->composerValidationHelper->getErrors() as $error) {
165
+                    foreach ($this->composerValidationHelper->getErrors() as $error) {
166 166
                         $this->session->getFlashBag()->add('error', $error);
167 167
                     }
168 168
                 }
169 169
             }
170 170
         }
171 171
 
172
-        if ($includeCore) {
172
+        if ($includeCore) {
173 173
             $this->appendCoreExtensionsMetaData($bundles);
174 174
         }
175 175
         $this->validate($bundles);
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 
180 180
     private function appendCoreExtensionsMetaData(array &$extensions): void
181 181
     {
182
-        foreach (ZikulaKernel::$coreExtension as $systemModule => $bundleClass) {
182
+        foreach (ZikulaKernel::$coreExtension as $systemModule => $bundleClass) {
183 183
             $bundle = $this->kernel->getBundle($systemModule);
184
-            if ($bundle instanceof AbstractExtension) {
184
+            if ($bundle instanceof AbstractExtension) {
185 185
                 $extensions[$systemModule] = $bundle->getMetaData()->getFilteredVersionInfoArray();
186 186
             }
187 187
         }
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
         ];
203 203
 
204 204
         // check for duplicate name, display name or url
205
-        foreach ($extensions as $dir => $modInfo) {
206
-            foreach ($fieldNames as $fieldName) {
205
+        foreach ($extensions as $dir => $modInfo) {
206
+            foreach ($fieldNames as $fieldName) {
207 207
                 $key = mb_strtolower($modInfo[$fieldName]);
208
-                if (!empty($moduleValues[$fieldName][$key]) && !empty($modInfo[$fieldName])) {
208
+                if (!empty($moduleValues[$fieldName][$key]) && !empty($modInfo[$fieldName])) {
209 209
                     $message = $this->translator->trans('Fatal error: Two extensions share the same %field%. [%ext1%] and [%ext2%]', [
210 210
                         '%field%' => $fieldName,
211 211
                         '%ext1%' => $modInfo['name'],
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
         array &$extensionsFromDB,
257 257
         bool $forceDefaults = false
258 258
     ): void {
259
-        foreach ($extensionsFromFile as $name => $extensionFromFile) {
260
-            foreach ($extensionsFromDB as $dbname => $extensionFromDB) {
261
-                if (isset($extensionFromDB['name']) && in_array($extensionFromDB['name'], (array)$extensionFromFile['oldnames'], true)) {
259
+        foreach ($extensionsFromFile as $name => $extensionFromFile) {
260
+            foreach ($extensionsFromDB as $dbname => $extensionFromDB) {
261
+                if (isset($extensionFromDB['name']) && in_array($extensionFromDB['name'], (array)$extensionFromFile['oldnames'], true)) {
262 262
                     // migrate its modvars
263 263
                     $this->extensionVarRepository->updateName($dbname, $name);
264 264
                     // rename the extension register
@@ -270,18 +270,18 @@  discard block
 block discarded – undo
270 270
             }
271 271
 
272 272
             // If extension was previously determined to be incompatible with the core. return to original state
273
-            if (isset($extensionsFromDB[$name]) && $extensionsFromDB[$name]['state'] > 10) {
273
+            if (isset($extensionsFromDB[$name]) && $extensionsFromDB[$name]['state'] > 10) {
274 274
                 $extensionsFromDB[$name]['state'] -= Constant::INCOMPATIBLE_CORE_SHIFT;
275 275
                 $this->extensionStateHelper->updateState($extensionsFromDB[$name]['id'], $extensionsFromDB[$name]['state']);
276 276
             }
277 277
 
278 278
             // update the DB information for this extension to reflect user settings (e.g. url)
279
-            if (isset($extensionsFromDB[$name]['id'])) {
279
+            if (isset($extensionsFromDB[$name]['id'])) {
280 280
                 $extensionFromFile['id'] = $extensionsFromDB[$name]['id'];
281
-                if (Constant::STATE_UNINITIALISED !== $extensionsFromDB[$name]['state'] && Constant::STATE_INVALID !== $extensionsFromDB[$name]['state']) {
281
+                if (Constant::STATE_UNINITIALISED !== $extensionsFromDB[$name]['state'] && Constant::STATE_INVALID !== $extensionsFromDB[$name]['state']) {
282 282
                     unset($extensionFromFile['version']);
283 283
                 }
284
-                if (!$forceDefaults) {
284
+                if (!$forceDefaults) {
285 285
                     unset($extensionFromFile['displayname'], $extensionFromFile['description'], $extensionFromFile['url']);
286 286
                 }
287 287
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                 /** @var ExtensionEntity $extension */
291 291
                 $extension = $this->extensionRepository->find($extensionFromFile['id']);
292 292
                 $extension->merge($extensionFromFile);
293
-                if (empty($extension->getIcon())) {
293
+                if (empty($extension->getIcon())) {
294 294
                     $extension->setIcon($extensionFromFile['capabilities']['admin']['icon']);
295 295
                 }
296 296
                 $this->extensionRepository->persistAndFlush($extension);
@@ -298,13 +298,13 @@  discard block
 block discarded – undo
298 298
 
299 299
             // check extension core requirement is compatible with current core
300 300
             $coreCompatibility = $extensionFromFile['coreCompatibility'];
301
-            if (isset($extensionsFromDB[$name])) {
302
-                if (!Semver::satisfies(ZikulaKernel::VERSION, $coreCompatibility)) {
301
+            if (isset($extensionsFromDB[$name])) {
302
+                if (!Semver::satisfies(ZikulaKernel::VERSION, $coreCompatibility)) {
303 303
                     // extension is incompatible with current core
304 304
                     $extensionsFromDB[$name]['state'] += Constant::INCOMPATIBLE_CORE_SHIFT;
305 305
                     $this->extensionStateHelper->updateState($extensionsFromDB[$name]['id'], $extensionsFromDB[$name]['state']);
306 306
                 }
307
-                if (isset($extensionsFromDB[$name]['state'])) {
307
+                if (isset($extensionsFromDB[$name]['state'])) {
308 308
                     $extensionFromFile['state'] = $extensionsFromDB[$name]['state'];
309 309
                 }
310 310
             }
@@ -316,26 +316,26 @@  discard block
 block discarded – undo
316 316
      */
317 317
     private function syncLostExtensions(array $extensionsFromFile, array &$extensionsFromDB): void
318 318
     {
319
-        foreach ($extensionsFromDB as $extensionName => $unusedVariable) {
320
-            if ($this->kernel::isCoreExtension($extensionName) || array_key_exists($extensionName, $extensionsFromFile)) {
319
+        foreach ($extensionsFromDB as $extensionName => $unusedVariable) {
320
+            if ($this->kernel::isCoreExtension($extensionName) || array_key_exists($extensionName, $extensionsFromFile)) {
321 321
                 continue;
322 322
             }
323 323
 
324 324
             $lostExtension = $this->extensionRepository->get($extensionName); // must obtain Entity because value from $extensionsFromDB is only an array
325
-            if (!$lostExtension) {
325
+            if (!$lostExtension) {
326 326
                 throw new RuntimeException($this->translator->trans('Error! Could not load data for %extension%.', ['%extension%' => $extensionName]));
327 327
             }
328 328
             $lostExtensionState = $lostExtension->getState();
329 329
             if ((Constant::STATE_INVALID === $lostExtensionState)
330
-                || ($lostExtensionState === Constant::STATE_INVALID + Constant::INCOMPATIBLE_CORE_SHIFT)) {
330
+                || ($lostExtensionState === Constant::STATE_INVALID + Constant::INCOMPATIBLE_CORE_SHIFT)) {
331 331
                 // extension was invalid and subsequently removed from file system,
332 332
                 // or extension was incompatible with core and subsequently removed, delete it
333 333
                 $this->extensionRepository->removeAndFlush($lostExtension);
334 334
             } elseif ((Constant::STATE_UNINITIALISED === $lostExtensionState)
335
-                || ($lostExtensionState === Constant::STATE_UNINITIALISED + Constant::INCOMPATIBLE_CORE_SHIFT)) {
335
+                || ($lostExtensionState === Constant::STATE_UNINITIALISED + Constant::INCOMPATIBLE_CORE_SHIFT)) {
336 336
                 // extension was uninitialised and subsequently removed from file system, delete it
337 337
                 $this->extensionRepository->removeAndFlush($lostExtension);
338
-            } else {
338
+            } else {
339 339
                 // Set state of extension to 'missing'
340 340
                 // This state cannot be reached in with an ACTIVE bundle. - ACTIVE bundles are part of the pre-compiled Kernel.
341 341
                 // extensions that are inactive can be marked as missing.
@@ -357,13 +357,13 @@  discard block
 block discarded – undo
357 357
     {
358 358
         $upgradedExtensions = [];
359 359
 
360
-        foreach ($extensionsFromFile as $name => $extensionFromFile) {
361
-            if (empty($extensionsFromDB[$name])) {
360
+        foreach ($extensionsFromFile as $name => $extensionFromFile) {
361
+            if (empty($extensionsFromDB[$name])) {
362 362
                 $extensionFromFile['state'] = Constant::STATE_UNINITIALISED;
363
-                if (!$extensionFromFile['version']) {
363
+                if (!$extensionFromFile['version']) {
364 364
                     // set state to invalid if we can't determine a version
365 365
                     $extensionFromFile['state'] = Constant::STATE_INVALID;
366
-                } else {
366
+                } else {
367 367
                     $coreCompatibility = $extensionFromFile['coreCompatibility'];
368 368
                     // shift state if extension is incompatible with core version
369 369
                     $extensionFromFile['state'] = Semver::satisfies(ZikulaKernel::VERSION, $coreCompatibility)
@@ -377,33 +377,33 @@  discard block
 block discarded – undo
377 377
                 // insert new extension to db
378 378
                 $newExtension = new ExtensionEntity();
379 379
                 $newExtension->merge($extensionFromFile);
380
-                if (empty($newExtension->getIcon())) {
380
+                if (empty($newExtension->getIcon())) {
381 381
                     $newExtension->setIcon($extensionFromFile['capabilities']['admin']['icon']);
382 382
                 }
383 383
                 $vetoEvent = new GenericEvent($newExtension);
384 384
                 $this->dispatcher->dispatch($vetoEvent, ExtensionEvents::INSERT_VETO);
385
-                if (!$vetoEvent->isPropagationStopped()) {
385
+                if (!$vetoEvent->isPropagationStopped()) {
386 386
                     $this->extensionRepository->persistAndFlush($newExtension);
387 387
                 }
388
-            } else {
388
+            } else {
389 389
                 // extension is in the db already
390 390
                 if ((Constant::STATE_MISSING === $extensionsFromDB[$name]['state'])
391
-                    || ($extensionsFromDB[$name]['state'] === Constant::STATE_MISSING + Constant::INCOMPATIBLE_CORE_SHIFT)) {
391
+                    || ($extensionsFromDB[$name]['state'] === Constant::STATE_MISSING + Constant::INCOMPATIBLE_CORE_SHIFT)) {
392 392
                     // extension was lost, now it is here again
393 393
                     $this->extensionStateHelper->updateState($extensionsFromDB[$name]['id'], Constant::STATE_INACTIVE);
394 394
                 } elseif (((Constant::STATE_INVALID === $extensionsFromDB[$name]['state'])
395 395
                         || ($extensionsFromDB[$name]['state'] === Constant::STATE_INVALID + Constant::INCOMPATIBLE_CORE_SHIFT))
396
-                    && $extensionFromFile['version']) {
396
+                    && $extensionFromFile['version']) {
397 397
                     $coreCompatibility = $extensionFromFile['coreCompatibility'];
398
-                    if (Semver::satisfies(ZikulaKernel::VERSION, $coreCompatibility)) {
398
+                    if (Semver::satisfies(ZikulaKernel::VERSION, $coreCompatibility)) {
399 399
                         // extension was invalid, now it is valid
400 400
                         $this->extensionStateHelper->updateState($extensionsFromDB[$name]['id'], Constant::STATE_UNINITIALISED);
401 401
                     }
402 402
                 }
403 403
 
404
-                if ($extensionsFromDB[$name]['version'] !== $extensionFromFile['version']) {
404
+                if ($extensionsFromDB[$name]['version'] !== $extensionFromFile['version']) {
405 405
                     if (Constant::STATE_UNINITIALISED !== $extensionsFromDB[$name]['state'] &&
406
-                        Constant::STATE_INVALID !== $extensionsFromDB[$name]['state']) {
406
+                        Constant::STATE_INVALID !== $extensionsFromDB[$name]['state']) {
407 407
                         $this->extensionStateHelper->updateState($extensionsFromDB[$name]['id'], Constant::STATE_UPGRADED);
408 408
                         $upgradedExtensions[$name] = $extensionFromFile['version'];
409 409
                     }
Please login to merge, or discard this patch.