Make it possible for subclasses to provide a different form
authorSam Wilson <sam@samwilson.id.au>
Thu, 10 Aug 2017 17:15:16 +0000 (13:15 -0400)
committerSam Wilson <sam@samwilson.id.au>
Thu, 10 Aug 2017 17:15:16 +0000 (13:15 -0400)
This makes it possible for subclasses of SpecialPreferences to
specify a different HtmlForm to use for the preferences' form.

Bug: T68869
Change-Id: I9d6bbc6383a3d5b5c6839394de49ce9ca81efec9

includes/specials/SpecialPreferences.php

index 40b50ea..ba5a57e 100644 (file)
@@ -81,7 +81,7 @@ class SpecialPreferences extends SpecialPage {
                        $user = $this->getUser();
                }
 
-               $htmlForm = Preferences::getFormObject( $user, $this->getContext() );
+               $htmlForm = $this->getFormObject( $user, $this->getContext() );
                $htmlForm->setSubmitCallback( [ 'Preferences', 'tryUISubmit' ] );
                $sectionTitles = $htmlForm->getPreferenceSections();
 
@@ -117,6 +117,16 @@ class SpecialPreferences extends SpecialPage {
                $htmlForm->show();
        }
 
+       /**
+        * Get the preferences form to use.
+        * @param User $user The user.
+        * @param IContextSource $context The context.
+        * @return PreferencesForm|HtmlForm
+        */
+       protected function getFormObject( $user, IContextSource $context ) {
+               return Preferences::getFormObject( $user, $context );
+       }
+
        private function showResetForm() {
                if ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) {
                        throw new PermissionsError( 'editmyoptions' );