@param string $contentType
@param string $content
@param StreamInterface|null $bodyStream

@return Mock|ResponseInterface
349118
public static function create($contentType, $content = '', $bodyStream = null)
    {
        /* @var ResponseInterface|MockInterface $response */
        $response = Mockery::mock(ResponseInterface::class);

        $response
            ->shouldReceive('getHeader')
            ->with('content-type')
            ->andReturn([
                $contentType,
            ]);

        $response
            ->shouldReceive('getHeaderLine')
            ->with('content-type')
            ->andReturn($contentType);

        if (empty($bodyStream)) {
            /* @var StreamInterface|Mock $bodyStream */
            $bodyStream = Mockery::mock(StreamInterface::class);
            $bodyStream
                ->shouldReceive('__toString')
                ->andReturn($content);
        }

        $response
            ->shouldReceive('getBody')
            ->andReturn($bodyStream);

        return $response;
    }
367363
protected OutputStream outputStream(String contentType, Map headers, int status) {
        try {
            RequestContext.setControllerResponse(new NopResponse(contentType, status));

            if (headers != null) {
                for (Object key : headers.keySet()) {
                    if (headers.get(key) != null)
                        RequestContext.getHttpResponse().addHeader(key.toString(), headers.get(key).toString());
                }
            }

            return RequestContext.getHttpResponse().getOutputStream();
        }catch(Exception e){
            throw new ControllerException(e);
        }
    }
1089954
public static function bySerializedContentType($contentType)
    {
        switch($contentType)
        {
            case PhpSerializer::SERIALIZED_CONTENT_TYPE:
                $serializer = new PhpSerializer();
                break;
            case JsonSerializer::SERIALIZED_CONTENT_TYPE:
                $serializer = new JsonSerializer();
                break;
            case NullSerializer::SERIALIZED_CONTENT_TYPE:
                $serializer = new NullSerializer();
                break;
            default:
                throw new Exception('Not supported content type!');
        }
        return $serializer;
    }
368824
final protected function header(string $content, string $type = null)
    {
        Response::header($content, $type);
    }
1104722
function put($path, $body, $contentType = null)
    {
        return $this->dispatchRequest(
            $this->buildRequest('PUT', $path, $body, $contentType)
        );
    }
83346
function post($path, $body, $contentType = null)
    {
        return $this->dispatchRequest(
            $this->buildRequest('POST', $path, $body, $contentType)
        );
    }
102142
public Response andContentType(String contentType) {
        Objects.requireNonNull(contentType, Required.CONTENT_TYPE.toString());
        this.contentType = contentType;
        this.headers.put(Header.CONTENT_TYPE.toHttpString(), contentType);

        return this;
    }
1151905
public function contentType($contentType = null) {
			if ($contentType != null) {
				$this->_contentType = $contentType;
				return true;
			}
			else {
				return $this->_contentType;
			}
		}
870022
public function setContent(string $content = null): ResponseContextAbstract
    {
        if (is_null($content)) {
            return $this;
        }

        $this->assertIsValid($content);

        $this->content = $content;

        return $this;
    }
573493
public static function getByType(string $type, string $content = null): ResponseContextAbstract
    {
        switch ($type) {
            case self::RESPONSE_TYPE_JSON:
                return new JsonResponseContext($content);
            default:
                return new DummyResponseContext($content);
        }
    }
914338
public static function setContentType($contentType, $encoding = null) {
		$value = $contentType;
		if (isset ( $encoding ))
			$value .= ' ;charset=' . $encoding;
		self::header ( 'Content-Type', $value );
	}
498553
public function setContentType($contentType = '')
    {
        $this->contentType = $contentType;
        $this->debug->debug(__FUNCTION__, 'setContentType: ', $this->contentType);
    }
1339846
public function resolveContentId($contentTypeId, $contentId)
    {
        // content type ?
        if (!$contentType = $this->contentTypeLoader->retrieve($contentTypeId)) {
            throw new InvalidContentException(sprintf(
                'No content type registered under "%s" id, check you configuration.',
                $contentTypeId
            ));
        }

        // content object
        if (!$content = $contentType->retrieveContent($contentId)) {
            throw new InvalidContentException(sprintf(
                'Unable to get a "%s" content under "%s" id.',
                $contentType->getName(),
                $contentId
            ));
        }

        return $this->wrap($contentType, $content);
    }
1157155
protected function respondWith(ResponseInterface $response, $contentType, $output)
    {
        $body = new Body(fopen('php://temp', 'r+'));
        $body->write($output);

        return $response->withHeader('Content-Type', $contentType)
            ->withBody($body);
    }
1359564
final private function convertResponseBodyToObject($body, $content_type)
	{
		/* No body to convert */
		if (empty($body)) {
			return null;
		}

		/*  Convert to Mollie_Response object or return as string. */
		if (preg_match('/(application|text)\/xml/i', $content_type)) {
			return simplexml_load_string($body, "Mollie_Response");
		}
		return $body;
	}
1227156
public function resolve(ContentInterface $content)
    {
        $contentType = $this->contentTypeLoader->retrieveAll()
            ->filter(function (ContentTypeInterface $contentType) use ($content) {
                return is_a($content, $contentType->getContentClass());
            })
            ->first()
        ;
        if (!$contentType) {
            throw new InvalidContentException(sprintf(
                'No content type registered for "%s" content, check you configuration.',
                is_string($content) ? $content : get_class($content)
            ));
        }

        return $this->wrap($contentType, $content);
    }
1127470
public function initAction(Request $request, $templateType, $contentType, $contentId = null)
    {
        $templateDomain = $this->container->get('synapse.template.domain');

        $template = empty($contentId)
            ? $templateDomain->createGlobal(
                $contentType,
                $templateType
            )
            : $templateDomain->createLocal(
                $this->container->get('synapse.content.resolver')->resolveContentId($contentType, $contentId),
                $templateType
            )
        ;

        return new RedirectResponse(empty($contentId)
            ? $this->container->get('router')->generate('synapse_admin_template_edition', array(
                'id' => $template->getId(),
            ))
            : $request->server->get('HTTP_REFERER')
        );
    }