SilverStripe solr Search

FieldResolver
in package
Uses GetSetSearchResolverTrait

Class FieldResolver Some additional introspection tools that are used often by the fulltext search code

Table of Contents

Properties

$ancestry  : array<string|int, mixed>
$hierarchy  : array<string|int, mixed>
$index  : BaseIndex

Methods

getHierarchy()  : array<string|int, mixed>
Get all the classes involved in a DataObject hierarchy - both super and optionally subclasses
getIndex()  : BaseIndex
Get the current index
isSubclassOf()  : bool
Check if class is subclass of (a) the class in $instanceOf, or (b) any of the classes in the array $instanceOf
resolveField()  : array<string|int, mixed>
Resolve a field ancestry
setIndex()  : $this
Set the current index
findOrigin()  : array<string|int, mixed>
Find the origin of a field
getBuildSources()  : array<string|int, mixed>
Get the sources to build in to a Solr field
getFieldOptions()  : array<string|int, mixed>
Create field options for the given index field
getHierarchyClasses()  : array<string|int, mixed>
Get the hierarchy for a class
getNext()  : array<string|int, mixed>
Get the next lookup item from the buildSources
getOriginForType()  : array<string|int, mixed>
Extraction to find the origin for a specific type field
getRelationData()  : string|array<string|int, mixed>|null
Relational data
getType()  : string
Get the type of this field
resolveNext()  : array<string|int, array<string|int, mixed>>
Resolve the next item in line to be indexed
resolveRelation()  : array<string|int, mixed>
Resolve relations if possible
excludeDataObjectIDx()  : array<string|int, mixed>
Objects to exclude from the index
getFoundOriginData()  : array<string|int, mixed>
FoundOriginData is a helper to make sure the options are properly set.
getSourceName()  : string
This is used to clean the source name from suffix suffixes are needed to support multiple relations with the same name on different page types
getSubClasses()  : array<string|int, mixed>
Get the subclasses for the given class Should be replaced with PHP native methods

Properties

$ancestry

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

Class Ancestry

$hierarchy

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

Class Hierarchy, could be replaced with Ancestry

Methods

getHierarchy()

Get all the classes involved in a DataObject hierarchy - both super and optionally subclasses

public static getHierarchy(string $class[, bool $dataOnly = false ]) : array<string|int, mixed>
Parameters
$class : string
  • The class to query
$dataOnly : bool = false
  • True to only return classes that have tables
Tags
static
throws
ReflectionException
Return values
array<string|int, mixed>
  • Integer keys, String values as classes sorted by depth (most super first)

isSubclassOf()

Check if class is subclass of (a) the class in $instanceOf, or (b) any of the classes in the array $instanceOf

public static isSubclassOf(string $class, array<string|int, mixed>|string $instanceOf) : bool
Parameters
$class : string

Name of the class to test

$instanceOf : array<string|int, mixed>|string

Class ancestry it should be in

Tags
static
Return values
bool

resolveField()

Resolve a field ancestry

public resolveField( $field) : array<string|int, mixed>
Parameters
$field :
Tags
throws
Exception
Return values
array<string|int, mixed>

setIndex()

Set the current index

public setIndex(mixed $index) : $this
Parameters
$index : mixed
Return values
$this

findOrigin()

Find the origin of a field

protected findOrigin( $field,  $fullfield, array<string|int, mixed> $found,  $class,  $fieldOptions) : array<string|int, mixed>
Parameters
$field :
$fullfield :
$found : array<string|int, mixed>
$class :
$fieldOptions :
Tags
throws
ReflectionException
Return values
array<string|int, mixed>

getBuildSources()

Get the sources to build in to a Solr field

protected getBuildSources() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFieldOptions()

Create field options for the given index field

protected getFieldOptions( $field, array<string|int, mixed> $sources, string $fullfield, array<string|int, mixed> $found) : array<string|int, mixed>
Parameters
$field :
$sources : array<string|int, mixed>
$fullfield : string
$found : array<string|int, mixed>
Tags
throws
ReflectionException
Return values
array<string|int, mixed>

getHierarchyClasses()

Get the hierarchy for a class

protected static getHierarchyClasses( $class) : array<string|int, mixed>
Parameters
$class :
Tags
throws
ReflectionException
todo

clean this up to be more compatible with PHP features

Return values
array<string|int, mixed>

getNext()

Get the next lookup item from the buildSources

protected getNext(array<string|int, mixed> $buildSources,  $lookup) : array<string|int, mixed>
Parameters
$buildSources : array<string|int, mixed>
$lookup :
Tags
throws
Exception
Return values
array<string|int, mixed>

getOriginForType()

Extraction to find the origin for a specific type field

protected getOriginForType( $field,  $fullfield, array<string|int, mixed> $found,  $fieldOptions,  $dataclass, string $type) : array<string|int, mixed>
Parameters
$field :
$fullfield :
$found : array<string|int, mixed>
$fieldOptions :
$dataclass :
$type : string
Return values
array<string|int, mixed>

getRelationData()

Relational data

protected getRelationData( $lookup, DataObjectSchema $schema,  $className, array<string|int, mixed> &$options) : string|array<string|int, mixed>|null
Parameters
$lookup :
$schema : DataObjectSchema
$className :
$options : array<string|int, mixed>
Tags
throws
Exception
Return values
string|array<string|int, mixed>|null

getType()

Get the type of this field

protected getType(array<string|int, mixed> $fields, string $field, string $dataclass) : string
Parameters
$fields : array<string|int, mixed>
$field : string
$dataclass : string
Return values
string

resolveNext()

Resolve the next item in line to be indexed

protected resolveNext(array<string|int, mixed> $options,  $lookup,  $dataClass, string $source, array<string|int, mixed> $next) : array<string|int, array<string|int, mixed>>
Parameters
$options : array<string|int, mixed>
$lookup :
$dataClass :
$source : string
$next : array<string|int, mixed>
Tags
throws
Exception
Return values
array<string|int, array<string|int, mixed>>

resolveRelation()

Resolve relations if possible

protected resolveRelation(string $source,  $lookup, array<string|int, mixed> $next, array<string|int, mixed> &$options) : array<string|int, mixed>
Parameters
$source : string
$lookup :
$next : array<string|int, mixed>
$options : array<string|int, mixed>
Tags
throws
ReflectionException
throws
Exception
Return values
array<string|int, mixed>

excludeDataObjectIDx()

Objects to exclude from the index

private static excludeDataObjectIDx(array<string|int, mixed> $classes) : array<string|int, mixed>
Parameters
$classes : array<string|int, mixed>
Return values
array<string|int, mixed>

getFoundOriginData()

FoundOriginData is a helper to make sure the options are properly set.

private getFoundOriginData(string $field, string $fullField, array<string|int, mixed> $fieldOptions, string $dataclass, string $type, array<string|int, mixed> $found) : array<string|int, mixed>
Parameters
$field : string
$fullField : string
$fieldOptions : array<string|int, mixed>
$dataclass : string
$type : string
$found : array<string|int, mixed>
Return values
array<string|int, mixed>

getSourceName()

This is used to clean the source name from suffix suffixes are needed to support multiple relations with the same name on different page types

private getSourceName(string $source) : string
Parameters
$source : string
Return values
string

getSubClasses()

Get the subclasses for the given class Should be replaced with PHP native methods

private static getSubClasses( $class, array<string|int, mixed> $classes) : array<string|int, mixed>
Parameters
$class :
$classes : array<string|int, mixed>
Tags
throws
ReflectionException
Return values
array<string|int, mixed>

        
On this page

Search results