protected function transform($data, $hypertextRoutes = [])
    {
        $links = $this->getHypertextJson($hypertextRoutes);
        if ($links && is_array($data)) {
            $data['_links'] = $links;
        } elseif ($links && !is_array($data)) {
            $data = [$data, '_links' => $links];
        }
        return json_encode($data);
    }
protected function transform($data, $hypertextRoutes = [])
    {
        $links = $this->getHypertextJson($hypertextRoutes);
        if ($links && is_array($data)) {
            $data['_links'] = $links;
        } elseif ($links && !is_array($data)) {
            $data = [$data, '_links' => $links];
        }
        return json_encode($data);
    }
protected function transform ( $ data , $ hypertextRoutes = [ ] ) { $ links = $ this -> getHypertextJson ( $ hypertextRoutes ) ; if ( $ links && is_array ( $ data ) ) { $ data [ '_links' ] = $ links ; } elseif ( $ links && ! is_array ( $ data ) ) { $ data = [ $ data , '_links' => $ links ] ; } return json_encode ( $ data ) ; }
Transforms the data into a json response.

@param mixed $data The data to transform.
@param optional array $hypertextRoutes An array with hypertext routes.

@return string The transformed response.
Transforms the data into a json response .