/** * @param Request $request * @param Created $payload */ public function created(Request $request, Created $payload) { $serializer = Reference::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 Found $payload */ public function found(Request $request, Found $payload) { $params = new Parameters($request->query->all()); $serializer = Skill::getSerializer(); $resource = new Resource($payload->getModel(), $serializer); $resource = $resource->with($params->getInclude(['sport', 'variations', 'variation-of', 'multiples', 'multiple-of', 'object', 'start-position', 'end-position', 'featured-picture', 'featured-video', 'featured-tutorial', 'kstruktur-root', 'function-phase-root', 'children', 'parents', 'parts', 'composites', 'groups', 'references', 'lineages', 'pictures', 'videos', 'kstrukturs', 'function-phases', 'sport.skills'])); $resource = $resource->fields($params->getFields(['skill' => Skill::getSerializer()->getFields(), 'sport' => Sport::getSerializer()->getFields(), 'variation' => Skill::getSerializer()->getFields(), 'variation-of' => Skill::getSerializer()->getFields(), 'multiple' => Skill::getSerializer()->getFields(), 'multiple-of' => Skill::getSerializer()->getFields(), 'object' => Object::getSerializer()->getFields(), 'start-position' => Position::getSerializer()->getFields(), 'end-position' => Position::getSerializer()->getFields(), 'featured-picture' => Picture::getSerializer()->getFields(), 'featured-video' => Video::getSerializer()->getFields(), 'featured-tutorial' => Video::getSerializer()->getFields(), 'kstruktur-root' => Kstruktur::getSerializer()->getFields(), 'function-phase-root' => FunctionPhase::getSerializer()->getFields(), 'child' => Skill::getSerializer()->getFields(), 'parent' => Skill::getSerializer()->getFields(), 'part' => Skill::getSerializer()->getFields(), 'composite' => Skill::getSerializer()->getFields(), 'group' => Group::getSerializer()->getFields(), 'reference' => Reference::getSerializer()->getFields(), 'lineage' => Lineage::getSerializer()->getFields(), 'picture' => Picture::getSerializer()->getFields(), 'video' => Video::getSerializer()->getFields(), 'kstruktur' => Kstruktur::getSerializer()->getFields(), 'function-phase' => FunctionPhase::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 = Reference::getSerializer(); $resource = new Resource($payload->getModel(), $serializer); $resource = $resource->with($params->getInclude(['videos', 'skills'])); $resource = $resource->fields($params->getFields(['reference' => Reference::getSerializer()->getFields(), 'video' => Video::getSerializer()->getFields(), 'skill' => Skill::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 = Reference::getSerializer(); $resource = new Collection($data, $serializer); $resource = $resource->with($params->getInclude(['videos', 'skills'])); $resource = $resource->fields($params->getFields(['reference' => Reference::getSerializer()->getFields(), 'video' => Video::getSerializer()->getFields(), 'skill' => Skill::getSerializer()->getFields()])); $document = new Document($resource); // meta if ($params->getPage('size') != -1) { $document->setMeta(['total' => $data->getNbResults(), 'first' => '%apiurl%/' . $serializer->getType(null) . '?' . $params->toQueryString(['page' => ['number' => $data->getFirstPage()]]), 'next' => '%apiurl%/' . $serializer->getType(null) . '?' . $params->toQueryString(['page' => ['number' => $data->getNextPage()]]), 'previous' => '%apiurl%/' . $serializer->getType(null) . '?' . $params->toQueryString(['page' => ['number' => $data->getPreviousPage()]]), 'last' => '%apiurl%/' . $serializer->getType(null) . '?' . $params->toQueryString(['page' => ['number' => $data->getLastPage()]])]); } // return response return new JsonResponse($document->toArray()); }
/** * 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->aSkill) { $this->aSkill->removeSkillReference($this); } if (null !== $this->aReference) { $this->aReference->removeSkillReference($this); } $this->skill_id = null; $this->reference_id = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
/** * @param Request $request * @param Found $payload */ public function found(Request $request, Found $payload) { $params = new Parameters($request->query->all()); $data = $payload->getModel(); $serializer = Skill::getSerializer(); $resource = new Collection($data, $serializer); $resource = $resource->with($params->getInclude(['sport', 'variations', 'variation-of', 'multiples', 'multiple-of', 'object', 'start-position', 'end-position', 'featured-picture', 'featured-video', 'featured-tutorial', 'kstruktur-root', 'function-phase-root', 'children', 'parents', 'parts', 'composites', 'groups', 'references', 'lineages', 'pictures', 'videos', 'kstrukturs', 'function-phases', 'sport.skills'])); $resource = $resource->fields($params->getFields(['skill' => Skill::getSerializer()->getFields(), 'sport' => Sport::getSerializer()->getFields(), 'variation' => Skill::getSerializer()->getFields(), 'variation-of' => Skill::getSerializer()->getFields(), 'multiple' => Skill::getSerializer()->getFields(), 'multiple-of' => Skill::getSerializer()->getFields(), 'object' => Object::getSerializer()->getFields(), 'start-position' => Position::getSerializer()->getFields(), 'end-position' => Position::getSerializer()->getFields(), 'featured-picture' => Picture::getSerializer()->getFields(), 'featured-video' => Video::getSerializer()->getFields(), 'featured-tutorial' => Video::getSerializer()->getFields(), 'kstruktur-root' => Kstruktur::getSerializer()->getFields(), 'function-phase-root' => FunctionPhase::getSerializer()->getFields(), 'child' => Skill::getSerializer()->getFields(), 'parent' => Skill::getSerializer()->getFields(), 'part' => Skill::getSerializer()->getFields(), 'composite' => Skill::getSerializer()->getFields(), 'group' => Group::getSerializer()->getFields(), 'reference' => Reference::getSerializer()->getFields(), 'lineage' => Lineage::getSerializer()->getFields(), 'picture' => Picture::getSerializer()->getFields(), 'video' => Video::getSerializer()->getFields(), 'kstruktur' => Kstruktur::getSerializer()->getFields(), 'function-phase' => FunctionPhase::getSerializer()->getFields()])); $document = new Document($resource); // meta if ($params->getPage('size') != -1) { $document->setMeta(['total' => $data->getNbResults(), 'first' => '%apiurl%/' . $serializer->getType(null) . '?' . $params->toQueryString(['page' => ['number' => $data->getFirstPage()]]), 'next' => '%apiurl%/' . $serializer->getType(null) . '?' . $params->toQueryString(['page' => ['number' => $data->getNextPage()]]), 'previous' => '%apiurl%/' . $serializer->getType(null) . '?' . $params->toQueryString(['page' => ['number' => $data->getPreviousPage()]]), 'last' => '%apiurl%/' . $serializer->getType(null) . '?' . $params->toQueryString(['page' => ['number' => $data->getLastPage()]])]); } // return response return new JsonResponse($document->toArray()); }
/** * Filter the query by a related \gossi\trixionary\model\Reference object * * @param \gossi\trixionary\model\Reference|ObjectCollection $reference 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 ChildVideoQuery The current query, for fluid interface */ public function filterByReference($reference, $comparison = null) { if ($reference instanceof \gossi\trixionary\model\Reference) { return $this->addUsingAlias(VideoTableMap::COL_REFERENCE_ID, $reference->getId(), $comparison); } elseif ($reference instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(VideoTableMap::COL_REFERENCE_ID, $reference->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByReference() only accepts arguments of type \\gossi\\trixionary\\model\\Reference or Collection'); } }
/** * @param Request $request * @param Updated $payload */ public function updated(Request $request, Updated $payload) { $serializer = Reference::getSerializer(); $relationship = $serializer->videos($payload->getModel()); return new JsonResponse($relationship->toArray()); }
/** * Interal mechanism to remove Videos from Reference * * @param Reference $model * @param mixed $data */ protected function doRemoveVideos(Reference $model, $data) { $errors = []; foreach ($data as $entry) { if (!isset($entry['id'])) { $errors[] = 'Missing id for Video'; } else { $related = VideoQuery::create()->findOneById($entry['id']); $model->removeVideo($related); } } if (count($errors) > 0) { return new ErrorsException($errors); } }
/** * Exclude object from result * * @param ChildReference $reference Object to remove from the list of results * * @return $this|ChildReferenceQuery The current query, for fluid interface */ public function prune($reference = null) { if ($reference) { $this->addUsingAlias(ReferenceTableMap::COL_ID, $reference->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * @param mixed $model * @return Relationship */ public function reference($model) { $serializer = Reference::getSerializer(); $id = $serializer->getId($model->getReference()); if ($id !== null) { $relationship = new Relationship(new Resource($model->getReference(), $serializer)); $relationship->setLinks(['related' => '%apiurl%' . $serializer->getType(null) . '/' . $id]); return $this->addRelationshipSelfLink($relationship, $model, 'reference'); } return null; }
/** * @param mixed $model * @return Relationship */ public function references($model) { $method = 'get' . $this->getCollectionMethodPluralName('references'); $relationship = new Relationship(new Collection($model->{$method}(), Reference::getSerializer())); return $this->addRelationshipSelfLink($relationship, $model, 'reference'); }
/** * 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->aSkill) { $this->aSkill->removeVideo($this); } if (null !== $this->aReference) { $this->aReference->removeVideo($this); } $this->id = null; $this->title = null; $this->description = null; $this->url = null; $this->is_tutorial = null; $this->athlete = null; $this->athlete_id = null; $this->uploader_id = null; $this->skill_id = null; $this->reference_id = null; $this->poster_url = null; $this->provider = null; $this->provider_id = null; $this->player_url = null; $this->width = null; $this->height = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }