2525use Pimcore \Bundle \StudioBackendBundle \Translation \Schema \UpdateTranslation ;
2626use Pimcore \Bundle \StudioBackendBundle \Translation \Service \TranslatorServiceInterface ;
2727use Pimcore \Bundle \StudioBackendBundle \Util \Constant \UserPermissions ;
28+ use Pimcore \Config ;
2829use Pimcore \Model \Translation ;
2930use Pimcore \Model \Translation \Listing ;
31+ use function array_unique ;
32+ use function array_values ;
3033use function in_array ;
3134use function sprintf ;
3235
@@ -41,6 +44,7 @@ public function __construct(
4144 private SettingsProviderInterface $ systemSettingsProvider ,
4245 private Connection $ db ,
4346 private SecurityServiceInterface $ securityService ,
47+ private Config $ config ,
4448 ) {
4549 $ settings = $ this ->systemSettingsProvider ->getSettings ();
4650 $ this ->validLanguages = $ settings ['validLanguages ' ] ?? [];
@@ -192,10 +196,10 @@ public function getTranslationKeysWithTextFilter(
192196
193197 public function getTranslationList (string $ domain = TranslatorServiceInterface::DOMAIN ): Listing
194198 {
199+ $ this ->assertValidDomain ($ domain );
200+
195201 $ list = new Translation \Listing ();
196202 $ list ->setDomain ($ domain );
197- $ list ->setOrder ('asc ' );
198- $ list ->setOrderKey ('translations_ ' . $ domain . '.key ' , false );
199203
200204 return $ list ;
201205 }
@@ -245,4 +249,15 @@ private function validateLocale(string $locale): void
245249 throw new InvalidLocaleException ($ locale );
246250 }
247251 }
252+
253+ /**
254+ * @throws NotFoundException
255+ */
256+ private function assertValidDomain (string $ domain ): void
257+ {
258+ $ allowedDomains = array_values (array_unique ($ this ->config ['translations ' ]['domains ' ] ?? []));
259+ if (!in_array ($ domain , $ allowedDomains , true )) {
260+ throw new NotFoundException ('Translation Domain ' , $ domain );
261+ }
262+ }
248263}
0 commit comments