-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathRelationController.php
More file actions
44 lines (33 loc) · 1.46 KB
/
Copy pathRelationController.php
File metadata and controls
44 lines (33 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php declare(strict_types=1);
namespace App\Controller;
use Ibexa\Contracts\Core\Repository\ContentService;
use Ibexa\Contracts\Core\Repository\LocationService;
use Ibexa\Core\MVC\Symfony\View\View;
class RelationController
{
private ContentService $contentService;
private LocationService $locationService;
public function __construct(ContentService $contentService, LocationService $locationService)
{
$this->contentService = $contentService;
$this->locationService = $locationService;
}
public function showContentAction(View $view, $locationId): View
{
$acceptedContentTypes = $view->getParameter('accepted_content_types');
$location = $this->locationService->loadLocation($locationId);
$contentInfo = $location->getContentInfo();
$versionInfo = $this->contentService->loadVersionInfo($contentInfo);
$relationList = $this->contentService->loadRelationList($versionInfo);
$items = [];
foreach ($relationList as $relationListItem) {
if ($relationListItem->hasRelation() && in_array($relationListItem->getRelation()->getDestinationContentInfo()->getContentType()->identifier, $acceptedContentTypes)) {
$items[] = $this->contentService->loadContentByContentInfo($relationListItem->getRelation()->getDestinationContentInfo());
}
}
$view->addParameters([
'items' => $items,
]);
return $view;
}
}