fix localized page management and builder synchronization
Validate locales and route uniqueness, report page deletion failures, and keep translation CRUD and route caches consistent. Show translation completeness in page settings and listings, and preserve locale-specific block data while synchronizing shared structure. Add translation service and page builder synchronization tests.
This commit is contained in:
+5
-13
@@ -129,14 +129,7 @@ class Page implements PageContract
|
||||
public function getTranslation(string $setting, ?string $locale = null)
|
||||
{
|
||||
$translations = $this->getTranslations();
|
||||
if (empty($translations)) {
|
||||
return null;
|
||||
}
|
||||
$locale = $locale ?? phpb_config('general.language');
|
||||
return $translations[$locale][$setting] ??
|
||||
$translations['en'][$setting] ??
|
||||
$translations[array_keys($translations)[0]][$setting] ??
|
||||
null;
|
||||
return (new PageTranslationService())->resolveTranslation($translations, $setting, $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,11 +171,10 @@ class Page implements PageContract
|
||||
*/
|
||||
public function invalidateCache()
|
||||
{
|
||||
$cache = phpb_instance('cache');
|
||||
$routes = array_map(function ($translation) {
|
||||
return $translation['route'] ?? null;
|
||||
}, $this->getTranslations());
|
||||
|
||||
foreach ($this->getTranslations() as $locale => $translationData) {
|
||||
$languageRoute = $this->getRoute($locale);
|
||||
$cache->invalidate($languageRoute);
|
||||
}
|
||||
(new PageTranslationService())->invalidateRoutes($routes);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user