public function parse(Message $message)
    {
        if (!isset($message->headers['Content-Type'])) {
            throw new Exceptions\Parser('Missing Content-Type header in message.');
        }

        $mediaTypeParts = explode(';', $message->headers['Content-Type']);
        $contentTypeParts = explode('+', $mediaTypeParts[0]);
        if (count($contentTypeParts) !== 2) {
            // TODO expose default format
            $contentTypeParts[1] = 'xml';
        }

        $media = $contentTypeParts[0];

        // add version if given
        if (count($mediaTypeParts) > 1) {
            $parameters = $this->parseParameters(implode(';', array_slice($mediaTypeParts, 1)));
            if (isset($parameters['version'])) {
                $media .= '; version=' . $parameters['version'];
            }
        }

        $format = $contentTypeParts[1];

        if (!isset($this->handlers[$format])) {
            throw new Exceptions\Parser("Unknown format specification: '{$format}'.");
        }

        $rawArray = $this->handlers[$format]->convert($message->body);

        // Only 1 XML root node
        $rootNodeArray = reset($rawArray);

        // @todo: This needs to be refactored in order to make the called URL
        // available to parsers in the server in a sane way
        if (isset($message->headers['Url'])) {
            $rootNodeArray['__url'] = $message->headers['Url'];
        }
        if (isset($message->headers['__publish'])) {
            $rootNodeArray['__publish'] = $message->headers['__publish'];
        }

        return $this->parsingDispatcher->parse($rootNodeArray, $media);
    }
public function parse(Message $message)
    {
        if (!isset($message->headers['Content-Type'])) {
            throw new Exceptions\Parser('Missing Content-Type header in message.');
        }

        $mediaTypeParts = explode(';', $message->headers['Content-Type']);
        $contentTypeParts = explode('+', $mediaTypeParts[0]);
        if (count($contentTypeParts) !== 2) {
            // TODO expose default format
            $contentTypeParts[1] = 'xml';
        }

        $media = $contentTypeParts[0];

        // add version if given
        if (count($mediaTypeParts) > 1) {
            $parameters = $this->parseParameters(implode(';', array_slice($mediaTypeParts, 1)));
            if (isset($parameters['version'])) {
                $media .= '; version=' . $parameters['version'];
            }
        }

        $format = $contentTypeParts[1];

        if (!isset($this->handlers[$format])) {
            throw new Exceptions\Parser("Unknown format specification: '{$format}'.");
        }

        $rawArray = $this->handlers[$format]->convert($message->body);

        // Only 1 XML root node
        $rootNodeArray = reset($rawArray);

        // @todo: This needs to be refactored in order to make the called URL
        // available to parsers in the server in a sane way
        if (isset($message->headers['Url'])) {
            $rootNodeArray['__url'] = $message->headers['Url'];
        }
        if (isset($message->headers['__publish'])) {
            $rootNodeArray['__publish'] = $message->headers['__publish'];
        }

        return $this->parsingDispatcher->parse($rootNodeArray, $media);
    }
public function parse ( Message $ message ) { if ( ! isset ( $ message -> headers [ 'Content-Type' ] ) ) { throw new Exceptions \ Parser ( 'Missing Content-Type header in message.' ) ; } $ mediaTypeParts = explode ( ';' , $ message -> headers [ 'Content-Type' ] ) ; $ contentTypeParts = explode ( '+' , $ mediaTypeParts [ 0 ] ) ; if ( count ( $ contentTypeParts ) !== 2 ) { // TODO expose default format $ contentTypeParts [ 1 ] = 'xml' ; } $ media = $ contentTypeParts [ 0 ] ; // add version if given if ( count ( $ mediaTypeParts ) > 1 ) { $ parameters = $ this -> parseParameters ( implode ( ';' , array_slice ( $ mediaTypeParts , 1 ) ) ) ; if ( isset ( $ parameters [ 'version' ] ) ) { $ media .= '; version=' . $ parameters [ 'version' ] ; } } $ format = $ contentTypeParts [ 1 ] ; if ( ! isset ( $ this -> handlers [ $ format ] ) ) { throw new Exceptions \ Parser ( "Unknown format specification: '{$format}'." ) ; } $ rawArray = $ this -> handlers [ $ format ] -> convert ( $ message -> body ) ; // Only 1 XML root node $ rootNodeArray = reset ( $ rawArray ) ; // @todo: This needs to be refactored in order to make the called URL // available to parsers in the server in a sane way if ( isset ( $ message -> headers [ 'Url' ] ) ) { $ rootNodeArray [ '__url' ] = $ message -> headers [ 'Url' ] ; } if ( isset ( $ message -> headers [ '__publish' ] ) ) { $ rootNodeArray [ '__publish' ] = $ message -> headers [ '__publish' ] ; } return $ this -> parsingDispatcher -> parse ( $ rootNodeArray , $ media ) ; }
Parse provided request.

@param \eZ\Publish\Core\REST\Common\Message $message

@return mixed
Parse provided request .