Skip to content

Commit c5a1501

Browse files
committed
[BUGFIX] Mitigate splitted DataHandler hook method of EXT:container
The `b13/container` extension (`EXT:container` ) implements a custom DataHandler hook to process data in the required manner and recently splitted the method `localizeOrCopyToLanguage()` into two dedicated methods for the `CommandMapPostProcessingHook` [2] to fix an issue [1]. `EXT:deepltranslate_core` needs to override that hook in case that extension is installed to ensure both extension to work and broke due to that change. This change mitigates this by verify the existance of the methods now and call the existing once and throws an exception if if will be renamed again in the future. [1] b13/container#609 [2] b13/container#617
1 parent 5a0a79c commit c5a1501

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Classes/Override/CommandMapPostProcessingHook.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,29 @@ public function processCmdmap_postProcess(
2626
}
2727
$id = (int)$id;
2828
if ($table === 'tt_content' && $command === 'deepltranslate') {
29-
$this->localizeOrCopyToLanguage($id, (int)$value, $command, $dataHandler);
29+
// b13/container reworked their DataHandler hook implementation and splitted the method into
30+
// dedicated methods, which needs to be handled here to allow multiple b13/container versions.
31+
// See:
32+
// - https://github.com/b13/container/issues/609
33+
// - https://github.com/b13/container/pull/617
34+
if (method_exists($this, 'localizeOrCopyToLanguage')) {
35+
$this->localizeOrCopyToLanguage($id, (int)$value, $command, $dataHandler);
36+
} elseif (method_exists($this, 'localizeChildren')) {
37+
$this->localizeChildren($id, (int)$value, $command, $dataHandler);
38+
} else {
39+
throw new \RuntimeException(
40+
sprintf(
41+
implode('', [
42+
'Extension "%s" changed their internal DataHandler hook implementation "%s" again. Please ',
43+
'open an issue on "%s" and report the issue so it can be adopted.',
44+
]),
45+
'b13/container',
46+
\B13\Container\Hooks\Datahandler\CommandMapPostProcessingHook::class,
47+
'https://github.com/web-vision/deepltranslate-core/issues',
48+
),
49+
1748860059,
50+
);
51+
}
3052
} else {
3153
parent::processCmdmap_postProcess($command, $table, $id, $value, $dataHandler, $pasteUpdate, $pasteDatamap);
3254
}

0 commit comments

Comments
 (0)