Use TextFormatter in the REST API
authorTim Starling <tstarling@wikimedia.org>
Tue, 16 Jul 2019 22:43:43 +0000 (08:43 +1000)
committerTim Starling <tstarling@wikimedia.org>
Tue, 17 Sep 2019 06:03:14 +0000 (16:03 +1000)
commit8b1a6cc58af722aff053c8b30948ae751e6d7f29
tree621154441d02d2e13d7fee45f8cea520080d7fa2
parent2aed14b6867314ef9f08d09cc2dc502f7dddb050
Use TextFormatter in the REST API

* Add ResponseFactory::createLocalizedHttpError(), which generates a
  JSON response body from a MessageValue
* ResponseFactory::__construct() accepts an array of TextFormatter
  objects. For ease of testing, the array may be empty. The integrated
  ResponseFactory has a TextFormatter for English, and one for
  $wgContLang if that is different.
* Use createLocalizedHttpError() to show helpful error messages for
  errors generated by Router.

Change-Id: I897a0aee42227916c568333ab384966f1b87f599
includes/Rest/EntryPoint.php
includes/Rest/LocalizedHttpException.php
includes/Rest/ResponseFactory.php
includes/Rest/Router.php
languages/i18n/en.json
languages/i18n/qqq.json
tests/phpunit/includes/Rest/BasicAccess/MWBasicRequestAuthorizerTest.php
tests/phpunit/includes/Rest/EntryPointTest.php
tests/phpunit/unit/includes/Rest/Handler/HelloHandlerTest.php
tests/phpunit/unit/includes/Rest/ResponseFactoryTest.php
tests/phpunit/unit/includes/Rest/RouterTest.php