Skip to content

Commit e57b5c7

Browse files
authored
Merge pull request #155 from SemanticMediaWiki/migrate-registration-to-extension-json
Migrate extension registration to extension.json
2 parents 0cc7158 + 6f4c51b commit e57b5c7

6 files changed

Lines changed: 45 additions & 65 deletions

File tree

‎.phpcs.xml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
<exclude name="MediaWiki.Commenting.PropertyDocumentation.WrongStyle" />
1414
<exclude name="MediaWiki.Commenting.MissingCovers.MissingCovers" />
1515
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
16-
<!-- Legacy entry-point filename (SemanticFormsSelect.hooks.php holds class Hooks). -->
17-
<exclude name="MediaWiki.Files.ClassMatchesFilename.NotMatch" />
1816
<!-- $IP in the test bootstrap is a MediaWiki core global. -->
1917
<exclude name="MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix" />
2018
<exclude name="Generic.Files.LineLength.TooLong" />

‎RELEASE-NOTES.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Compatible with MediaWiki 1.43 up to 1.45, PHP 8.1 up to 8.4, and Semantic Media
1010
* Raised the minimum required Page Forms version to 6.0.6
1111
* Added support for Semantic MediaWiki 7.0
1212
* Migrated the query processing to Semantic MediaWiki 7.0's namespaced `SMW\Query\QueryProcessor` API
13+
* Completed the migration of extension registration to `extension.json` (declarative API module and autoloading, removed the procedural registration callback and the root entry-point file)
14+
* Removed the unused `$wgScriptSelectCount` configuration setting (it was read nowhere)
1315

1416
### 4.0.0
1517

‎SemanticFormsSelect.hooks.php‎

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

‎composer.json‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@
5151
"dev-master": "5.x-dev"
5252
}
5353
},
54-
"autoload": {
55-
"psr-4": {
56-
"SFS\\": "src/"
57-
}
58-
},
5954
"config": {
6055
"process-timeout": 0,
6156
"allow-plugins": {

‎extension.json‎

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,54 +20,46 @@
2020
"PageForms": ">= 6.0.6"
2121
}
2222
},
23-
"AutoloadClasses": {
24-
"SFS\\Hooks": "SemanticFormsSelect.hooks.php",
25-
"SFS\\SemanticFormsSelectInput": "src/SemanticFormsSelectInput.php",
26-
"SFS\\Output": "src/Output.php",
27-
"SFS\\SelectField": "src/SelectField.php",
28-
"SFS\\ApiSemanticFormsSelectRequestProcessor": "src/ApiSemanticFormsSelectRequestProcessor.php",
29-
"SFS\\ApiSemanticFormsSelect": "src/ApiSemanticFormsSelect.php"
23+
"AutoloadNamespaces": {
24+
"SFS\\": "src/"
3025
},
3126
"config": {
32-
"ScriptSelectCount": {
33-
"value": 0
34-
},
3527
"SF_Select_debug": {
3628
"value": false
3729
}
3830
},
39-
"callback": "SFS\\Hooks::onRegistration",
31+
"APIModules": {
32+
"sformsselect": "SFS\\ApiSemanticFormsSelect"
33+
},
4034
"MessagesDirs": {
4135
"SemanticFormsSelect": [
4236
"i18n"
4337
]
4438
},
39+
"ResourceFileModulePaths": {
40+
"localBasePath": "res",
41+
"remoteExtPath": "SemanticFormsSelect/res"
42+
},
4543
"ResourceModules": {
4644
"ext.sfs": {
4745
"scripts": [
48-
"res/pf.originalValueLookup.js",
49-
"res/sfs.js",
50-
"res/index.js"
46+
"pf.originalValueLookup.js",
47+
"sfs.js",
48+
"index.js"
5149
],
5250
"styles": [
53-
"res/select2.css"
51+
"select2.css"
5452
],
5553
"dependencies": [
5654
"ext.pageforms.main",
5755
"ext.pageforms.select2"
58-
],
59-
"position": "bottom"
56+
]
6057
}
6158
},
62-
"ResourceFileModulePaths": {
63-
"localBasePath": "",
64-
"remoteExtPath": "SemanticFormsSelect"
65-
},
6659
"Hooks": {
6760
"ParserFirstCallInit": [
6861
"SFS\\Hooks::onSemanticFormsSelectSetup"
6962
]
7063
},
71-
"load_composer_autoloader":true,
7264
"manifest_version": 2
7365
}

‎src/Hooks.php‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace SFS;
4+
5+
use Parser;
6+
7+
/**
8+
* @license GPL-2.0-or-later
9+
* @since 3.0
10+
* @author Alexander Gesinn
11+
*/
12+
class Hooks {
13+
14+
/**
15+
* Register the Page Forms input type.
16+
*
17+
* Attached to the MediaWiki 'ParserFirstCallInit' hook.
18+
*
19+
* @param Parser $parser
20+
* @return bool
21+
*/
22+
public static function onSemanticFormsSelectSetup( Parser $parser ) {
23+
if ( isset( $GLOBALS['wgPageFormsFormPrinter'] ) ) {
24+
$GLOBALS['wgPageFormsFormPrinter']->registerInputType( SemanticFormsSelectInput::class );
25+
}
26+
27+
return true;
28+
}
29+
}

0 commit comments

Comments
 (0)