public function serialize(ContentItem $contentItem, array $options = [])
    {
        $serialized = [];

        if (1 === preg_match('#^text\/[^/]+$#', $contentItem->getQuestion()->getMimeType())) {
            $serialized['data'] = $contentItem->getData();
        } else {
            $serialized['url'] = $contentItem->getData();
        }

        return $serialized;
    }
public function serialize(ContentItem $contentItem, array $options = [])
    {
        $serialized = [];

        if (1 === preg_match('#^text\/[^/]+$#', $contentItem->getQuestion()->getMimeType())) {
            $serialized['data'] = $contentItem->getData();
        } else {
            $serialized['url'] = $contentItem->getData();
        }

        return $serialized;
    }
public function serialize ( ContentItem $ contentItem , array $ options = [ ] ) { $ serialized = [ ] ; if ( 1 === preg_match ( '#^text\/[^/]+$#' , $ contentItem -> getQuestion ( ) -> getMimeType ( ) ) ) { $ serialized [ 'data' ] = $ contentItem -> getData ( ) ; } else { $ serialized [ 'url' ] = $ contentItem -> getData ( ) ; } return $ serialized ; }
Converts a content item into a JSON-encodable structure.

@param ContentItem $contentItem
@param array       $options

@return array
Converts a content item into a JSON - encodable structure .