Skip to content

Commit

Permalink
NEW Add NullSpamProtector
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jan 18, 2023
1 parent 8357015 commit 5afed61
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions _config/spamprotection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: frameworktest-spamprotection
---
SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension:
default_spam_protector: SilverStripe\FrameworkTest\NullSpamProtector\NullSpamProtector
28 changes: 28 additions & 0 deletions code/null-spam-protector/NullSpamProtector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace SilverStripe\FrameworkTest\NullSpamProtector;

use SilverStripe\Forms\HiddenField;
use SilverStripe\SpamProtection\SpamProtector;

if (!interface_exists(SpamProtector::class)) {
return;
}

/**
* This is a minimum implementation used in CI for silverstripe/spamprotector so there's a default_spam_protector
*
* This used to be done by silverstripe/akismet, but that's no longer being used in CMS 5
*/
class NullSpamProtector implements SpamProtector
{
public function getFormField($name = null, $title = null, $value = null)
{
return new HiddenField('NullSpamProtector');
}

public function setFieldMapping($fieldMapping)
{
// no-op
}
}

0 comments on commit 5afed61

Please sign in to comment.