Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Too few arguments to function LanguageService::__construct() #526

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Classes/Utility/TemplaVoilaUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use Psr\Log\LoggerAwareInterface;
use Tvp\TemplaVoilaPlus\Domain\Repository\Localization\LocalizationRepository;
use Tvp\TemplaVoilaPlus\Exception\ProcessingException;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Context\LanguageAspect;
Expand All @@ -27,6 +28,8 @@
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Site\Entity\NullSite;
use TYPO3\CMS\Core\Site\PseudoSiteFinder;
Expand Down Expand Up @@ -72,14 +75,24 @@ public static function getBackendUser(): BackendUserAuthentication
}

/**
* @return \TYPO3\CMS\Lang\LanguageService
* @return LanguageService
* @throws ProcessingException
*/
public static function getLanguageService()
public static function getLanguageService(): LanguageService
{
// for backend
if (isset($GLOBALS['LANG'])) {
return $GLOBALS['LANG'];
}
return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageService::class);
// for frontend
if (isset($GLOBALS['TYPO3_REQUEST'])) {
$languageServiceFactory = GeneralUtility::makeInstance(LanguageServiceFactory::class);
return $languageServiceFactory->createFromSiteLanguage(
$GLOBALS['TYPO3_REQUEST']->getAttribute('language')
?? $GLOBALS['TYPO3_REQUEST']->getAttribute('site')->getDefaultLanguage()
);
}
throw new ProcessingException('Trying to instantiate LanguageService failed',1691061481968);
}

/**
Expand Down
Loading