public function put($id) { $data = $this->getPayload(); $id_key = $this->model->getId(); $id_schema = $this->model->getSchema($id_key); if ($id_schema['type'] == 'id' && !$id instanceof \MongoId) { $id = new \MongoId($id); } $data[$id_key] = $id; try { $this->model->save($data); } catch (ValidationException $e) { $status = 400; $this->badRequest($e->getMessage(), $status); } catch (InvalidException $e) { $status = 405; // Method Not Allowed $this->badRequest($e->getMessage(), $status); } try { // The Deal instance already has all our settings. So, let's use // that instance to get them and inform the queue about them, // Then he use it to create connections/channels to the queue. He can // also pass along that config to workers who can then create their // own db connections which are needed for models, etc. $queue = new Queue($this->app->settings()); $queue->push(get_class($this->model), $id, 'put'); } catch (ValidationException $e) { $status = 400; $this->badRequest($e->getMessage(), $status); } $this->response->status(201); return $this->getSingular((string) $id); }