Skip to content

Commit d14d105

Browse files
committed
[FEATURE] Configure inventories via guides.xml
1 parent 1b367ad commit d14d105

File tree

8 files changed

+49
-31
lines changed

8 files changed

+49
-31
lines changed

packages/guides/src/DependencyInjection/GuidesExtension.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ public function getConfigTreeBuilder(): TreeBuilder
3939
->scalarNode('version')->end()
4040
->end()
4141
->end()
42+
->arrayNode('inventories')
43+
->children()
44+
->arrayNode('inventory')
45+
->arrayPrototype()
46+
->children()
47+
->scalarNode('id')->end()
48+
->scalarNode('url')->end()
49+
->end()
50+
->end()
51+
->end()
52+
->end()
53+
->end()
4254
->scalarNode('html_theme')->end()
4355
->arrayNode('base_template_paths')
4456
->defaultValue([])
@@ -79,13 +91,22 @@ public function load(array $configs, ContainerBuilder $container): void
7991
$loader->load('command_bus.php');
8092
$loader->load('guides.php');
8193

94+
$projectSettings = [];
8295
if (isset($config['project'])) {
8396
if (isset($config['project']['version'])) {
8497
$config['project']['version'] = (string) $config['project']['version'];
8598
}
8699

100+
$projectSettings = $config['project'];
101+
}
102+
103+
if (isset($config['inventories'])) {
104+
$projectSettings['inventories'] = $config['inventories']['inventory'];
105+
}
106+
107+
if ($projectSettings) {
87108
$container->getDefinition(SettingsManager::class)
88-
->addMethodCall('setProjectSettings', [new ProjectSettings($config['project'])]);
109+
->addMethodCall('setProjectSettings', [new ProjectSettings($projectSettings)]);
89110
}
90111

91112
if (isset($config['html_theme'])) {

packages/guides/src/Intersphinx/InventoryRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ public function __construct(private readonly InventoryLoader $inventoryLoader)
1818
{
1919
}
2020

21-
/** @param array<string, string> $inventoryConfigs */
21+
/** @param array<int, array<string, string>> $inventoryConfigs */
2222
public function initialize(array $inventoryConfigs): void
2323
{
2424
$this->inventories = [];
25-
foreach ($inventoryConfigs as $key => $url) {
26-
$this->inventories[$key] = new Inventory($url);
25+
foreach ($inventoryConfigs as $inventory) {
26+
$this->inventories[$inventory['id']] = new Inventory($inventory['url']);
2727
}
2828
}
2929

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<guides>
3+
<project title="My Project" version="main (development)" />
4+
<inventories>
5+
<inventory id="t3coreapi" url="https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/" />
6+
<inventory id="someapi" url="https://docs.typo3.org/m/typo3/reference-someapi/main/en-us/" />
7+
</inventories>
8+
</guides>

tests/Integration/tests/intersphinx-link/input/settings.php

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<guides>
3+
<project title="My Project" version="main (development)" />
4+
<inventories>
5+
<inventory id="t3coreapi" url="https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/" />
6+
<inventory id="t3home" url="https://docs.typo3.org/" />
7+
</inventories>
8+
</guides>

tests/Integration/tests/intersphinx-numeric/input/settings.php

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<guides>
3+
<project title="My Project" version="3.1.4" />
4+
<inventories>
5+
<inventory id="t3coreapi" url="https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/" />
6+
<inventory id="t3home" url="https://docs.typo3.org/" />
7+
</inventories>
8+
</guides>

tests/Integration/tests/settings/input/settings.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)