Phuedx has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/328485 )

Change subject: Hygiene: Tidy SpecialMobileOptions module listing
......................................................................

Hygiene: Tidy SpecialMobileOptions module listing

Generating a list of modules that should be added to the output is its
own small slice of responsibility. Formalize this by moving it into a
private method.

Changes:
* SpecialMobileOptions#getSettingsForm -> #addSettingsForm as it's not a
  getter - it adds the rendered settings form to the output.
* Add SpecialMobileOptions#getModules to get the list of modules that
  should be added to the output and make #addSettingsForm defer to it.

Bug: T148193
Change-Id: Icf664d4512c9e65f89d8572b5cebf1a0c7551593
---
M includes/specials/SpecialMobileOptions.php
1 file changed, 25 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/85/328485/1

diff --git a/includes/specials/SpecialMobileOptions.php 
b/includes/specials/SpecialMobileOptions.php
index 40e781a..7d91ecb 100644
--- a/includes/specials/SpecialMobileOptions.php
+++ b/includes/specials/SpecialMobileOptions.php
@@ -63,18 +63,31 @@
                        if ( $this->getRequest()->wasPosted() ) {
                                $this->submitSettingsForm();
                        } else {
-                               if ( $context->getConfigVariable( 
'MinervaEnableFontChanger' ) ) {
-                                       $this->getOutput()->addModules( 
'mobile.special.mobileoptions.scripts.fontchanger' );
-                               }
-                               $this->getSettingsForm();
+                               $this->addSettingsForm();
                        }
                }
        }
 
        /**
-        * Render the settings form (with actual set settings) to display to 
user
+        * Gets the Resource Loader modules that should be added to the output.
+        *
+        * @return string[]
         */
-       private function getSettingsForm() {
+       private function getModules( MobileContext $context ) {
+               $result = [];
+
+               if ( $context->getConfigVariable( 'MinervaEnableFontChanger' ) 
) {
+                       $result[] = 
'mobile.special.mobileoptions.scripts.fontchanger';
+               }
+
+               return $result;
+       }
+
+       /**
+        * Render the settings form (with actual set settings) and add it to the
+        * output as well as any supporting modules.
+        */
+       private function addSettingsForm() {
                $out = $this->getOutput();
                $context = MobileContext::singleton();
                $user = $this->getUser();
@@ -153,6 +166,11 @@
 HTML;
                // @codingStandardsIgnoreEnd
                $out->addHTML( $html );
+
+               $modules = $this->getModules( $context );
+
+               $this->getOutput()
+                       ->addModules( $modules );
        }
 
        /**
@@ -234,7 +252,7 @@
                        $schemaData['action'] = 'error';
                        $schemaData['errorText'] = $errorText;
                        ExtMobileFrontend::eventLog( $schema, $schemaRevision, 
$schemaData );
-                       $this->getSettingsForm();
+                       $this->addSettingsForm();
                        return;
                }
                wfIncrStats( 'mobile.options.saves' );

-- 
To view, visit https://gerrit.wikimedia.org/r/328485
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icf664d4512c9e65f89d8572b5cebf1a0c7551593
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Phuedx <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to