Skip to content

Commit 07de946

Browse files
committed
[BUGFIX] Fixed Type Error when cObj returns null
- Implemented `getContentObjectRenderer()` method to handle cases where `cObj` might be null in some cases where request is not build completely - Adjusted `applyStdWrapProperties()` to ensure graceful fallback when `cObj` is not available. This improves error handling and diagnostics, making the extension more reliable and easier to maintain. Resolves: #37
1 parent 542c4da commit 07de946

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Classes/Helper/TypoScriptHelper.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ public function hasReplaceEntry(array $typoScriptConfiguration, $key): bool
102102

103103
public function applyStdWrapProperties(string $content, array $stdWrapConfiguration): string
104104
{
105-
return $this->getContentObjectRenderer()->stdWrap($content, $stdWrapConfiguration);
105+
$contentObjectRenderer = $this->getContentObjectRenderer();
106+
if ($contentObjectRenderer === null) {
107+
return $content;
108+
}
109+
110+
return $contentObjectRenderer->stdWrap($content, $stdWrapConfiguration);
106111
}
107112
}

Classes/Traits/GetTypoScriptFrontendControllerTrait.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ protected function getTypoScriptFrontendController(): TypoScriptFrontendControll
2929
return $GLOBALS['TSFE'];
3030
}
3131

32-
protected function getContentObjectRenderer(): ContentObjectRenderer
32+
protected function getContentObjectRenderer(): ?ContentObjectRenderer
3333
{
34-
return $this->getTypoScriptFrontendController()->cObj;
34+
$tsfe = $this->getTypoScriptFrontendController();
35+
36+
if (!$tsfe->cObj) {
37+
return null;
38+
}
39+
40+
return $tsfe->cObj;
3541
}
3642
}

0 commit comments

Comments
 (0)