|
4 | 4 |
|
5 | 5 | namespace MyVendor\MySitepackage\PageTitle;
|
6 | 6 |
|
| 7 | +use Psr\Http\Message\ServerRequestInterface; |
7 | 8 | use TYPO3\CMS\Core\PageTitle\PageTitleProviderInterface;
|
8 | 9 | use TYPO3\CMS\Core\Site\SiteFinder;
|
9 |
| -use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; |
| 10 | +use TYPO3\CMS\Frontend\Page\PageInformation; |
10 | 11 |
|
11 |
| -final class WebsiteTitleProvider implements PageTitleProviderInterface |
| 12 | +final readonly class WebsiteTitleProvider implements PageTitleProviderInterface |
12 | 13 | {
|
13 | 14 | public function __construct(
|
14 |
| - private readonly SiteFinder $siteFinder, |
| 15 | + private SiteFinder $siteFinder, |
15 | 16 | ) {}
|
16 | 17 |
|
17 | 18 | public function getTitle(): string
|
18 | 19 | {
|
19 |
| - $site = $this->siteFinder->getSiteByPageId($this->getTypoScriptFrontendController()->page['uid']); |
| 20 | + /** @var PageInformation $pageInformation */ |
| 21 | + $pageInformation = $this->getRequest()->getAttribute('frontend.page.information'); |
| 22 | + |
| 23 | + $site = $this->siteFinder->getSiteByPageId($pageInformation->getId()); |
20 | 24 | $titles = [
|
21 |
| - $this->getTypoScriptFrontendController()->page['title'], |
| 25 | + $pageInformation->getPageRecord()['title'], |
22 | 26 | $site->getAttribute('websiteTitle'),
|
23 | 27 | ];
|
24 | 28 |
|
25 |
| - // do something |
26 | 29 | return implode(' - ', $titles);
|
27 | 30 | }
|
28 | 31 |
|
29 |
| - private function getTypoScriptFrontendController(): TypoScriptFrontendController |
| 32 | + private function getRequest(): ServerRequestInterface |
30 | 33 | {
|
31 |
| - return $GLOBALS['TSFE']; |
| 34 | + return $GLOBALS['TYPO3_REQUEST']; |
32 | 35 | }
|
33 | 36 | }
|
0 commit comments