forked from TYPO3-Documentation/render-guides
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileTextRole.php
More file actions
30 lines (24 loc) · 1.02 KB
/
FileTextRole.php
File metadata and controls
30 lines (24 loc) · 1.02 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
<?php
namespace T3Docs\Typo3DocsTheme\TextRoles;
use phpDocumentor\Guides\Nodes\Inline\AbstractLinkInlineNode;
use phpDocumentor\Guides\RestructuredText\Parser\DocumentParserContext;
use T3Docs\Typo3DocsTheme\Nodes\Inline\FileInlineNode;
final class FileTextRole extends CustomLinkTextRole
{
public function getName(): string
{
return 'file';
}
public function getAliases(): array
{
return [];
}
protected function createNode(DocumentParserContext $documentParserContext, string $referenceTarget, string|null $referenceName, string $role): AbstractLinkInlineNode
{
return $this->createNodeWithInterlink($documentParserContext, $referenceTarget, '', $referenceName ?? $referenceTarget);
}
private function createNodeWithInterlink(DocumentParserContext $documentParserContext, string $referenceTarget, string $interlinkDomain, string $fileLabel): AbstractLinkInlineNode
{
return new FileInlineNode($referenceTarget, $fileLabel, $interlinkDomain, 'typo3:file');
}
}