jenkins-bot has submitted this change and it was merged.
Change subject: Add MWTidy::factory()
......................................................................
Add MWTidy::factory()
A convenient factory function to eliminate code duplication in
ParserMigration's MigrationEditPage::tidyParserOutput().
Change-Id: I058912885025e7a9402912236c65c44e32ef036e
---
M includes/parser/MWTidy.php
1 file changed, 32 insertions(+), 21 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/parser/MWTidy.php b/includes/parser/MWTidy.php
index 32d8373..46ea773 100644
--- a/includes/parser/MWTidy.php
+++ b/includes/parser/MWTidy.php
@@ -101,32 +101,43 @@
} else {
return false;
}
- switch ( $config['driver'] ) {
- case 'RaggettInternalHHVM':
- self::$instance = new
MediaWiki\Tidy\RaggettInternalHHVM( $config );
- break;
- case 'RaggettInternalPHP':
- self::$instance = new
MediaWiki\Tidy\RaggettInternalPHP( $config );
- break;
- case 'RaggettExternal':
- self::$instance = new
MediaWiki\Tidy\RaggettExternal( $config );
- break;
- case 'Html5Depurate':
- self::$instance = new
MediaWiki\Tidy\Html5Depurate( $config );
- break;
- case 'Html5Internal':
- self::$instance = new
MediaWiki\Tidy\Html5Internal( $config );
- break;
- case 'disabled':
- return false;
- default:
- throw new MWException( "Invalid tidy
driver: \"{$config['driver']}\"" );
- }
+ self::$instance = self::factory( $config );
}
return self::$instance;
}
/**
+ * Create a new Tidy driver object from configuration.
+ * @see $wgTidyConfig
+ * @param array $config
+ * @return TidyDriverBase
+ */
+ public static function factory( array $config ) {
+ switch ( $config['driver'] ) {
+ case 'RaggettInternalHHVM':
+ $instance = new
MediaWiki\Tidy\RaggettInternalHHVM( $config );
+ break;
+ case 'RaggettInternalPHP':
+ $instance = new
MediaWiki\Tidy\RaggettInternalPHP( $config );
+ break;
+ case 'RaggettExternal':
+ $instance = new MediaWiki\Tidy\RaggettExternal(
$config );
+ break;
+ case 'Html5Depurate':
+ $instance = new MediaWiki\Tidy\Html5Depurate(
$config );
+ break;
+ case 'Html5Internal':
+ $instance = new MediaWiki\Tidy\Html5Internal(
$config );
+ break;
+ case 'disabled':
+ return false;
+ default:
+ throw new MWException( "Invalid tidy driver:
\"{$config['driver']}\"" );
+ }
+ return $instance;
+ }
+
+ /**
* Set the driver to be used. This is for testing.
* @param TidyDriverBase|false|null $instance
*/
--
To view, visit https://gerrit.wikimedia.org/r/301063
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I058912885025e7a9402912236c65c44e32ef036e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Tim Starling <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits