jenkins-bot has submitted this change and it was merged.

Change subject: Split ConfigMerger class into own file
......................................................................


Split ConfigMerger class into own file

Change-Id: I2d664a8eb9c23d046e22025f43ea943005d8af4d
---
M ZeroPortal.php
A includes/ConfigMerger.php
M includes/PortalSpecialPage.php
3 files changed, 61 insertions(+), 54 deletions(-)

Approvals:
  Reedy: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/ZeroPortal.php b/ZeroPortal.php
index c591cfb..a4e56a9 100644
--- a/ZeroPortal.php
+++ b/ZeroPortal.php
@@ -36,7 +36,7 @@
 $wgAutoloadClasses['ZeroPortal\\ConfigPageHooks'] = __DIR__ . 
'/includes/ConfigPageHooks.php';
 $wgAutoloadClasses['ZeroPortal\\LuaLibrary'] = __DIR__ . 
'/includes/LuaLibrary.php';
 $wgAutoloadClasses['ZeroPortal\\PortalSpecialPage'] = __DIR__ . 
'/includes/PortalSpecialPage.php';
-$wgAutoloadClasses['ZeroPortal\\ConfigMerger'] = __DIR__ . 
'/includes/PortalSpecialPage.php';
+$wgAutoloadClasses['ZeroPortal\\ConfigMerger'] = __DIR__ . 
'/includes/ConfigMerger.php';
 $wgAutoloadClasses['ZeroPortal\\ZeroConfigView'] = __DIR__ . 
'/includes/ZeroConfigView.php';
 
 $wgResourceModules['zeroportal.config'] = array(
diff --git a/includes/ConfigMerger.php b/includes/ConfigMerger.php
new file mode 100644
index 0000000..2aaa6a7
--- /dev/null
+++ b/includes/ConfigMerger.php
@@ -0,0 +1,60 @@
+<?php
+
+namespace ZeroPortal;
+
+use JsonConfig\JCObjContent;
+use JsonConfig\JCUtils;
+use JsonConfig\JCValue;
+use ZeroBanner\ZeroConfig;
+
+class ConfigMerger extends JCObjContent {
+
+       /** @var array */
+       private $newData;
+       /** @var array */
+       public $errorData;
+
+       public function __construct( ZeroConfig $content, $newData ) {
+               $this->newData = $newData;
+               $this->errorData = array();
+               parent::__construct( $content->getNativeData(), 
$content->getModel(), false );
+       }
+
+       public function validateContent() {
+               if ( !JCUtils::isDictionary( $this->newData ) ) {
+                       $this->errorData['error'] = 'bad-change';
+                       $this->errorData['msg'] = '"change" parameter is not a 
dictionary';
+                       return;
+               }
+               $self = $this;
+               foreach ( $this->newData as $path => $data ) {
+                       $cmd = substr( $path, 0, 1 );
+                       if ( $cmd === ' ' ) {
+                               $cmd = '+'; // Makes debugging simpler - the 
'+' is urlencoded as ' '
+                       }
+                       $p = substr( $path, 1 );
+                       if ( !$p ) {
+                               $this->errorData['error'] = 'bad-change';
+                               $this->errorData['msg'] = '"change" parameter 
key must be longer than 1 symbol';
+                               return;
+                       }
+                       $this->test( $p,
+                               function ( JCValue $jcv ) use ( $self, $cmd, 
$data ) {
+                                       if ( $cmd === '-' ) {
+                                               if ( !$jcv->isMissing() ) {
+                                                       $jcv->status( 
JCValue::MISSING ); // delete value
+                                               }
+                                       } elseif ( $cmd === '+' ) {
+                                               $jcv->setValue( $data, 
JCValue::CHECKED ); // replace or add value
+                                       } else {
+                                               $self->errorData['error'] = 
'bad-change';
+                                               $self->errorData['msg'] = 
'"change" key must begin with either "+" or "-"';
+                                       }
+                                       return false; // only one validator per 
test, simplifies things
+                               } );
+                       if ( $this->errorData ) {
+                               break;
+                       }
+               }
+       }
+}
diff --git a/includes/PortalSpecialPage.php b/includes/PortalSpecialPage.php
index 7849918..bfa4f7a 100644
--- a/includes/PortalSpecialPage.php
+++ b/includes/PortalSpecialPage.php
@@ -220,56 +220,3 @@
                return 'other';
        }
 }
-
-
-class ConfigMerger extends JCObjContent {
-
-       /** @var array */
-       private $newData;
-       /** @var array */
-       public $errorData;
-
-       public function __construct( ZeroConfig $content, $newData ) {
-               $this->newData = $newData;
-               $this->errorData = array();
-               parent::__construct( $content->getNativeData(), 
$content->getModel(), false );
-       }
-
-       public function validateContent() {
-               if ( !JCUtils::isDictionary( $this->newData ) ) {
-                       $this->errorData['error'] = 'bad-change';
-                       $this->errorData['msg'] = '"change" parameter is not a 
dictionary';
-                       return;
-               }
-               $self = $this;
-               foreach ( $this->newData as $path => $data ) {
-                       $cmd = substr( $path, 0, 1 );
-                       if ( $cmd === ' ' ) {
-                               $cmd = '+'; // Makes debugging simpler - the 
'+' is urlencoded as ' '
-                       }
-                       $p = substr( $path, 1 );
-                       if ( !$p ) {
-                               $this->errorData['error'] = 'bad-change';
-                               $this->errorData['msg'] = '"change" parameter 
key must be longer than 1 symbol';
-                               return;
-                       }
-                       $this->test( $p,
-                               function ( JCValue $jcv ) use ( $self, $cmd, 
$data ) {
-                                       if ( $cmd === '-' ) {
-                                               if ( !$jcv->isMissing() ) {
-                                                       $jcv->status( 
JCValue::MISSING ); // delete value
-                                               }
-                                       } elseif ( $cmd === '+' ) {
-                                               $jcv->setValue( $data, 
JCValue::CHECKED ); // replace or add value
-                                       } else {
-                                               $self->errorData['error'] = 
'bad-change';
-                                               $self->errorData['msg'] = 
'"change" key must begin with either "+" or "-"';
-                                       }
-                                       return false; // only one validator per 
test, simplifies things
-                               } );
-                       if ( $this->errorData ) {
-                               break;
-                       }
-               }
-       }
-}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2d664a8eb9c23d046e22025f43ea943005d8af4d
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/ZeroPortal
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to