Example #1
0
 /**
  * Serializes a set of models.
  * @param array $models
  * @return array the array representation of the models
  */
 protected function serializeModels(array $models)
 {
     list($fields, $expand) = $this->getRequestedFields();
     foreach ($models as $i => $model) {
         if ($model instanceof Arrayable) {
             $models[$i] = $model->toArray($fields, $expand);
         } elseif (is_array($model)) {
             $models[$i] = ArrayHelper::toArray($model);
         }
     }
     return $models;
 }