SilverStripe\FullTextSearch\Search\Services\SearchableService
Checks if a DataObject is publicly viewable, thus able to be added to or retrieved from a publicly searchable index.
Results are cached because these checks may be run multiple times, as there a few different code paths that search
results might follow in real-world search implementations.
Synopsis
class SearchableService
{
- // members
- private static array $indexing_canview_exclude_classes = ;
- private static bool $variant_state_draft_excluded = true;
- private array $cache = ;
- // methods
- public void clearCache()
- public bool variantStateExcluded()
- private bool isDraftVariantState()
- public bool isIndexable()
- public bool isViewable()
- private bool isSearchable()
- private string getCacheKey()
- private bool classSkipsCanViewCheck()
Hierarchy
Uses
- SilverStripe\Core\Injector\Injectable
- SilverStripe\Core\Extensible
- SilverStripe\Core\Config\Configurable
Members
private
- $cache
—
array
Non-persistant memory cache that only lasts the lifetime of the request - $indexing_canview_exclude_classes
—
array
Skip the canView() check at a class level to increase performance of search reindex. - $variant_state_draft_excluded
—
SilverStripe\FullTextSearch\Search\Services\bool
Configurable value to index draft content. Default is true for better security.
Methods
private
- classSkipsCanViewCheck()
- getCacheKey()
- isDraftVariantState() — Check if a state array represents a draft variant
- isSearchable() — Checks and caches whether the given DataObject can be indexed. This is determined by two factors: - Whether the ShowInSearch property / getShowInSearch() method evaluates to true - Whether the canView method evaluates to true against an anonymous user (optional, can be disabled)
public
- clearCache() — Clears the internal cache
- isIndexable() — Used during search reindex
- isViewable() — Used when retrieving search results
- variantStateExcluded() — Check to exclude a variant state