mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
BUG Dont try and load SearchVariants that dont apply to this env
This commit is contained in:
parent
9534eeff8a
commit
b9c6ff44ec
@ -15,6 +15,12 @@ abstract class SearchVariant {
|
||||
* with specific ones
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
abstract function appliesToEnvironment();
|
||||
|
||||
/**
|
||||
* Return true if this variant applies to the passed class & subclass
|
||||
*/
|
||||
@ -61,7 +67,10 @@ abstract class SearchVariant {
|
||||
$concrete = array();
|
||||
foreach ($classes as $variantclass) {
|
||||
$ref = new ReflectionClass($variantclass);
|
||||
if ($ref->isInstantiable()) $concrete[$variantclass] = singleton($variantclass);
|
||||
if ($ref->isInstantiable()) {
|
||||
$variant = singleton($variantclass);
|
||||
if ($variant->appliesToEnvironment()) $concrete[$variantclass] = $variant;
|
||||
}
|
||||
}
|
||||
|
||||
self::$variants = $concrete;
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
class SearchVariantSiteTreeSubsitesPolyhome extends SearchVariant {
|
||||
|
||||
function appliesToEnvironment() {
|
||||
return class_exists('Subsite') && class_exists('SubsitePolyhome');
|
||||
}
|
||||
|
||||
function appliesTo($class, $includeSubclasses) {
|
||||
return SearchIntrospection::has_extension($class, 'SiteTreeSubsitesPolyhome', $includeSubclasses);
|
||||
}
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
class SearchVariantVersioned extends SearchVariant {
|
||||
|
||||
function appliesToEnvironment() {
|
||||
return class_exists('Versioned');
|
||||
}
|
||||
|
||||
function appliesTo($class, $includeSubclasses) {
|
||||
return SearchIntrospection::has_extension($class, 'Versioned', $includeSubclasses);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user