MediaWiki  1.34.0
ExternalStore.php
Go to the documentation of this file.
1 <?php
7 
58  public static function getStoreObject( $proto, array $params = [] ) {
59  try {
60  return MediaWikiServices::getInstance()
61  ->getExternalStoreFactory()
62  ->getStore( $proto, $params );
63  } catch ( ExternalStoreException $e ) {
64  return false;
65  }
66  }
67 
77  public static function fetchFromURL( $url, array $params = [] ) {
78  try {
79  return MediaWikiServices::getInstance()
80  ->getExternalStoreAccess()
81  ->fetchFromURL( $url, $params );
82  } catch ( ExternalStoreException $e ) {
83  return false;
84  }
85  }
86 
99  public static function insert( $url, $data, array $params = [] ) {
100  try {
101  $esFactory = MediaWikiServices::getInstance()->getExternalStoreFactory();
102  $location = $esFactory->getStoreLocationFromUrl( $url );
103 
104  return $esFactory->getStoreForUrl( $url, $params )->store( $location, $data );
105  } catch ( ExternalStoreException $e ) {
106  return false;
107  }
108  }
109 
119  public static function batchFetchFromURLs( array $urls ) {
120  return MediaWikiServices::getInstance()->getExternalStoreAccess()->fetchFromURLs( $urls );
121  }
122 
135  public static function insertToDefault( $data, array $params = [] ) {
136  return MediaWikiServices::getInstance()->getExternalStoreAccess()->insert( $data, $params );
137  }
138 
152  public static function insertWithFallback( array $tryStores, $data, array $params = [] ) {
153  return MediaWikiServices::getInstance()
154  ->getExternalStoreAccess()
155  ->insert( $data, $params, $tryStores );
156  }
157 
165  public static function insertToForeignDefault( $data, $wiki ) {
166  return MediaWikiServices::getInstance()
167  ->getExternalStoreAccess()
168  ->insert( $data, [ 'domain' => $wiki ] );
169  }
170 }
ExternalStore\insertToDefault
static insertToDefault( $data, array $params=[])
Like insert() above, but does more of the work for us.
Definition: ExternalStore.php:135
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:117
ExternalStore\fetchFromURL
static fetchFromURL( $url, array $params=[])
Fetch data from given URL.
Definition: ExternalStore.php:77
ExternalStore\insertWithFallback
static insertWithFallback(array $tryStores, $data, array $params=[])
Like insert() above, but does more of the work for us.
Definition: ExternalStore.php:152
ExternalStore
Constructor class for key/value blob data kept in external repositories.
Definition: ExternalStore.php:49
ExternalStore\getStoreObject
static getStoreObject( $proto, array $params=[])
Get an external store object of the given type, with the given parameters.
Definition: ExternalStore.php:58
ExternalStore\insert
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...
Definition: ExternalStore.php:99
ExternalStore\batchFetchFromURLs
static batchFetchFromURLs(array $urls)
Fetch data from multiple URLs with a minimum of round trips.
Definition: ExternalStore.php:119
ExternalStore\insertToForeignDefault
static insertToForeignDefault( $data, $wiki)
Definition: ExternalStore.php:165
ExternalStoreException
Definition: ExternalStoreException.php:3