Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/281652
Change subject: Drop unused EntityId parameter from
PlaceholderExpander/TextInjector
......................................................................
Drop unused EntityId parameter from PlaceholderExpander/TextInjector
Change-Id: If0a8e363d93c12e4fa181a9dc51b81b35b7cfb24
---
M view/src/EntityView.php
M view/src/EntityViewPlaceholderExpander.php
M view/src/TextInjector.php
M view/tests/phpunit/EntityViewPlaceholderExpanderTest.php
M view/tests/phpunit/TextInjectorTest.php
5 files changed, 15 insertions(+), 30 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/52/281652/1
diff --git a/view/src/EntityView.php b/view/src/EntityView.php
index f2441db..f7aecf9 100644
--- a/view/src/EntityView.php
+++ b/view/src/EntityView.php
@@ -87,7 +87,7 @@
*
* @since 0.1
*
- * @param EntityDocument $entityDocument the entity to render
+ * @param EntityDocument $entity the entity to render
*
* @return string HTML
*/
@@ -159,7 +159,7 @@
return $this->entityTermsView->getHtml(
$entity->getFingerprint(),
$id,
- $this->getHtmlForTermBox( $id ),
+ $this->getHtmlForTermBox(),
$this->textInjector
);
}
@@ -168,21 +168,12 @@
}
/**
- * @param EntityId $entityId
- *
* @return string HTML
*/
- private function getHtmlForTermBox( EntityId $entityId = null ) {
- if ( $entityId !== null ) {
- // Placeholder for a termbox for the present item.
- // EntityViewPlaceholderExpander must know about the
parameters used here.
- return $this->textInjector->newMarker(
- 'termbox',
- $entityId->getSerialization()
- );
- }
-
- return '';
+ private function getHtmlForTermBox() {
+ // Placeholder for a termbox for the present item.
+ // EntityViewPlaceholderExpander must know about the parameters
used here.
+ return $this->textInjector->newMarker( 'termbox' );
}
}
diff --git a/view/src/EntityViewPlaceholderExpander.php
b/view/src/EntityViewPlaceholderExpander.php
index 025faf2..36aec1e 100644
--- a/view/src/EntityViewPlaceholderExpander.php
+++ b/view/src/EntityViewPlaceholderExpander.php
@@ -165,11 +165,8 @@
* @return string HTML to be substituted for the placeholder in the
output.
*/
public function getHtmlForPlaceholder( $name /*...*/ ) {
- $args = func_get_args();
- $name = array_shift( $args );
-
try {
- $html = $this->expandPlaceholder( $name, $args );
+ $html = $this->expandPlaceholder( $name );
return $html;
} catch ( MWException $ex ) {
wfWarn( "Expansion of $name failed: " .
$ex->getMessage() );
@@ -187,11 +184,10 @@
* intended meaning.
*
* @param string $name
- * @param array $args
*
* @return string
*/
- protected function expandPlaceholder( $name, array $args ) {
+ protected function expandPlaceholder( $name ) {
switch ( $name ) {
case 'termbox':
return $this->renderTermBox();
diff --git a/view/src/TextInjector.php b/view/src/TextInjector.php
index 8d9e07a..800719b 100644
--- a/view/src/TextInjector.php
+++ b/view/src/TextInjector.php
@@ -48,15 +48,13 @@
* All parameters passed to this function will be associated with the
marker.
*
* @param string $name
- * @param string [$arg,...]
*
* @return string
*/
- public function newMarker( $name /*...*/ ) {
+ public function newMarker( $name ) {
$marker = '$' . $this->uniqPrefix . '#' . ++$this->markerIndex
. '$';
- $args = func_get_args();
- $this->markers[$marker] = $args;
+ $this->markers[$marker] = array( $name );
return $marker;
}
diff --git a/view/tests/phpunit/EntityViewPlaceholderExpanderTest.php
b/view/tests/phpunit/EntityViewPlaceholderExpanderTest.php
index d728b68..0e3fd4f 100644
--- a/view/tests/phpunit/EntityViewPlaceholderExpanderTest.php
+++ b/view/tests/phpunit/EntityViewPlaceholderExpanderTest.php
@@ -114,7 +114,7 @@
public function testGetHtmlForPlaceholder( Item $item, AliasesProvider
$aliasesProvider = null ) {
$expander = $this->newExpander( $this->newUser(), $item,
$item->getId(), $aliasesProvider );
- $html = $expander->getHtmlForPlaceholder( 'termbox', 'Q23' );
+ $html = $expander->getHtmlForPlaceholder( 'termbox' );
$this->assertInternalType( 'string', $html );
}
diff --git a/view/tests/phpunit/TextInjectorTest.php
b/view/tests/phpunit/TextInjectorTest.php
index 11a4fd8..4d1ac49 100644
--- a/view/tests/phpunit/TextInjectorTest.php
+++ b/view/tests/phpunit/TextInjectorTest.php
@@ -27,7 +27,7 @@
$injector = new TextInjector();
$foo = $injector->newMarker( 'foo' );
- $bar = $injector->newMarker( 'bar', 1, 2, 3 );
+ $bar = $injector->newMarker( 'bar' );
$markers = $injector->getMarkers();
@@ -35,16 +35,16 @@
$this->assertEquals( array( 'foo' ), $markers[$foo] );
$this->assertArrayHasKey( $bar, $markers );
- $this->assertEquals( array( 'bar', 1, 2, 3 ), $markers[$bar] );
+ $this->assertEquals( array( 'bar' ), $markers[$bar] );
}
public function testInject() {
$injector = new TextInjector();
$text = 'Good ' . $injector->newMarker( 'morning' )
- . ' to ' . $injector->newMarker( 'you', 'all' ) . '!';
+ . ' to ' . $injector->newMarker( 'you' ) . '!';
- $expected = 'Good morning to you all!';
+ $expected = 'Good morning to you!';
$actual = $injector->inject( $text, function () {
$args = func_get_args();
--
To view, visit https://gerrit.wikimedia.org/r/281652
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If0a8e363d93c12e4fa181a9dc51b81b35b7cfb24
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