Пример #1
0
 /**
  * @param Request $request
  * @param Created $payload
  */
 public function created(Request $request, Created $payload)
 {
     $serializer = Competition::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 = 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);
 }
Пример #4
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());
 }
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $data = $payload->getModel();
     $serializer = Competition::getSerializer();
     $resource = new Collection($data, $serializer);
     $resource = $resource->with($params->getInclude(['startgroups']));
     $resource = $resource->fields($params->getFields(['competition' => Competition::getSerializer()->getFields(), 'startgroup' => Startgroup::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());
 }
Пример #6
0
 /**
  * Updates a Competition 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' => 'Competition not found.']);
     }
     // hydrate
     $serializer = Competition::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 CompetitionEvent($model);
     $dispatcher = $this->getServiceContainer()->getDispatcher();
     $dispatcher->dispatch(CompetitionEvent::PRE_UPDATE, $event);
     $dispatcher->dispatch(CompetitionEvent::PRE_SAVE, $event);
     $rows = $model->save();
     $dispatcher->dispatch(CompetitionEvent::POST_UPDATE, $event);
     $dispatcher->dispatch(CompetitionEvent::POST_SAVE, $event);
     $payload = ['model' => $model];
     if ($rows === 0) {
         return new NotUpdated($payload);
     }
     return new Updated($payload);
 }
Пример #7
0
 /**
  */
 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)];
 }
Пример #8
0
 /**
  * Filter the query by a related \iuf\junia\model\Competition object
  *
  * @param \iuf\junia\model\Competition|ObjectCollection $competition 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 ChildStartgroupQuery The current query, for fluid interface
  */
 public function filterByCompetition($competition, $comparison = null)
 {
     if ($competition instanceof \iuf\junia\model\Competition) {
         return $this->addUsingAlias(StartgroupTableMap::COL_COMPETITION_ID, $competition->getId(), $comparison);
     } elseif ($competition instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(StartgroupTableMap::COL_COMPETITION_ID, $competition->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByCompetition() only accepts arguments of type \\iuf\\junia\\model\\Competition or Collection');
     }
 }
Пример #9
0
 /**
  * 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->aCompetition) {
         $this->aCompetition->removeStartgroup($this);
     }
     if (null !== $this->aEvent) {
         $this->aEvent->removeStartgroup($this);
     }
     if (null !== $this->aPerformanceTotalStatistic) {
         $this->aPerformanceTotalStatistic->removeStartgroupRelatedByPerformanceTotalStatisticId($this);
     }
     if (null !== $this->aPerformanceExecutionStatistic) {
         $this->aPerformanceExecutionStatistic->removeStartgroupRelatedByPerformanceExecutionStatisticId($this);
     }
     if (null !== $this->aPerformanceChoreographyStatistic) {
         $this->aPerformanceChoreographyStatistic->removeStartgroupRelatedByPerformanceChoreographyStatisticId($this);
     }
     if (null !== $this->aPerformanceMusicAndTimingStatistic) {
         $this->aPerformanceMusicAndTimingStatistic->removeStartgroupRelatedByPerformanceMusicAndTimingStatisticId($this);
     }
     $this->id = null;
     $this->name = null;
     $this->slug = null;
     $this->competition_id = null;
     $this->event_id = null;
     $this->performance_total_statistic_id = null;
     $this->performance_execution_statistic_id = null;
     $this->performance_choreography_statistic_id = null;
     $this->performance_music_and_timing_statistic_id = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
 /**
  * @param Request $request
  * @param Updated $payload
  */
 public function updated(Request $request, Updated $payload)
 {
     $serializer = Competition::getSerializer();
     $relationship = $serializer->startgroups($payload->getModel());
     return new JsonResponse($relationship->toArray());
 }
Пример #11
0
 /**
  * Exclude object from result
  *
  * @param   ChildCompetition $competition Object to remove from the list of results
  *
  * @return $this|ChildCompetitionQuery The current query, for fluid interface
  */
 public function prune($competition = null)
 {
     if ($competition) {
         $this->addUsingAlias(CompetitionTableMap::COL_ID, $competition->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }