/** * {@inheritdoc} */ public function send() { $data = array_merge(array('success' => $this->statusCode >= 200 && $this->statusCode <= 300, 'data' => $this->normalize($this->data)), $this->extra); switch (strtolower($this->request->get('format'))) { case 'debug': $this->setContent(sprintf('<pre>%s</pre>', print_r($data, true))); return parent::send(); break; case 'rjson': $response = new RJsonResponse($data, $this->statusCode, $this->headers->all()); break; default: $response = new JsonResponse($data, $this->statusCode, $this->headers->all()); } return $response->send(); }
/** * Reschedule movie. * * @param string $id * @param Request $request * * @return JsonResponse */ public function rescheduleAction($id, Request $request) { $command = new RescheduleMovieCommand(MovieId::fromString($id), new DateTime($request->get('schedule'))); $response = $this->invoke($command); return $this->response(!empty($response) ? $response[0][0] : null); }