public function sendResource($contentType = NULL)
{
if (!$this->resource instanceof IResource) {
$this->resource = $this->resourceFactory->create($this->resource);
}
try {
$response = $this->responseFactory->create($this->resource, $contentType);
$this->sendResponse($response);
} catch (InvalidStateException $e) {
$this->sendErrorResource(BadRequestException::unsupportedMediaType($e->getMessage(), $e), $contentType);
}
}