1 | <?php |
||||
2 | |||||
3 | namespace Jaxon\Di\Traits; |
||||
4 | |||||
5 | use Jaxon\App\Config\ConfigManager; |
||||
6 | use Jaxon\App\I18n\Translator; |
||||
7 | use Jaxon\Di\Container; |
||||
8 | use Jaxon\Plugin\Manager\PluginManager; |
||||
9 | use Jaxon\Response\Manager\ResponseManager; |
||||
10 | use Jaxon\Response\Response; |
||||
11 | use Jaxon\Response\ResponseInterface; |
||||
12 | use Nyholm\Psr7\Factory\Psr17Factory; |
||||
13 | use Psr\Http\Message\ServerRequestInterface; |
||||
14 | |||||
15 | use function trim; |
||||
16 | |||||
17 | trait ResponseTrait |
||||
18 | { |
||||
19 | /** |
||||
20 | * Register the values into the container |
||||
21 | * |
||||
22 | * @return void |
||||
23 | */ |
||||
24 | private function registerResponses() |
||||
25 | { |
||||
26 | // Global Response |
||||
27 | $this->set(Response::class, function($di) { |
||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
28 | return new Response($di->g(PluginManager::class), |
||||
29 | $di->g(Psr17Factory::class), $di->g(ServerRequestInterface::class)); |
||||
30 | }); |
||||
31 | // Response Manager |
||||
32 | $this->set(ResponseManager::class, function($di) { |
||||
33 | return new ResponseManager(trim($di->g(ConfigManager::class)->getOption('core.encoding', '')), |
||||
34 | $di->g(Container::class), $di->g(Translator::class)); |
||||
35 | }); |
||||
36 | } |
||||
37 | |||||
38 | /** |
||||
39 | * Get the response manager |
||||
40 | * |
||||
41 | * @return ResponseManager |
||||
42 | */ |
||||
43 | public function getResponseManager(): ResponseManager |
||||
44 | { |
||||
45 | return $this->g(ResponseManager::class); |
||||
0 ignored issues
–
show
It seems like
g() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
46 | } |
||||
47 | |||||
48 | /** |
||||
49 | * Get the global Response object |
||||
50 | * |
||||
51 | * @return ResponseInterface |
||||
52 | */ |
||||
53 | public function getResponse(): ResponseInterface |
||||
54 | { |
||||
55 | return $this->g(Response::class); |
||||
56 | } |
||||
57 | |||||
58 | /** |
||||
59 | * Create a new Jaxon response object |
||||
60 | * |
||||
61 | * @return ResponseInterface |
||||
62 | */ |
||||
63 | public function newResponse(): ResponseInterface |
||||
64 | { |
||||
65 | return new Response($this->g(PluginManager::class), |
||||
66 | $this->g(Psr17Factory::class), $this->g(ServerRequestInterface::class)); |
||||
67 | } |
||||
68 | |||||
69 | /** |
||||
70 | * Get the Psr17 factory |
||||
71 | * |
||||
72 | * @return Psr17Factory |
||||
73 | */ |
||||
74 | public function getPsr17Factory(): Psr17Factory |
||||
75 | { |
||||
76 | return $this->g(Psr17Factory::class); |
||||
77 | } |
||||
78 | } |
||||
79 |