eZ\Publish\Core\Repository\ContentTypeService::copyContentType PHP Method

copyContentType() public method

New Type will have $creator as creator / modifier, created / modified should be updated with current time, updated remoteId and identifier should be appended with '_' + unique string.
public copyContentType ( eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType, eZ\Publish\API\Repository\Values\User\User $creator = null ) : eZ\Publish\API\Repository\Values\ContentType\ContentType
$contentType eZ\Publish\API\Repository\Values\ContentType\ContentType
$creator eZ\Publish\API\Repository\Values\User\User if null the current-user is used
return eZ\Publish\API\Repository\Values\ContentType\ContentType
    public function copyContentType(APIContentType $contentType, User $creator = null)
    {
        if ($this->repository->hasAccess('class', 'create') !== true) {
            throw new UnauthorizedException('ContentType', 'create');
        }
        if (empty($creator)) {
            $creator = $this->repository->getCurrentUserReference();
        }
        $this->repository->beginTransaction();
        try {
            $spiContentType = $this->contentTypeHandler->copy($creator->getUserId(), $contentType->id, SPIContentType::STATUS_DEFINED);
            $this->repository->commit();
        } catch (Exception $e) {
            $this->repository->rollback();
            throw $e;
        }
        return $this->loadContentType($spiContentType->id);
    }