1 | <?php |
||
13 | class ParamConverterManager |
||
14 | { |
||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $converters = []; |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $namedConverters = []; |
||
24 | |||
25 | /** |
||
26 | * Applies all converters to the passed configurations and stops when a |
||
27 | * converter is applied it will move on to the next configuration and so on. |
||
28 | * |
||
29 | * @param Request $request |
||
30 | * @param array|object $configurations |
||
31 | */ |
||
32 | 13 | public function apply(Request $request, $configurations) |
|
42 | |||
43 | /** |
||
44 | * Apply converter on request based on the given configuration. |
||
45 | * |
||
46 | * @param Request $request |
||
47 | * @param ParamConverter $configuration |
||
48 | */ |
||
49 | 7 | protected function applyConverter(Request $request, ParamConverter $configuration) |
|
73 | |||
74 | /** |
||
75 | * @param Request $request |
||
76 | * @param ParamConverter $configuration |
||
77 | */ |
||
78 | 3 | protected function applyNamedConverter(Request $request, ParamConverter $configuration) |
|
99 | |||
100 | /** |
||
101 | * Adds a parameter converter. |
||
102 | * |
||
103 | * Converters match either explicitly via $name or by iteration over all |
||
104 | * converters with a $priority. If you pass a $priority = null then the |
||
105 | * added converter will not be part of the iteration chain and can only |
||
106 | * be invoked explicitly. |
||
107 | * |
||
108 | * @param ParamConverterInterface $converter A ParamConverterInterface instance |
||
109 | * @param int $priority The priority (between -10 and 10). |
||
110 | * @param string $name Name of the converter. |
||
111 | */ |
||
112 | 13 | public function add(ParamConverterInterface $converter, $priority = 0, $name = null) |
|
126 | |||
127 | /** |
||
128 | * Returns all registered param converters. |
||
129 | * |
||
130 | * @return array An array of param converters |
||
131 | */ |
||
132 | 4 | public function all() |
|
143 | } |
||
144 |