NEW Allow autoconfigure to be disabled via configuration

This commit is contained in:
Robbie Averill 2018-03-20 16:32:32 +13:00
parent c9a0fef326
commit 7a3e2d0823
2 changed files with 26 additions and 0 deletions

View File

@ -30,6 +30,20 @@ common interfaces to fulltext engine functionality, abstracting out common behav
offers its own extensions, and there is some behaviour (such as getting the fulltext search engines installed, configured
and running) that each connector deals with itself, in a way best suited to that search engine's design.
## Disabling automatic configuration
If you have this module installed but do not have a Solr server running, you can disable the database manipulation
hooks that trigger automatic index updates:
```yaml
# File: mysite/_config/search.yml
---
Name: mysitesearch
---
SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater:
enabled: false
```
## Basic usage
Basic usage is a four step process:

View File

@ -37,6 +37,14 @@ class SearchUpdater
*/
private static $flush_on_shutdown = true;
/**
* Whether the updater is enabled. Set to false for local development if you don't have a Solr server.
*
* @config
* @var bool
*/
private static $enabled = true;
public static $registered = false;
/** @var SearchUpdateProcessor */
public static $processor = null;
@ -53,6 +61,10 @@ class SearchUpdater
*/
public static function handle_manipulation($manipulation)
{
if (!static::config()->get('enabled')) {
return;
}
// First, extract any state that is in the manipulation itself
foreach ($manipulation as $table => $details) {
if (!isset($manipulation[$table]['class'])) {