MediaWiki
master
HashSiteStore.php
Go to the documentation of this file.
1
<?php
21
namespace
MediaWiki\Site
;
22
31
class
HashSiteStore
implements
SiteStore
{
33
private
$sites = [];
34
38
public
function
__construct
( array $sites = [] ) {
39
$this->
saveSites
( $sites );
40
}
41
49
public
function
saveSite
(
Site
$site ) {
50
$this->sites[$site->
getGlobalId
()] = $site;
51
52
return
true
;
53
}
54
62
public
function
saveSites
( array $sites ) {
63
foreach
( $sites as $site ) {
64
$this->
saveSite
( $site );
65
}
66
67
return
true
;
68
}
69
79
public
function
getSite
( $globalId,
$source
=
'cache'
) {
80
return
$this->sites[$globalId] ??
null
;
81
}
82
94
public
function
getSites
(
$source
=
'cache'
) {
95
return
new
SiteList
( $this->sites );
96
}
97
106
public
function
clear
() {
107
$this->sites = [];
108
return
true
;
109
}
110
111
}
112
114
class_alias( HashSiteStore::class,
'HashSiteStore'
);
MediaWiki\Site\HashSiteStore
In-memory SiteStore implementation, stored in an associative array.
Definition
HashSiteStore.php:31
MediaWiki\Site\HashSiteStore\saveSite
saveSite(Site $site)
Save the provided site.
Definition
HashSiteStore.php:49
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:79
MediaWiki\Site\HashSiteStore\getSites
getSites( $source='cache')
Return a list of all sites.
Definition
HashSiteStore.php:94
MediaWiki\Site\HashSiteStore\clear
clear()
Delete all sites from the database.
Definition
HashSiteStore.php:106
MediaWiki\Site\HashSiteStore\saveSites
saveSites(array $sites)
Save the provided sites.
Definition
HashSiteStore.php:62
MediaWiki\Site\HashSiteStore\__construct
__construct(array $sites=[])
Definition
HashSiteStore.php:38
MediaWiki\Site\SiteList
Array-like collection of Site objects.
Definition
SiteList.php:37
MediaWiki\Site\Site
Represents a single site.
Definition
Site.php:36
MediaWiki\Site\Site\getGlobalId
getGlobalId()
Returns the global site identifier (ie enwiktionary).
Definition
Site.php:147
MediaWiki\Site\SiteStore
Interface for storing and retrieving Site objects.
Definition
SiteStore.php:32
$source
$source
Definition
mwdoc-filter.php:36
MediaWiki\Site
Definition
CachingSiteStore.php:21
includes
site
HashSiteStore.php
Generated on Sat Dec 21 2024 14:25:46 for MediaWiki by
1.10.0