Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| Hooks | |
0.00% |
0 / 8 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| onParserFirstCallInit | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |||
| onSoftwareInfo | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\Score; |
| 4 | |
| 5 | use MediaWiki\Config\Config; |
| 6 | use MediaWiki\MainConfigNames; |
| 7 | use MediaWiki\Parser\Hook\ParserFirstCallInitHook; |
| 8 | use MediaWiki\Parser\Parser; |
| 9 | use MediaWiki\Specials\Hook\SoftwareInfoHook; |
| 10 | |
| 11 | class Hooks implements |
| 12 | ParserFirstCallInitHook, |
| 13 | SoftwareInfoHook |
| 14 | { |
| 15 | public function __construct( |
| 16 | private readonly Config $config, |
| 17 | ) { |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * @param Parser $parser |
| 22 | */ |
| 23 | public function onParserFirstCallInit( $parser ) { |
| 24 | global $wgScoreTrim; |
| 25 | if ( $this->config->get( 'ScoreUseSvg' ) ) { |
| 26 | // For SVG, always set true |
| 27 | $wgScoreTrim = true; |
| 28 | } |
| 29 | if ( $wgScoreTrim === null ) { |
| 30 | // Default to if we use Image Magick, since it requires Image Magick. |
| 31 | $wgScoreTrim = $this->config->get( MainConfigNames::UseImageMagick ); |
| 32 | } |
| 33 | $parser->setHook( 'score', [ Score::class, 'render' ] ); |
| 34 | } |
| 35 | |
| 36 | /** @inheritDoc */ |
| 37 | public function onSoftwareInfo( &$software ) { |
| 38 | try { |
| 39 | $software[ '[https://lilypond.org/ LilyPond]' ] = Score::getLilypondVersion(); |
| 40 | } catch ( ScoreException ) { |
| 41 | // LilyPond executable can't found |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | } |