当前位置: 首页>>代码示例>>PHP>>正文


PHP Model::toArray方法代码示例

本文整理汇总了PHP中Phalcon\Mvc\Model::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::toArray方法的具体用法?PHP Model::toArray怎么用?PHP Model::toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\Mvc\Model的用法示例。


在下文中一共展示了Model::toArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 public function save($data = null, $whiteList = null)
 {
     $response = array();
     if (parent::save($data, $whiteList) == false) {
         foreach (parent::getMessages() as $message) {
             $response['errors'][] = (string) $message;
         }
     } else {
         foreach (parent::toArray() as $key => $value) {
             $response[$key] = $value;
         }
         $response['msg'] = 'ok';
     }
     return $response;
 }
开发者ID:Archcry,项目名称:PhalconApiBase,代码行数:15,代码来源:Model.php

示例2: toArray

 public function toArray($columns = null)
 {
     if (is_null($columns) && is_array($this->visible)) {
         // Only show the visible columns
         $columns = $this->visible;
     }
     $attributes = parent::toArray($columns);
     if (is_null($columns) && is_array($this->hidden) && count($attributes)) {
         // Only show columns which have not been hidden
         foreach ($attributes as $key => $value) {
             if (in_array($key, $this->hidden)) {
                 unset($attributes[$key]);
             }
         }
     }
     return $attributes;
 }
开发者ID:dotronglong,项目名称:phalcon-engine,代码行数:17,代码来源:Factory.php

示例3: onRemoveFailed

 protected function onRemoveFailed(Model $item)
 {
     throw new Exception(ErrorCodes::DATA_FAILED, 'Unable to remove item', ['messages' => $this->_getMessages($item->getMessages()), 'item' => $item->toArray()]);
 }
开发者ID:olivierandriessen,项目名称:phalcon-rest,代码行数:4,代码来源:CrudResourceController.php

示例4: getDiff

 /**
  * @return \Diff\DiffOp\DiffOp[]
  */
 protected function getDiff()
 {
     $oldModel = $this->oldModel ? $this->oldModel->toArray() : array();
     $newModel = $this->newModel ? $this->newModel->toArray() : array();
     return $this->differ->doDiff($oldModel, $newModel);
 }
开发者ID:sergeytkachenko,项目名称:phalcon-rest-jpa,代码行数:9,代码来源:ChangedData.php

示例5: respondWithModel

 /**
  * Respond with a single model, pass function name
  */
 protected function respondWithModel(Model $model, $functionName = null)
 {
     // Return a partial response
     if ($functionName && isset($this->partialFields)) {
         // Validate that there are fields set for this method
         if (!isset($this->allowedPartialFields[$functionName])) {
             throw new Exception('Partial fields not specified for ' . $functionName);
         }
         // Determines if fields is a strict subset of allowed fields
         if (array_diff($this->partialFields, $this->allowedPartialFields[$functionName])) {
             // todo rework exception
             throw new HTTPException("The fields you asked for cannot be returned.", 401, array('dev' => 'You requested to return fields that are not available to be returned in partial responses.', 'internalCode' => 'P1000', 'more' => ''));
         }
         $this->response->data = $model->toArray($this->partialFields);
     } else {
         $this->response->data = (object) $model->toArray();
         $this->response->getMeta()->count = count($this->response->data);
     }
     // Expand related models
     if ($this->isExpand) {
         // todo allow for parsed related fields, model.field
         foreach ($this->expandFields as $modelField) {
             //$this->response[$modelField] = $model->getRelated($modelField)->toArray();
         }
     }
     return $this->response;
 }
开发者ID:phrest,项目名称:api,代码行数:30,代码来源:RESTController.php


注:本文中的Phalcon\Mvc\Model::toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。