Page MenuHomePhabricator

Make hook entries in extension.json less verbose
Closed, ResolvedPublic

Description

We should be able to write:

{
	"Hooks": {
		"ParserFirstCallInit": [
			"MassMessageHooks::onParserFirstCallInit"
		],
		"SpecialStatsAddExtra": [
			"MassMessageHooks::onSpecialStatsAddExtra"
		],
		"APIQuerySiteInfoStatisticsInfo": [
			"MassMessageHooks::onAPIQuerySiteInfoStatisticsInfo"
		],
		"RenameUserPreRename": [
			"MassMessageHooks::onRenameUserPreRename"
		],
		"UserGetReservedNames": [
			"MassMessageHooks::onUserGetReservedNames"
		],
		"UnitTestsList": [
			"MassMessageHooks::onUnitTestsList"
		],
		"BeforeEchoEventInsert": [
			"MassMessageHooks::onBeforeEchoEventInsert"
		],
		"SkinTemplateNavigation": [
			"MassMessageHooks::onSkinTemplateNavigation"
		],
		"BeforePageDisplay": [
			"MassMessageHooks::onBeforePageDisplay"
		],
		"ListDefinedTags": [
			"MassMessageHooks::onRegisterTags"
		],
		"ChangeTagsListActive": [
			"MassMessageHooks::onRegisterTags"
		]
	}
}

as

{
	"Hooks": {
		"ParserFirstCallInit": "MassMessageHooks::onParserFirstCallInit",
		"SpecialStatsAddExtra": "MassMessageHooks::onSpecialStatsAddExtra",
		"APIQuerySiteInfoStatisticsInfo": "MassMessageHooks::onAPIQuerySiteInfoStatisticsInfo",
		"RenameUserPreRename": "MassMessageHooks::onRenameUserPreRename",
		"UserGetReservedNames": "MassMessageHooks::onUserGetReservedNames",
		"UnitTestsList": "MassMessageHooks::onUnitTestsList",
		"BeforeEchoEventInsert": "MassMessageHooks::onBeforeEchoEventInsert",
		"SkinTemplateNavigation": "MassMessageHooks::onSkinTemplateNavigation",
		"BeforePageDisplay": "MassMessageHooks::onBeforePageDisplay",
		"ListDefinedTags": "MassMessageHooks::onRegisterTags",
		"ChangeTagsListActive": "MassMessageHooks::onRegisterTags"

	}
}

That's so much better. And if for some reason an extension has two hooks for the same event, they can use the array syntax. But we should encourage the string one by default (aka have the conversion script use it)