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