Exemplo n.º 1
0
 /**
  * Automatically generated run method
  * 
  * @param Request $request
  * @return Response
  */
 public function run(Request $request)
 {
     $id = $this->getParam('id');
     $body = Json::decode($request->getContent());
     if (!isset($body['data'])) {
         throw new InvalidParameterException();
     }
     $data = $body['data'];
     $domain = new ObjectDomain($this->getServiceContainer());
     $payload = $domain->update($id, $data);
     return $this->responder->run($request, $payload);
 }
Exemplo n.º 2
0
 /**
  * Automatically generated run method
  *
  * @param Request $request
  * @return Response
  */
 public function run(Request $request)
 {
     $object = ObjectQuery::create()->findOneById($this->getParam('objectId'));
     $data = ['sport' => $object->getSport(), '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->update($object->getId(), ['attributes' => $attribs]);
         if ($payload instanceof NotValid) {
             $payload = new NotValid(array_merge($data, $payload->get()));
         }
     }
     return $this->responder->run($request, $payload);
 }