yii\rest\Controller::serializeData PHP Method

serializeData() protected method

The default implementation will create a serializer based on the configuration given by [[serializer]]. It then uses the serializer to serialize the given data.
protected serializeData ( mixed $data ) : mixed
$data mixed the data to be serialized
return mixed the serialized data.
    protected function serializeData($data)
    {
        return Yii::createObject($this->serializer)->serialize($data);
    }

Usage Example

コード例 #1
0
 protected function serializeData($data)
 {
     if ($this->jsonCallback) {
         $result['data'] = parent::serializeData($data);
         $result['callback'] = $this->jsonCallback;
         return $result;
     }
     return parent::serializeData($data);
 }