MediaWiki
master
HashSiteStore.php
Go to the documentation of this file.
1
<?php
7
namespace
MediaWiki\Site
;
8
17
class
HashSiteStore
implements
SiteStore
{
19
private
$sites = [];
20
24
public
function
__construct
( array $sites = [] ) {
25
$this->
saveSites
( $sites );
26
}
27
35
public
function
saveSite
(
Site
$site ) {
36
$this->sites[$site->
getGlobalId
()] = $site;
37
38
return
true
;
39
}
40
48
public
function
saveSites
( array $sites ) {
49
foreach
( $sites as $site ) {
50
$this->
saveSite
( $site );
51
}
52
53
return
true
;
54
}
55
65
public
function
getSite
( $globalId,
$source
=
'cache'
) {
66
return
$this->sites[$globalId] ??
null
;
67
}
68
80
public
function
getSites
(
$source
=
'cache'
) {
81
return
new
SiteList
( $this->sites );
82
}
83
92
public
function
clear
() {
93
$this->sites = [];
94
return
true
;
95
}
96
97
}
98
100
class_alias( HashSiteStore::class,
'HashSiteStore'
);
MediaWiki\Site\HashSiteStore
In-memory SiteStore implementation, stored in an associative array.
Definition
HashSiteStore.php:17
MediaWiki\Site\HashSiteStore\saveSite
saveSite(Site $site)
Save the provided site.
Definition
HashSiteStore.php:35
MediaWiki\Site\HashSiteStore\getSite
getSite( $globalId, $source='cache')
Return the site with provided global ID, or null if there is no such site.
Definition
HashSiteStore.php:65
MediaWiki\Site\HashSiteStore\getSites
getSites( $source='cache')
Return a list of all sites.
Definition
HashSiteStore.php:80
MediaWiki\Site\HashSiteStore\clear
clear()
Delete all sites from the database.
Definition
HashSiteStore.php:92
MediaWiki\Site\HashSiteStore\saveSites
saveSites(array $sites)
Save the provided sites.
Definition
HashSiteStore.php:48
MediaWiki\Site\HashSiteStore\__construct
__construct(array $sites=[])
Definition
HashSiteStore.php:24
MediaWiki\Site\SiteList
Array-like collection of Site objects.
Definition
SiteList.php:23
MediaWiki\Site\Site
Represents a single site.
Definition
Site.php:22
MediaWiki\Site\Site\getGlobalId
getGlobalId()
Returns the global site identifier (ie enwiktionary).
Definition
Site.php:133
MediaWiki\Site\SiteStore
Interface for storing and retrieving Site objects.
Definition
SiteStore.php:18
$source
$source
Definition
mwdoc-filter.php:36
MediaWiki\Site
Definition
CachingSiteStore.php:7
includes
Site
HashSiteStore.php
Generated on Fri Mar 6 2026 02:27:09 for MediaWiki by
1.10.0