MaxSem has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/315840

Change subject: Move the rest of hooks into the Hooks class
......................................................................

Move the rest of hooks into the Hooks class

Change-Id: I70ab6aa3dd4051fd25248aaca8c059b9b9e461dc
---
M extension.json
M includes/Graph.body.php
M includes/Graph.hooks.php
M tests/parserTests.txt
4 files changed, 33 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Graph 
refs/changes/40/315840/1

diff --git a/extension.json b/extension.json
index 34866da..620032e 100644
--- a/extension.json
+++ b/extension.json
@@ -165,10 +165,10 @@
        },
        "Hooks": {
                "ParserFirstCallInit": [
-                       "Graph\\Singleton::onParserFirstCallInit"
+                       "Graph\\Hooks::onParserFirstCallInit"
                ],
                "ParserAfterParse": [
-                       "Graph\\Singleton::onParserAfterParse"
+                       "Graph\\Hooks::onParserAfterParse"
                ],
                "ResourceLoaderTestModules": [
                        "Graph\\Hooks::onResourceLoaderTestModules"
diff --git a/includes/Graph.body.php b/includes/Graph.body.php
index 75ae23e..879eb33 100644
--- a/includes/Graph.body.php
+++ b/includes/Graph.body.php
@@ -16,29 +16,20 @@
 use Parser;
 use ParserOptions;
 use ParserOutput;
+use PPFrame;
 use Title;
 
 class Singleton {
-
-       public static function onParserFirstCallInit( Parser $parser ) {
-               $parser->setHook( 'graph', 'Graph\Singleton::onGraphTag' );
-               return true;
-       }
-
-       public static function onParserAfterParse( Parser $parser ) {
-               self::finalizeParserOutput( $parser, $parser->getTitle(), 
$parser->getOutput() );
-               return true;
-       }
 
        /**
         * @param $input
         * @param array $args
         * @param Parser $parser
-        * @param \PPFrame $frame
+        * @param PPFrame $frame
         * @return string
         */
-       public static function onGraphTag( $input, array $args, Parser $parser, 
\PPFrame $frame ) {
-               return self::buildHtml( $input, $parser->getTitle(), 
$parser->getRevisionId(),
+       public static function onGraphTag( $input, array $args, Parser $parser, 
PPFrame $frame ) {
+               return Singleton::buildHtml( $input, $parser->getTitle(), 
$parser->getRevisionId(),
                        $parser->getOutput(), 
$parser->getOptions()->getIsPreview(), $args );
        }
 
diff --git a/includes/Graph.hooks.php b/includes/Graph.hooks.php
index 1b0e3c3..27cecda 100644
--- a/includes/Graph.hooks.php
+++ b/includes/Graph.hooks.php
@@ -8,11 +8,13 @@
 
 namespace Graph;
 
+use Parser;
 use ResourceLoader;
 
 class Hooks {
        /**
-        * Conditionally register the unit testing module for the 
ext.graph.visualEditor module
+        * ResourceLoaderTestModules hook handler.
+        * Conditionally registers the unit testing module for the 
ext.graph.visualEditor module
         * only if that module is loaded
         *
         * @param array $testModules The array of registered test modules
@@ -42,4 +44,27 @@
 
                return true;
        }
+
+       /**
+        * ParserFirstCallInit hook handler.
+        * Registers the <graph> tag
+        *
+        * @param Parser $parser
+        * @return bool
+        */
+       public static function onParserFirstCallInit( Parser $parser ) {
+               $parser->setHook( 'graph', 'Graph\Singleton::onGraphTag' );
+               return true;
+       }
+
+       /**
+        * ParserAfterParse hook handler.
+        *
+        * @param Parser $parser
+        * @return bool
+        */
+       public static function onParserAfterParse( Parser $parser ) {
+               Singleton::finalizeParserOutput( $parser, $parser->getTitle(), 
$parser->getOutput() );
+               return true;
+       }
 }
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index ba0983b..b31f43f 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -33,5 +33,5 @@
 <p><span class="error">Syntax error</span>
 </p>
 <div class="mw-graph mw-graph-always" style="min-width:200px;min-height:200px" 
data-graph-id="4406ae21fb62ba4a67e041d0f9e026a2819e48a8"></div>
-
+fail
 !! end

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I70ab6aa3dd4051fd25248aaca8c059b9b9e461dc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Graph
Gerrit-Branch: master
Gerrit-Owner: MaxSem <maxsem.w...@gmail.com>

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

Reply via email to