System\Classes\SiteManager

Overview

SiteManager class manages sites


Protected Properties

protected array $sites

sites collection of sites

protected array $siteIdCache

siteIdCache caches sites by their identifier

protected mixed $editSiteCache

protected bool $globalContext

globalContext disables site filters globally.

protected SiteDefinition|null $siteContext

siteContext overrides the current site context.


Public Methods

public applyActiveSite()

public applyActiveSite($site): void

applyActiveSite applies active site configuration values to the application, typically used for frontend requests.

public applyEditSite()

public applyEditSite($site): void

applyEditSite applies edit site configuration values to the application, typically used for backend requests.

public getActiveSite()

public getActiveSite(): void

public getActiveSiteId()

public getActiveSiteId(): void

public getAnyEditSite()

public getAnyEditSite(): void

hasAnyEditSite returns true if there are edit sites

public getAnySite()

public getAnySite(): void

getAnySite returns any site, with priority to primary

public getEditSite()

public getEditSite(): void

getEditSite returns the edit theme

public getEditSiteId()

public getEditSiteId(): void

public getPrimarySite()

public getPrimarySite(): void

public getSiteCodeFromContext()

public getSiteCodeFromContext(): string|null 

public getSiteForLocale()

public getSiteForLocale($locale): void

public getSiteFromBrowser()

public getSiteFromBrowser($acceptLanguage): void

getSiteFromBrowser locates the site based on the browser locale, e.g. HTTP_ACCEPT_LANGUAGE

public getSiteFromContext()

public getSiteFromContext(): SiteDefinition 

public getSiteFromId()

public getSiteFromId($id): void

public getSiteFromRequest()

public getSiteFromRequest($host, $uri): void

getSiteFromRequest locates the site based on the hostname and URI

public getSiteIdFromContext()

public getSiteIdFromContext(): int|null 

public hasAnyEditSite()

public hasAnyEditSite(): bool 

hasAnyEditSite returns true if there are edit sites

public hasAnySite()

public hasAnySite(): bool 

hasAnySite returns true if there is a frontend

public hasFeature()

public hasFeature($name = null): bool 

hasFeature returns true if a multisite feature is enabled

public hasGlobalContext()

public hasGlobalContext(): bool 

public hasMultiEditSite()

public hasMultiEditSite(): bool 

hasMultiEditSite returns true if there are multiple sites for editing

public hasMultiSite()

public hasMultiSite(): bool 

hasMultiSite returns true if there are multiple sites

public hasSiteGroups()

public hasSiteGroups(): bool 

public static instance()

public static instance(): static 

instance creates a new instance of this singleton

public listEditEnabled()

public listEditEnabled(): void

public listEditSites()

public listEditSites(): void

public listEnabled()

public listEnabled(): void

public listSiteIds()

public listSiteIds(): void

public listSiteIdsInContext()

public listSiteIdsInContext(): void

public listSiteIdsInGroup()

public listSiteIdsInGroup($siteId = null): void

public listSiteIdsInLocale()

public listSiteIdsInLocale($siteId = null): void

public listSites()

public listSites(): void

public resetCache()

public resetCache(): void

resetCache resets any memory or cache involved with the sites

public setActiveSite()

public setActiveSite($site): void

public setActiveSiteId()

public setActiveSiteId($id): void

setActiveSite

public setEditSite()

public setEditSite($site): void

public setEditSiteId()

public setEditSiteId($id): void

public withContext()

public withContext($siteId, $callback): void

public withGlobalContext()

public withGlobalContext($callback): void

Protected Methods

protected broadcastSiteChange()

protected broadcastSiteChange($siteId): void

broadcastSiteChange is a generic event used when the site changes

protected findAcceptedLocales()

protected findAcceptedLocales($acceptedStr): array 

findAcceptedLocales based on an accepted string, e.g. en-GB,en-US;q=0.9,en;q=0.8 Returns a sorted array in format of [(string) locale => (float) priority]

protected listSitesForManifest()

protected listSitesForManifest($sites): void

protected listSitesFromManifest()

protected listSitesFromManifest($sites): void