MediaWiki  1.30.0
HashSiteStore.php
Go to the documentation of this file.
1 <?php
32 class HashSiteStore implements SiteStore {
33 
37  private $sites = [];
38 
42  public function __construct( $sites = [] ) {
43  $this->saveSites( $sites );
44  }
45 
55  public function saveSite( Site $site ) {
56  $this->sites[$site->getGlobalId()] = $site;
57 
58  return true;
59  }
60 
70  public function saveSites( array $sites ) {
71  foreach ( $sites as $site ) {
72  $this->saveSite( $site );
73  }
74 
75  return true;
76  }
77 
89  public function getSite( $globalId, $source = 'cache' ) {
90  if ( isset( $this->sites[$globalId] ) ) {
91  return $this->sites[$globalId];
92  } else {
93  return null;
94  }
95  }
96 
109  public function getSites( $source = 'cache' ) {
110  return new SiteList( $this->sites );
111  }
112 
118  public function clear() {
119  $this->sites = [];
120 
121  return true;
122  }
123 
124 }
HashSiteStore\getSite
getSite( $globalId, $source='cache')
Returns the site with provided global id, or null if there is no such site.
Definition: HashSiteStore.php:89
HashSiteStore\__construct
__construct( $sites=[])
Definition: HashSiteStore.php:42
HashSiteStore\saveSite
saveSite(Site $site)
Saves the provided site.
Definition: HashSiteStore.php:55
HashSiteStore\clear
clear()
Deletes all sites from the database.
Definition: HashSiteStore.php:118
HashSiteStore\getSites
getSites( $source='cache')
Returns a list of all sites.
Definition: HashSiteStore.php:109
php
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
SiteStore
Definition: SiteStore.php:29
Site\getGlobalId
getGlobalId()
Returns the global site identifier (ie enwiktionary).
Definition: Site.php:140
SiteList
Definition: SiteList.php:29
HashSiteStore
In-memory SiteStore implementation, storing sites in an associative array.
Definition: HashSiteStore.php:32
Site
Definition: Site.php:29
HashSiteStore\saveSites
saveSites(array $sites)
Saves the provided sites.
Definition: HashSiteStore.php:70
HashSiteStore\$sites
Site[] $sites
Definition: HashSiteStore.php:37
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
$source
$source
Definition: mwdoc-filter.php:46
array
the array() calling protocol came about after MediaWiki 1.4rc1.