Completed
Push — master ( 785ff6...8cec79 )
by
unknown
28:03 queued 12:03
created

AbstractContentObject::setRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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
16
namespace TYPO3\CMS\Frontend\ContentObject;
17
18
use Psr\Http\Message\ServerRequestInterface;
19
use TYPO3\CMS\Core\Page\PageRenderer;
20
use TYPO3\CMS\Core\Utility\GeneralUtility;
21
22
/**
23
 * Contains an abstract class for all tslib content class implementations.
24
 */
25
abstract class AbstractContentObject
26
{
27
    /**
28
     * @var ContentObjectRenderer
29
     */
30
    protected $cObj;
31
32
    /**
33
     * @var PageRenderer
34
     */
35
    protected $pageRenderer;
36
37
    protected ?ServerRequestInterface $request = null;
38
39
    /**
40
     * Default constructor.
41
     *
42
     * @param ContentObjectRenderer $cObj
43
     */
44
    public function __construct(ContentObjectRenderer $cObj)
45
    {
46
        $this->cObj = $cObj;
47
    }
48
49
    /**
50
     * Renders the content object.
51
     *
52
     * @param array $conf
53
     * @return string
54
     */
55
    abstract public function render($conf = []);
56
57
    /**
58
     * Getter for current ContentObjectRenderer
59
     *
60
     * @return ContentObjectRenderer
61
     */
62
    public function getContentObjectRenderer()
63
    {
64
        return $this->cObj;
65
    }
66
67
    public function setRequest(ServerRequestInterface $request): void
68
    {
69
        $this->request = $request;
70
    }
71
72
    /**
73
     * @return PageRenderer
74
     */
75
    protected function getPageRenderer()
76
    {
77
        if ($this->pageRenderer === null) {
78
            $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
79
        }
80
81
        return $this->pageRenderer;
82
    }
83
}
84