/** * @param mixed $position */ public function getPerformanceJudge($position) { $judges = $this->getJudges(); foreach ($judges as $judge) { if ($judge->getPosition() == 'P' . $position) { return $judge; } } $judge = new Judge(); $judge->setPosition('P' . $position); $judge->setStartgroup($this); $judge->save(); return $judge; }
/** * @param Request $request * @param Created $payload */ public function created(Request $request, Created $payload) { $serializer = Judge::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 = PerformanceScore::getSerializer(); $resource = new Resource($payload->getModel(), $serializer); $resource = $resource->with($params->getInclude(['routine', 'judge'])); $resource = $resource->fields($params->getFields(['performance-score' => PerformanceScore::getSerializer()->getFields(), 'routine' => Routine::getSerializer()->getFields(), 'judge' => Judge::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()); $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); }
/** * @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 mixed $model * @return Relationship */ public function judge($model) { $serializer = Judge::getSerializer(); $id = $serializer->getId($model->getJudge()); if ($id !== null) { $relationship = new Relationship(new Resource($model->getJudge(), $serializer)); $relationship->setLinks(['related' => '%apiurl%' . $serializer->getType(null) . '/' . $id]); return $this->addRelationshipSelfLink($relationship, $model, 'judge'); } return null; }
/** * @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()); }
/** * @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 read(Request $request, Found $payload) { $serializer = Judge::getSerializer(); $relationship = $serializer->user($payload->getModel()); return new JsonResponse($relationship->toArray()); }
/** * Filter the query by a related \iuf\junia\model\Judge object * * @param \iuf\junia\model\Judge|ObjectCollection $judge The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @throws \Propel\Runtime\Exception\PropelException * * @return ChildPerformanceScoreQuery The current query, for fluid interface */ public function filterByJudge($judge, $comparison = null) { if ($judge instanceof \iuf\junia\model\Judge) { return $this->addUsingAlias(PerformanceScoreTableMap::COL_JUDGE_ID, $judge->getId(), $comparison); } elseif ($judge instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(PerformanceScoreTableMap::COL_JUDGE_ID, $judge->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByJudge() only accepts arguments of type \\iuf\\junia\\model\\Judge or Collection'); } }
/** * @param mixed $model * @return Relationship */ public function judges($model) { $relationship = new Relationship(new Collection($model->getJudges(), Judge::getSerializer())); return $this->addRelationshipSelfLink($relationship, $model, 'judge'); }
/** * Clears the current object, sets all attributes to their default values and removes * outgoing references as well as back-references (from other objects to this one. Results probably in a database * change of those foreign objects when you call `save` there). */ public function clear() { if (null !== $this->aScore) { $this->aScore->removePerformanceScore($this); } if (null !== $this->aRoutine) { $this->aRoutine->removePerformanceScore($this); } if (null !== $this->aJudge) { $this->aJudge->removePerformanceScore($this); } $this->execution = null; $this->choreography = null; $this->music_and_timing = null; $this->id = null; $this->routine_id = null; $this->judge_id = null; $this->total = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
/** * @param ChildJudge $judge The ChildJudge object to add. */ protected function doAddJudge(ChildJudge $judge) { $this->collJudges[] = $judge; $judge->setStartgroup($this); }
/** * Updates a Judge 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' => 'Judge not found.']); } // hydrate $serializer = Judge::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 JudgeEvent($model); $dispatcher = $this->getServiceContainer()->getDispatcher(); $dispatcher->dispatch(JudgeEvent::PRE_UPDATE, $event); $dispatcher->dispatch(JudgeEvent::PRE_SAVE, $event); $rows = $model->save(); $dispatcher->dispatch(JudgeEvent::POST_UPDATE, $event); $dispatcher->dispatch(JudgeEvent::POST_SAVE, $event); $payload = ['model' => $model]; if ($rows === 0) { return new NotUpdated($payload); } return new Updated($payload); }
/** * Filter the query by a related \iuf\junia\model\Judge object * * @param \iuf\junia\model\Judge|ObjectCollection $judge the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildStartgroupQuery The current query, for fluid interface */ public function filterByJudge($judge, $comparison = null) { if ($judge instanceof \iuf\junia\model\Judge) { return $this->addUsingAlias(StartgroupTableMap::COL_ID, $judge->getStartgroupId(), $comparison); } elseif ($judge instanceof ObjectCollection) { return $this->useJudgeQuery()->filterByPrimaryKeys($judge->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByJudge() only accepts arguments of type \\iuf\\junia\\model\\Judge or Collection'); } }
/** * Exclude object from result * * @param ChildJudge $judge Object to remove from the list of results * * @return $this|ChildJudgeQuery The current query, for fluid interface */ public function prune($judge = null) { if ($judge) { $this->addUsingAlias(JudgeTableMap::COL_ID, $judge->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Clears the current object, sets all attributes to their default values and removes * outgoing references as well as back-references (from other objects to this one. Results probably in a database * change of those foreign objects when you call `save` there). */ public function clear() { if (null !== $this->aRoutine) { $this->aRoutine->removeScore($this); } if (null !== $this->aJudge) { $this->aJudge->removeScore($this); } $this->id = null; $this->routine_id = null; $this->judge_id = null; $this->total = null; $this->descendant_class = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }