Skip to content

Commit

Permalink
[BUGFIX] Respect correct namespace for used b13/container class
Browse files Browse the repository at this point in the history
`b13/container` moved a class with v2.1.0 to another
namespace. We instantiated and called that class to
re-run code in xclassed class which both extensions
needs to xclass and combine both tasks.

This change now checks for both possible classes and
use the correct ones. Using kind of package or composer
information is not reliable enough and more complex
than the chosen `class_exist` check.

The newer namespace is checked first, in case the
container extensions adds a class_alias for the old
one. Directly using the new class if existing is the
better way.

See: b13/container@5d57961#diff-1b5dddc7fdc72ce709fe89a91a8873332a6f6755209043cb81c3b116ee70f738

Resolves: #276
  • Loading branch information
calien666 committed Jul 21, 2023
1 parent 64aa19e commit ffbcc23
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Classes/Override/LocalizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,16 @@ public function getRecordLocalizeSummary(ServerRequestInterface $request): Respo
// s. EXT:containers Xclass B13\Container\Xclasses\LocalizationController
if (
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('container')
&& class_exists(\B13\Container\Xclasses\RecordLocalizeSummaryModifier::class)
) {
$recordLocalizeSummaryModifier = GeneralUtility::makeInstance(\B13\Container\Xclasses\RecordLocalizeSummaryModifier::class);
$payloadBody = $recordLocalizeSummaryModifier->rebuildPayload($payloadBody);
if (class_exists(\B13\Container\Service\RecordLocalizeSummaryModifier::class)) {
// since b13/container 2.1.0
$recordLocalizeSummaryModifier = GeneralUtility::makeInstance(\B13\Container\Service\RecordLocalizeSummaryModifier::class);
$payloadBody = $recordLocalizeSummaryModifier->rebuildPayload($payloadBody);
} elseif (class_exists(\B13\Container\Xclasses\RecordLocalizeSummaryModifier::class)) {
// before b13/container 2.1.0
$recordLocalizeSummaryModifier = GeneralUtility::makeInstance(\B13\Container\Xclasses\RecordLocalizeSummaryModifier::class);
$payloadBody = $recordLocalizeSummaryModifier->rebuildPayload($payloadBody);
}
}

return (new JsonResponse())->setPayload($payloadBody);
Expand Down

0 comments on commit ffbcc23

Please sign in to comment.