Skip to content

Commit a2599db

Browse files
committed
[TASK] Make TextRoleFactory exchangable
1 parent 51976c3 commit a2599db

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

packages/guides-restructured-text/src/RestructuredText/DependencyInjection/Compiler/TextRolePass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace phpDocumentor\Guides\RestructuredText\DependencyInjection\Compiler;
66

7-
use phpDocumentor\Guides\RestructuredText\TextRoles\DefaultTextRoleFactory;
7+
use phpDocumentor\Guides\RestructuredText\TextRoles\TextRoleFactory;
88
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
99
use Symfony\Component\DependencyInjection\ContainerBuilder;
1010
use Symfony\Component\DependencyInjection\Reference;
@@ -13,7 +13,7 @@ class TextRolePass implements CompilerPassInterface
1313
{
1414
public function process(ContainerBuilder $container): void
1515
{
16-
$textRoleFactory = $container->findDefinition(DefaultTextRoleFactory::class);
16+
$textRoleFactory = $container->findDefinition(TextRoleFactory::class);
1717
$domains = [];
1818
$textRoles = [];
1919

packages/guides-restructured-text/src/RestructuredText/Directives/DefaultRoleDirective.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use phpDocumentor\Guides\Nodes\Node;
1717
use phpDocumentor\Guides\RestructuredText\Parser\Directive;
1818
use phpDocumentor\Guides\RestructuredText\Parser\DocumentParserContext;
19-
use phpDocumentor\Guides\RestructuredText\TextRoles\DefaultTextRoleFactory;
19+
use phpDocumentor\Guides\RestructuredText\TextRoles\TextRoleFactory;
2020

2121
/**
2222
* sets the default interpreted text role, the role that is used for interpreted text without an explicit role.
@@ -26,7 +26,7 @@
2626
class DefaultRoleDirective extends BaseDirective
2727
{
2828
public function __construct(
29-
private readonly DefaultTextRoleFactory $textRoleFactory,
29+
private readonly TextRoleFactory $textRoleFactory,
3030
) {
3131
}
3232

packages/guides-restructured-text/src/RestructuredText/Directives/RoleDirective.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
use phpDocumentor\Guides\RestructuredText\Parser\Directive;
1818
use phpDocumentor\Guides\RestructuredText\Parser\DocumentParserContext;
1919
use phpDocumentor\Guides\RestructuredText\TextRoles\BaseTextRole;
20-
use phpDocumentor\Guides\RestructuredText\TextRoles\DefaultTextRoleFactory;
2120
use phpDocumentor\Guides\RestructuredText\TextRoles\GenericTextRole;
21+
use phpDocumentor\Guides\RestructuredText\TextRoles\TextRoleFactory;
2222
use Psr\Log\LoggerInterface;
2323

2424
use function is_string;
@@ -34,7 +34,7 @@ class RoleDirective extends BaseDirective
3434
{
3535
public function __construct(
3636
private readonly LoggerInterface $logger,
37-
private readonly DefaultTextRoleFactory $textRoleFactory,
37+
private readonly TextRoleFactory $textRoleFactory,
3838
) {
3939
}
4040

packages/guides-restructured-text/src/RestructuredText/Parser/Productions/InlineRules/DefaultTextRoleRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
use phpDocumentor\Guides\Nodes\Inline\LiteralInlineNode;
1010
use phpDocumentor\Guides\RestructuredText\Parser\DocumentParserContext;
1111
use phpDocumentor\Guides\RestructuredText\Parser\InlineLexer;
12-
use phpDocumentor\Guides\RestructuredText\TextRoles\DefaultTextRoleFactory;
12+
use phpDocumentor\Guides\RestructuredText\TextRoles\TextRoleFactory;
1313

1414
/**
1515
* Rule to parse for default text roles such as `something`
1616
*/
1717
class DefaultTextRoleRule extends AbstractInlineRule
1818
{
19-
public function __construct(private readonly DefaultTextRoleFactory $textRoleFactory)
19+
public function __construct(private readonly TextRoleFactory $textRoleFactory)
2020
{
2121
}
2222

packages/guides-restructured-text/src/RestructuredText/TextRoles/TextRoleFactory.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,12 @@
77
interface TextRoleFactory
88
{
99
public function getTextRole(string $name, string|null $domain = null): TextRole;
10+
11+
public function registerTextRole(TextRole $textRole): void;
12+
13+
public function replaceTextRole(TextRole $newTextRole): void;
14+
15+
public function setDefaultTextRole(string $roleName): void;
16+
17+
public function getDefaultTextRole(): TextRole;
1018
}

0 commit comments

Comments
 (0)