eZ\Bundle\EzPublishRestBundle\Features\Context\SubContext\EzRest::convertResponseBodyToObject PHP Method

convertResponseBodyToObject() public method

Convert the body/content of a response into an object.
public convertResponseBodyToObject ( string $responseBody, string $contentTypeHeader ) : eZ\Publish\API\Repository\Values\ValueObject
$responseBody string Body/content of the response (with the object)
$contentTypeHeader string Value of the content-type header
return eZ\Publish\API\Repository\Values\ValueObject
    public function convertResponseBodyToObject($responseBody, $contentTypeHeader)
    {
        try {
            $this->responseObject = $this->getKernel()->getContainer()->get('ezpublish_rest.input.dispatcher')->parse(new Message(array('Content-Type' => $contentTypeHeader), $responseBody));
        } catch (\Exception $e) {
            // when errors/exceptions popup on form the response we need also to
            // test/verify them
            $this->responseObject = $e;
        }
        return $this->responseObject;
    }