Tobias Gritschacher has submitted this change and it was merged. Change subject: Add registration of formatter argument as being used by Wikibase ......................................................................
Add registration of formatter argument as being used by Wikibase Change-Id: I1b70263a3d928693c2129298e95dc5febb1b3068 --- M DataTypes/includes/DataTypeFactory.php M DataTypes/tests/includes/DataTypeTest.php 2 files changed, 12 insertions(+), 4 deletions(-) Approvals: Tobias Gritschacher: Looks good to me, approved jenkins-bot: Verified diff --git a/DataTypes/includes/DataTypeFactory.php b/DataTypes/includes/DataTypeFactory.php index 57a83eb..9be642f 100644 --- a/DataTypes/includes/DataTypeFactory.php +++ b/DataTypes/includes/DataTypeFactory.php @@ -103,9 +103,17 @@ $parser = new $parser(); } -// $formatter = array_key_exists( 'formatter', $typeData ) ? $typeData['formatter'] : 'NullFormatter'; -// $formatter = new $formatter(); - $formatters = array(); // TODO + $formatters = array(); + + if ( array_key_exists( 'formatter', $typeData ) ) { + $formatter = $typeData['formatter']; + + if ( is_string( $formatter ) ) { + $formatter = new $formatter(); + } + + $formatters[] = $formatter; + } if ( array_key_exists( 'validators', $typeData ) ) { $validators = is_array( $typeData['validators'] ) ? $typeData['validators'] : array( $typeData['validators'] ); diff --git a/DataTypes/tests/includes/DataTypeTest.php b/DataTypes/tests/includes/DataTypeTest.php index 20576ab..dcbca1c 100644 --- a/DataTypes/tests/includes/DataTypeTest.php +++ b/DataTypes/tests/includes/DataTypeTest.php @@ -84,7 +84,7 @@ $this->assertInternalType( 'array', $type->getFormatters() ); foreach ( $type->getFormatters() as $formatter ) { - $this->assertInstanceOf( 'ValueParsers\ValueFormatter', $formatter ); + $this->assertInstanceOf( 'ValueFormatters\ValueFormatter', $formatter ); } } -- To view, visit https://gerrit.wikimedia.org/r/58083 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1b70263a3d928693c2129298e95dc5febb1b3068 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DataValues Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits