1 | <?php |
||
12 | class AbstractController extends Controller |
||
13 | { |
||
14 | /** |
||
15 | * Gets the current request object. |
||
16 | * |
||
17 | * @return Request |
||
18 | */ |
||
19 | protected function getCurrentRequest() |
||
23 | |||
24 | /** |
||
25 | * Gets the bundle name. |
||
26 | * |
||
27 | * <b>Attention! This method returns the bundle name as the conventions of framewok.</b> |
||
28 | * Example: "Mero/Bundle/BaseBundle" or "Mero/BaseBundle" returns "MeroBaseBundle". |
||
29 | * |
||
30 | * @return string |
||
31 | */ |
||
32 | protected function getBundleName() |
||
42 | |||
43 | /** |
||
44 | * Gets the action name. |
||
45 | * |
||
46 | * @return string Action name |
||
47 | */ |
||
48 | protected function getActionName() |
||
55 | |||
56 | /** |
||
57 | * Return JSON response. |
||
58 | * |
||
59 | * @param mixed $data The response data |
||
60 | * @param int $status The response status code |
||
61 | * @param string $format Response format(json or xml) |
||
62 | * |
||
63 | * @throws UnsupportedFormatException When format is not json or xml |
||
64 | * |
||
65 | * @return JsonResponse |
||
66 | */ |
||
67 | protected function apiResponse($data, $status, $format = 'json') |
||
78 | |||
79 | /** |
||
80 | * Returns a InvalidEntityException. |
||
81 | * |
||
82 | * This method returns an invalid entity exception. Usage exemple: |
||
83 | * |
||
84 | * throw $this->createInvalidEntityException('Invalid entity'); |
||
85 | * |
||
86 | * @param string $message A message |
||
87 | * @param \Exception|null $previous The previous exception |
||
88 | * |
||
89 | * @return InvalidEntityException |
||
90 | */ |
||
91 | protected function createInvalidEntityException($message = 'Entity is not object', \Exception $previous = null) |
||
95 | } |
||
96 |