Skip to content

Commit

Permalink
Bugfix release
Browse files Browse the repository at this point in the history
[TASK] Set version to 1.2.3.
[BUGFIX] Apply translation arguments only when a translation exists.
[BUGFIX] Fix "undefined array key" in TypoScript condition for page types.
[BUGFIX] Fix "undefined array key" when checking if TypoScript is available in contexts other than Frontend.
[BUGFIX] Load general EarlyAccessConstants also when there is a context specific file.
  • Loading branch information
phantasie-schmiede authored Oct 14, 2022
1 parent 3c90b3a commit 8707a33
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,20 @@ public function getGlobalVariables(): array
$contextParts = explode('/', Environment::getContext()->__toString());
$lastIndex = count($contextParts) - 1;
$contextParts[$lastIndex] = lcfirst($contextParts[$lastIndex]);
$filePath = self::DIRECTORY . implode('/', $contextParts) . '.yaml';
$contextSpecificFilePath = self::DIRECTORY . implode('/', $contextParts) . '.yaml';

foreach ($allExtensionInformation as $extensionInformation) {
$yamlFile = GeneralUtility::getFileAbsFileName('EXT:' . $extensionInformation->getExtensionKey() . $filePath);
$basePath = 'EXT:' . $extensionInformation->getExtensionKey();
$yamlFiles = [
GeneralUtility::getFileAbsFileName($basePath . self::DIRECTORY . 'constants.yaml'),
GeneralUtility::getFileAbsFileName($basePath . $contextSpecificFilePath),
];

if (!file_exists($yamlFile)) {
$yamlFile = GeneralUtility::getFileAbsFileName('EXT:' . $extensionInformation->getExtensionKey() . self::DIRECTORY . 'constants.yaml');
}

if (file_exists($yamlFile)) {
$constants = Yaml::parseFile($yamlFile) ?? [];
ArrayUtility::mergeRecursiveWithOverrule($mergedConstants, $constants);
foreach ($yamlFiles as $yamlFile) {
if (file_exists($yamlFile)) {
$constants = Yaml::parseFile($yamlFile) ?? [];
ArrayUtility::mergeRecursiveWithOverrule($mergedConstants, $constants);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/Utility/ContextUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static function isFrontend(): bool
*/
public static function isTypoScriptAvailable(): bool
{
if (null !== $GLOBALS['TSFE'] && self::isFrontend()) {
if (isset($GLOBALS['TSFE']) && self::isFrontend()) {
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions Classes/Utility/TypoScript/TypoScriptUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static function registerPageType(PageObjectConfiguration $pageTypeConfigu
[
'userFunc' => $pageTypeConfiguration->getUserFunc(),
],
$pageTypeConfiguration->getUserFuncParameters()
$pageTypeConfiguration->getUserFuncParameters(),
);
} else {
$contentConfiguration = [
Expand All @@ -127,7 +127,7 @@ public static function registerPageType(PageObjectConfiguration $pageTypeConfigu
$contentConfiguration[self::TYPO_SCRIPT_KEYS['OBJECT_TYPE']] = $internalContentType;

$typoScript = [
self::TYPO_SCRIPT_KEYS['CONDITION'] => 'request.getQueryParams()[\'type\'] == ' . $pageTypeConfiguration->getTypeNum(),
self::TYPO_SCRIPT_KEYS['CONDITION'] => $pageTypeConfiguration->getTypeNum() . ' == traverse(request.getQueryParams(), \'type\')',
$pageTypeConfiguration->getTypoScriptObjectName() => [
self::TYPO_SCRIPT_KEYS['OBJECT_TYPE'] => 'PAGE',
10 => $contentConfiguration,
Expand Down Expand Up @@ -160,7 +160,7 @@ public static function registerPageType(PageObjectConfiguration $pageTypeConfigu
public static function registerTypoScript(
ExtensionInformationInterface $extensionInformation,
string $path,
string $title
string $title,
): void {
ExtensionManagementUtility::addStaticFile($extensionInformation->getExtensionKey(), $path, $title);
}
Expand Down
12 changes: 6 additions & 6 deletions Classes/ViewHelpers/TranslateViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TranslateViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\TranslateViewHelp
public static function renderStatic(
array $arguments,
Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
RenderingContextInterface $renderingContext,
): ?string {
[
'arguments' => $translateArguments,
Expand Down Expand Up @@ -77,16 +77,16 @@ public static function renderStatic(
try {
$value = static::translate($id, $extensionName, $translateArguments, $arguments['languageKey'],
$arguments['alternativeLanguageKeys']);
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException) {
$value = null;
}

if (null === $value) {
$value = $default ?? $renderChildrenClosure();
}

if (!empty($translateArguments)) {
$value = vsprintf($value, $translateArguments);
}
if (null !== $value && !empty($translateArguments)) {
$value = vsprintf($value, $translateArguments);
}

return $value;
Expand All @@ -110,7 +110,7 @@ protected static function translate(
$extensionName,
$arguments,
$languageKey,
$alternativeLanguageKeys
$alternativeLanguageKeys,
): ?string {
return GeneralUtility::makeInstance(LocalizationService::class)
->translate($id, $extensionName, $arguments, $languageKey, $alternativeLanguageKeys);
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
'description' => 'Configuration framework for TYPO3 extension development',
'state' => 'stable',
'title' => 'PSbits | Foundation',
'version' => '1.2.2',
'version' => '1.2.3',
];

0 comments on commit 8707a33

Please sign in to comment.