mirror of
https://github.com/silverstripe/silverstripe-spamprotection.git
synced 2024-10-22 14:05:59 +02:00
API Refactor field mapping from FormSpamProtectionExtension into SpamProtector API EditableSpamProtectionField may now be configured for spam on an individual field basis Translations added
This commit is contained in:
parent
39f7f0be45
commit
9abe13fcb6
@ -13,7 +13,6 @@ if(class_exists('EditableFormField')) {
|
|||||||
static $singular_name = 'Spam Protection Field';
|
static $singular_name = 'Spam Protection Field';
|
||||||
|
|
||||||
static $plural_name = 'Spam Protection Fields';
|
static $plural_name = 'Spam Protection Fields';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fields to include spam detection for
|
* Fields to include spam detection for
|
||||||
*
|
*
|
||||||
@ -27,10 +26,9 @@ if(class_exists('EditableFormField')) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
public function getFormField() {
|
public function getFormField() {
|
||||||
|
|
||||||
// Get protector
|
// Get protector
|
||||||
$protector = FormSpamProtectionExtension::get_protector();
|
$protector = FormSpamProtectionExtension::get_protector();
|
||||||
if(empty($protector)) return false;
|
if(!$protector) return false;
|
||||||
|
|
||||||
// Extract saved field mappings and update this field.
|
// Extract saved field mappings and update this field.
|
||||||
$fieldMapping = array();
|
$fieldMapping = array();
|
||||||
|
@ -51,15 +51,15 @@ class FormSpamProtectionExtension extends Extension {
|
|||||||
// generate the spam protector
|
// generate the spam protector
|
||||||
if(isset($options['protector'])) {
|
if(isset($options['protector'])) {
|
||||||
$protector = $options['protector'];
|
$protector = $options['protector'];
|
||||||
|
|
||||||
if(is_string($protector)) {
|
|
||||||
$protector = Injector::inst()->create($protector);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$protector = Config::inst()->get('FormSpamProtectionExtension', 'default_spam_protector');
|
$protector = Config::inst()->get('FormSpamProtectionExtension', 'default_spam_protector');
|
||||||
$protector = Injector::inst()->create($protector);
|
|
||||||
}
|
}
|
||||||
return $protector;
|
|
||||||
|
if($protector && class_exists($protector)) {
|
||||||
|
return Injector::inst()->create($protector);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user