Ejemplo n.º 1
0
 /**
  * Automatically generated run method
  *
  * @param Request $request
  * @return Response
  */
 public function run(Request $request)
 {
     $sport = SportQuery::create()->findOneById($this->getParam('id'));
     $object = new Object();
     $object->setSport($sport);
     $data = ['sport' => $sport, 'object' => $object];
     $payload = new Blank($data);
     if ($request->isMethod('POST')) {
         $post = $request->request;
         $domain = new ObjectDomain($this->getServiceContainer());
         $serializer = Object::getSerializer();
         $fields = $serializer->getFields();
         $attribs = [];
         foreach ($fields as $field) {
             if ($post->has($field)) {
                 $attribs[$field] = $post->get($field);
             }
         }
         $attribs['fixed'] = $post->has('fixed');
         $payload = $domain->create(['attributes' => $attribs, 'relationships' => ['sport' => ['data' => ['id' => $sport->getId()]]]]);
         if ($payload instanceof NotValid) {
             $payload = new NotValid(array_merge($data, $payload->get()));
         }
     }
     return $this->responder->run($request, $payload);
 }
Ejemplo n.º 2
0
 protected function preSave(Object $object)
 {
     // set slug
     if (Text::create($object->getSlug())->isEmpty()) {
         $slugifier = new Slugify();
         $object->setSlug($slugifier->slugify($object->getTitle()));
     }
 }
Ejemplo n.º 3
0
 /**
  * @param Request $request
  * @param Created $payload
  */
 public function created(Request $request, Created $payload)
 {
     $serializer = Object::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 201, ['Location' => $resource->getLinks()['self']]);
 }
Ejemplo n.º 4
0
 /**
  * @param Request $request
  * @param Updated $payload
  */
 public function updated(Request $request, Updated $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = Sport::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['objects', 'positions', 'skills', 'groups', 'skills.groups', 'skills.objects', 'skills.start-position', 'skills.end-position', 'skills.variationOf', 'skills.parents', 'skills.lineages', 'skills.lineages.ancestor', 'skills.lineages.skill', 'skills.featured-picture']));
     $resource = $resource->fields($params->getFields(['sport' => Sport::getSerializer()->getFields(), 'object' => Object::getSerializer()->getFields(), 'position' => Position::getSerializer()->getFields(), 'skill' => Skill::getSerializer()->getFields(), 'group' => Group::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
Ejemplo n.º 5
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = Object::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['sport', 'skills', 'skills.variations', 'skills.variationOf', 'skills.multiples', 'sport.objects']));
     $resource = $resource->fields($params->getFields(['object' => Object::getSerializer()->getFields(), 'sport' => Sport::getSerializer()->getFields(), 'skill' => Skill::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
Ejemplo n.º 6
0
 /**
  * @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 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 = Sport::getSerializer();
     $resource = new Collection($data, $serializer);
     $resource = $resource->with($params->getInclude(['objects', 'positions', 'skills', 'groups', 'skills.groups', 'skills.objects', 'skills.start-position', 'skills.end-position', 'skills.variationOf', 'skills.parents', 'skills.lineages', 'skills.lineages.ancestor', 'skills.lineages.skill', 'skills.featured-picture']));
     $resource = $resource->fields($params->getFields(['sport' => Sport::getSerializer()->getFields(), 'object' => Object::getSerializer()->getFields(), 'position' => Position::getSerializer()->getFields(), 'skill' => Skill::getSerializer()->getFields(), 'group' => Group::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());
 }
Ejemplo n.º 9
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function read(Request $request, Found $payload)
 {
     $serializer = Object::getSerializer();
     $relationship = $serializer->sport($payload->getModel());
     return new JsonResponse($relationship->toArray());
 }
Ejemplo n.º 10
0
 /**
  * @param Request $request
  * @param Updated $payload
  */
 public function updated(Request $request, Updated $payload)
 {
     $serializer = Object::getSerializer();
     $relationship = $serializer->skills($payload->getModel());
     return new JsonResponse($relationship->toArray());
 }
Ejemplo n.º 11
0
 /**
  * Filter the query by a related \gossi\trixionary\model\Object object
  *
  * @param \gossi\trixionary\model\Object|ObjectCollection $object the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildSportQuery The current query, for fluid interface
  */
 public function filterByObject($object, $comparison = null)
 {
     if ($object instanceof \gossi\trixionary\model\Object) {
         return $this->addUsingAlias(SportTableMap::COL_ID, $object->getSportId(), $comparison);
     } elseif ($object instanceof ObjectCollection) {
         return $this->useObjectQuery()->filterByPrimaryKeys($object->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByObject() only accepts arguments of type \\gossi\\trixionary\\model\\Object or Collection');
     }
 }
Ejemplo n.º 12
0
 /**
  * @param mixed $model
  * @return Relationship
  */
 public function objects($model)
 {
     $method = 'get' . $this->getCollectionMethodPluralName('objects');
     $relationship = new Relationship(new Collection($model->{$method}(), Object::getSerializer()));
     return $this->addRelationshipSelfLink($relationship, $model, 'object');
 }
Ejemplo n.º 13
0
 /**
  * @param mixed $model
  * @return Relationship
  */
 public function object($model)
 {
     $serializer = Object::getSerializer();
     $id = $serializer->getId($model->getObject());
     if ($id !== null) {
         $relationship = new Relationship(new Resource($model->getObject(), $serializer));
         $relationship->setLinks(['related' => '%apiurl%' . $serializer->getType(null) . '/' . $id]);
         return $this->addRelationshipSelfLink($relationship, $model, 'object');
     }
     return null;
 }
Ejemplo n.º 14
0
 /**
  * @param ChildObject $object The ChildObject object to add.
  */
 protected function doAddObject(ChildObject $object)
 {
     $this->collObjects[] = $object;
     $object->setSport($this);
 }
Ejemplo n.º 15
0
 /**
  * Filter the query by a related \gossi\trixionary\model\Object object
  *
  * @param \gossi\trixionary\model\Object|ObjectCollection $object 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 ChildSkillQuery The current query, for fluid interface
  */
 public function filterByObject($object, $comparison = null)
 {
     if ($object instanceof \gossi\trixionary\model\Object) {
         return $this->addUsingAlias(SkillTableMap::COL_OBJECT_ID, $object->getId(), $comparison);
     } elseif ($object instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(SkillTableMap::COL_OBJECT_ID, $object->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByObject() only accepts arguments of type \\gossi\\trixionary\\model\\Object or Collection');
     }
 }
Ejemplo n.º 16
0
 /**
  * Exclude object from result
  *
  * @param   ChildObject $object Object to remove from the list of results
  *
  * @return $this|ChildObjectQuery The current query, for fluid interface
  */
 public function prune($object = null)
 {
     if ($object) {
         $this->addUsingAlias(ObjectTableMap::COL_ID, $object->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Ejemplo n.º 17
0
 /**
  * Internal mechanism to set the Sport id
  * 
  * @param Object $model
  * @param mixed $relatedId
  */
 protected function doSetSportId(Object $model, $relatedId)
 {
     if ($model->getSportId() !== $relatedId) {
         $model->setSportId($relatedId);
         return true;
     }
     return false;
 }