Ejemplo n.º 1
0
Archivo: Api.php Proyecto: c15k0/psfs
 /**
  * Modify {__API__} model
  *
  * @PUT
  * @PAYLOAD {__API__}
  * @ROUTE /api/{__API__}/{pk}
  *
  * @param string $pk
  *
  * @return \PSFS\base\dto\JsonResponse(data={__API__})
  *
  */
 public function put($pk)
 {
     $this->hydrateModel($pk);
     $status = 400;
     $updated = FALSE;
     $model = NULL;
     if (NULL !== $this->model) {
         $this->con->beginTransaction();
         $this->model->fromArray($this->data);
         if ($this->model->save($this->con) !== FALSE) {
             $updated = TRUE;
             $status = 200;
             $model = $this->model->toArray();
         }
     }
     return $this->json(new JsonResponse($model, $updated), $status);
 }
 /**
  * Formats an ActiveRecord object
  *
  * @param ActiveRecordInterface $record the object to format
  *
  * @return array The original record turned into an array
  */
 public function formatRecord(ActiveRecordInterface $record = null)
 {
     return $record ? $record->toArray() : array();
 }
 private function getIdenticalObject(ActiveRecordInterface $object)
 {
     foreach ($this as $obj) {
         if ($obj instanceof ActiveRecordInterface && $obj->hashCode() === $object->hashCode()) {
             return $obj;
         }
     }
     return null;
 }
Ejemplo n.º 4
0
 public function update(ActiveRecordInterface $record, array $params)
 {
     $record->fromArray($params, TableMap::TYPE_CAMELNAME);
 }