MediaWiki REL1_41
VirtualRESTService.php
Go to the documentation of this file.
1<?php
37abstract class VirtualRESTService {
39 protected $params = [];
40
44 public function __construct( array $params ) {
46 get_class( $this ) .
47 ' is deprecated since 1.41. Use MultiHttpClient from the HttpRequestFactory.'
48 );
49 $this->params = $params;
50 }
51
58 public function getName() {
59 return $this->params['name'] ?? static::class;
60 }
61
84 public function onRequests( array $reqs, Closure $idGeneratorFunc ) {
85 $result = [];
86 foreach ( $reqs as $key => $req ) {
87 // The default encoding treats the URL as a REST style path that uses
88 // forward slash as a hierarchical delimiter (and never otherwise).
89 // Subclasses can override this, and should be documented in any case.
90 $parts = array_map( 'rawurlencode', explode( '/', $req['url'] ) );
91 $req['url'] = $this->params['baseUrl'] . '/' . implode( '/', $parts );
92 $result[$key] = $req;
93 }
94 return $result;
95 }
96
119 public function onResponses( array $reqs, Closure $idGeneratorFunc ) {
120 return $reqs;
121 }
122}
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Virtual HTTP service instance that can be mounted on to a VirtualRESTService.
array $params
Key/value map.
onResponses(array $reqs, Closure $idGeneratorFunc)
Mangle or replace virtual HTTP(S) requests which have been responded to.
__construct(array $params)
onRequests(array $reqs, Closure $idGeneratorFunc)
Prepare virtual HTTP(S) requests (for this service) for execution.
getName()
Return the name of this service, in a form suitable for error reporting or debugging.