-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathWebinarEventTitleFulltextFieldMapper.php
More file actions
38 lines (32 loc) · 1.3 KB
/
Copy pathWebinarEventTitleFulltextFieldMapper.php
File metadata and controls
38 lines (32 loc) · 1.3 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
<?php declare(strict_types=1);
namespace App\Search\FieldMapper;
use Ibexa\Contracts\Core\Persistence\Content;
use Ibexa\Contracts\Core\Persistence\Content\Handler as ContentHandler;
use Ibexa\Contracts\Core\Persistence\Content\Location\Handler as LocationHandler;
use Ibexa\Contracts\Core\Search;
use Ibexa\Contracts\Solr\FieldMapper\ContentFieldMapper;
class WebinarEventTitleFulltextFieldMapper extends ContentFieldMapper
{
public function __construct(protected ContentHandler $contentHandler, protected LocationHandler $locationHandler)
{
}
public function accept(Content $content): bool
{
// ContentType with ID 42 is webinar event
return $content->versionInfo->contentInfo->contentTypeId == 42;
}
public function mapFields(Content $content): array
{
$mainLocationId = $content->versionInfo->contentInfo->mainLocationId;
$location = $this->locationHandler->load($mainLocationId);
$parentLocation = $this->locationHandler->load($location->parentId);
$parentContentInfo = $this->contentHandler->loadContentInfo($parentLocation->contentId);
return [
new Search\Field(
'fulltext',
$parentContentInfo->name,
new Search\FieldType\FullTextField()
),
];
}
}