Consider the following use case:
An extension (e.g. InputBox) creates input fields, if a special parser tag is added in wikitext. Currently OOJs UI in core can be easily enabled with [[ https://doc.wikimedia.org/mediawiki-core/master/php/OutputPage_8php_source.html#l03954 | OutputPage::enableOOUI() ]]. For these extensions it isn't easily possible to add OOUI elements in the parser function. As a workaround they could enableOOUI via:
```
RequestContext::getMain()->getOutput()->enableOOUI();
```
which would workaround a fatal error, which would throw, if you use any OOUI element without setting a theme.
But if a user views a page, the form will be unstyled, because the oojs-ui Resource modules aren't added to OutputPage when the page is viewed. This could be fixed by another workaround, by using the OutputPageParserOutput hook:
```
public static function onOutputPageParserOutput( OutputPage &$out, ParserOutput $parserOutput ) {
if ( $parserOutput->getProperty( 'enableOOUI' ) ) {
$out->enableOOUI();
}
}
```
Both workarounds work very well, but it feels a bit bad to let extensions handle this anytime again. There should be a better approach, e.g.:
- enableOOUI() in ParserOutput, too, which enables OOUI
- enableOOUI() set's the 'enableOOUI' property by itself (or any other reasonable property)
- if enableOOUI() is set, OutputPage should enable OOUI by itself, when the ParserOutput object is added to it