Passed
Push — master ( d78354...23b09b )
by
unknown
14:05
created

ControllerContext::setResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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