From 9c9b2a3e2046f2c73b2582993f19db471e6c7ce9 Mon Sep 17 00:00:00 2001 From: Scott Hutchinson Date: Mon, 5 Aug 2019 16:17:49 +1200 Subject: [PATCH] ENHANCEMENT Add extension point to appliesTo for SearchVariantSubsites --- src/Search/Variants/SearchVariant.php | 2 ++ src/Search/Variants/SearchVariantSubsites.php | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Search/Variants/SearchVariant.php b/src/Search/Variants/SearchVariant.php index f1b4463..eeaf970 100644 --- a/src/Search/Variants/SearchVariant.php +++ b/src/Search/Variants/SearchVariant.php @@ -4,6 +4,7 @@ namespace SilverStripe\FullTextSearch\Search\Variants; use ReflectionClass; use SilverStripe\Core\ClassInfo; +use SilverStripe\Core\Extensible; use SilverStripe\Core\Config\Configurable; use SilverStripe\FullTextSearch\Search\Indexes\SearchIndex; use SilverStripe\FullTextSearch\Search\Queries\SearchQuery; @@ -16,6 +17,7 @@ use SilverStripe\FullTextSearch\Utils\CombinationsArrayIterator; abstract class SearchVariant { use Configurable; + use Extensible; /** * Whether this variant is enabled diff --git a/src/Search/Variants/SearchVariantSubsites.php b/src/Search/Variants/SearchVariantSubsites.php index 96ca6a2..e58c9da 100644 --- a/src/Search/Variants/SearchVariantSubsites.php +++ b/src/Search/Variants/SearchVariantSubsites.php @@ -36,10 +36,14 @@ class SearchVariantSubsites extends SearchVariant // Include all DataExtensions that contain a SubsiteID. // TODO: refactor subsites to inherit a common interface, so we can run introspection once only. - return SearchIntrospection::has_extension($class, SiteTreeSubsites::class, $includeSubclasses) + $appliesTo = SearchIntrospection::has_extension($class, SiteTreeSubsites::class, $includeSubclasses) || SearchIntrospection::has_extension($class, GroupSubsites::class, $includeSubclasses) || SearchIntrospection::has_extension($class, FileSubsites::class, $includeSubclasses) || SearchIntrospection::has_extension($class, SiteConfigSubsites::class, $includeSubclasses); + + $this->extend('updateAppliesTo', $appliesTo, $class, $includeSubclasses); + + return $appliesTo; } public function currentState()