mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-08-29 21:00:39 +08:00
Prevent recaching of language metadata on navigation
This commit is contained in:
parent
537f734601
commit
17c86b5a8b
1 changed files with 25 additions and 15 deletions
|
@ -273,17 +273,14 @@ class AppMetadataProvider implements AppMetadataProviderInterface
|
||||||
|
|
||||||
|
|
||||||
$metadata->setNavigation([]);
|
$metadata->setNavigation([]);
|
||||||
|
$navigation = $this->getNavigation($userId);
|
||||||
if (in_array('navigation', $exposed, true)) {
|
if (in_array('navigation', $exposed, true)) {
|
||||||
$navigation = $this->cache->get('app-metadata-navigation-' . $userId, function () {
|
|
||||||
return $this->navigationService->getNavbar()->toArray();
|
|
||||||
});
|
|
||||||
$metadata->setNavigation($navigation);
|
$metadata->setNavigation($navigation);
|
||||||
}
|
}
|
||||||
|
|
||||||
$metadata->setModuleMetadata([]);
|
$metadata->setModuleMetadata([]);
|
||||||
$metadata->setMinimalModuleMetadata([]);
|
$metadata->setMinimalModuleMetadata([]);
|
||||||
if (in_array('moduleMetadata', $exposed, true)) {
|
if (in_array('moduleMetadata', $exposed, true)) {
|
||||||
$navigation = $this->navigationService->getNavbar();
|
|
||||||
$moduleMetadata = $this->getModuleMetadata($moduleName, $navigation) ?? [];
|
$moduleMetadata = $this->getModuleMetadata($moduleName, $navigation) ?? [];
|
||||||
$metadata->setModuleMetadata($moduleMetadata);
|
$metadata->setModuleMetadata($moduleMetadata);
|
||||||
} elseif (in_array('minimalModuleMetadata', $exposed, true)) {
|
} elseif (in_array('minimalModuleMetadata', $exposed, true)) {
|
||||||
|
@ -292,7 +289,6 @@ class AppMetadataProvider implements AppMetadataProviderInterface
|
||||||
|
|
||||||
$metadata->setGlobalRecentlyViewedMetadata([]);
|
$metadata->setGlobalRecentlyViewedMetadata([]);
|
||||||
if (in_array('globalRecentlyViewed', $exposed, true)) {
|
if (in_array('globalRecentlyViewed', $exposed, true)) {
|
||||||
$navigation = $this->navigationService->getNavbar();
|
|
||||||
$metadata->setGlobalRecentlyViewedMetadata($this->getGlobalRecentlyViewedMetadata($navigation));
|
$metadata->setGlobalRecentlyViewedMetadata($this->getGlobalRecentlyViewedMetadata($navigation));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,13 +476,13 @@ class AppMetadataProvider implements AppMetadataProviderInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $module
|
* @param string $module
|
||||||
* @param Navbar $navigation
|
* @param array $navigation
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getModuleMetadata(string $module, Navbar $navigation): array
|
protected function getModuleMetadata(string $module, array $navigation): array
|
||||||
{
|
{
|
||||||
$max = $navigation->maxTabs;
|
$max = $navigation['maxTabs'];
|
||||||
$modules = $navigation->tabs ?? [];
|
$modules = $navigation['tabs'] ?? [];
|
||||||
|
|
||||||
if (!in_array($module, $modules, true)) {
|
if (!in_array($module, $modules, true)) {
|
||||||
$modules[] = $module;
|
$modules[] = $module;
|
||||||
|
@ -499,7 +495,7 @@ class AppMetadataProvider implements AppMetadataProviderInterface
|
||||||
'calendar' => true,
|
'calendar' => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
$type = $navigation->type ?? '';
|
$type = $navigation['type'] ?? '';
|
||||||
if ($type === 'gm') {
|
if ($type === 'gm') {
|
||||||
$groupedTabsModules = $this->getGroupedTabModules($navigation, $module);
|
$groupedTabsModules = $this->getGroupedTabModules($navigation, $module);
|
||||||
|
|
||||||
|
@ -557,11 +553,12 @@ class AppMetadataProvider implements AppMetadataProviderInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param array $navigation
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getGlobalRecentlyViewedMetadata(Navbar $navigation): array
|
protected function getGlobalRecentlyViewedMetadata(array $navigation): array
|
||||||
{
|
{
|
||||||
$modules = $navigation->tabs ?? [];
|
$modules = $navigation['tabs'] ?? [];
|
||||||
$legacyModuleNames = [];
|
$legacyModuleNames = [];
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
$legacyModuleNames[] = $this->moduleNameMapper->toLegacy($module);
|
$legacyModuleNames[] = $this->moduleNameMapper->toLegacy($module);
|
||||||
|
@ -616,13 +613,13 @@ class AppMetadataProvider implements AppMetadataProviderInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Navbar $navigation
|
* @param array $navigation
|
||||||
* @param string $module
|
* @param string $module
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
protected function getGroupedTabModules(Navbar $navigation, string $module): array
|
protected function getGroupedTabModules(array $navigation, string $module): array
|
||||||
{
|
{
|
||||||
$groupedTabs = $navigation->groupedTabs ?? [];
|
$groupedTabs = $navigation['groupedTabs'] ?? [];
|
||||||
$groupedTabsModules = [];
|
$groupedTabsModules = [];
|
||||||
|
|
||||||
foreach ($groupedTabs as $groupedTab) {
|
foreach ($groupedTabs as $groupedTab) {
|
||||||
|
@ -732,4 +729,17 @@ class AppMetadataProvider implements AppMetadataProviderInterface
|
||||||
|
|
||||||
return $modules;
|
return $modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $userId
|
||||||
|
* @return array
|
||||||
|
* @throws \Psr\Cache\InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function getNavigation(string $userId): array
|
||||||
|
{
|
||||||
|
$navigation = $this->cache->get('app-metadata-navigation-' . $userId, function () {
|
||||||
|
return $this->navigationService->getNavbar()->toArray();
|
||||||
|
});
|
||||||
|
return $navigation ?? [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue