1 | <?php |
||
36 | class ServerContext implements ServerContextInterface |
||
37 | { |
||
38 | /** |
||
39 | * Optionally Holds an container implementation of third party environment. |
||
40 | * So every mod depending on his environment can use this as a container to transfer environment specific stuff. |
||
41 | * |
||
42 | * @var mixed |
||
43 | */ |
||
44 | protected $container; |
||
45 | |||
46 | /** |
||
47 | * All logger instances will be hold here. |
||
48 | * Every logger instance has to be a PSR compatible |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | protected $loggers; |
||
53 | |||
54 | /** |
||
55 | * Holds upstream instances |
||
56 | * |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $upstreams; |
||
60 | |||
61 | /** |
||
62 | * Holds the config instance |
||
63 | * |
||
64 | * @var \AppserverIo\Server\Interfaces\ServerConfigurationInterface $serverConfig |
||
65 | */ |
||
66 | protected $serverConfig; |
||
67 | |||
68 | /** |
||
69 | * Initialises the server context |
||
70 | * |
||
71 | * @param \AppserverIo\Server\Interfaces\ServerConfigurationInterface $serverConfig The servers configuration |
||
72 | * |
||
73 | * @return void |
||
74 | */ |
||
75 | public function init(ServerConfigurationInterface $serverConfig) |
||
84 | |||
85 | /** |
||
86 | * Returns the server config instance |
||
87 | * |
||
88 | * @return \AppserverIo\Server\Interfaces\ServerConfigurationInterface The server config instance |
||
89 | */ |
||
90 | public function getServerConfig() |
||
94 | |||
95 | /** |
||
96 | * Injects the stream context object for the server socket to be bound with. |
||
97 | * |
||
98 | * @param resource $streamContext The stream context instance to inject |
||
99 | * |
||
100 | * @return void |
||
101 | */ |
||
102 | public function injectStreamContext($streamContext) |
||
106 | |||
107 | /** |
||
108 | * Returns the corresponding stream context for server socket to be bound with. |
||
109 | * |
||
110 | * @return resource |
||
111 | */ |
||
112 | public function getStreamContext() |
||
116 | |||
117 | /** |
||
118 | * Injects the container for further use in specific server mods etc... |
||
119 | * |
||
120 | * @param mixed $container An container instance for third party environment |
||
121 | * |
||
122 | * @return void |
||
123 | */ |
||
124 | public function injectContainer($container) |
||
128 | |||
129 | /** |
||
130 | * Returns the container instance |
||
131 | * |
||
132 | * @return mixed The container instance for third party environment |
||
133 | */ |
||
134 | public function getContainer() |
||
138 | |||
139 | /** |
||
140 | * Injects upstream instances |
||
141 | * |
||
142 | * @param array $upstreams The array of upstream instances |
||
143 | * |
||
144 | * @return void |
||
145 | */ |
||
146 | public function injectUpstreams(array $upstreams) |
||
153 | |||
154 | /** |
||
155 | * Returns specific upstream by given name from upstream collection |
||
156 | * |
||
157 | * @param string $upstreamName The upstreams name to find |
||
158 | * |
||
159 | * @throws ServerException |
||
160 | * @return \AppserverIo\Server\Interfaces\UpstreamInterface |
||
161 | */ |
||
162 | public function getUpstream($upstreamName) |
||
170 | |||
171 | /** |
||
172 | * Injects compatible logger instances |
||
173 | * |
||
174 | * @param array<\Psr\Log\LoggerInterface> $loggers The array of logger instances |
||
175 | * |
||
176 | * @return void |
||
177 | */ |
||
178 | public function injectLoggers(array $loggers) |
||
185 | |||
186 | /** |
||
187 | * Queries if the requested logger type is registered or not. |
||
188 | * |
||
189 | * @param string $loggerType The logger type we want to query |
||
190 | * |
||
191 | * @return boolean TRUE if the logger is registered, else FALSE |
||
192 | */ |
||
193 | public function hasLogger($loggerType) |
||
197 | |||
198 | /** |
||
199 | * Returns the logger instance |
||
200 | * |
||
201 | * @param string $loggerType the logger's type to get |
||
202 | * |
||
203 | * @return \Psr\Log\LoggerInterface|null The logger instance |
||
204 | * @throws \AppserverIo\Server\Exceptions\ServerException |
||
205 | */ |
||
206 | public function getLogger($loggerType = self::DEFAULT_LOGGER_TYPE) |
||
216 | } |
||
217 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: