/** * @param Request $request * @param Created $payload */ public function created(Request $request, Created $payload) { $serializer = Event::getSerializer(); $resource = new Resource($payload->getModel(), $serializer); $document = new Document($resource); return new JsonResponse($document->toArray(), 201, ['Location' => $resource->getLinks()['self']]); }
/** * @param Request $request * @param Updated $payload */ public function updated(Request $request, Updated $payload) { $params = new Parameters($request->query->all()); $serializer = Startgroup::getSerializer(); $resource = new Resource($payload->getModel(), $serializer); $resource = $resource->with($params->getInclude(['competition', 'event', 'performance-total-statistic', 'performance-execution-statistic', 'performance-choreography-statistic', 'performance-music-and-timing-statistic', 'routines', 'judges', 'routines.performance-total-statistic', 'routines.performance-execution-statistic', 'routines.performance-choreography-statistic', 'routines.performance-music-and-timing-statistic', 'routines.performance-scores', 'routines.performance-scores.judge'])); $resource = $resource->fields($params->getFields(['startgroup' => Startgroup::getSerializer()->getFields(), 'competition' => Competition::getSerializer()->getFields(), 'event' => Event::getSerializer()->getFields(), 'performance-total-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-execution-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-choreography-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-music-and-timing-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'routine' => Routine::getSerializer()->getFields(), 'judge' => Judge::getSerializer()->getFields()])); $document = new Document($resource); return new JsonResponse($document->toArray(), 200); }
/** * @param Request $request * @param Updated $payload */ public function updated(Request $request, Updated $payload) { $params = new Parameters($request->query->all()); $serializer = PerformanceStatistic::getSerializer(); $resource = new Resource($payload->getModel(), $serializer); $resource = $resource->with($params->getInclude(['events', 'startgroups', 'routine'])); $resource = $resource->fields($params->getFields(['performance-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'event' => Event::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields(), 'routine' => Routine::getSerializer()->getFields()])); $document = new Document($resource); return new JsonResponse($document->toArray(), 200); }
/** * @param Request $request * @param Found $payload */ public function found(Request $request, Found $payload) { $params = new Parameters($request->query->all()); $data = $payload->getModel(); $serializer = Startgroup::getSerializer(); $resource = new Collection($data, $serializer); $resource = $resource->with($params->getInclude(['competition', 'event', 'performance-total-statistic', 'performance-execution-statistic', 'performance-choreography-statistic', 'performance-music-and-timing-statistic', 'routines', 'judges', 'routines.performance-total-statistic', 'routines.performance-execution-statistic', 'routines.performance-choreography-statistic', 'routines.performance-music-and-timing-statistic', 'routines.performance-scores', 'routines.performance-scores.judge'])); $resource = $resource->fields($params->getFields(['startgroup' => Startgroup::getSerializer()->getFields(), 'competition' => Competition::getSerializer()->getFields(), 'event' => Event::getSerializer()->getFields(), 'performance-total-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-execution-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-choreography-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-music-and-timing-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'routine' => Routine::getSerializer()->getFields(), 'judge' => Judge::getSerializer()->getFields()])); $document = new Document($resource); // meta $document->setMeta(['total' => $data->getNbResults(), 'first' => $data->getFirstPage(), 'next' => $data->getNextPage(), 'previous' => $data->getPreviousPage(), 'last' => $data->getLastPage()]); // return response return new JsonResponse($document->toArray()); }
/** * @param Request $request * @param Found $payload */ public function found(Request $request, Found $payload) { $params = new Parameters($request->query->all()); $data = $payload->getModel(); $serializer = PerformanceStatistic::getSerializer(); $resource = new Collection($data, $serializer); $resource = $resource->with($params->getInclude(['events', 'startgroups', 'routine'])); $resource = $resource->fields($params->getFields(['performance-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'event' => Event::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields(), 'routine' => Routine::getSerializer()->getFields()])); $document = new Document($resource); // meta $document->setMeta(['total' => $data->getNbResults(), 'first' => $data->getFirstPage(), 'next' => $data->getNextPage(), 'previous' => $data->getPreviousPage(), 'last' => $data->getLastPage()]); // return response return new JsonResponse($document->toArray()); }
/** */ public function getRelationships() { return ['competition' => Competition::getSerializer()->getType(null), 'event' => Event::getSerializer()->getType(null), 'performance-total-statistic' => PerformanceStatistic::getSerializer()->getType(null), 'performance-execution-statistic' => PerformanceStatistic::getSerializer()->getType(null), 'performance-choreography-statistic' => PerformanceStatistic::getSerializer()->getType(null), 'performance-music-and-timing-statistic' => PerformanceStatistic::getSerializer()->getType(null), 'routines' => Routine::getSerializer()->getType(null), 'judges' => Judge::getSerializer()->getType(null)]; }
/** */ public function getRelationships() { return ['events' => Event::getSerializer()->getType(null), 'startgroups' => Startgroup::getSerializer()->getType(null), 'routine' => Routine::getSerializer()->getType(null)]; }
/** * @param Request $request * @param Found $payload */ public function read(Request $request, Found $payload) { $serializer = Event::getSerializer(); $relationship = $serializer->performanceChoreographyStatistic($payload->getModel()); return new JsonResponse($relationship->toArray()); }
/** * Updates a Event with the given idand the provided data * * @param mixed $id * @param mixed $data * @return PayloadInterface */ public function update($id, $data) { // find $model = $this->get($id); if ($model === null) { return new NotFound(['message' => 'Event not found.']); } // hydrate $serializer = Event::getSerializer(); $model = $serializer->hydrate($model, $data); // validate $validator = $this->getValidator(); if ($validator !== null && !$validator->validate($model)) { return new NotValid(['errors' => $validator->getValidationFailures()]); } // dispatch $event = new EventEvent($model); $dispatcher = $this->getServiceContainer()->getDispatcher(); $dispatcher->dispatch(EventEvent::PRE_UPDATE, $event); $dispatcher->dispatch(EventEvent::PRE_SAVE, $event); $rows = $model->save(); $dispatcher->dispatch(EventEvent::POST_UPDATE, $event); $dispatcher->dispatch(EventEvent::POST_SAVE, $event); $payload = ['model' => $model]; if ($rows === 0) { return new NotUpdated($payload); } return new Updated($payload); }
/** * @param Request $request * @param Updated $payload */ public function updated(Request $request, Updated $payload) { $serializer = Event::getSerializer(); $relationship = $serializer->startgroups($payload->getModel()); return new JsonResponse($relationship->toArray()); }