Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Contracts\Core\Repository\Exceptions;

interface ContentTypeOwnedBySomeoneElseException extends Exception
{
}
20 changes: 20 additions & 0 deletions src/lib/Base/Exceptions/ContentTypeOwnedBySomeoneElseException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Core\Base\Exceptions;

use Ibexa\Contracts\Core\Repository\Exceptions\ContentTypeOwnedBySomeoneElseException as APIContentTypeOwnedBySomeoneElseException;
use Throwable;

final class ContentTypeOwnedBySomeoneElseException extends NotFoundException implements APIContentTypeOwnedBySomeoneElseException
{
public function __construct(int $contentTypeId, ?Throwable $previous = null)
{
parent::__construct('The content type is owned by someone else', $contentTypeId, $previous);
}
}
5 changes: 2 additions & 3 deletions src/lib/Repository/ContentTypeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use Ibexa\Contracts\Core\Repository\Values\User\User;
use Ibexa\Core\Base\Exceptions\BadStateException;
use Ibexa\Core\Base\Exceptions\ContentTypeFieldDefinitionValidationException;
use Ibexa\Core\Base\Exceptions\ContentTypeOwnedBySomeoneElseException;
use Ibexa\Core\Base\Exceptions\ContentTypeValidationException;
use Ibexa\Core\Base\Exceptions\InvalidArgumentException;
use Ibexa\Core\Base\Exceptions\InvalidArgumentType;
Expand Down Expand Up @@ -767,8 +768,6 @@ public function loadContentTypeByRemoteId(string $remoteId, array $prioritizedLa
* @param int $contentTypeId
* @param bool $ignoreOwnership if true, method will return draft even if the owner is different than currently logged in user
*
* @todo Use another exception when user of draft is someone else
*
* @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft
*/
public function loadContentTypeDraft(int $contentTypeId, bool $ignoreOwnership = false): APIContentTypeDraft
Expand All @@ -779,7 +778,7 @@ public function loadContentTypeDraft(int $contentTypeId, bool $ignoreOwnership =
);

if (!$ignoreOwnership && $spiContentType->modifierId != $this->permissionResolver->getCurrentUserReference()->getUserId()) {
throw new NotFoundException('The content type is owned by someone else', $contentTypeId);
throw new ContentTypeOwnedBySomeoneElseException($contentTypeId);
}

return $this->contentTypeDomainMapper->buildContentTypeDraftDomainObject($spiContentType);
Expand Down
Loading