‪TYPO3CMS  11.5
AbstractContentObject.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Psr\Http\Message\ServerRequestInterface;
20 use TYPO3\CMS\Core\Page\PageRenderer;
24 
29 {
33  protected ‪$cObj;
34 
38  protected ‪$pageRenderer;
39 
40  protected ?ServerRequestInterface ‪$request = null;
41 
47  public function ‪__construct(ContentObjectRenderer ‪$cObj)
48  {
49  $this->cObj = ‪$cObj;
50  }
51 
58  abstract public function ‪render($conf = []);
59 
65  public function ‪getContentObjectRenderer()
66  {
67  return ‪$this->cObj;
68  }
69 
70  public function ‪setRequest(ServerRequestInterface ‪$request): void
71  {
72  $this->request = ‪$request;
73  }
74 
75  public function ‪setContentObjectRenderer(ContentObjectRenderer ‪$cObj): void
76  {
77  $this->cObj = ‪$cObj;
78  }
79 
80  protected function ‪hasTypoScriptFrontendController(): bool
81  {
82  return $this->cObj->getTypoScriptFrontendController() instanceof ‪TypoScriptFrontendController;
83  }
84 
88  protected function ‪getTypoScriptFrontendController()
89  {
90  if (!$this->‪hasTypoScriptFrontendController()) {
91  throw new ContentRenderingException('TypoScriptFrontendController is not available.', 1655723512);
92  }
93 
94  return $this->cObj->getTypoScriptFrontendController();
95  }
96 
100  protected function ‪getPageRepository()
101  {
102  if (!$this->‪hasTypoScriptFrontendController()) {
103  return GeneralUtility::makeInstance(PageRepository::class);
104  }
106  if (!$this->‪getTypoScriptFrontendController()->sys_page instanceof PageRepository) {
107  return GeneralUtility::makeInstance(
108  PageRepository::class,
109  $this->‪getTypoScriptFrontendController()->getContext()
110  );
111  }
112  return $this->‪getTypoScriptFrontendController()->sys_page;
113  }
114 
118  protected function ‪getPageRenderer()
119  {
120  if ($this->pageRenderer === null) {
121  $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
122  }
123 
124  return ‪$this->pageRenderer;
125  }
126 }
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\$pageRenderer
‪PageRenderer $pageRenderer
Definition: AbstractContentObject.php:36
‪TYPO3\CMS\Frontend\ContentObject
Definition: AbstractContentObject.php:16
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\setContentObjectRenderer
‪setContentObjectRenderer(ContentObjectRenderer $cObj)
Definition: AbstractContentObject.php:73
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\$request
‪ServerRequestInterface $request
Definition: AbstractContentObject.php:38
‪TYPO3\CMS\Frontend\ContentObject\Exception\ContentRenderingException
Definition: ContentRenderingException.php:24
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\hasTypoScriptFrontendController
‪hasTypoScriptFrontendController()
Definition: AbstractContentObject.php:78
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\getPageRepository
‪PageRepository getPageRepository()
Definition: AbstractContentObject.php:98
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\getTypoScriptFrontendController
‪TypoScriptFrontendController getTypoScriptFrontendController()
Definition: AbstractContentObject.php:86
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
Definition: AbstractContentObject.php:29
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\$cObj
‪ContentObjectRenderer $cObj
Definition: AbstractContentObject.php:32
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\__construct
‪__construct(ContentObjectRenderer $cObj)
Definition: AbstractContentObject.php:45
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\getContentObjectRenderer
‪ContentObjectRenderer getContentObjectRenderer()
Definition: AbstractContentObject.php:63
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:104
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\setRequest
‪setRequest(ServerRequestInterface $request)
Definition: AbstractContentObject.php:68
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\getPageRenderer
‪PageRenderer getPageRenderer()
Definition: AbstractContentObject.php:116
‪TYPO3\CMS\Core\Domain\Repository\PageRepository
Definition: PageRepository.php:53
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\render
‪string render($conf=[])