コード例 #1
0
 /**
  * @param Request $request
  * @param Created $payload
  */
 public function created(Request $request, Created $payload)
 {
     $serializer = Startgroup::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 201, ['Location' => $resource->getLinks()['self']]);
 }
コード例 #2
0
 /**
  * @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);
 }
コード例 #3
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = Routine::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['startgroup', 'performance-total-statistic', 'performance-execution-statistic', 'performance-choreography-statistic', 'performance-music-and-timing-statistic', 'performance-scores']));
     $resource = $resource->fields($params->getFields(['routine' => Routine::getSerializer()->getFields(), 'startgroup' => Startgroup::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(), 'performance-score' => PerformanceScore::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
コード例 #4
0
ファイル: JudgeReadJsonResponder.php プロジェクト: iuf/junia
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = Judge::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['startgroup', 'user', 'performance-score']));
     $resource = $resource->fields($params->getFields(['judge' => Judge::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields(), 'user' => User::getSerializer()->getFields(), 'performance-score' => PerformanceScore::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
コード例 #5
0
 /**
  * @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);
 }
コード例 #6
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = Competition::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['startgroups']));
     $resource = $resource->fields($params->getFields(['competition' => Competition::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
コード例 #7
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $data = $payload->getModel();
     $serializer = Judge::getSerializer();
     $resource = new Collection($data, $serializer);
     $resource = $resource->with($params->getInclude(['startgroup', 'user', 'performance-score']));
     $resource = $resource->fields($params->getFields(['judge' => Judge::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields(), 'user' => User::getSerializer()->getFields(), 'performance-score' => PerformanceScore::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());
 }
コード例 #8
0
 /**
  * @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());
 }
コード例 #9
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function read(Request $request, Found $payload)
 {
     $serializer = Startgroup::getSerializer();
     $relationship = $serializer->performanceTotalStatistic($payload->getModel());
     return new JsonResponse($relationship->toArray());
 }
コード例 #10
0
 /**
  * @param Request $request
  * @param Updated $payload
  */
 public function updated(Request $request, Updated $payload)
 {
     $serializer = Startgroup::getSerializer();
     $relationship = $serializer->routines($payload->getModel());
     return new JsonResponse($relationship->toArray());
 }
コード例 #11
0
 /**
  * @param mixed $model
  * @return Relationship
  */
 public function startgroups($model)
 {
     $relationship = new Relationship(new Collection($model->getStartgroups(), Startgroup::getSerializer()));
     return $this->addRelationshipSelfLink($relationship, $model, 'startgroup');
 }
コード例 #12
0
ファイル: RoutineSerializerTrait.php プロジェクト: iuf/junia
 /**
  * @param mixed $model
  * @return Relationship
  */
 public function startgroup($model)
 {
     $serializer = Startgroup::getSerializer();
     $id = $serializer->getId($model->getStartgroup());
     if ($id !== null) {
         $relationship = new Relationship(new Resource($model->getStartgroup(), $serializer));
         $relationship->setLinks(['related' => '%apiurl%' . $serializer->getType(null) . '/' . $id]);
         return $this->addRelationshipSelfLink($relationship, $model, 'startgroup');
     }
     return null;
 }
コード例 #13
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function read(Request $request, Found $payload)
 {
     $serializer = Startgroup::getSerializer();
     $relationship = $serializer->competition($payload->getModel());
     return new JsonResponse($relationship->toArray());
 }
コード例 #14
0
ファイル: StartgroupDomainTrait.php プロジェクト: iuf/junia
 /**
  * Updates a Startgroup 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' => 'Startgroup not found.']);
     }
     // hydrate
     $serializer = Startgroup::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 StartgroupEvent($model);
     $dispatcher = $this->getServiceContainer()->getDispatcher();
     $dispatcher->dispatch(StartgroupEvent::PRE_UPDATE, $event);
     $dispatcher->dispatch(StartgroupEvent::PRE_SAVE, $event);
     $rows = $model->save();
     $dispatcher->dispatch(StartgroupEvent::POST_UPDATE, $event);
     $dispatcher->dispatch(StartgroupEvent::POST_SAVE, $event);
     $payload = ['model' => $model];
     if ($rows === 0) {
         return new NotUpdated($payload);
     }
     return new Updated($payload);
 }