File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ final class RichEditorExtension extends AbstractExtension
3131{
3232 private const ADMIN_FIREWALL_CONTEXT = 'security.firewall.map.context.admin ' ;
3333
34+ private const SYLIUS_ADMIN_SECTION = 'admin ' ;
35+
3436 private RegistryInterface $ uiElementRegistry ;
3537
3638 private Environment $ twig ;
@@ -284,6 +286,9 @@ public function getMediaManagerFilePath(string $path): string
284286 return $ path ;
285287 }
286288
289+ /**
290+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
291+ */
287292 private function isAdmin (array $ context ): bool
288293 {
289294 /** @var ?AppVariable $app */
@@ -292,6 +297,19 @@ private function isAdmin(array $context): bool
292297 return false ;
293298 }
294299
295- return self ::ADMIN_FIREWALL_CONTEXT === $ request ->get ('_firewall_context ' );
300+ // Check Sylius section to know if we are in the admin
301+ /** @var ?array $sylius */
302+ $ sylius = $ request ->get ('_sylius ' );
303+ if (isset ($ sylius ['section ' ])) {
304+ return self ::SYLIUS_ADMIN_SECTION === $ sylius ['section ' ];
305+ }
306+
307+ // Check firewall context to know if we are in the admin
308+ if ($ request ->attributes ->has ('_firewall_context ' )) {
309+ return self ::ADMIN_FIREWALL_CONTEXT === $ request ->attributes ->get ('_firewall_context ' );
310+ }
311+
312+ // False by default
313+ return false ;
296314 }
297315}
You can’t perform that action at this time.
0 commit comments