MediaWiki master
ExternalStore.php
Go to the documentation of this file.
1<?php
8
10
24 public static function getStoreObject( $proto, array $params = [] ) {
25 try {
27 ->getExternalStoreFactory()
28 ->getStore( $proto, $params );
29 } catch ( ExternalStoreException ) {
30 return false;
31 }
32 }
33
42 public static function fetchFromURL( $url, array $params = [] ) {
43 try {
45 ->getExternalStoreAccess()
46 ->fetchFromURL( $url, $params );
47 } catch ( ExternalStoreException ) {
48 return false;
49 }
50 }
51
63 public static function insert( $url, $data, array $params = [] ) {
64 try {
65 $esFactory = MediaWikiServices::getInstance()->getExternalStoreFactory();
66 $location = $esFactory->getStoreLocationFromUrl( $url );
67
68 return $esFactory->getStoreForUrl( $url, $params )->store( $location, $data );
69 } catch ( ExternalStoreException ) {
70 return false;
71 }
72 }
73
83 public static function batchFetchFromURLs( array $urls ) {
84 return MediaWikiServices::getInstance()->getExternalStoreAccess()->fetchFromURLs( $urls );
85 }
86
99 public static function insertToDefault( $data, array $params = [] ) {
100 return MediaWikiServices::getInstance()->getExternalStoreAccess()->insert( $data, $params );
101 }
102
116 public static function insertWithFallback( array $tryStores, $data, array $params = [] ) {
118 ->getExternalStoreAccess()
119 ->insert( $data, $params, $tryStores );
120 }
121
129 public static function insertToForeignDefault( $data, $wiki ) {
131 ->getExternalStoreAccess()
132 ->insert( $data, [ 'domain' => $wiki ] );
133 }
134}
135
137class_alias( ExternalStore::class, 'ExternalStore' );
static insertToDefault( $data, array $params=[])
Like insert() above, but does more of the work for us.
static insertWithFallback(array $tryStores, $data, array $params=[])
Like insert() above, but does more of the work for us.
static getStoreObject( $proto, array $params=[])
Get an external store object of the given type, with the given parameters.
static batchFetchFromURLs(array $urls)
Fetch data from multiple URLs with a minimum of round trips.
static insertToForeignDefault( $data, $wiki)
static insert( $url, $data, array $params=[])
Store a data item to an external store, identified by a partial URL The protocol part is used to iden...
static fetchFromURL( $url, array $params=[])
Fetch data from given URL.
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.