1 | <?php |
||
10 | class AbstractController extends Controller |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * Constant with webservice response type JSON |
||
15 | */ |
||
16 | const WS_RESPONSE_JSON = 'json'; |
||
17 | |||
18 | /** |
||
19 | * Constant with webservice response type XML |
||
20 | */ |
||
21 | const WS_RESPONSE_XML = 'xml'; |
||
22 | |||
23 | /** |
||
24 | * Gets the current request object. |
||
25 | * |
||
26 | * @return Request |
||
27 | */ |
||
28 | protected function getCurrentRequest() |
||
32 | |||
33 | /** |
||
34 | * Gets the action name. |
||
35 | * |
||
36 | * @param Request $request HTTP request object |
||
37 | * |
||
38 | * @return string Action name |
||
39 | */ |
||
40 | protected function getActionName(Request &$request) |
||
46 | |||
47 | /** |
||
48 | * Gets the bundle name. |
||
49 | * |
||
50 | * <b>Attention! This method returns the bundle name as the conventions of framewok.</b> |
||
51 | * Example: "Mero/Bundle/BaseBundle" or "Mero/BaseBundle" returns "MeroBaseBundle". |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | protected function getBundleName() |
||
65 | |||
66 | /** |
||
67 | * Gets the route name. |
||
68 | * |
||
69 | * @param Request $request HTTP request object |
||
70 | * |
||
71 | * @return string Route name |
||
72 | */ |
||
73 | protected function getRouteName(Request &$request) |
||
77 | |||
78 | /** |
||
79 | * Return webservice(API Rest JSON or SOAP XML) response. |
||
80 | * |
||
81 | * @param mixed $data The response data |
||
82 | * @param int $status The response status code |
||
83 | * @param array $headers An array of response headers |
||
84 | * @param string $format Response format(json or xml) |
||
85 | * |
||
86 | * @throws UnsupportedFormatException When format is not json or xml |
||
87 | * |
||
88 | * @return Response |
||
89 | */ |
||
90 | protected function wsResponse($data, $status = 200, array $headers = [], $format = self::WS_RESPONSE_JSON) |
||
102 | } |
||
103 |