|
1
|
|
|
<?php |
|
2
|
|
|
|
|
|
|
|
|
|
3
|
|
|
namespace Jaxon\Container\Traits; |
|
4
|
|
|
|
|
5
|
|
|
use Jaxon\Jaxon; |
|
6
|
|
|
use Jaxon\Plugin\Manager as PluginManager; |
|
7
|
|
|
use Jaxon\Request\Factory\ParameterFactory; |
|
8
|
|
|
use Jaxon\Request\Factory\RequestFactory; |
|
9
|
|
|
use Jaxon\Request\Handler\Handler as RequestHandler; |
|
10
|
|
|
use Jaxon\Request\Plugin\FileUpload; |
|
11
|
|
|
use Jaxon\Request\Support\CallableRegistry; |
|
12
|
|
|
use Jaxon\Response\Manager as ResponseManager; |
|
13
|
|
|
use Jaxon\Response\Plugin\DataBag; |
|
14
|
|
|
|
|
15
|
|
|
trait RequestTrait |
|
|
|
|
|
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* Register the values into the container |
|
19
|
|
|
* |
|
20
|
|
|
* @return void |
|
21
|
|
|
*/ |
|
22
|
|
|
private function registerRequests() |
|
|
|
|
|
|
23
|
|
|
{ |
|
24
|
|
|
// Request Handler |
|
25
|
|
|
$this->set(RequestHandler::class, function($c) { |
|
|
|
|
|
|
26
|
|
|
return new RequestHandler($c->g(Jaxon::class), $c->g(PluginManager::class), |
|
27
|
|
|
$c->g(ResponseManager::class), $c->g(FileUpload::class), $c->g(DataBag::class)); |
|
28
|
|
|
}); |
|
29
|
|
|
// Request Factory |
|
30
|
|
|
$this->set(RequestFactory::class, function($c) { |
|
31
|
|
|
return new RequestFactory($c->g(CallableRegistry::class)); |
|
32
|
|
|
}); |
|
33
|
|
|
// Parameter Factory |
|
34
|
|
|
$this->set(ParameterFactory::class, function() { |
|
35
|
|
|
return new ParameterFactory(); |
|
36
|
|
|
}); |
|
37
|
|
|
} |
|
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Get the request handler |
|
41
|
|
|
* |
|
42
|
|
|
* @return RequestHandler |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getRequestHandler() |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->g(RequestHandler::class); |
|
|
|
|
|
|
47
|
|
|
} |
|
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Get the request factory |
|
51
|
|
|
* |
|
52
|
|
|
* @return RequestFactory |
|
53
|
|
|
*/ |
|
54
|
|
|
public function getRequestFactory() |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->g(RequestFactory::class); |
|
57
|
|
|
} |
|
|
|
|
|
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Get the parameter factory |
|
61
|
|
|
* |
|
62
|
|
|
* @return ParameterFactory |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getParameterFactory() |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->g(ParameterFactory::class); |
|
67
|
|
|
} |
|
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|