-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from heyday/master
SilverStripe 4 Upgrade
- Loading branch information
Showing
5 changed files
with
67 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,38 @@ | ||
# SilverStripe honeypot | ||
# SilverStripe Honey Pot | ||
|
||
For a SilverStripe `2.4` compatible version use the branch `1.0` | ||
A SilverStripe 4.x compatible version of camspiers/honeypot | ||
|
||
## Installation (with composer) | ||
|
||
$ composer require camspiers/honeypot | ||
$ composer require heyday/silverstripe-honeypot | ||
|
||
Set the default spam protector in *mysite/_config/spamprotection.yml* | ||
Set the default spam protector in *app/_config/spamprotection.yml* | ||
|
||
--- | ||
name: spamprotection | ||
--- | ||
FormSpamProtectionExtension: | ||
default_spam_protector: HoneyPotSpamProtector | ||
SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension: | ||
default_spam_protector: Heyday\SilverStripe\HoneyPot\HoneyPotSpamProtector | ||
|
||
Or, on a form by form basis | ||
|
||
use Heyday\SilverStripe\HoneyPot\HoneyPotField; | ||
use SilverStripe\Forms\Form; | ||
use SilverStripe\Control\Controller; | ||
use SilverStripe\Forms\FieldList; | ||
|
||
/** | ||
* Class SomeForm | ||
*/ | ||
class SomeForm extends Form | ||
{ | ||
/** | ||
* @param Controller $controller | ||
*/ | ||
public function __construct(Controller $controller) | ||
{ | ||
$fields = new FieldList(); | ||
$fields->push(new HoneyPotField('Website')); // 'Website' here can be any old string | ||
... | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
<?php | ||
|
||
/** | ||
* @package honeypot | ||
*/ | ||
namespace Heyday\SilverStripe\HoneyPot; | ||
|
||
use SilverStripe\SpamProtection\SpamProtector; | ||
|
||
class HoneyPotSpamProtector implements SpamProtector { | ||
|
||
/** | ||
* Returns the {@link HoneyPotField} associated with this protector | ||
* | ||
* @return HoneyPotField | ||
*/ | ||
/** | ||
* Returns the {@link HoneyPotField} associated with this protector | ||
* | ||
* @param null $name | ||
* @param null $title | ||
* @param null $value | ||
* @return HoneyPotField | ||
*/ | ||
public function getFormField($name = null, $title = null, $value = null) { | ||
return new HoneyPotField($name, $title, $value); | ||
} | ||
|
||
/** | ||
* Not used by HoneyPotSpamProtector | ||
*/ | ||
/** | ||
* Not used by HoneyPotSpamProtector | ||
* @param $fieldMapping | ||
*/ | ||
public function setFieldMapping($fieldMapping) {} | ||
|
||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
{ | ||
"name": "camspiers/honeypot", | ||
"name": "heyday/silverstripe-honeypot", | ||
"type": "silverstripe-module", | ||
"require": { | ||
"silverstripe/spamprotection": "~2.0.0", | ||
"silverstripe/spamprotection": "~3.0.0", | ||
"composer/installers": "~1.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Heyday\\SilverStripe\\HoneyPot\\": "code/" | ||
} | ||
} | ||
} |