-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Remove usage of sys_language table
because this table was removed in TYPO3 12. Now we are using the first site for a mapping from language identifier to a language label Related: #40
- Loading branch information
1 parent
8020710
commit 7626b29
Showing
6 changed files
with
58 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
namespace In2code\Lux\Domain\Repository; | ||
|
||
use In2code\Lux\Domain\Service\SiteService; | ||
use TYPO3\CMS\Core\SingletonInterface; | ||
|
||
class LanguageRepository implements SingletonInterface | ||
{ | ||
/** | ||
* e.g. | ||
* [ | ||
* 0 => 'English', | ||
* 1 => 'Deutsch', | ||
* ] | ||
* | ||
* @var array | ||
*/ | ||
protected array $languages = []; | ||
|
||
protected SiteService $siteService; | ||
|
||
public function __construct(SiteService $siteService) | ||
{ | ||
$this->siteService = $siteService; | ||
} | ||
|
||
public function getLabelToLanguageIdentifier(int $identifier): string | ||
{ | ||
if (array_key_exists($identifier, $this->languages) === false) { | ||
$languages = $this->siteService->getDefaultSite()->getLanguages(); | ||
foreach ($languages as $language) { | ||
if ($language->getLanguageId() === $identifier) { | ||
$this->languages[$identifier] = $language->getTitle(); | ||
} | ||
} | ||
} | ||
return $this->languages[$identifier] ?? 'undefined'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters