@@ -17,8 +17,8 @@ |
||
17 | 17 | use Twig\Environment; |
18 | 18 | use Zikula\ExtensionsModule\AbstractCoreTheme; |
19 | 19 | |
20 | -class ZikulaRssTheme extends AbstractCoreTheme |
|
21 | -{ |
|
20 | +class ZikulaRssTheme extends AbstractCoreTheme |
|
21 | +{ |
|
22 | 22 | /** |
23 | 23 | * Override parent method in order to add Content-type header to Response. |
24 | 24 | */ |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | * 2) public/themes/$theme/$bundleName/* |
37 | 37 | * 3) public/modules/$bundleName/* |
38 | 38 | */ |
39 | -class Asset |
|
40 | -{ |
|
39 | +class Asset |
|
40 | +{ |
|
41 | 41 | /** |
42 | 42 | * @var ZikulaHttpKernelInterface |
43 | 43 | */ |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | RouterInterface $router, |
70 | 70 | Filesystem $fileSystem, |
71 | 71 | Engine $themeEngine |
72 | - ) { |
|
72 | + ) { |
|
73 | 73 | $this->kernel = $kernel; |
74 | 74 | $this->assetPackages = $assetPackages; |
75 | 75 | $this->router = $router; |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | $httpRootDir = str_replace($basePath, '', $publicDir); |
89 | 89 | |
90 | 90 | // return immediately for straight asset paths |
91 | - if ('@' !== $path[0]) { |
|
92 | - if (0 === mb_strpos($path, '/')) { |
|
91 | + if ('@' !== $path[0]) { |
|
92 | + if (0 === mb_strpos($path, '/')) { |
|
93 | 93 | $path = mb_substr($path, 1); |
94 | 94 | } |
95 | 95 | $publicPath = $this->assetPackages->getUrl($path); |
96 | - if (false !== realpath($httpRootDir . $publicPath)) { |
|
96 | + if (false !== realpath($httpRootDir . $publicPath)) { |
|
97 | 97 | return $publicPath; |
98 | 98 | } |
99 | 99 | } |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | $bundleAssetPath |
114 | 114 | ]; |
115 | 115 | |
116 | - foreach ($foldersToCheck as $folder) { |
|
116 | + foreach ($foldersToCheck as $folder) { |
|
117 | 117 | $fullPath = $publicDir . '/' . $folder . '/' . $relativeAssetPath; |
118 | - if (false !== realpath($fullPath)) { |
|
118 | + if (false !== realpath($fullPath)) { |
|
119 | 119 | return str_replace($httpRootDir, '', $fullPath); |
120 | 120 | } |
121 | 121 | } |
@@ -137,15 +137,15 @@ discard block |
||
137 | 137 | */ |
138 | 138 | private function getBundleAssetPath(?string $bundleName): string |
139 | 139 | { |
140 | - if (!isset($bundleName)) { |
|
140 | + if (!isset($bundleName)) { |
|
141 | 141 | throw new InvalidArgumentException('No bundle name resolved, must be like "@AcmeBundle"'); |
142 | 142 | } |
143 | 143 | $bundle = $this->kernel->getBundle(mb_substr($bundleName, 1)); |
144 | - if (!$bundle instanceof Bundle) { |
|
144 | + if (!$bundle instanceof Bundle) { |
|
145 | 145 | throw new InvalidArgumentException('Bundle ' . $bundleName . ' not found.'); |
146 | 146 | } |
147 | 147 | |
148 | - if ($bundle instanceof AbstractExtension) { |
|
148 | + if ($bundle instanceof AbstractExtension) { |
|
149 | 149 | return $bundle->getRelativeAssetPath(); |
150 | 150 | } |
151 | 151 |
@@ -45,8 +45,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -13,6 +13,6 @@ |
||
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 | } |
@@ -19,8 +19,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -13,8 +13,8 @@ |
||
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'; |
@@ -50,8 +50,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -19,8 +19,8 @@ discard block |
||
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 |
||
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 | } |
@@ -77,11 +77,11 @@ discard block |
||
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 |
||
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 |