/** * Copy Type incl fields and groupIds to a new Type object * * 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. * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the current-user is not allowed to copy a content type * * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType * @param \eZ\Publish\API\Repository\Values\User\User $creator 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->getCurrentUser(); } $this->repository->beginTransaction(); try { $spiContentType = $this->contentTypeHandler->copy( $creator->id, $contentType->id, SPIContentType::STATUS_DEFINED ); $this->repository->commit(); } catch ( Exception $e ) { $this->repository->rollback(); throw $e; } return $this->loadContentType( $spiContentType->id ); }
/** * @param mixed $userId * @param mixed $contentTypeId * @param int $status One of Type::STATUS_DEFINED|Type::STATUS_DRAFT|Type::STATUS_MODIFIED * @return Type */ public function copy($userId, $contentTypeId, $status) { $this->clearCache(); return $this->innerHandler->copy($userId, $contentTypeId, $status); }