mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 12:05:29 +00:00
SS 4.0 - Update Variants
This commit is contained in:
parent
fcf9a4f888
commit
eac9485924
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Search\Variants;
|
||||
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
/**
|
||||
* A Search Variant handles decorators and other situations where the items to reindex or search through are modified
|
||||
@ -22,7 +24,10 @@ abstract class SearchVariant
|
||||
* 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 public function appliesToEnvironment();
|
||||
public function appliesToEnvironment()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this variant applies to the passed class & subclass
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace SilverStripe\FullTextSearch\Search\Variants;
|
||||
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
|
||||
class SearchVariantSiteTreeSubsitesPolyhome extends SearchVariant
|
||||
{
|
||||
public function appliesToEnvironment()
|
||||
@ -78,7 +80,7 @@ class SearchVariantSiteTreeSubsitesPolyhome extends SearchVariant
|
||||
}
|
||||
|
||||
if (self::$subsites === null) {
|
||||
$query = new SQLQuery('ID', 'Subsite');
|
||||
$query = new SQLSelect('ID', 'Subsite');
|
||||
self::$subsites = array_merge(array('0'), $query->execute()->column());
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Search\Variants;
|
||||
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
|
||||
class SearchVariantSubsites extends SearchVariant
|
||||
{
|
||||
public function appliesToEnvironment()
|
||||
@ -74,7 +78,7 @@ class SearchVariantSubsites extends SearchVariant
|
||||
public function extractManipulationWriteState(&$writes)
|
||||
{
|
||||
$self = get_class($this);
|
||||
$query = new SQLQuery('"ID"', '"Subsite"');
|
||||
$query = new SQLSelect('"ID"', '"Subsite"');
|
||||
$subsites = array_merge(array('0'), $query->execute()->column());
|
||||
|
||||
foreach ($writes as $key => $write) {
|
||||
|
@ -3,14 +3,9 @@ namespace SilverStripe\FullTextSearch\Search\Variants;
|
||||
|
||||
class SearchVariantVersioned extends SearchVariant
|
||||
{
|
||||
public function appliesToEnvironment()
|
||||
{
|
||||
return class_exists('Versioned');
|
||||
}
|
||||
|
||||
public function appliesTo($class, $includeSubclasses)
|
||||
{
|
||||
return SearchIntrospection::has_extension($class, 'Versioned', $includeSubclasses);
|
||||
return SearchIntrospection::has_extension($class, Versioned::class, $includeSubclasses);
|
||||
}
|
||||
|
||||
public function currentState()
|
||||
|
Loading…
x
Reference in New Issue
Block a user