MediaWiki REL1_39
ExternalStore.php
Go to the documentation of this file.
1<?php
22
36 public static function getStoreObject( $proto, array $params = [] ) {
37 try {
38 return MediaWikiServices::getInstance()
39 ->getExternalStoreFactory()
40 ->getStore( $proto, $params );
41 } catch ( ExternalStoreException $e ) {
42 return false;
43 }
44 }
45
55 public static function fetchFromURL( $url, array $params = [] ) {
56 try {
57 return MediaWikiServices::getInstance()
58 ->getExternalStoreAccess()
59 ->fetchFromURL( $url, $params );
60 } catch ( ExternalStoreException $e ) {
61 return false;
62 }
63 }
64
77 public static function insert( $url, $data, array $params = [] ) {
78 try {
79 $esFactory = MediaWikiServices::getInstance()->getExternalStoreFactory();
80 $location = $esFactory->getStoreLocationFromUrl( $url );
81
82 return $esFactory->getStoreForUrl( $url, $params )->store( $location, $data );
83 } catch ( ExternalStoreException $e ) {
84 return false;
85 }
86 }
87
97 public static function batchFetchFromURLs( array $urls ) {
98 return MediaWikiServices::getInstance()->getExternalStoreAccess()->fetchFromURLs( $urls );
99 }
100
113 public static function insertToDefault( $data, array $params = [] ) {
114 return MediaWikiServices::getInstance()->getExternalStoreAccess()->insert( $data, $params );
115 }
116
130 public static function insertWithFallback( array $tryStores, $data, array $params = [] ) {
131 return MediaWikiServices::getInstance()
132 ->getExternalStoreAccess()
133 ->insert( $data, $params, $tryStores );
134 }
135
143 public static function insertToForeignDefault( $data, $wiki ) {
144 return MediaWikiServices::getInstance()
145 ->getExternalStoreAccess()
146 ->insert( $data, [ 'domain' => $wiki ] );
147 }
148}
static insertWithFallback(array $tryStores, $data, array $params=[])
Like insert() above, but does more of the work for us.
static fetchFromURL( $url, array $params=[])
Fetch data from given URL.
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 batchFetchFromURLs(array $urls)
Fetch data from multiple URLs with a minimum of round trips.
static insertToDefault( $data, array $params=[])
Like insert() above, but does more of the work for us.
static insertToForeignDefault( $data, $wiki)
static getStoreObject( $proto, array $params=[])
Get an external store object of the given type, with the given parameters.
Service locator for MediaWiki core services.