Debian Codegraph @

extensions/VisualEditor/editcheck/includes/ResourceLoaderData.php

raw symbols SCIP
1 <?php
2 /**
3 * Utilities for ResourceLoader modules used by EditCheck.
4 *
5 * @file
6 * @ingroup Extensions
7 * @license MIT
8 */
9
10 namespace MediaWiki\Extension\VisualEditor\EditCheck;
11
12 use MessageLocalizer;
13
14 class ResourceLoaderData {
15
16 private const DEFAULTS = [
17 'addReference' => [
18 'minimumCharacters' => 50,
19 'beforePunctuation' => false,
20 // TODO: when we have multiple edit checks this will likely be a generic block:
21 // account: loggedin, loggedout, anything non-truthy means allow either
22 'account' => false,
23 'maximumEditcount' => 100,
24 'ignoreSections' => [],
25 'ignoreLeadSection' => false,
26 ],
27 ];
28
29 /**
30 * Return configuration data for edit checks, fetched from an on-wiki JSON message
31 *
32 * @param MessageLocalizer $context
33 * @return array Configuration data for edit checks
34 */
35 public static function getConfig( MessageLocalizer $context ): array {
36 $raw_config = json_decode( $context->msg( 'editcheck-config.json' )->inContentLanguage()->plain(), true );
37
38 return array_replace_recursive( self::DEFAULTS, $raw_config ?? [] );
39 }
40 }