From edcb88f03c6ab7cefe8c5f74f1bf99626e83c867 Mon Sep 17 00:00:00 2001 From: sebastien <2le@2le.net> Date: Tue, 24 Oct 2023 10:42:08 +0200 Subject: [PATCH] CredentialWarmup --- src/Service/CruditCredentialWarmup.php | 85 +++++++++++++++++++++++ src/Service/FrontMenuCredentialWarmup.php | 47 +++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 src/Service/CruditCredentialWarmup.php create mode 100644 src/Service/FrontMenuCredentialWarmup.php diff --git a/src/Service/CruditCredentialWarmup.php b/src/Service/CruditCredentialWarmup.php new file mode 100644 index 00000000..18d8e0f7 --- /dev/null +++ b/src/Service/CruditCredentialWarmup.php @@ -0,0 +1,85 @@ +cruditConfigs as $cruditConfig) { + $rubrique = $cruditConfig->getName(); + + // Page Roles + foreach ($keys as $key) { + $this->checkAndCreateCredential( + 'ROLE_' . $cruditConfig->getName() . '_' . $key, + $rubrique, + $cruditConfig->getName() . $key, + $i++ + ); + } + + // Actions Roles + foreach ($cruditConfig->getListActions() as $action) { + if ($action->getPath()->getRole()) { + $this->checkAndCreateCredential( + $action->getPath()->getRole(), + $rubrique, + $action->getLabel(), + $i++ + ); + } + } + // Item Actions Roles + foreach ($cruditConfig->getItemActions() as $action) { + if ($action->getPath()->getRole()) { + $this->checkAndCreateCredential( + $action->getPath()->getRole(), + $rubrique, + $action->getLabel(), + $i++ + ); + } + } + + // Tabs Roles + foreach ($cruditConfig->getTabs() as $key => $brickConfigList) { + foreach ($brickConfigList as $brickConfig) { + if ($brickConfig->getRole()) { + $this->checkAndCreateCredential( + $brickConfig->getRole(), + $rubrique, + $key . "/" . strtolower(str_replace("ROLE_${rubrique}_","",$brickConfig->getRole())), + $i++ + ); + } + } + } + } + } +} diff --git a/src/Service/FrontMenuCredentialWarmup.php b/src/Service/FrontMenuCredentialWarmup.php new file mode 100644 index 00000000..5d8abab9 --- /dev/null +++ b/src/Service/FrontMenuCredentialWarmup.php @@ -0,0 +1,47 @@ +menuRegistry->getElements("") as $menuItem) { + if ($menuItem->getRole()) { + $this->checkAndCreateCredential( + $menuItem->getRole(), + $rubrique, + "Menu " . str_replace("menu.", "", $menuItem->getId()), + $i++ + ); + } + foreach ($menuItem->getChildren() as $submenuItem) { + if ($submenuItem->getRole()) { + $this->checkAndCreateCredential( + $submenuItem->getRole(), + $rubrique, + "↳ Sous menu " . str_replace("menu.", "", $submenuItem->getId()), + $i++ + ); + } + } + } + } +}