toArray() публичный Метод

Converts the object into an array.
public toArray ( array $fields = [], array $expand = [], boolean $recursive = true ) : array
$fields array the fields that the output array should contain. Fields not specified in [[fields()]] will be ignored. If this parameter is empty, all fields as specified in [[fields()]] will be returned.
$expand array the additional fields that the output array should contain. Fields not specified in [[extraFields()]] will be ignored. If this parameter is empty, no extra fields will be returned.
$recursive boolean whether to recursively return array representation of embedded objects.
Результат array the array representation of the object
Пример #1
0
 /**
  * Serializes a model object.
  * @param Arrayable $model
  * @return array the array representation of the model
  */
 protected function serializeModel($model)
 {
     if ($this->request->getIsHead()) {
         return null;
     } else {
         list($fields, $expand) = $this->getRequestedFields();
         return $model->toArray($fields, $expand);
     }
 }
Пример #2
0
 /**
  * Serializes a model object.
  * @param Arrayable $model
  * @return array the array representation of the model
  */
 protected function serializeModel($model)
 {
     return $model->toArray();
 }
Пример #3
0
 /**
  * Serializes a model object.
  * @param \yii\base\Arrayable $model
  * @return array the array representation of the model
  */
 protected function serializeModel($model)
 {
     list($fields, $expand) = $this->getRequestedFields();
     return $model->toArray($fields, $expand);
 }
Пример #4
0
 /**
  * Serializes a model object.
  * @param Arrayable $model
  * @return array the array representation of the model
  */
 protected function serializeModel($model)
 {
     if ($this->request->getIsHead()) {
         return null;
     } else {
         list($fields, $expand) = $this->getRequestedFields();
         return ['success' => 1, 'message' => \Yii::$app->response->statusText, 'status' => \Yii::$app->response->getStatusCode(), $this->collectionEnvelope => $model->toArray($fields, $expand)];
     }
 }