ControllerContext::getUriBuilder()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 11
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 0
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\Extbase\Mvc\Controller;
17
18
use TYPO3\CMS\Core\Messaging\FlashMessageService;
19
use TYPO3\CMS\Core\Utility\GeneralUtility;
20
use TYPO3\CMS\Extbase\Mvc\Request;
21
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
22
use TYPO3\CMS\Extbase\Service\ExtensionService;
23
24
/**
25
 * The controller context contains information from the controller
26
 */
27
class ControllerContext
28
{
29
    /**
30
     * @var \TYPO3\CMS\Extbase\Mvc\Request
31
     */
32
    protected $request;
33
34
    /**
35
     * @var \TYPO3\CMS\Extbase\Mvc\Controller\Arguments
36
     */
37
    protected $arguments;
38
39
    /**
40
     * @var UriBuilder
41
     */
42
    protected $uriBuilder;
43
44
    /**
45
     * @var string
46
     */
47
    protected $flashMessageQueueDefaultIdentifier;
48
49
    /**
50
     * @var \TYPO3\CMS\Core\Messaging\FlashMessageService
51
     */
52
    protected $flashMessageService;
53
54
    /**
55
     * @var \TYPO3\CMS\Extbase\Service\ExtensionService
56
     */
57
    protected $extensionService;
58
59
    /**
60
     * @param \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService
61
     */
62
    public function injectFlashMessageService(FlashMessageService $flashMessageService)
63
    {
64
        $this->flashMessageService = $flashMessageService;
65
    }
66
67
    /**
68
     * @param \TYPO3\CMS\Extbase\Service\ExtensionService $extensionService
69
     */
70
    public function injectExtensionService(ExtensionService $extensionService)
71
    {
72
        $this->extensionService = $extensionService;
73
    }
74
75
    /**
76
     * Set the request of the controller
77
     *
78
     * @param \TYPO3\CMS\Extbase\Mvc\Request $request
79
     */
80
    public function setRequest(Request $request)
81
    {
82
        $this->request = $request;
83
    }
84
85
    /**
86
     * Get the request of the controller
87
     *
88
     * @return \TYPO3\CMS\Extbase\Mvc\Request
89
     */
90
    public function getRequest()
91
    {
92
        return $this->request;
93
    }
94
95
    /**
96
     * Set the arguments of the controller
97
     *
98
     * @param \TYPO3\CMS\Extbase\Mvc\Controller\Arguments $arguments
99
     */
100
    public function setArguments(Arguments $arguments)
101
    {
102
        $this->arguments = $arguments;
103
    }
104
105
    /**
106
     * Get the arguments of the controller
107
     *
108
     * @return \TYPO3\CMS\Extbase\Mvc\Controller\Arguments
109
     */
110
    public function getArguments()
111
    {
112
        return $this->arguments;
113
    }
114
115
    /**
116
     * @param UriBuilder $uriBuilder
117
     */
118
    public function setUriBuilder(UriBuilder $uriBuilder)
119
    {
120
        $this->uriBuilder = $uriBuilder;
121
    }
122
123
    /**
124
     * @return UriBuilder
125
     * @deprecated since v11, will be removed in v12
126
     */
127
    public function getUriBuilder()
128
    {
129
        // todo: trigger an error as soon as this whole object can be deprecated
130
131
        if (!$this->uriBuilder) {
132
            $this->uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
133
            if ($this->request) {
134
                $this->uriBuilder->setRequest($this->request);
135
            }
136
        }
137
        return $this->uriBuilder;
138
    }
139
140
    /**
141
     * @param string $identifier Queue-identifier
142
     * @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue
143
     * @deprecated since v11, will be removed in v12
144
     */
145
    public function getFlashMessageQueue($identifier = null)
146
    {
147
        // todo: trigger an error as soon as this whole object can be deprecated
148
149
        if ($identifier === null) {
150
            if ($this->flashMessageQueueDefaultIdentifier === null) {
151
                // cache the default-identifier for performance-reasons
152
                $this->flashMessageQueueDefaultIdentifier = 'extbase.flashmessages.' . $this->extensionService->getPluginNamespace($this->request->getControllerExtensionName(), $this->request->getPluginName());
153
            }
154
            $identifier = $this->flashMessageQueueDefaultIdentifier;
155
        }
156
        return $this->flashMessageService->getMessageQueueByIdentifier($identifier);
157
    }
158
}
159