public function edit($myNamespace, $id) { $this->view->displayLayout = false; $fView['myNamespace'] = $myNamespace; $fView['message'] = ''; $fView['result'] = true; if ($this->request->isPost()) { try { $data = $this->request->getPost('json'); $data = \MongoDB\BSON\toPHP(\MongoDB\BSON\fromJSON($data)); $result = $this->Document->update($myNamespace, $data, $id); } catch (\Exception $e) { $fView['result'] = false; $fView['message'] = $e->getCode() . ':' . $e->getMessage(); } $fView['data'] = $data; $fView['url'] = $this->request->url(['controller' => 'collection', 'action' => 'index', 'params' => ['myNamespace' => $myNamespace]]); if ($fView['result']) { $this->FlashMessages->set("The Document has been updated", ['class' => 'success']); } } $this->view->set(['json' => $fView]); }
function bson_decode($payload) { return MongoDB\BSON\toPHP($payload, ['root' => 'array', 'document' => 'array']); }
/** * Deserializes a BSON object into a PHP array * * @param string $bson The BSON to be deserialized. * @return array Returns the deserialized BSON object. */ function bson_decode($bson) { return TypeConverter::toLegacy(\MongoDB\BSON\toPHP($bson)); }