/** * 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); }
/** * @param ChildObject $object The ChildObject object to add. */ protected function doAddObject(ChildObject $object) { $this->collObjects[] = $object; $object->setSport($this); }