@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $this->variableApi->set(VariableApi::CONFIG, 'locale', $params['locale']); |
124 | 124 | // Set the System Identifier as a unique string. |
125 | 125 | if (!$this->variableApi->get(VariableApi::CONFIG, 'system_identifier')) { |
126 | - $this->variableApi->set(VariableApi::CONFIG, 'system_identifier', str_replace('.', '', uniqid((string) (random_int(1000000000, 9999999999)), true))); |
|
126 | + $this->variableApi->set(VariableApi::CONFIG, 'system_identifier', str_replace('.', '', uniqid((string)(random_int(1000000000, 9999999999)), true))); |
|
127 | 127 | } |
128 | 128 | // add admin email as site email |
129 | 129 | $this->variableApi->set(VariableApi::CONFIG, 'adminmail', $params['email']); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | } |
163 | 163 | |
164 | 164 | // on upgrade, if a user doesn't add their custom theme back to the /theme dir, it should be reset to a core theme, if available. |
165 | - $defaultTheme = (string) $this->variableApi->getSystemVar('Default_Theme'); |
|
165 | + $defaultTheme = (string)$this->variableApi->getSystemVar('Default_Theme'); |
|
166 | 166 | if (!$this->kernel->isBundle($defaultTheme) && $this->kernel->isBundle('ZikulaBootstrapTheme')) { |
167 | 167 | $this->variableApi->set(VariableApi::CONFIG, 'Default_Theme', 'ZikulaBootstrapTheme'); |
168 | 168 | } |
@@ -47,23 +47,23 @@ discard block |
||
47 | 47 | |
48 | 48 | $pwd = getcwd(); |
49 | 49 | if (is_dir($buildDir)) { |
50 | - system("rm -rf ${buildDir}"); |
|
50 | + system("rm -rf ${builddir}"); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // build env |
54 | 54 | $filesystem->mkdir($buildDir, 0755); |
55 | 55 | $progress->advance(); |
56 | 56 | |
57 | - $filesystem->mirror($sourceDir, "${buildDir}/${name}"); |
|
57 | + $filesystem->mirror($sourceDir, "${builddir}/${name}"); |
|
58 | 58 | $progress->advance(); |
59 | 59 | |
60 | - PurgeVendorsCommand::cleanVendors("${buildDir}/${name}/vendor", $progress); |
|
61 | - FixAutoloaderCommand::fix("${buildDir}/${name}/vendor", $progress); |
|
60 | + PurgeVendorsCommand::cleanVendors("${builddir}/${name}/vendor", $progress); |
|
61 | + FixAutoloaderCommand::fix("${builddir}/${name}/vendor", $progress); |
|
62 | 62 | |
63 | 63 | $writableArray = [ |
64 | - "${buildDir}/${name}/var/cache", |
|
65 | - "${buildDir}/${name}/var/log", |
|
66 | - "${buildDir}/${name}/public/uploads", |
|
64 | + "${builddir}/${name}/var/cache", |
|
65 | + "${builddir}/${name}/var/log", |
|
66 | + "${builddir}/${name}/public/uploads", |
|
67 | 67 | ]; |
68 | 68 | $filesystem->chmod($writableArray, 0777); |
69 | 69 | $progress->advance(); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $zip = new ZipArchive(); |
87 | 87 | $fileName = "${name}.zip"; |
88 | 88 | if (true !== $zip->open($fileName, ZipArchive::CREATE)) { |
89 | - $output->writeln("<error>Error creating ${fileName}</error>"); |
|
89 | + $output->writeln("<error>Error creating ${filename}</error>"); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | foreach ($allFiles as $file) { |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | |
100 | 100 | // build tar |
101 | 101 | $fileName = "${name}.tar"; |
102 | - system("tar cp ${name} > ${fileName}"); |
|
102 | + system("tar cp ${name} > ${filename}"); |
|
103 | 103 | $progress->advance(); |
104 | - system("gzip ${fileName}"); |
|
104 | + system("gzip ${filename}"); |
|
105 | 105 | $progress->advance(); |
106 | 106 | |
107 | 107 | // checksums |
@@ -117,17 +117,17 @@ discard block |
||
117 | 117 | -----------------sha1sums----------------- |
118 | 118 | ${zipSha1} ${name}.zip |
119 | 119 | ${tarSha1} ${name}.tar.gz |
120 | -CHECKSUM; |
|
120 | +checksum; |
|
121 | 121 | file_put_contents("${name}-checksum.txt", $checksum); |
122 | 122 | $progress->advance(); |
123 | 123 | |
124 | 124 | // cleanup |
125 | - system("rm -rf ${buildDir} ${name}"); |
|
125 | + system("rm -rf ${builddir} ${name}"); |
|
126 | 126 | chdir($pwd); |
127 | 127 | $progress->advance(); |
128 | 128 | $progress->finish(); |
129 | 129 | |
130 | - $output->writeln("<info>Artifacts built in ${buildDir}/ folder</info>"); |
|
130 | + $output->writeln("<info>Artifacts built in ${builddir}/ folder</info>"); |
|
131 | 131 | |
132 | 132 | return 0; |
133 | 133 | } |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @see https://symfony.com/doc/current/routing/custom_route_loader.html |
38 | 38 | */ |
39 | -class RouteLoader extends Loader |
|
40 | -{ |
|
39 | +class RouteLoader extends Loader |
|
40 | +{ |
|
41 | 41 | /** |
42 | 42 | * @var bool |
43 | 43 | */ |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | ExtractTranslationHelper $extractTranslationHelper, |
86 | 86 | PathBuilderHelper $pathBuilderHelper, |
87 | 87 | SanitizeHelper $sanitizeHelper, |
88 | - string $locale) |
|
89 | - { |
|
88 | + string $locale) |
|
89 | + { |
|
90 | 90 | $this->kernel = $kernel; |
91 | 91 | $this->translator = $translator; |
92 | 92 | $this->entityFactory = $entityFactory; |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | $this->locale = $locale; |
97 | 97 | } |
98 | 98 | |
99 | - public function load($resource, string $type = null) |
|
100 | - { |
|
101 | - if (true === $this->loaded) { |
|
99 | + public function load($resource, string $type = null) |
|
100 | + { |
|
101 | + if (true === $this->loaded) { |
|
102 | 102 | throw new RuntimeException('Do not add the "zikularoutesmodule" loader twice'); |
103 | 103 | } |
104 | 104 | |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | |
109 | 109 | $routeCollection->addCollection($topRoutes); |
110 | 110 | |
111 | - try { |
|
111 | + try { |
|
112 | 112 | $customRoutes = $this->entityFactory->getRepository('route')->findBy([], ['sort' => 'ASC']); |
113 | - } catch (Exception $exception) { |
|
113 | + } catch (Exception $exception) { |
|
114 | 114 | $routeCollection->addCollection($middleRoutes); |
115 | 115 | $routeCollection->addCollection($bottomRoutes); |
116 | 116 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | return $routeCollection; |
119 | 119 | } |
120 | 120 | |
121 | - if (!empty($customRoutes)) { |
|
121 | + if (!empty($customRoutes)) { |
|
122 | 122 | $this->addCustomRoutes($routeCollection, $customRoutes); |
123 | 123 | } |
124 | 124 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $topRoutes = new RouteCollection(); |
145 | 145 | $middleRoutes = new RouteCollection(); |
146 | 146 | $bottomRoutes = new RouteCollection(); |
147 | - foreach ($extensions as $extension) { |
|
147 | + foreach ($extensions as $extension) { |
|
148 | 148 | [$currentMiddleRoutes, $currentTopRoutes, $currentBottomRoutes] = $this->find($extension); |
149 | 149 | $middleRoutes->addCollection($currentMiddleRoutes); |
150 | 150 | $topRoutes->addCollection($currentTopRoutes); |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | */ |
162 | 162 | private function find(AbstractExtension $extension): array |
163 | 163 | { |
164 | - try { |
|
164 | + try { |
|
165 | 165 | $path = $this->kernel->locateResource($extension->getRoutingConfig()); |
166 | - } catch (InvalidArgumentException $exception) { |
|
166 | + } catch (InvalidArgumentException $exception) { |
|
167 | 167 | // Routing file does not exist (e.g. because the extension could not be located). |
168 | 168 | return [new RouteCollection(), new RouteCollection(), new RouteCollection()]; |
169 | 169 | } |
@@ -182,19 +182,19 @@ discard block |
||
182 | 182 | // Add all resources from the imported route collection to the middleRouteCollection. |
183 | 183 | // The actual collection (top, middle, bottom) to add the resources too does not matter, |
184 | 184 | // they just must be added to one of them, so that they don't get lost. |
185 | - foreach ($routeCollection->getResources() as $resource) { |
|
185 | + foreach ($routeCollection->getResources() as $resource) { |
|
186 | 186 | $middleRoutes->addResource($resource); |
187 | 187 | } |
188 | 188 | |
189 | 189 | /** @var Route $route */ |
190 | - foreach ($routeCollection as $oldRouteName => $route) { |
|
190 | + foreach ($routeCollection as $oldRouteName => $route) { |
|
191 | 191 | // set break here with $oldRouteName == 'zikula_routesmodule_route_renew' |
192 | 192 | $this->prependExtensionPrefix($route, $extension); |
193 | 193 | [$type, $func] = $this->setZikulaDefaults($route, $extension, $name); |
194 | 194 | $routeName = $this->getRouteName($oldRouteName, $name, $type, $func); |
195 | 195 | |
196 | - if ($route->hasOption('zkPosition')) { |
|
197 | - switch ($route->getOption('zkPosition')) { |
|
196 | + if ($route->hasOption('zkPosition')) { |
|
197 | + switch ($route->getOption('zkPosition')) { |
|
198 | 198 | case 'top': |
199 | 199 | $topRoutes->add($routeName, $route); |
200 | 200 | break; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | default: |
205 | 205 | $middleRoutes->add($routeName, $route); |
206 | 206 | } |
207 | - } else { |
|
207 | + } else { |
|
208 | 208 | $middleRoutes->add($routeName, $route); |
209 | 209 | } |
210 | 210 | } |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | private function addCustomRoutes(RouteCollection $routeCollection, array $customRoutes = []): void |
219 | 219 | { |
220 | 220 | /** @var RouteEntity $dbRoute */ |
221 | - foreach ($customRoutes as $dbRoute) { |
|
221 | + foreach ($customRoutes as $dbRoute) { |
|
222 | 222 | $extensionName = $dbRoute->getBundle(); |
223 | - if (!$this->kernel->isBundle($extensionName)) { |
|
223 | + if (!$this->kernel->isBundle($extensionName)) { |
|
224 | 224 | continue; |
225 | 225 | } |
226 | 226 | $extension = $this->kernel->getBundle($extensionName); |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | // We have to prepend the extension prefix (see detailed description in docblock of prependExtensionPrefix() method). |
238 | 238 | $options = $dbRoute->getOptions(); |
239 | 239 | $prependExtension = empty($this->extractTranslationHelper->getBundleName()) && isset($options['i18n']) && !$options['i18n']; |
240 | - if ($prependExtension) { |
|
240 | + if ($prependExtension) { |
|
241 | 241 | $path = $this->pathBuilderHelper->getPathWithBundlePrefix($dbRoute); |
242 | - } else { |
|
242 | + } else { |
|
243 | 243 | $path = $dbRoute->getPath(); |
244 | 244 | } |
245 | 245 | |
@@ -272,9 +272,9 @@ discard block |
||
272 | 272 | $defaults = $route->getDefaults(); |
273 | 273 | |
274 | 274 | $defaults['_zkBundle'] = $extensionName; |
275 | - if ($extension instanceof AbstractModule) { |
|
275 | + if ($extension instanceof AbstractModule) { |
|
276 | 276 | $defaults['_zkModule'] = $extensionName; |
277 | - } else if ($extension instanceof AbstractTheme) { |
|
277 | + } else if ($extension instanceof AbstractTheme) { |
|
278 | 278 | $defaults['_zkTheme'] = $extensionName; |
279 | 279 | } |
280 | 280 | |
@@ -300,24 +300,24 @@ discard block |
||
300 | 300 | * If i18n is set to true, Zikula's customized pattern generation strategy will take care of it. |
301 | 301 | * See Zikula\RoutesModule\Translation\ZikulaPatternGenerationStrategy |
302 | 302 | */ |
303 | - private function prependExtensionPrefix(Route $route, AbstractExtension $extension) |
|
304 | - { |
|
303 | + private function prependExtensionPrefix(Route $route, AbstractExtension $extension) |
|
304 | + { |
|
305 | 305 | $prefix = ''; |
306 | 306 | $options = $route->getOptions(); |
307 | 307 | $prependExtension = empty($this->extractTranslationHelper->getBundleName()) && isset($options['i18n']) && !$options['i18n']; |
308 | - if (!$prependExtension) { |
|
308 | + if (!$prependExtension) { |
|
309 | 309 | return; |
310 | 310 | } |
311 | - if ((isset($options['zkNoBundlePrefix']) && $options['zkNoBundlePrefix'])) { |
|
311 | + if ((isset($options['zkNoBundlePrefix']) && $options['zkNoBundlePrefix'])) { |
|
312 | 312 | return; |
313 | 313 | } |
314 | 314 | |
315 | 315 | // get url from extension meta data first. May be empty. |
316 | 316 | $untranslatedPrefix = $extension->getMetaData()->getUrl(false); |
317 | - if (!empty($untranslatedPrefix)) { |
|
318 | - if ($this->translator->getCatalogue($this->locale)->has($untranslatedPrefix, strtolower($extension->getName()))) { |
|
317 | + if (!empty($untranslatedPrefix)) { |
|
318 | + if ($this->translator->getCatalogue($this->locale)->has($untranslatedPrefix, strtolower($extension->getName()))) { |
|
319 | 319 | $prefix = $this->translator->trans(/** @Ignore */$untranslatedPrefix, [], strtolower($extension->getName()), $this->locale); |
320 | - } else { |
|
320 | + } else { |
|
321 | 321 | $prefix = $untranslatedPrefix; |
322 | 322 | } |
323 | 323 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | */ |
334 | 334 | private function sanitizeController(string $extensionName, string $controllerString): string |
335 | 335 | { |
336 | - if (0 === preg_match('#^(.*?\\\\Controller\\\\(.+)Controller)::(.+)Action$#', $controllerString, $match)) { |
|
336 | + if (0 === preg_match('#^(.*?\\\\Controller\\\\(.+)Controller)::(.+)Action$#', $controllerString, $match)) { |
|
337 | 337 | return $controllerString; |
338 | 338 | } |
339 | 339 | |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | { |
349 | 349 | $suffix = ''; |
350 | 350 | $lastHit = strrpos($oldRouteName, '_'); |
351 | - if (false !== $lastHit) { |
|
351 | + if (false !== $lastHit) { |
|
352 | 352 | $lastPart = substr($oldRouteName, $lastHit); |
353 | - if (is_numeric($lastPart)) { |
|
353 | + if (is_numeric($lastPart)) { |
|
354 | 354 | // If the last part of the old route name is numeric, also append it to the new route name. |
355 | 355 | // This allows multiple routes for the same action. |
356 | 356 | $suffix = '_' . $lastPart; |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return boolean |
367 | 367 | */ |
368 | - public function supports($resource, string $type = null) |
|
369 | - { |
|
368 | + public function supports($resource, string $type = null) |
|
369 | + { |
|
370 | 370 | return 'zikularoutesmodule' === $type; |
371 | 371 | } |
372 | 372 | } |
@@ -18,20 +18,20 @@ discard block |
||
18 | 18 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
19 | 19 | use Zikula\RoutesModule\Helper\ExtractTranslationHelper; |
20 | 20 | |
21 | -class ConsoleCommandListener implements EventSubscriberInterface |
|
22 | -{ |
|
21 | +class ConsoleCommandListener implements EventSubscriberInterface |
|
22 | +{ |
|
23 | 23 | /** |
24 | 24 | * @var ExtractTranslationHelper |
25 | 25 | */ |
26 | 26 | private $extractTranslationHelper; |
27 | 27 | |
28 | - public function __construct(ExtractTranslationHelper $extractTranslationHelper) |
|
29 | - { |
|
28 | + public function __construct(ExtractTranslationHelper $extractTranslationHelper) |
|
29 | + { |
|
30 | 30 | $this->extractTranslationHelper = $extractTranslationHelper; |
31 | 31 | } |
32 | 32 | |
33 | - public static function getSubscribedEvents() |
|
34 | - { |
|
33 | + public static function getSubscribedEvents() |
|
34 | + { |
|
35 | 35 | return [ |
36 | 36 | ConsoleEvents::COMMAND => ['checkBundleForTranslatingRoutes'] |
37 | 37 | ]; |
@@ -43,21 +43,21 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function checkBundleForTranslatingRoutes(ConsoleCommandEvent $event): void |
45 | 45 | { |
46 | - if ('translation:extract' !== $event->getCommand()->getName()) { |
|
46 | + if ('translation:extract' !== $event->getCommand()->getName()) { |
|
47 | 47 | return; |
48 | 48 | } |
49 | 49 | |
50 | 50 | $this->extractTranslationHelper->setExtensionName(''); |
51 | 51 | |
52 | 52 | $bundle = null; |
53 | - if ($event->getInput()->hasParameterOption('-b')) { |
|
53 | + if ($event->getInput()->hasParameterOption('-b')) { |
|
54 | 54 | $bundle = $event->getInput()->getParameterOption('-b'); |
55 | - } elseif ($event->getInput()->hasParameterOption('--bundle')) { |
|
55 | + } elseif ($event->getInput()->hasParameterOption('--bundle')) { |
|
56 | 56 | $bundle = $event->getInput()->getParameterOption('--bundle'); |
57 | 57 | } |
58 | 58 | |
59 | - if (null !== $bundle) { |
|
60 | - if ('@' === $bundle[0]) { |
|
59 | + if (null !== $bundle) { |
|
60 | + if ('@' === $bundle[0]) { |
|
61 | 61 | $bundle = substr($bundle, 1); |
62 | 62 | } |
63 | 63 |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | use Zikula\ExtensionsModule\AbstractExtension; |
19 | 19 | use Zikula\RoutesModule\Entity\RouteEntity; |
20 | 20 | |
21 | -class PathBuilderHelper |
|
22 | -{ |
|
21 | +class PathBuilderHelper |
|
22 | +{ |
|
23 | 23 | /** |
24 | 24 | * @var ZikulaHttpKernelInterface |
25 | 25 | */ |
26 | 26 | private $kernel; |
27 | 27 | |
28 | - public function __construct(ZikulaHttpKernelInterface $kernel) |
|
29 | - { |
|
28 | + public function __construct(ZikulaHttpKernelInterface $kernel) |
|
29 | + { |
|
30 | 30 | $this->kernel = $kernel; |
31 | 31 | } |
32 | 32 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function getPathWithBundlePrefix(RouteEntity $route): string |
37 | 37 | { |
38 | 38 | $options = $route->getOptions(); |
39 | - if (isset($options['zkNoBundlePrefix']) && $options['zkNoBundlePrefix']) { |
|
39 | + if (isset($options['zkNoBundlePrefix']) && $options['zkNoBundlePrefix']) { |
|
40 | 40 | // return path only |
41 | 41 | return $route->getPath(); |
42 | 42 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @var AbstractExtension $extensionBundle |
46 | 46 | */ |
47 | 47 | $extensionBundle = null; |
48 | - try { |
|
48 | + try { |
|
49 | 49 | $extensionBundle = $this->kernel->getBundle($route->getBundle()); |
50 | - } catch (Exception $exception) { |
|
50 | + } catch (Exception $exception) { |
|
51 | 51 | return $route->getPath(); |
52 | 52 | } |
53 | 53 |
@@ -13,8 +13,8 @@ |
||
13 | 13 | |
14 | 14 | namespace Zikula\RoutesModule\Helper; |
15 | 15 | |
16 | -class ExtractTranslationHelper |
|
17 | -{ |
|
16 | +class ExtractTranslationHelper |
|
17 | +{ |
|
18 | 18 | /** |
19 | 19 | * @var string |
20 | 20 | */ |
@@ -17,8 +17,8 @@ |
||
17 | 17 | use Twig\Environment; |
18 | 18 | use Zikula\ExtensionsModule\AbstractCoreTheme; |
19 | 19 | |
20 | -class ZikulaAtomTheme extends AbstractCoreTheme |
|
21 | -{ |
|
20 | +class ZikulaAtomTheme extends AbstractCoreTheme |
|
21 | +{ |
|
22 | 22 | /** |
23 | 23 | * Override parent method in order to add Content-type header to Response. |
24 | 24 | */ |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | * This class provides an API for interaction with and management of blocks. The class is mainly used internally |
33 | 33 | * by Twig-based theme tags in order to 'decorate' a page with the requested blocks. |
34 | 34 | */ |
35 | -class BlockApi implements BlockApiInterface |
|
36 | -{ |
|
35 | +class BlockApi implements BlockApiInterface |
|
36 | +{ |
|
37 | 37 | public const BLOCK_ACTIVE = 1; |
38 | 38 | |
39 | 39 | public const BLOCK_INACTIVE = 0; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | BlockFactoryApiInterface $blockFactoryApi, |
64 | 64 | ExtensionRepositoryInterface $extensionRepository, |
65 | 65 | BlockCollector $blockCollector |
66 | - ) { |
|
66 | + ) { |
|
67 | 67 | $this->blockPositionRepository = $blockPositionRepository; |
68 | 68 | $this->blockFactory = $blockFactoryApi; |
69 | 69 | $this->extensionRespository = $extensionRepository; |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | |
73 | 73 | public function getBlocksByPosition(string $positionName): array |
74 | 74 | { |
75 | - if (empty($positionName)) { |
|
75 | + if (empty($positionName)) { |
|
76 | 76 | throw new InvalidArgumentException('Name must not be empty.'); |
77 | 77 | } |
78 | 78 | |
79 | 79 | /** @var BlockPositionEntity $position */ |
80 | 80 | $position = $this->blockPositionRepository->findByName($positionName); |
81 | 81 | $blocks = []; |
82 | - if (null === $position) { |
|
82 | + if (null === $position) { |
|
83 | 83 | return $blocks; |
84 | 84 | } |
85 | 85 | |
86 | - foreach ($position->getPlacements() as $placement) { |
|
86 | + foreach ($position->getPlacements() as $placement) { |
|
87 | 87 | /** @var BlockEntity $block */ |
88 | 88 | $block = $placement->getBlock(); |
89 | 89 | $blocks[$block->getBid()] = $block; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | public function createInstanceFromBKey(string $bKey): BlockHandlerInterface |
96 | 96 | { |
97 | - if (false !== mb_strpos($bKey, ':')) { |
|
97 | + if (false !== mb_strpos($bKey, ':')) { |
|
98 | 98 | @trigger_error('The BKey should not contain the module name with a colon as of Core-3.0.0'); |
99 | 99 | } |
100 | 100 | |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | $modulesByName = []; |
107 | 107 | $modules = isset($moduleEntity) ? [$moduleEntity] : $this->extensionRespository->findBy(['state' => Constant::STATE_ACTIVE]); |
108 | 108 | /** @var ExtensionEntity $module */ |
109 | - foreach ($modules as $module) { |
|
109 | + foreach ($modules as $module) { |
|
110 | 110 | $modulesByName[$module->getName()] = $module; |
111 | 111 | } |
112 | 112 | |
113 | 113 | $foundBlocks = []; |
114 | - foreach ($this->blockCollector->getBlocks() as $id => $blockInstance) { |
|
114 | + foreach ($this->blockCollector->getBlocks() as $id => $blockInstance) { |
|
115 | 115 | /** @var AbstractBlockHandler $blockInstance */ |
116 | 116 | $bundleName = $blockInstance->getExtension()->getName(); |
117 | - if (!array_key_exists($bundleName, $modulesByName)) { |
|
117 | + if (!array_key_exists($bundleName, $modulesByName)) { |
|
118 | 118 | continue; |
119 | 119 | } |
120 | 120 | |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | { |
130 | 130 | $modules = $this->extensionRespository->findBy(['state' => Constant::STATE_ACTIVE]); |
131 | 131 | $modulesContainingBlocks = []; |
132 | - foreach ($modules as $module) { |
|
132 | + foreach ($modules as $module) { |
|
133 | 133 | /** @var ExtensionEntity $module */ |
134 | 134 | $blocks = $this->getAvailableBlockTypes($module); |
135 | - if (!empty($blocks)) { |
|
135 | + if (!empty($blocks)) { |
|
136 | 136 | $modulesContainingBlocks[$module->getId()] = $module->getName(); |
137 | 137 | } |
138 | 138 | } |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | * Class BlockController |
36 | 36 | * @Route("/admin/block") |
37 | 37 | */ |
38 | -class BlockController extends AbstractController |
|
39 | -{ |
|
38 | +class BlockController extends AbstractController |
|
39 | +{ |
|
40 | 40 | /** |
41 | 41 | * @Route("/new") |
42 | 42 | * @Theme("admin") |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | $form = $this->createForm(NewBlockType::class); |
49 | 49 | $form->handleRequest($request); |
50 | - if ($form->isSubmitted() && $form->isValid()) { |
|
50 | + if ($form->isSubmitted() && $form->isValid()) { |
|
51 | 51 | $bkey = json_encode($form->getData()['bkey']); |
52 | 52 | |
53 | 53 | return $this->redirectToRoute('zikulablocksmodule_block_edit', ['bkey' => $bkey]); |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | ): Response { |
75 | 75 | $requiredAccessLevel = ACCESS_EDIT; |
76 | 76 | $isCreation = false; |
77 | - if (null === $blockEntity) { |
|
77 | + if (null === $blockEntity) { |
|
78 | 78 | $isCreation = true; |
79 | 79 | $bKey = json_decode($request->query->get('bkey')); |
80 | - if (empty($bKey)) { |
|
80 | + if (empty($bKey)) { |
|
81 | 81 | return $this->redirectToRoute('zikulablocksmodule_block_new'); |
82 | 82 | } |
83 | 83 | $blockEntity = new BlockEntity(); // sets defaults in constructor |
@@ -85,31 +85,31 @@ discard block |
||
85 | 85 | $requiredAccessLevel = ACCESS_ADD; |
86 | 86 | } |
87 | 87 | |
88 | - if (!$this->hasPermission('ZikulaBlocksModule::', $blockEntity->getBlocktype() . ':' . $blockEntity->getTitle() . ':' . $blockEntity->getBid(), $requiredAccessLevel)) { |
|
88 | + if (!$this->hasPermission('ZikulaBlocksModule::', $blockEntity->getBlocktype() . ':' . $blockEntity->getTitle() . ':' . $blockEntity->getBid(), $requiredAccessLevel)) { |
|
89 | 89 | throw new AccessDeniedException(); |
90 | 90 | } |
91 | 91 | |
92 | 92 | $blockInstance = $blockApi->createInstanceFromBKey($blockEntity->getBkey()); |
93 | - if (true === $isCreation) { |
|
93 | + if (true === $isCreation) { |
|
94 | 94 | $blockEntity->setProperties($blockInstance->getPropertyDefaults()); |
95 | 95 | } |
96 | 96 | $blockType = $blockEntity->getBlocktype(); |
97 | - if (empty($blockType)) { |
|
97 | + if (empty($blockType)) { |
|
98 | 98 | $blockEntity->setBlocktype($blockInstance->getType()); |
99 | 99 | } |
100 | 100 | |
101 | 101 | $form = $this->createForm(BlockType::class, $blockEntity, ['locale' => $request->getLocale()]); |
102 | - if ($blockInstance instanceof BlockHandlerInterface && '' !== $blockInstance->getFormClassName()) { |
|
102 | + if ($blockInstance instanceof BlockHandlerInterface && '' !== $blockInstance->getFormClassName()) { |
|
103 | 103 | $form->add('properties', $blockInstance->getFormClassName(), $blockInstance->getFormOptions()); |
104 | 104 | } |
105 | 105 | $form->handleRequest($request); |
106 | 106 | |
107 | 107 | $moduleName = $blockInstance->getExtension()->getName(); |
108 | - if ($form->isSubmitted()) { |
|
109 | - if ($form->isValid() && $form->get('save')->isClicked()) { |
|
108 | + if ($form->isSubmitted()) { |
|
109 | + if ($form->isValid() && $form->get('save')->isClicked()) { |
|
110 | 110 | // remove orphan properties (#3892) |
111 | 111 | $properties = []; |
112 | - foreach ($form->get('properties')->all() as $child) { |
|
112 | + foreach ($form->get('properties')->all() as $child) { |
|
113 | 113 | $properties[$child->getName()] = $child->getData(); |
114 | 114 | } |
115 | 115 | $blockEntity->setProperties($properties); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $em->persist($blockEntity); |
129 | 129 | $em->flush(); |
130 | 130 | $this->addFlash('status', 'Done! Block saved.'); |
131 | - } elseif ($form->get('cancel')->isClicked()) { |
|
131 | + } elseif ($form->get('cancel')->isClicked()) { |
|
132 | 132 | $this->addFlash('status', 'Operation cancelled.'); |
133 | 133 | } |
134 | 134 | |
@@ -152,19 +152,19 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function deleteAction(Request $request, BlockEntity $blockEntity): Response |
154 | 154 | { |
155 | - if (!$this->hasPermission('ZikulaBlocksModule::', $blockEntity->getBkey() . ':' . $blockEntity->getTitle() . ':' . $blockEntity->getBid(), ACCESS_DELETE)) { |
|
155 | + if (!$this->hasPermission('ZikulaBlocksModule::', $blockEntity->getBkey() . ':' . $blockEntity->getTitle() . ':' . $blockEntity->getBid(), ACCESS_DELETE)) { |
|
156 | 156 | throw new AccessDeniedException(); |
157 | 157 | } |
158 | 158 | |
159 | 159 | $form = $this->createForm(DeletionType::class); |
160 | 160 | $form->handleRequest($request); |
161 | - if ($form->isSubmitted() && $form->isValid()) { |
|
162 | - if ($form->get('delete')->isClicked()) { |
|
161 | + if ($form->isSubmitted() && $form->isValid()) { |
|
162 | + if ($form->get('delete')->isClicked()) { |
|
163 | 163 | $em = $this->getDoctrine()->getManager(); |
164 | 164 | $em->remove($blockEntity); |
165 | 165 | $em->flush(); |
166 | 166 | $this->addFlash('status', 'Done! Block deleted.'); |
167 | - } elseif ($form->get('cancel')->isClicked()) { |
|
167 | + } elseif ($form->get('cancel')->isClicked()) { |
|
168 | 168 | $this->addFlash('status', 'Operation cancelled.'); |
169 | 169 | } |
170 | 170 | |
@@ -186,16 +186,16 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function toggleblockAction(Request $request): JsonResponse |
188 | 188 | { |
189 | - if (!$this->hasPermission('ZikulaBlocksModule::', '::', ACCESS_ADMIN)) { |
|
189 | + if (!$this->hasPermission('ZikulaBlocksModule::', '::', ACCESS_ADMIN)) { |
|
190 | 190 | return $this->json($this->trans('No permission for this action.'), Response::HTTP_FORBIDDEN); |
191 | 191 | } |
192 | 192 | $bid = $request->request->getInt('bid', -1); |
193 | - if (-1 === $bid) { |
|
193 | + if (-1 === $bid) { |
|
194 | 194 | return $this->json($this->trans('No block ID passed.'), Response::HTTP_BAD_REQUEST); |
195 | 195 | } |
196 | 196 | $em = $this->getDoctrine()->getManager(); |
197 | 197 | $block = $em->find('ZikulaBlocksModule:BlockEntity', $bid); |
198 | - if (null !== $block) { |
|
198 | + if (null !== $block) { |
|
199 | 199 | $block->setActive(BlockApi::BLOCK_ACTIVE === $block->getActive() ? BlockApi::BLOCK_INACTIVE : BlockApi::BLOCK_ACTIVE); |
200 | 200 | $em->flush(); |
201 | 201 | } |