Merge pull request #210 from creative-commoners/pulls/3.2/disable-config

NEW Allow autoconfigure to be disabled via configuration
This commit is contained in:
Daniel Hensby 2018-03-20 11:01:29 +00:00 committed by GitHub
commit bd01a56346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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'])) {