1 | <?php |
||
8 | trait ContentNegotiation |
||
9 | { |
||
10 | /** |
||
11 | * Get request, set for controller |
||
12 | * |
||
13 | * @return ServerRequestInterface |
||
14 | */ |
||
15 | abstract public function getRequest(); |
||
16 | |||
17 | /** |
||
18 | * Pick best content type |
||
19 | * |
||
20 | * @param array $priorities |
||
21 | * @return string |
||
22 | */ |
||
23 | 2 | public function negotiateContentType(array $priorities) |
|
27 | |||
28 | /** |
||
29 | * Pick best language |
||
30 | * |
||
31 | * @param array $priorities |
||
32 | * @return string |
||
33 | */ |
||
34 | 2 | public function negotiateLanguage(array $priorities) |
|
38 | |||
39 | /** |
||
40 | * Pick best encoding |
||
41 | * |
||
42 | * @param array $priorities |
||
43 | * @return string |
||
44 | */ |
||
45 | 2 | public function negotiateEncoding(array $priorities) |
|
49 | |||
50 | /** |
||
51 | * Pick best charset |
||
52 | * |
||
53 | * @param array $priorities |
||
54 | * @return string |
||
55 | */ |
||
56 | 2 | public function negotiateCharset(array $priorities) |
|
60 | |||
61 | /** |
||
62 | * Generalize negotiation |
||
63 | * |
||
64 | * @param array $priorities |
||
65 | * @param string $type Negotiator type |
||
66 | * @return string |
||
67 | */ |
||
68 | 8 | protected function negotiate(array $priorities, $type = '') |
|
84 | |||
85 | /** |
||
86 | * Get negotiation library instance |
||
87 | * |
||
88 | * @param string $type Negotiator type |
||
89 | * @return Negotiation\AbstractNegotiator |
||
90 | */ |
||
91 | protected function getNegotiator($type = '') |
||
97 | |||
98 | /** |
||
99 | * Get negotiator name |
||
100 | * |
||
101 | * @param string $type |
||
102 | * @return string |
||
103 | */ |
||
104 | 8 | protected function getNegotiatorName($type = '') |
|
108 | } |
||
109 |