eZ\Publish\Core\REST\Server\Controller\ContentType::createContentTypeDraft PHP Method

createContentTypeDraft() public method

Creates a draft and updates it with the given data.
public createContentTypeDraft ( $contentTypeId, Request $request ) : CreatedContentType
$contentTypeId
$request Symfony\Component\HttpFoundation\Request
return eZ\Publish\Core\REST\Server\Values\CreatedContentType
    public function createContentTypeDraft($contentTypeId, Request $request)
    {
        $contentType = $this->contentTypeService->loadContentType($contentTypeId);
        try {
            $contentTypeDraft = $this->contentTypeService->createContentTypeDraft($contentType);
        } catch (BadStateException $e) {
            throw new ForbiddenException($e->getMessage());
        }
        $contentTypeUpdateStruct = $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type')), $request->getContent()));
        try {
            $this->contentTypeService->updateContentTypeDraft($contentTypeDraft, $contentTypeUpdateStruct);
        } catch (InvalidArgumentException $e) {
            throw new ForbiddenException($e->getMessage());
        }
        return new Values\CreatedContentType(array('contentType' => new Values\RestContentType($this->contentTypeService->loadContentTypeDraft($contentTypeDraft->id))));
    }