System\Classes\SiteManager
Overview
SiteManager class manages sites
Extends
Public Properties
There are no public properties in the class.
Show inherited public properties
Inherited Public Properties
- $implement - extensions for this class. (defined in October\Rain\Extension\Extendable)
Protected Properties
protected array $sites
sites collection of sites
protected array $siteIdCache
siteIdCache caches sites by their identifier
protected array $emitterSingleEventCollection
emitterSingleEventCollection of events to be fired once only
protected array $emitterEventCollection
emitterEventCollection of all registered events
protected array $emitterEventSorted
emitterEventSorted collection
protected mixed $editSiteCache
protected bool $globalContext
globalContext disables site filters globally.
protected SiteDefinition|null $siteContext
siteContext overrides the current site context.
Show inherited protected properties
Inherited Protected Properties
- $extensionData - contains class reflection information, including behaviors. (defined in October\Rain\Extension\Extendable)
- $extendableStaticMethods - is a collection of static methods used by behaviors. (defined in October\Rain\Extension\Extendable)
Public Methods
public applyActiveSite()
public applyActiveSite($site): void
applyActiveSite applies active site configuration values to the application, typically used for frontend requests.
public applyActiveSiteId()
public applyActiveSiteId($id): void
public applyEditSite()
public applyEditSite($site): void
applyEditSite applies edit site configuration values to the application, typically used for backend requests.
public applyEditSiteId()
public applyEditSiteId($id): void
public bindEvent()
public bindEvent($event, $callback, $priority = 0): void
bindEvent creates a new event binding
public bindEventOnce()
public bindEventOnce($event, $callback, $priority = 0): void
bindEventOnce creates a new event binding that fires once only
public fireEvent()
public fireEvent(
string $event,
array $params = [],
boolean $halt = false
): array
fireEvent and call the listeners
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 getEditSiteFromRequest()
public getEditSiteFromRequest(): void
getEditSiteFromRequest resolves the edit site from the current request by checking cookie, user preference, and falling back to any edit site.
public getEditSiteId()
public getEditSiteId(): void
public getLocaleKeyChain()
public getLocaleKeyChain($locale): array
getLocaleKeyChain returns locale lookup keys in priority order, where a regional locale (fr-CA) degrades to its base language (fr).
public getLocalesFromBrowser()
public getLocalesFromBrowser($acceptedStr): array
getLocalesFromBrowser 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]
public getPrimarySite()
public getPrimarySite(): void
public getSiteCodeFromContext()
public getSiteCodeFromContext(): string|null
public getSiteForLocale()
public getSiteForLocale($locale): void
public getSiteFromBrowser()
public getSiteFromBrowser($acceptLanguage, $groupId = null): 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($rootUrl, $uri): void
getSiteFromRequest locates the site based on the hostname and URI
public getSiteGroupIdFromContext()
public getSiteGroupIdFromContext(): int
getSiteGroupIdFromContext returns the site group id for the active site.
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 isModelMultisite()
public isModelMultisite($model, $attribute = null): bool
isModelMultisite returns true if the model implements multisite. If an attribute it will check that the attribute is multisite enabled (not propagated)
public isModelMultisiteGroup()
public isModelMultisiteGroup($model): bool
isModelMultisiteGroup returns true if the model implements multisite group scoping
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 storeEditSitePreference()
public storeEditSitePreference($id): void
storeEditSitePreference persists the edit site selection to user preference and cookie when the user actively switches sites.
public unbindEvent()
public unbindEvent($event = null): void
unbindEvent destroys an event binding
public withContext()
public withContext($siteId, $callback): void
public withGlobalContext()
public withGlobalContext($callback): void
Inherited Public Methods
- __call() - calls an undefined local method. (defined in October\Rain\Extension\Extendable)
- __callStatic() - calls an undefined static method. (defined in October\Rain\Extension\Extendable)
- __construct() - the extendable class. (defined in October\Rain\Extension\Extendable)
- __get() - an undefined property. (defined in October\Rain\Extension\Extendable)
- __set() - an undefined property. (defined in October\Rain\Extension\Extendable)
- __sleep() - prepare the object for serialization. (defined in October\Rain\Extension\Extendable)
- __wakeup() - when a model is being unserialized, check if it needs to be booted. (defined in October\Rain\Extension\Extendable)
- addDynamicMethod() - programmatically adds a method to the extendable class. (defined in October\Rain\Extension\Extendable)
- addDynamicProperty() - programmatically adds a property to the extendable class. (defined in October\Rain\Extension\Extendable)
- asExtension() - is short hand for
getClassExtension()method, except takes the short. (defined in October\Rain\Extension\Extendable) - clearExtendedClasses() - (defined in October\Rain\Extension\Extendable)
- extend() - this class with a closure. (defined in October\Rain\Extension\Extendable)
- extendClassWith() - dynamically extends a class with a specified behavior. (defined in October\Rain\Extension\Extendable)
- extendableCall() - magic method for
__call(). (defined in October\Rain\Extension\Extendable) - extendableCallStatic() - magic method for
__callStatic(). (defined in October\Rain\Extension\Extendable) - extendableConstruct() - should be called as part of the constructor. (defined in October\Rain\Extension\Extendable)
- extendableDestruct() - should be called when serializing the object. (defined in October\Rain\Extension\Extendable)
- extendableExtendCallback() - is a helper method for
::extend()static method. (defined in October\Rain\Extension\Extendable) - extendableGet() - magic method for
__get(). (defined in October\Rain\Extension\Extendable) - extendableSet() - magic method for
__set(). (defined in October\Rain\Extension\Extendable) - getClassExtension() - returns a behavior object from an extendable class, example:. (defined in October\Rain\Extension\Extendable)
- getClassMethodAsReflector() - (defined in October\Rain\Extension\Extendable)
- getClassMethods() - gets a list of class methods, extension equivalent of get_class_methods(). (defined in October\Rain\Extension\Extendable)
- getDynamicProperties() - returns all dynamic properties and their values. (defined in October\Rain\Extension\Extendable)
- implementClassWith() - will implement an extension using non-interference and should. (defined in October\Rain\Extension\Extendable)
- isClassExtendedWith() - checks if extendable class is extended with a behavior object. (defined in October\Rain\Extension\Extendable)
- isClassInstanceOf() - checks if the class implements the supplied interface methods. (defined in October\Rain\Extension\Extendable)
- methodExists() - checks if a method exists, extension equivalent of method_exists(). (defined in October\Rain\Extension\Extendable)
- propertyExists() - checks if a property exists, extension equivalent of
property_exists(). (defined in October\Rain\Extension\Extendable)
Protected Methods
protected broadcastSiteChange()
protected broadcastSiteChange($siteId): void
broadcastSiteChange is a generic event used when the site changes
protected emitterEventSortEvents()
protected emitterEventSortEvents($eventName, $combined = []): array
emitterEventSortEvents sorts the listeners for a given event by priority
protected listSitesForManifest()
protected listSitesForManifest($sites): void
protected listSitesFromManifest()
protected listSitesFromManifest($sites): void
Show inherited protected methods
Inherited Protected Methods
- extendableIsAccessible() - checks if a property is accessible, property equivalent. (defined in October\Rain\Extension\Extendable)
- extensionExtractImplements() - will return classes to implement. (defined in October\Rain\Extension\Extendable)
- extensionExtractMethods() - extracts the available methods from a behavior and adds it. (defined in October\Rain\Extension\Extendable)
- getExtendableMethodFromDynamicMethods() - (defined in October\Rain\Extension\Extendable)
- getExtendableMethodFromExtensions() - (defined in October\Rain\Extension\Extendable)