class SearchVariantSubsites extends SearchVariant (View source)

Properties

protected static $variants

Holds a cache of all variants

from  SearchVariant
protected static $class_variants

Holds a cache of the variants keyed by "class!" "1"? (1 = include subclasses)

from  SearchVariant
protected static $call_instances

Holds a cache of SearchVariant_Caller instances, one for each class/includeSubclasses setting

from  SearchVariant

Methods

public
__construct()

No description

public
appliesToEnvironment()

Return false if there is something missing from the environment (probably a not installed module) that means this variant can't apply to any class

public
appliesTo($class, $includeSubclasses)

Return true if this variant applies to the passed class & subclass

public
currentState()

Return the current state

public
reindexStates()

Return all states to step through to reindex all items

public
activateState($state)

Activate the passed state

public
alterQuery(SearchQuery $query, SearchIndex $index)

This field has been altered to allow a user to obtain search results for a particular subsite When attempting to do this in project code, SearchVariantSubsites kicks and overwrites any filter you've applied This fix prevents the module from doing this if a filter is applied on the index or the query, or if a field is being excluded specifically before being executed.

public static 
array
variants(string $class = null, bool $includeSubclasses = true)

Returns an array of variants.

public static 
with(string $class = null, bool $includeSubclasses = true)

Lets you call any function on all variants that support it, in the same manner as "Object#extend" calls a method from extensions.

public static 
call($method, $a1 = null, $a2 = null, $a3 = null, $a4 = null, $a5 = null, $a6 = null, $a7 = null)

A shortcut to with when calling without passing in a class,

public static 
array
current_state($class = null, $includeSubclasses = true)

Get the current state of every variant

public static 
void
activate_state($state)

Activate all the states in the passed argument

public static 
SearchVariant_ReindexStateIteratorRet
reindex_states(string $class = null, bool $includeSubclasses = true)

Return an iterator that, when used in a for loop, activates one combination of reindex states per loop, and restores back to the original state at the end

protected
addFilterField(SearchIndex $index, string $name, array $field)

Add new filter field to index safely.

protected
array|string
mergeClasses(array|string $left, array|string $right)

Merge sets of (or individual) class names together for a search index field.

public
alterDefinition($class, $index)

No description

public
extractManipulationWriteState($writes)

We need really complicated logic to find just the changed subsites (because we use versions there's no explicit deletes, just new versions with different members) so just always use all of them

protected
bool
isFieldFiltered($field, $query)

Determine if a field with a certain name is filtered by the search query or on the index This is the equivalent of saying "show me the results that do ONLY contain this value"

Details

__construct()

No description

appliesToEnvironment()

Return false if there is something missing from the environment (probably a not installed module) that means this variant can't apply to any class

appliesTo($class, $includeSubclasses)

Return true if this variant applies to the passed class & subclass

Parameters

$class
$includeSubclasses

currentState()

Return the current state

reindexStates()

Return all states to step through to reindex all items

activateState($state)

Activate the passed state

Parameters

$state

alterQuery(SearchQuery $query, SearchIndex $index)

This field has been altered to allow a user to obtain search results for a particular subsite When attempting to do this in project code, SearchVariantSubsites kicks and overwrites any filter you've applied This fix prevents the module from doing this if a filter is applied on the index or the query, or if a field is being excluded specifically before being executed.

A pull request has been raised for this issue. Once accepted this forked module can be deleted and the parent project should be used instead.

Parameters

SearchQuery $query
SearchIndex $index

static array variants(string $class = null, bool $includeSubclasses = true)

Returns an array of variants.

With no arguments, returns all variants

With a classname as the first argument, returns the variants that apply to that class (optionally including subclasses)

Parameters

string $class
  • The class name to get variants for
bool $includeSubclasses
  • True if variants should be included if they apply to at least one subclass of $class

Return Value

array
  • An array of (string)$variantClassName => (Object)$variantInstance pairs

static SearchVariant_Caller with(string $class = null, bool $includeSubclasses = true)

Lets you call any function on all variants that support it, in the same manner as "Object#extend" calls a method from extensions.

Usage: SearchVariant::with(...)->call($method, $arg1, ...);

Parameters

string $class
  • (Optional) a classname. If passed, only variants that apply to that class will be checked / called
bool $includeSubclasses
  • (Optional) If false, only variants that apply strictly to the passed class or its super-classes will be checked. If true (the default), variants that apply to any sub-class of the passed class with also be checked

Return Value

SearchVariant_Caller

An object with one method, call()

static call($method, $a1 = null, $a2 = null, $a3 = null, $a4 = null, $a5 = null, $a6 = null, $a7 = null)

A shortcut to with when calling without passing in a class,

SearchVariant::call(...) ==== SearchVariant::with()->call(...);

Parameters

$method
$a1
$a2
$a3
$a4
$a5
$a6
$a7

static array current_state($class = null, $includeSubclasses = true)

Get the current state of every variant

Parameters

$class
$includeSubclasses

Return Value

array

static void activate_state($state)

Activate all the states in the passed argument

Parameters

$state

Return Value

void

static SearchVariant_ReindexStateIteratorRet reindex_states(string $class = null, bool $includeSubclasses = true)

Return an iterator that, when used in a for loop, activates one combination of reindex states per loop, and restores back to the original state at the end

Parameters

string $class
  • The class name to get variants for
bool $includeSubclasses
  • True if variants should be included if they apply to at least one subclass of $class

Return Value

SearchVariant_ReindexStateIteratorRet
  • The iterator to foreach loop over

protected addFilterField(SearchIndex $index, string $name, array $field)

Add new filter field to index safely.

This method will respect existing filters with the same field name that correspond to multiple classes

Parameters

SearchIndex $index
string $name

Field name

array $field

Field spec

protected array|string mergeClasses(array|string $left, array|string $right)

Merge sets of (or individual) class names together for a search index field.

If there is only one unique class name, then just return it as a string instead of array.

Parameters

array|string $left

Left class(es)

array|string $right

Right class(es)

Return Value

array|string

List of classes, or single class

alterDefinition($class, $index)

No description

Parameters

$class
$index

extractManipulationWriteState($writes)

We need really complicated logic to find just the changed subsites (because we use versions there's no explicit deletes, just new versions with different members) so just always use all of them

Parameters

$writes

protected bool isFieldFiltered($field, $query)

Determine if a field with a certain name is filtered by the search query or on the index This is the equivalent of saying "show me the results that do ONLY contain this value"

Parameters

$field

string name of the field being filtered

$query

SearchQuery currently being executed

Return Value

bool

true if $field is being filtered, false if it is not being filtered