From bca1e4f881d2126b32bb2652fa6965e9a858b1ee Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 18 Dec 2019 20:12:54 -0800 Subject: [PATCH] (REF) AfformSaveTrait - Extract helper $isChanged I was originally expecting to need to flush the menu whenever the `permission` changed. That's not necessary now (because the true permission check is deferred until it's needed), but the cleanup may still be helpful in the future (e.g. if we enable nav-menu integration or change the way permissions are implemented). --- ext/afform/core/Civi/Api4/Utils/AfformSaveTrait.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ext/afform/core/Civi/Api4/Utils/AfformSaveTrait.php b/ext/afform/core/Civi/Api4/Utils/AfformSaveTrait.php index 700146ce95..eae07c5ee4 100644 --- a/ext/afform/core/Civi/Api4/Utils/AfformSaveTrait.php +++ b/ext/afform/core/Civi/Api4/Utils/AfformSaveTrait.php @@ -63,7 +63,11 @@ trait AfformSaveTrait { // We may have changed list of files covered by the cache. _afform_clear(); - if (($item['server_route'] ?? NULL) !== ($orig['server_route'] ?? NULL)) { + $isChanged = function($field) use ($item, $orig) { + return ($item[$field] ?? NULL) !== ($orig[$field] ?? NULL); + }; + // Right now, permission-checks are completely on-demand. + if ($isChanged('server_route') /* || $isChanged('permission') */) { \CRM_Core_Menu::store(); \CRM_Core_BAO_Navigation::resetNavigation(); } -- 2.25.1