diff --git a/src/Extension/FormSpamProtectionExtension.php b/src/Extension/FormSpamProtectionExtension.php index 07de263..7170881 100644 --- a/src/Extension/FormSpamProtectionExtension.php +++ b/src/Extension/FormSpamProtectionExtension.php @@ -6,6 +6,7 @@ use LogicException; use SilverStripe\Core\Config\Configurable; use SilverStripe\Core\Extension; use SilverStripe\Core\Injector\Injector; +use Psr\Log\LoggerInterface; /** * An extension to the {@link Form} class which provides the method @@ -28,6 +29,13 @@ class FormSpamProtectionExtension extends Extension */ private static $default_spam_protector; + /** + * @config + * + * @var bool + */ + private static $throw_exception_on_missing_protector = true; + /** * @config * @@ -109,7 +117,13 @@ class FormSpamProtectionExtension extends Extension $protector = self::get_protector($options); if ($protector === null) { - throw new LogicException('No spam protector has been set. Null is not valid value.'); + if ($this->config()->get('throw_exception_on_missing_protector')) { + throw new LogicException('No spam protector has been set. Null is not valid value.'); + } else { + Injector::inst()->get(LoggerInterface::class)->warning( + 'No spam protector has been set. Null is not valid value.' + ); + } } if ($protector && isset($options['mapping'])) {