MediaWiki REL1_40
HashSiteStore.php
Go to the documentation of this file.
1<?php
29class HashSiteStore implements SiteStore {
31 private $sites = [];
32
36 public function __construct( array $sites = [] ) {
37 $this->saveSites( $sites );
38 }
39
47 public function saveSite( Site $site ) {
48 $this->sites[$site->getGlobalId()] = $site;
49
50 return true;
51 }
52
60 public function saveSites( array $sites ) {
61 foreach ( $sites as $site ) {
62 $this->saveSite( $site );
63 }
64
65 return true;
66 }
67
77 public function getSite( $globalId, $source = 'cache' ) {
78 return $this->sites[$globalId] ?? null;
79 }
80
92 public function getSites( $source = 'cache' ) {
93 return new SiteList( $this->sites );
94 }
95
104 public function clear() {
105 $this->sites = [];
106 return true;
107 }
108
109}
In-memory SiteStore implementation, stored in an associative array.
saveSite(Site $site)
Save the provided site.
getSite( $globalId, $source='cache')
Return the site with provided global ID, or null if there is no such site.
saveSites(array $sites)
Save the provided sites.
__construct(array $sites=[])
clear()
Delete all sites from the database.
getSites( $source='cache')
Return a list of all sites.
Collection of Site objects.
Definition SiteList.php:28
Represents a single site.
Definition Site.php:32
getGlobalId()
Returns the global site identifier (ie enwiktionary).
Definition Site.php:143
Interface for storing and retreiving Site objects.
Definition SiteStore.php:30
$source