-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathRichTextResolver.php
More file actions
64 lines (57 loc) · 1.83 KB
/
RichTextResolver.php
File metadata and controls
64 lines (57 loc) · 1.83 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace BD\EzPlatformGraphQLBundle\GraphQL\Resolver;
use DOMDocument;
use eZ\Publish\API\Repository\ContentService;
use eZ\Publish\API\Repository\Values\Content\Relation;
use eZ\Publish\Core\FieldType\RichText\Converter as RichTextConverterInterface;
use eZ\Publish\Core\FieldType\RichText;
class RichTextResolver
{
/**
* @var RichTextConverterInterface
*/
private $richTextConverter;
/**
* @var RichTextConverterInterface
*/
private $richTextEditConverter;
/**
* @var RichText\Type
*/
private $fieldType;
/**
* @var ContentService
*/
private $contentService;
public function __construct(
RichTextConverterInterface $richTextConverter,
RichTextConverterInterface $richTextEditConverter,
ContentService $contentService,
RichText\Type $fieldType
)
{
$this->richTextConverter = $richTextConverter;
$this->richTextEditConverter = $richTextEditConverter;
$this->fieldType = $fieldType;
$this->contentService = $contentService;
}
public function xmlToHtml5(DOMDocument $document)
{
return $this->richTextConverter->convert($document)->saveHTML();
}
public function xmlToHtml5Edit(DOMDocument $document)
{
return $this->richTextEditConverter->convert($document)->saveHTML();
}
public function resolveEmbeds(RichText\Value $value)
{
foreach ($this->fieldType->getRelations($value)[Relation::EMBED]['contentIds'] as $embeddedContentId) {
// @todo Handle locationIds as well
yield $this->contentService->loadContentInfo($embeddedContentId);
}
}
}