Skip to content

Commit ca9cd44

Browse files
authored
IBX-9103: Replaced Relation const calls with RelationType enum (#166)
1 parent b97ee5b commit ca9cd44

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/lib/Server/Controller/Content/ContentVersionRelationDeleteController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use ApiPlatform\OpenApi\Model;
1212
use Ibexa\Contracts\Core\Repository\ContentService;
1313
use Ibexa\Contracts\Core\Repository\Values\Content\Relation;
14+
use Ibexa\Contracts\Core\Repository\Values\Content\RelationType;
1415
use Ibexa\Contracts\Rest\Exceptions;
1516
use Ibexa\Rest\Server\Controller as RestController;
1617
use Ibexa\Rest\Server\Exceptions\ForbiddenException;
@@ -95,7 +96,7 @@ public function removeRelation(int $contentId, int $versionNumber, int $relation
9596

9697
foreach ($versionRelations as $relation) {
9798
if ($relation->id == $relationId) {
98-
if ($relation->type !== Relation::COMMON) {
99+
if ($relation->type !== RelationType::COMMON->value) {
99100
throw new ForbiddenException('Relation is not of type COMMON');
100101
}
101102

src/lib/Server/Output/ValueObjectVisitor/RestRelation.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Ibexa\Rest\Server\Output\ValueObjectVisitor;
99

10-
use Ibexa\Contracts\Core\Repository\Values\Content\Relation as RelationValue;
10+
use Ibexa\Contracts\Core\Repository\Values\Content\RelationType;
1111
use Ibexa\Contracts\Rest\Output\Generator;
1212
use Ibexa\Contracts\Rest\Output\ValueObjectVisitor;
1313
use Ibexa\Contracts\Rest\Output\Visitor;
@@ -92,19 +92,19 @@ protected function getRelationTypeString($relationType)
9292
{
9393
$relationTypeList = [];
9494

95-
if (RelationValue::COMMON & $relationType) {
95+
if (RelationType::COMMON->value & $relationType) {
9696
$relationTypeList[] = 'COMMON';
9797
}
98-
if (RelationValue::EMBED & $relationType) {
98+
if (RelationType::EMBED->value & $relationType) {
9999
$relationTypeList[] = 'EMBED';
100100
}
101-
if (RelationValue::LINK & $relationType) {
101+
if (RelationType::LINK->value & $relationType) {
102102
$relationTypeList[] = 'LINK';
103103
}
104-
if (RelationValue::FIELD & $relationType) {
104+
if (RelationType::FIELD->value & $relationType) {
105105
$relationTypeList[] = 'ATTRIBUTE';
106106
}
107-
if (RelationValue::ASSET & $relationType) {
107+
if (RelationType::ASSET->value & $relationType) {
108108
$relationTypeList[] = 'ASSET';
109109
}
110110

0 commit comments

Comments
 (0)