From 19ddacb246ea3ff912001249ce56a074f5bd4887 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Wed, 1 Apr 2020 11:45:27 +0200 Subject: [PATCH] Use pageinfo and remove extension scanner false positive As only pageinfo is used, only this is stored for now. Also the single line accessing the property is marked to be ignored by extension scanner. --- Classes/Hooks/Backend/PageLayoutHeader.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Classes/Hooks/Backend/PageLayoutHeader.php b/Classes/Hooks/Backend/PageLayoutHeader.php index afe53a8..33cbae2 100644 --- a/Classes/Hooks/Backend/PageLayoutHeader.php +++ b/Classes/Hooks/Backend/PageLayoutHeader.php @@ -29,15 +29,16 @@ use TYPO3\CMS\Frontend\Resource\FileCollector; class PageLayoutHeader { /** - * @var PageLayoutController + * @var array */ - private $pageLayoutController; + private $pageinfo; public function render( array $params, PageLayoutController $pageLayoutController ): string { - $this->pageLayoutController = $pageLayoutController; + // @extensionScannerIgnoreLine At least in v10 this is a false positive + $this->pageinfo = $pageLayoutController->pageinfo; // TODO: Check whether two levels up is uid 2, which holds all blog posts // To prevent rendering on non blog posts @@ -45,29 +46,29 @@ class PageLayoutHeader $view = $this->getView(); $view->assignMultiple([ - 'record' => $this->pageLayoutController->pageinfo, + 'record' => $this->pageinfo, 'metaInfo' => [ [ 'label' => 'meta-description', - 'value' => $this->pageLayoutController->pageinfo['description'], + 'value' => $this->pageinfo['description'], 'field' => 'description', 'type' => 'string', ], [ 'label' => 'introduction', - 'value' => $this->pageLayoutController->pageinfo['abstract'], + 'value' => $this->pageinfo['abstract'], 'field' => 'abstract', 'type' => 'string', ], [ 'label' => 'published', - 'value' => $this->pageLayoutController->pageinfo['lastUpdated'], + 'value' => $this->pageinfo['lastUpdated'], 'field' => 'lastUpdated', 'type' => 'date', ], [ 'label' => 'updated', - 'value' => $this->pageLayoutController->pageinfo['SYS_LASTCHANGED'], + 'value' => $this->pageinfo['SYS_LASTCHANGED'], 'type' => 'date', ], [ @@ -90,7 +91,7 @@ class PageLayoutHeader private function resolvePageMedia(): array { - $page = ['uid' => $this->pageLayoutController->pageinfo['uid']]; + $page = ['uid' => $this->pageinfo['uid']]; $files = new FileCollector(); $files->addFilesFromRelation('pages', 'media', $page);