Skip to content

Commit

Permalink
Adjusted to changes in core package
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed Oct 31, 2024
1 parent 506d459 commit 3af7694
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 75 deletions.
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ services:
- '@ibexa.api.service.section'
- '@ibexa.api.repository'
- '@Ibexa\Contracts\Core\Repository\PermissionResolver'
- '@Ibexa\Core\Helper\RelationListHelper'
- '@Ibexa\Contracts\Core\Repository\ContentService\RelationListFacade'
tags: [controller.service_arguments]

Ibexa\Rest\Server\Controller\URLWildcard:
Expand Down
8 changes: 4 additions & 4 deletions src/bundle/Resources/config/value_object_visitors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ services:
parent: Ibexa\Contracts\Rest\Output\ValueObjectVisitor
class: Ibexa\Rest\Server\Output\ValueObjectVisitor\UserGroup
arguments:
$relationListHelper: '@Ibexa\Core\Helper\RelationListHelper'
$relationListFacade: '@Ibexa\Contracts\Core\Repository\ContentService\RelationListFacade'
tags:
- { name: ibexa.rest.output.value_object.visitor, type: Ibexa\Contracts\Core\Repository\Values\User\UserGroup }

Expand Down Expand Up @@ -272,7 +272,7 @@ services:
parent: Ibexa\Contracts\Rest\Output\ValueObjectVisitor
class: Ibexa\Rest\Server\Output\ValueObjectVisitor\User
arguments:
$relationListHelper: '@Ibexa\Core\Helper\RelationListHelper'
$relationListFacade: '@Ibexa\Contracts\Core\Repository\ContentService\RelationListFacade'
tags:
- { name: ibexa.rest.output.value_object.visitor, type: Ibexa\Contracts\Core\Repository\Values\User\User }

Expand Down Expand Up @@ -477,7 +477,7 @@ services:
- { name: ibexa.rest.output.value_object.visitor, type: Ibexa\Contracts\Core\Repository\Values\Content\Location }
arguments:
$locationService: '@ibexa.api.service.location'
$relationListHelper: '@Ibexa\Core\Helper\RelationListHelper'
$relationListFacade: '@Ibexa\Contracts\Core\Repository\ContentService\RelationListFacade'

Ibexa\Rest\Server\Output\ValueObjectVisitor\LocationList:
parent: Ibexa\Contracts\Rest\Output\ValueObjectVisitor
Expand All @@ -504,7 +504,7 @@ services:
class: Ibexa\Rest\Server\Output\ValueObjectVisitor\RestExecutedView
arguments:
- '@ibexa.api.service.location'
- '@Ibexa\Core\Helper\RelationListHelper'
- '@Ibexa\Contracts\Core\Repository\ContentService\RelationListFacade'
tags:
- { name: ibexa.rest.output.value_object.visitor, type: Ibexa\Rest\Server\Values\RestExecutedView }

Expand Down
28 changes: 12 additions & 16 deletions src/lib/Server/Controller/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Ibexa\Contracts\Core\Repository\Values\Content\Relation;
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo;
use Ibexa\Contracts\Rest\Exceptions;
use Ibexa\Core\Helper\RelationListHelper;
use Ibexa\Rest\Message;
use Ibexa\Rest\Server\Controller as RestController;
use Ibexa\Rest\Server\Exceptions\BadRequestException;
Expand All @@ -27,14 +26,11 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;

/**
* Content controller.
*/
class Content extends RestController
{
public function __construct(
private readonly ContentService $contentService,
private readonly RelationListHelper $relationListHelper
private readonly ContentService\RelationListFacade $relationListFacade
) {
}

Expand Down Expand Up @@ -90,15 +86,15 @@ public function loadContent($contentId, Request $request)
$languages = $this->getLanguages($request);

$contentVersion = $this->repository->getContentService()->loadContent($contentId, $languages);
$relations = $this->relationListHelper->getRelations($contentVersion->getVersionInfo());
$relations = $this->relationListFacade->getRelations($contentVersion->getVersionInfo());
}

$restContent = new Values\RestContent(
$contentInfo,
$mainLocation,
$contentVersion,
$contentType,
$relations,
$relations !== null ? iterator_to_array($relations) : null,
$request->getPathInfo()
);

Expand Down Expand Up @@ -208,7 +204,7 @@ public function loadContentInVersion($contentId, $versionNumber, Request $reques
$versionValue = new Values\Version(
$content,
$contentType,
$this->relationListHelper->getRelations($content->getVersionInfo()),
iterator_to_array($this->relationListFacade->getRelations($content->getVersionInfo())),
$request->getPathInfo()
);

Expand Down Expand Up @@ -443,7 +439,7 @@ public function createDraftFromVersion($contentId, $versionNumber)
'version' => new Values\Version(
$contentDraft,
$contentType,
$this->relationListHelper->getRelations($contentDraft->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($contentDraft->getVersionInfo()))
),
]
);
Expand Down Expand Up @@ -477,7 +473,7 @@ public function createDraftFromCurrentVersion($contentId)
'version' => new Values\Version(
$contentDraft,
$contentType,
$this->relationListHelper->getRelations($contentDraft->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($contentDraft->getVersionInfo()))
),
]
);
Expand Down Expand Up @@ -544,7 +540,7 @@ public function updateVersion($contentId, $versionNumber, Request $request)
return new Values\Version(
$content,
$contentType,
$this->relationListHelper->getRelations($content->getVersionInfo()),
iterator_to_array($this->relationListFacade->getRelations($content->getVersionInfo())),
$request->getPathInfo()
);
}
Expand Down Expand Up @@ -659,7 +655,7 @@ public function loadVersionRelations($contentId, $versionNumber, Request $reques
public function loadVersionRelation($contentId, $versionNumber, $relationId, Request $request)
{
$contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
$relationList = $this->relationListHelper->getRelations(
$relationList = $this->relationListFacade->getRelations(
$this->repository->getContentService()->loadVersionInfo($contentInfo, $versionNumber)
);

Expand Down Expand Up @@ -700,7 +696,7 @@ public function removeRelation($contentId, $versionNumber, $relationId, Request
$versionNumber
);

$versionRelations = $this->relationListHelper->getRelations($versionInfo);
$versionRelations = $this->relationListFacade->getRelations($versionInfo);
foreach ($versionRelations as $relation) {
if ($relation->id == $relationId) {
if ($relation->type !== Relation::COMMON) {
Expand Down Expand Up @@ -752,7 +748,7 @@ public function createRelation($contentId, $versionNumber, Request $request)
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}

$existingRelations = $this->relationListHelper->getRelations($versionInfo);
$existingRelations = $this->relationListFacade->getRelations($versionInfo);
foreach ($existingRelations as $existingRelation) {
if ($existingRelation->getDestinationContentInfo()->id == $destinationContentId) {
throw new ForbiddenException('Relation of type COMMON to the selected destination content ID already exists');
Expand Down Expand Up @@ -857,7 +853,7 @@ protected function doCreateContent(Request $request, RestContentCreateStruct $co
$contentType = $this->repository->getContentTypeService()->loadContentType(
$content->getVersionInfo()->getContentInfo()->contentTypeId
);
$relations = $this->relationListHelper->getRelations($contentValue->getVersionInfo());
$relations = $this->relationListFacade->getRelations($contentValue->getVersionInfo());
}

return new Values\CreatedContent(
Expand All @@ -867,7 +863,7 @@ protected function doCreateContent(Request $request, RestContentCreateStruct $co
null,
$contentValue,
$contentType,
$relations
$relations !== null ? iterator_to_array($relations) : null,
),
]
);
Expand Down
39 changes: 19 additions & 20 deletions src/lib/Server/Controller/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Ibexa\Contracts\Core\Repository\Values\User\UserRoleAssignment;
use Ibexa\Contracts\Rest\Exceptions\NotFoundException;
use Ibexa\Core\Base\Exceptions\UnauthorizedException;
use Ibexa\Core\Helper\RelationListHelper;
use Ibexa\Rest\Message;
use Ibexa\Rest\Server\Controller as RestController;
use Ibexa\Rest\Server\Exceptions;
Expand Down Expand Up @@ -63,7 +62,7 @@ final class User extends RestController

private PermissionResolver $permissionResolver;

private RelationListHelper $relationListHelper;
private ContentService\RelationListFacade $relationListFacade;

public function __construct(
UserService $userService,
Expand All @@ -74,7 +73,7 @@ public function __construct(
SectionService $sectionService,
Repository $repository,
PermissionResolver $permissionResolver,
RelationListHelper $relationListHelper
ContentService\RelationListFacade $relationListFacade
) {
$this->userService = $userService;
$this->roleService = $roleService;
Expand All @@ -84,7 +83,7 @@ public function __construct(
$this->sectionService = $sectionService;
$this->repository = $repository;
$this->permissionResolver = $permissionResolver;
$this->relationListHelper = $relationListHelper;
$this->relationListFacade = $relationListFacade;
}

/**
Expand Down Expand Up @@ -126,7 +125,7 @@ public function loadUserGroup(string $groupPath): RestValue
$contentType,
$userGroupContentInfo,
$userGroupLocation,
$this->relationListHelper->getRelations($userGroup->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($userGroup->getVersionInfo()))
),
['locationId' => $userGroupLocation->id]
);
Expand All @@ -141,7 +140,7 @@ public function loadUser(int $userId): RestValue

try {
$userMainLocation = $this->locationService->loadLocation($userContentInfo->mainLocationId);
$relations = $this->relationListHelper->getRelations($user->getVersionInfo());
$relations = $this->relationListFacade->getRelations($user->getVersionInfo());
} catch (UnauthorizedException $e) {
// TODO: Hack for special case to allow current logged in user to load him/here self (but not relations)
if ($user->id == $this->permissionResolver->getCurrentUserReference()->getUserId()) {
Expand All @@ -163,7 +162,7 @@ function () use ($userContentInfo) {
$contentType,
$userContentInfo,
$userMainLocation,
$relations
iterator_to_array($relations)
),
['locationId' => $userContentInfo->mainLocationId]
);
Expand Down Expand Up @@ -224,7 +223,7 @@ public function createUserGroup(string $groupPath, Request $request): Values\Cre
$contentType,
$createdContentInfo,
$createdLocation,
$this->relationListHelper->getRelations($createdUserGroup->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($createdUserGroup->getVersionInfo()))
),
]
);
Expand Down Expand Up @@ -269,7 +268,7 @@ public function createUser(string $groupPath, Request $request): Values\CreatedU
$contentType,
$createdContentInfo,
$createdLocation,
$this->relationListHelper->getRelations($createdUser->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($createdUser->getVersionInfo()))
),
]
);
Expand Down Expand Up @@ -314,7 +313,7 @@ public function updateUserGroup(string $groupPath, Request $request): Values\Res
$contentType,
$updatedGroup->getVersionInfo()->getContentInfo(),
$userGroupLocation,
$this->relationListHelper->getRelations($updatedGroup->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($updatedGroup->getVersionInfo()))
);
}

Expand Down Expand Up @@ -351,7 +350,7 @@ public function updateUser(int $userId, Request $request): Values\RestUser
$contentType,
$updatedContentInfo,
$mainLocation,
$this->relationListHelper->getRelations($updatedUser->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($updatedUser->getVersionInfo()))
);
}

Expand Down Expand Up @@ -486,7 +485,7 @@ private function buildRestUserObject(RepositoryUser $user): Values\RestUser
$this->contentTypeService->loadContentType($user->contentInfo->contentTypeId),
$user->contentInfo,
$this->locationService->loadLocation($user->contentInfo->mainLocationId),
$this->relationListHelper->getRelations($user->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($user->getVersionInfo()))
);
}

Expand All @@ -508,7 +507,7 @@ public function loadUserGroups(Request $request): RestValue
$contentType,
$userGroupContentInfo,
$userGroupMainLocation,
$this->relationListHelper->getRelations($userGroup->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($userGroup->getVersionInfo()))
),
];
} elseif ($request->query->has('roleId')) {
Expand Down Expand Up @@ -541,7 +540,7 @@ public function loadUserGroupByRemoteId(Request $request): Values\RestUserGroup
$contentType,
$contentInfo,
$userGroupLocation,
$this->relationListHelper->getRelations($userGroup->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($userGroup->getVersionInfo()))
);
}

Expand Down Expand Up @@ -571,7 +570,7 @@ public function loadUserGroupsAssignedToRole($roleId): array
$contentType,
$userGroupContentInfo,
$userGroupLocation,
$this->relationListHelper->getRelations($userGroup->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($userGroup->getVersionInfo()))
);
}
}
Expand Down Expand Up @@ -722,7 +721,7 @@ public function loadSubUserGroups(string $groupPath, Request $request): RestValu
$contentType,
$subGroupContentInfo,
$subGroupLocation,
$this->relationListHelper->getRelations($subGroup->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($subGroup->getVersionInfo()))
);
}

Expand Down Expand Up @@ -768,7 +767,7 @@ public function loadUserGroupsOfUser(int $userId, Request $request): RestValue
$contentType,
$userGroupContentInfo,
$userGroupLocation,
$this->relationListHelper->getRelations($userGroup->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($userGroup->getVersionInfo()))
);
}

Expand Down Expand Up @@ -812,7 +811,7 @@ public function loadUsersFromGroup(string $groupPath, Request $request): RestVal
$contentType,
$userContentInfo,
$userLocation,
$this->relationListHelper->getRelations($user->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($user->getVersionInfo()))
);
}

Expand Down Expand Up @@ -864,7 +863,7 @@ public function unassignUserFromUserGroup(int $userId, string $groupPath): Value
$contentType,
$userGroupContentInfo,
$userGroupLocation,
$this->relationListHelper->getRelations($userGroup->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($userGroup->getVersionInfo()))
);
}

Expand Down Expand Up @@ -922,7 +921,7 @@ public function assignUserToUserGroup(int $userId, Request $request): Values\Use
$contentType,
$userGroupContentInfo,
$userGroupLocation,
$this->relationListHelper->getRelations($userGroup->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($userGroup->getVersionInfo()))
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/Server/Output/ValueObjectVisitor/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

namespace Ibexa\Rest\Server\Output\ValueObjectVisitor;

use Ibexa\Contracts\Core\Repository\ContentService\RelationListFacade;
use Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException;
use Ibexa\Contracts\Core\Repository\LocationService;
use Ibexa\Contracts\Core\Repository\Values\Content;
use Ibexa\Contracts\Rest\Output\Generator;
use Ibexa\Contracts\Rest\Output\ValueObjectVisitor;
use Ibexa\Contracts\Rest\Output\Visitor;
use Ibexa\Core\Helper\RelationListHelper;
use Ibexa\Rest\Server\Values\RestContent as RestContentValue;

/**
Expand All @@ -23,7 +23,7 @@ class Location extends ValueObjectVisitor
{
public function __construct(
private readonly LocationService $locationService,
private readonly RelationListHelper $relationListHelper
private readonly RelationListFacade $relationListFacade
) {
}

Expand Down Expand Up @@ -164,7 +164,7 @@ protected function visitLocationAttributes(
$mainLocation,
$content,
$content->getContentType(),
$this->relationListHelper->getRelations($content->getVersionInfo())
iterator_to_array($this->relationListFacade->getRelations($content->getVersionInfo()))
)
);

Expand Down
Loading

0 comments on commit 3af7694

Please sign in to comment.