Thiemo Mättig (WMDE) has uploaded a new change for review.

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

Change subject: Delete duplicate WikibaseDiffOpFactory
......................................................................

Delete duplicate WikibaseDiffOpFactory

Change-Id: Ia659d3bc91c5637ad7816c255985b965ff1b1007
---
D lib/includes/WikibaseDiffOpFactory.php
M lib/includes/changes/DiffChange.php
2 files changed, 2 insertions(+), 56 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/31/259231/1

diff --git a/lib/includes/WikibaseDiffOpFactory.php 
b/lib/includes/WikibaseDiffOpFactory.php
deleted file mode 100644
index 2ab0d5f..0000000
--- a/lib/includes/WikibaseDiffOpFactory.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-namespace Wikibase;
-
-use Diff\DiffOp\DiffOp;
-use Diff\DiffOpFactory;
-use Wikibase\DataModel\Services\Diff\EntityDiff;
-
-/**
- * Class for changes that can be represented as a Diff.
- *
- * @since 0.4
- *
- * @licence GNU GPL v2+
- * @author Daniel Kinzler
- */
-class WikibaseDiffOpFactory extends DiffOpFactory {
-
-       public function newFromArray( array $diffOp ) {
-               $this->assertHasKey( 'type', $diffOp );
-
-               // see EntityDiff::getType() and ItemDiff::getType()
-               if ( preg_match( '!^diff/(.*)$!', $diffOp['type'], $matches ) ) 
{
-                       $itemType = $matches[1];
-                       $this->assertHasKey( 'operations', $diffOp );
-
-                       $operations = $this->createOperations( 
$diffOp['operations'] );
-                       $diff = EntityDiff::newForType( $itemType, $operations 
);
-
-                       return $diff;
-               }
-
-               return parent::newFromArray( $diffOp );
-       }
-
-       /**
-        * Converts a list of diff operations represented by arrays into a list 
of
-        * DiffOp objects.
-        *
-        * @todo: pull this up into DiffOpFactory
-        *
-        * @param array $data the input data
-        * @return DiffOp[] The diff ops
-        */
-       private function createOperations( array $data ) {
-               $operations = array();
-
-               foreach ( $data as $key => $operation ) {
-                       $operations[$key] = $this->newFromArray( $operation );
-               }
-
-               return $operations;
-       }
-
-}
diff --git a/lib/includes/changes/DiffChange.php 
b/lib/includes/changes/DiffChange.php
index d74e3a8..187a9d7 100644
--- a/lib/includes/changes/DiffChange.php
+++ b/lib/includes/changes/DiffChange.php
@@ -4,6 +4,7 @@
 
 use Diff\DiffOp\Diff\Diff;
 use Diff\DiffOp\DiffOp;
+use Wikibase\DataModel\Services\Diff\EntityTypeAwareDiffOpFactory;
 
 /**
  * Class for changes that can be represented as a Diff.
@@ -109,7 +110,7 @@
                static $factory = null;
 
                if ( $factory == null ) {
-                       $factory = new WikibaseDiffOpFactory( array( $this, 
'objectifyArrays' ) );
+                       $factory = new EntityTypeAwareDiffOpFactory( array( 
$this, 'objectifyArrays' ) );
                }
 
                $info = parent::unserializeInfo( $str );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia659d3bc91c5637ad7816c255985b965ff1b1007
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

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

Reply via email to