1 | <?php |
||
16 | class RequestHandler |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * @var Serializer $serializer |
||
21 | */ |
||
22 | private $serializer; |
||
23 | |||
24 | /** |
||
25 | * @var RequestInterface $entity |
||
26 | */ |
||
27 | private $entity; |
||
28 | |||
29 | /** |
||
30 | * @var int $argumentPosition |
||
31 | */ |
||
32 | private $argumentPosition = 0; |
||
33 | |||
34 | /** |
||
35 | * @var bool $bound |
||
36 | */ |
||
37 | private $bound = false; |
||
38 | |||
39 | /** |
||
40 | * @param Serializer $serializer |
||
41 | */ |
||
42 | public function __construct(Serializer $serializer) |
||
46 | |||
47 | /** |
||
48 | * Method will deserialize request content and bind it to the provided entity |
||
49 | * |
||
50 | * @param string $entityClass |
||
51 | * @param string $content |
||
52 | * @param DeserializationContext $context |
||
53 | */ |
||
54 | public function deserialize($entityClass, $content, DeserializationContext $context = null) |
||
68 | |||
69 | /** |
||
70 | * Hydrating request objects from arrays |
||
71 | * |
||
72 | * @param string $entityClass |
||
73 | * @param array $content |
||
74 | */ |
||
75 | public function hydrate($entityClass, array $content) |
||
88 | |||
89 | /** |
||
90 | * Position of our entity in method parameters |
||
91 | * |
||
92 | * @param int $position |
||
93 | * @return $this |
||
94 | */ |
||
95 | public function setArgumentPosition($position) |
||
101 | |||
102 | /** |
||
103 | * Get the deserialized entity |
||
104 | * |
||
105 | * @return null|RequestInterface |
||
106 | */ |
||
107 | public function getBoundRequest() |
||
111 | |||
112 | /** |
||
113 | * Did we manage to find an entity for this request? |
||
114 | * |
||
115 | * @return bool |
||
116 | */ |
||
117 | public function isBound() |
||
121 | |||
122 | /** |
||
123 | * We inject our deserialized entity into method parameters |
||
124 | * |
||
125 | * @param $parameters |
||
126 | * @return array |
||
127 | */ |
||
128 | public function bindRequest(array $parameters) |
||
139 | |||
140 | } |
||
141 |