aboutsummaryrefslogtreecommitdiffstats
path: root/includes/preferences/Hook
diff options
context:
space:
mode:
authorTim Starling <tstarling@wikimedia.org>2020-03-04 09:50:34 +1100
committerTim Starling <tstarling@wikimedia.org>2020-04-20 13:31:05 +1000
commitf5aaf75ad15813bfeb93dcb4e5fbaaa52b23c7fe (patch)
tree1598e7d4c3d1e6d2914de4ae61ca01b2cbd3f470 /includes/preferences/Hook
parentcedee2b62058a3834c2d883eeeecc2707eed9c93 (diff)
downloadmediawikicore-f5aaf75ad15813bfeb93dcb4e5fbaaa52b23c7fe.tar.gz
mediawikicore-f5aaf75ad15813bfeb93dcb4e5fbaaa52b23c7fe.zip
Automatically generated hook interfaces
Add hook interfaces which were generated by a script which parses hooks.txt and identifies caller namespaces and directories. Hook interfaces are mostly placed in a Hook/ subdirectory relative to the caller location. When there are callers in multiple directories, a "primary" caller was manually selected. The exceptions to this are: * The source root, maintenance and tests, which use includes/Hook. Test hooks need to be autoloadable in a non-test request so that implementing test interfaces in a generic handler will not fail. * resources uses includes/resourceloader/Hook * The following third-level subdirectories had their hooks placed in the parent ../Hook: * includes/filerepo/file * includes/search/searchwidgets * includes/specials/forms * includes/specials/helpers * includes/specials/pagers Parameters marked as legacy references in hooks.txt are passed by value in the interfaces. Bug: T240307 Change-Id: I6efe2e7dd1f0c6a3d0f4d100a4c34e41f8428720
Diffstat (limited to 'includes/preferences/Hook')
-rw-r--r--includes/preferences/Hook/GetPreferencesHook.php20
-rw-r--r--includes/preferences/Hook/PreferencesFormPreSaveHook.php25
2 files changed, 45 insertions, 0 deletions
diff --git a/includes/preferences/Hook/GetPreferencesHook.php b/includes/preferences/Hook/GetPreferencesHook.php
new file mode 100644
index 000000000000..acaaeacc2ec2
--- /dev/null
+++ b/includes/preferences/Hook/GetPreferencesHook.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace MediaWiki\Preferences\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface GetPreferencesHook {
+ /**
+ * Modify user preferences.
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $user User whose preferences are being modified.
+ * @param ?mixed &$preferences Preferences description array, to be fed to an HTMLForm object
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onGetPreferences( $user, &$preferences );
+}
diff --git a/includes/preferences/Hook/PreferencesFormPreSaveHook.php b/includes/preferences/Hook/PreferencesFormPreSaveHook.php
new file mode 100644
index 000000000000..85d4aec56223
--- /dev/null
+++ b/includes/preferences/Hook/PreferencesFormPreSaveHook.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace MediaWiki\Preferences\Hook;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface PreferencesFormPreSaveHook {
+ /**
+ * Override preferences being saved
+ *
+ * @since 1.35
+ *
+ * @param ?mixed $formData array of user submitted data
+ * @param ?mixed $form HTMLForm object, also a ContextSource
+ * @param ?mixed $user User object with preferences to be saved set
+ * @param ?mixed &$result boolean indicating success
+ * @param ?mixed $oldUserOptions array with user old options (before save)
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onPreferencesFormPreSave( $formData, $form, $user, &$result,
+ $oldUserOptions
+ );
+}