MediaWiki  master
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 }
static insertWithFallback(array $tryStores, $data, array $params=[])
Like insert() above, but does more of the work for us.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2147
static batchFetchFromURLs(array $urls)
Fetch data from multiple URLs with a minimum of round trips.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
static insertToDefault( $data, array $params=[])
Like insert() above, but does more of the work for us.
static insertToForeignDefault( $data, $wiki)
$params
static getStoreObject( $proto, array $params=[])
Get an external store object of the given type, with the given parameters.
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...
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
static fetchFromURL( $url, array $params=[])
Fetch data from given URL.
Constructor class for key/value blob data kept in external repositories.