SilverStripe solr Search

FluentSiteState extends SiteState
in package
implements SiteStateInterface

Class \Firesphere\SolrFluent\States\FluentSiteState

Manage the state of the site to apply the correct locale from Fluent to search

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  : array<string|int, mixed>

Methods

activateState()  : mixed
Activate a given state. This should only be done if the state is applicable
addState()  : void
Add a state
addStates()  : void
Add multiple states
alterQuery()  : void
Alter the query for each instance
appliesTo()  : bool
Does the state apply to this class
appliesToEnvironment()  : bool
Does this state apply to the current object/environment settings
currentState()  : string|null
Return the current state of the site
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 Stub method for readability
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
updateQuery()  : mixed
Update the Solr query to match the current State
variants()  : array<string|int, mixed>
Returns an array of variants.
withState()  : void
Activate a site state for indexing
updatePart()  : void
Update a part of the query for the get and set methods.
updateTerms()  : array<string|int, mixed>
Update the field filters to localised filters

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

private static array<string|int, mixed> $methods = ['BoostedFields', 'Filter', 'Exclude']

get/set methods that needs to be called to update the query

Methods

activateState()

Activate a given state. This should only be done if the state is applicable

public activateState(string $state) : mixed
Parameters
$state : string

Activate the given state

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

appliesTo()

Does the state apply to this class

public appliesTo(string $class) : bool
Parameters
$class : string

Class to check

Tags
throws
ReflectionException
Return values
bool

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

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 Stub method for readability

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

Reset to default state

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

public stateIsApplicable(string $state) : bool
Parameters
$state : string

State to validate

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

updatePart()

Update a part of the query for the get and set methods.

protected updatePart(BaseQuery &$query, string $locale, string $method) : void
Parameters
$query : BaseQuery

Query that needs updating for the given method

$locale : string

Localisation to use

$method : string

Get method to call

updateTerms()

Update the field filters to localised filters

protected updateTerms(string|array<string|int, mixed> $term, string $locale, array<string|int, mixed> $localisedTerms) : array<string|int, mixed>
Parameters
$term : string|array<string|int, mixed>

Array of terms

$locale : string

Localisation to use

$localisedTerms : array<string|int, mixed>

Currently localised terms

Return values
array<string|int, mixed>

        
On this page

Search results