|
| 1 | + |
| 2 | +.. _guides-xml: |
| 3 | + |
| 4 | +========== |
| 5 | +guides.xml |
| 6 | +========== |
| 7 | + |
| 8 | +.. todo: Add general docs about guides.xml |
| 9 | +
|
| 10 | +.. _guides-xml-add-config-extension: |
| 11 | + |
| 12 | +Add a configuration option (Extension) |
| 13 | +====================================== |
| 14 | + |
| 15 | +Extension authors can add additional configuration options in the |
| 16 | +:xml:`extension` tag (allowed to occur multiple times): |
| 17 | + |
| 18 | +.. code-block:: xml |
| 19 | + :caption: guides.xml |
| 20 | +
|
| 21 | + <extension class="\T3Docs\Typo3DocsTheme\DependencyInjection\Typo3DocsThemeExtension" |
| 22 | + project-home="https://docs.typo3.org/" |
| 23 | + project-contact="https://typo3.slack.com/archives/C028JEPJL"/> |
| 24 | +
|
| 25 | +These must then be interpreted by the extension itself. The interpretation |
| 26 | +is usually done in a :php:class:`phpDocumentor\Guides\Event\PostProjectNodeCreated` |
| 27 | +event. |
| 28 | + |
| 29 | +.. _guides-xml-add-config-core: |
| 30 | + |
| 31 | +Add a configuration option (Contributors, directly in the guides) |
| 32 | +================================================================= |
| 33 | + |
| 34 | +In order to add a configuration option to the :file:`guides.xml` the option |
| 35 | +must be added to the XML schema, :file:`guides.xsd`. You can find |
| 36 | +it at :file:`packages/guides-cli/resources/schema/guides.xsd` in the |
| 37 | +mono repository. |
| 38 | + |
| 39 | +Register the new configuration option in the :php:`TreeBuilder` at |
| 40 | +:php:func:`phpDocumentor\Guides\DependencyInjection\GuidesExtension::getConfigTreeBuilder`. |
| 41 | + |
| 42 | +.. seealso:: |
| 43 | + |
| 44 | + `Defining and Processing Configuration Values (Symfony Documentation) |
| 45 | + <https://symfony.com/doc/current/components/config/definition.html>`__ |
| 46 | + |
| 47 | +Using the tree builder is a topic of itself. Refer to the according symfony documentation. |
| 48 | + |
| 49 | +If the configuration is a setting option to controll the applications workflow you can |
| 50 | +save it in the :php:class:`phpDocumentor\Guides\Settings\ProjectSettings`. Examples of |
| 51 | +settings options would be `logPath`, `showProgressBar` or `theme`. |
| 52 | + |
| 53 | +If the configuration contains data that should be output in the templates, it |
| 54 | +is advised to save the value in the |
| 55 | +:php:class:`phpDocumentor\Guides\Nodes\ProjectNode`. Examples would be `copyright`, |
| 56 | +`release` or `keywords` (for the metadata area). |
| 57 | + |
| 58 | +Save a configuration value into the :php:`ProjectSettings` |
| 59 | +---------------------------------------------------------- |
| 60 | + |
| 61 | +To add a configuration value to the :php:`ProjectSettings`, |
| 62 | +register the setting in |
| 63 | +:php:func:`phpDocumentor\Guides\DependencyInjection\GuidesExtension::load`. |
| 64 | + |
| 65 | +.. code-block:: php |
| 66 | + :caption: phpDocumentor\Guides\DependencyInjection\GuidesExtension::load |
| 67 | +
|
| 68 | + if (isset($config['ignored_domain']) && is_array($config['ignored_domain'])) { |
| 69 | + $projectSettings->setIgnoredDomains($config['ignored_domain']); |
| 70 | + } |
| 71 | +
|
| 72 | +Save a configuration value to the :php:`ProjectNode` |
| 73 | +---------------------------------------------------- |
| 74 | + |
| 75 | +Additional settings can be added to the ProjectNode in a |
| 76 | +:php:`phpDocumentor\Guides\Event\PostProjectNodeCreated` event. |
| 77 | + |
| 78 | +.. todo: Add example |
0 commit comments