MediaWiki master
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
54 public static function fetchFromURL( $url, array $params = [] ) {
55 try {
56 return MediaWikiServices::getInstance()
57 ->getExternalStoreAccess()
58 ->fetchFromURL( $url, $params );
59 } catch ( ExternalStoreException $e ) {
60 return false;
61 }
62 }
63
75 public static function insert( $url, $data, array $params = [] ) {
76 try {
77 $esFactory = MediaWikiServices::getInstance()->getExternalStoreFactory();
78 $location = $esFactory->getStoreLocationFromUrl( $url );
79
80 return $esFactory->getStoreForUrl( $url, $params )->store( $location, $data );
81 } catch ( ExternalStoreException $e ) {
82 return false;
83 }
84 }
85
95 public static function batchFetchFromURLs( array $urls ) {
96 return MediaWikiServices::getInstance()->getExternalStoreAccess()->fetchFromURLs( $urls );
97 }
98
111 public static function insertToDefault( $data, array $params = [] ) {
112 return MediaWikiServices::getInstance()->getExternalStoreAccess()->insert( $data, $params );
113 }
114
128 public static function insertWithFallback( array $tryStores, $data, array $params = [] ) {
129 return MediaWikiServices::getInstance()
130 ->getExternalStoreAccess()
131 ->insert( $data, $params, $tryStores );
132 }
133
141 public static function insertToForeignDefault( $data, $wiki ) {
142 return MediaWikiServices::getInstance()
143 ->getExternalStoreAccess()
144 ->insert( $data, [ 'domain' => $wiki ] );
145 }
146}
array $params
The job parameters.
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.