/** * @param Request $request * @param Created $payload */ public function created(Request $request, Created $payload) { $serializer = Lineage::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 = Lineage::getSerializer(); $resource = new Resource($payload->getModel(), $serializer); $resource = $resource->with($params->getInclude(['skill', 'ancestor'])); $resource = $resource->fields($params->getFields(['lineage' => Lineage::getSerializer()->getFields(), 'skill' => Skill::getSerializer()->getFields(), 'ancestor' => 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 = 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()); }
/** * @param Request $request * @param Found $payload */ public function found(Request $request, Found $payload) { $params = new Parameters($request->query->all()); $data = $payload->getModel(); $serializer = Lineage::getSerializer(); $resource = new Collection($data, $serializer); $resource = $resource->with($params->getInclude(['skill', 'ancestor'])); $resource = $resource->fields($params->getFields(['lineage' => Lineage::getSerializer()->getFields(), 'skill' => Skill::getSerializer()->getFields(), 'ancestor' => 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()); }
/** * Filter the query by a related \gossi\trixionary\model\Lineage object * * @param \gossi\trixionary\model\Lineage|ObjectCollection $lineage the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildSkillQuery The current query, for fluid interface */ public function filterByLineageRelatedByAncestorId($lineage, $comparison = null) { if ($lineage instanceof \gossi\trixionary\model\Lineage) { return $this->addUsingAlias(SkillTableMap::COL_ID, $lineage->getAncestorId(), $comparison); } elseif ($lineage instanceof ObjectCollection) { return $this->useLineageRelatedByAncestorIdQuery()->filterByPrimaryKeys($lineage->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByLineageRelatedByAncestorId() only accepts arguments of type \\gossi\\trixionary\\model\\Lineage or Collection'); } }
/** * Internal mechanism to set the Skill id * * @param Lineage $model * @param mixed $relatedId */ protected function doSetSkillId(Lineage $model, $relatedId) { if ($model->getSkillId() !== $relatedId) { $model->setSkillId($relatedId); return true; } return false; }
/** * @param Request $request * @param Found $payload */ public function read(Request $request, Found $payload) { $serializer = Lineage::getSerializer(); $relationship = $serializer->ancestor($payload->getModel()); return new JsonResponse($relationship->toArray()); }
/** * Exclude object from result * * @param ChildLineage $lineage Object to remove from the list of results * * @return $this|ChildLineageQuery The current query, for fluid interface */ public function prune($lineage = null) { if ($lineage) { $this->addUsingAlias(LineageTableMap::COL_ID, $lineage->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * @param mixed $model * @return Relationship */ public function lineages($model) { $method = 'get' . $this->getCollectionMethodPluralName('lineages'); $relationship = new Relationship(new Collection($model->{$method}(), Lineage::getSerializer())); return $this->addRelationshipSelfLink($relationship, $model, 'lineage'); }
public function calculateGeneration(Skill $skill) { if ($this->processedGenerationSkills->contains($skill)) { return; } $this->lineage = []; $generation = 1; $ancestors = $this->getAncestors($skill); if (count($ancestors)) { $root = $this->findRoot($ancestors); if ($root !== null) { $generation = $this->nextStep($root, $skill, $ancestors); } } $skill->setGeneration($generation); $skill->clearLineagesRelatedBySkillId(); // set generations foreach ($this->lineage as $pos => $ancestor) { $lin = new Lineage(); $lin->setSkill($skill); $lin->setAncestor($ancestor); $lin->setPosition($pos); } $this->modifiedSkills->add($skill); $this->processedGenerationSkills->add($skill); $this->processGenerationQueue(); }