Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
context.php
1<?php
2
10namespace Bitrix\Main;
11
13
18{
20 protected $application;
21
23 protected $response;
24
26 protected $request;
27
29 protected $server;
30
32 protected $language;
33
35 protected $site;
36
38 protected $env;
39
41 protected $culture;
42
44 protected $params;
45
51 public function __construct(Application $application)
52 {
53 $this->application = $application;
54 }
55
64 public function initialize(Request $request, Response $response, Server $server, array $params = [])
65 {
66 $this->request = $request;
67 $this->response = $response;
68 $this->server = $server;
69 $this->params = $params;
70 }
71
72 public function getEnvironment()
73 {
74 if ($this->env === null)
75 {
76 $this->env = new Environment($this->params['env']);
77 }
78 return $this->env;
79 }
80
86 public function getResponse()
87 {
88 return $this->response;
89 }
90
97 public function setResponse(Response $response)
98 {
99 $this->response = $response;
100 return $this;
101 }
102
108 public function getRequest()
109 {
110 return $this->request;
111 }
112
118 public function getServer()
119 {
120 return $this->server;
121 }
122
128 public function getApplication()
129 {
130 return $this->application;
131 }
132
138 public function getCulture()
139 {
140 return $this->culture;
141 }
142
148 public function getLanguage()
149 {
150 return $this->language ? $this->language->getLid() : null;
151 }
152
158 public function getLanguageObject(): ?Localization\EO_Language
159 {
160 return $this->language;
161 }
162
168 public function getSite()
169 {
170 return $this->site ? $this->site->getLid() : null;
171 }
172
178 public function getSiteObject(): ?EO_Site
179 {
180 return $this->site;
181 }
182
189 public function setCulture(Context\Culture $culture)
190 {
191 $this->culture = $culture;
192 return $this;
193 }
194
201 public function setLanguage($language)
202 {
203 if ($language instanceof Localization\EO_Language)
204 {
205 $this->language = $language;
206 }
207 else
208 {
209 $this->language = Localization\LanguageTable::wakeUpObject($language);
210 $this->language->fill(ORM\Fields\FieldTypeMask::SCALAR | ORM\Fields\FieldTypeMask::EXPRESSION);
211 }
212 return $this;
213 }
214
221 public function setSite($site)
222 {
223 if ($site instanceof EO_Site)
224 {
225 $this->site = $site;
226 }
227 else
228 {
229 $this->site = SiteTable::wakeUpObject($site);
230 $this->site->fill(ORM\Fields\FieldTypeMask::SCALAR | ORM\Fields\FieldTypeMask::EXPRESSION);
231 }
232 return $this;
233 }
234
241 public static function getCurrent()
242 {
244 {
246 return $application->getContext();
247 }
248
249 return null;
250 }
251}
__construct(Application $application)
Definition context.php:51
initialize(Request $request, Response $response, Server $server, array $params=[])
Definition context.php:64
static getCurrent()
Definition context.php:241
setLanguage($language)
Definition context.php:201
setResponse(Response $response)
Definition context.php:97
setCulture(Context\Culture $culture)
Definition context.php:189