SilverStripe solr Search

SubsiteState extends SiteState
in package
implements SiteStateInterface

Class \Firesphere\SolrSubsites\States\SubsiteState

Apply states for Subsites

Table of Contents

Interfaces

SiteStateInterface
Interface SiteStateInterface defines the methods every State altering must implement.

Constants

DEFAULT_STATE  = 'default'

Properties

$enabled  : bool
$states  : array<string|int, mixed>
States that can be applied
$variants  : array<string|int, mixed>
Variants of SiteState that can be activated
$defaultStates  : array<string|int, mixed>
$state  : string

Methods

activateState()  : void
Activate a given state. This should only be done if the state is applicable In the case of Subsites, we just want to disable the filter
addState()  : void
Add a state
addStates()  : void
Add multiple states
alterQuery()  : void
Alter the query for each instance
appliesToEnvironment()  : bool
Does this state apply to the current object/environment settings
currentState()  : string|null
Return the current state of the site The current state does not need to be reset in any way for pages
currentStates()  : array<string|int, mixed>
Get the current state of every variant
getDefaultStates()  : array<string|int, mixed>
Get the states set as default
getStates()  : array<string|int, mixed>
Get available states
hasExtension()  : bool
Does this class, it's parent (or optionally one of it's children) have the passed extension attached?
isApplicable()  : bool
Is this extension applied and instantiable, and should it be applied to the current state of the site
isEnabled()  : bool
Is this state enabled
setDefaultState()  : mixed
Reset the SiteState to it's default state In case of subsites, we don't care about it, as it's handled at query time
setDefaultStates()  : void
Set the default states
setEnabled()  : void
Set the state to whatever is required. Most commonly true
setStates()  : void
Set states
stateIsApplicable()  : bool
Is this state applicable to this extension In case of subsites, only apply if there actually are subsites
updateQuery()  : void
Method to alter the query. Can be no-op.
variants()  : array<string|int, mixed>
Returns an array of variants.
withState()  : void
Activate a site state for indexing
addSubsiteFilter()  : void
Add the Subsite specific filter if the class has the extension applied

Constants

DEFAULT_STATE

public mixed DEFAULT_STATE = 'default'

Properties

$enabled

public bool $enabled = true

Is this State enabled

$states

States that can be applied

public static array<string|int, mixed> $states = [self::DEFAULT_STATE]

$variants

Variants of SiteState that can be activated

public static array<string|int, mixed> $variants = []

$defaultStates

protected static array<string|int, mixed> $defaultStates = []

Default states

$state

protected string $state

current state

Methods

activateState()

Activate a given state. This should only be done if the state is applicable In the case of Subsites, we just want to disable the filter

public activateState(int $state) : void
Parameters
$state : int

addState()

Add a state

public static addState( $state) : void
Parameters
$state :
Tags
static

addStates()

Add multiple states

public static addStates(array<string|int, mixed> $states) : void
Parameters
$states : array<string|int, mixed>
Tags
static

alterQuery()

Alter the query for each instance

public static alterQuery(BaseQuery &$query) : void
Parameters
$query : BaseQuery
Tags
throws
ReflectionException

appliesToEnvironment()

Does this state apply to the current object/environment settings

public appliesToEnvironment() : bool
Return values
bool

currentState()

Return the current state of the site The current state does not need to be reset in any way for pages

public currentState() : string|null
Return values
string|null

currentStates()

Get the current state of every variant

public static currentStates() : array<string|int, mixed>
Tags
static
throws
ReflectionException
Return values
array<string|int, mixed>

getDefaultStates()

Get the states set as default

public static getDefaultStates() : array<string|int, mixed>
Return values
array<string|int, mixed>

getStates()

Get available states

public static getStates() : array<string|int, mixed>
Tags
static
Return values
array<string|int, mixed>

hasExtension()

Does this class, it's parent (or optionally one of it's children) have the passed extension attached?

public static hasExtension(string $class, string $extension) : bool
Parameters
$class : string
$extension : string
Tags
static
throws
ReflectionException
Return values
bool

isApplicable()

Is this extension applied and instantiable, and should it be applied to the current state of the site

public static isApplicable( $variantClass) : bool
Parameters
$variantClass :
Tags
static
throws
ReflectionException
Return values
bool

isEnabled()

Is this state enabled

public isEnabled() : bool
Return values
bool

setDefaultState()

Reset the SiteState to it's default state In case of subsites, we don't care about it, as it's handled at query time

public setDefaultState([string|null $state = null ]) : mixed
Parameters
$state : string|null = null

setDefaultStates()

Set the default states

public static setDefaultStates(array<string|int, mixed> $defaultStates) : void
Parameters
$defaultStates : array<string|int, mixed>

setEnabled()

Set the state to whatever is required. Most commonly true

public setEnabled(bool $enabled) : void
Parameters
$enabled : bool

setStates()

Set states

public static setStates(array<string|int, mixed> $states) : void
Parameters
$states : array<string|int, mixed>
Tags
static

stateIsApplicable()

Is this state applicable to this extension In case of subsites, only apply if there actually are subsites

public stateIsApplicable(int|string $state) : bool
Parameters
$state : int|string
Return values
bool

variants()

Returns an array of variants.

public static variants([bool $force = false ]) : array<string|int, mixed>
Parameters
$force : bool = false

Force updating the variants

Tags
static
throws
ReflectionException
Return values
array<string|int, mixed>
  • An array of (string)$variantClassName => (Object)$variantInstance pairs

withState()

Activate a site state for indexing

public static withState( $state) : void
Parameters
$state :
Tags
throws
ReflectionException

addSubsiteFilter()

Add the Subsite specific filter if the class has the extension applied

protected addSubsiteFilter(BaseQuery &$query, string $class) : void
Parameters
$query : BaseQuery
$class : string

        
On this page

Search results