mirror of
https://github.com/silverstripe/silverstripe-spamprotection.git
synced 2024-10-22 14:05:59 +02:00
MNT: use short array syntax
This commit is contained in:
parent
6d2ec29d32
commit
fa8366e706
@ -41,15 +41,15 @@ class EditableSpamProtectionField extends EditableFormField
|
||||
* @var array
|
||||
* @config
|
||||
*/
|
||||
private static $check_fields = array(
|
||||
private static $check_fields = [
|
||||
EditableEmailField::class,
|
||||
EditableTextField::class,
|
||||
EditableNumericField::class
|
||||
);
|
||||
];
|
||||
|
||||
private static $db = array(
|
||||
private static $db = [
|
||||
'SpamFieldSettings' => 'Text'
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @var FormField
|
||||
@ -69,7 +69,7 @@ class EditableSpamProtectionField extends EditableFormField
|
||||
}
|
||||
|
||||
// Extract saved field mappings and update this field.
|
||||
$fieldMapping = array();
|
||||
$fieldMapping = [];
|
||||
foreach ($this->getCandidateFields() as $otherField) {
|
||||
$mapSetting = "Map-{$otherField->Name}";
|
||||
$spamField = $this->spamMapValue($mapSetting);
|
||||
@ -106,7 +106,7 @@ class EditableSpamProtectionField extends EditableFormField
|
||||
|
||||
// Get list of all configured classes available for spam detection
|
||||
$types = $this->config()->get('check_fields');
|
||||
$typesInherit = array();
|
||||
$typesInherit = [];
|
||||
foreach ($types as $type) {
|
||||
$subTypes = ClassInfo::subclassesFor($type);
|
||||
$typesInherit = array_merge($typesInherit, $subTypes);
|
||||
@ -132,7 +132,7 @@ class EditableSpamProtectionField extends EditableFormField
|
||||
{
|
||||
$fieldMap = json_decode($this->SpamFieldSettings ?? '', true);
|
||||
if (empty($fieldMap)) {
|
||||
$fieldMap = array();
|
||||
$fieldMap = [];
|
||||
}
|
||||
|
||||
foreach ($this->record as $key => $value) {
|
||||
@ -202,7 +202,7 @@ class EditableSpamProtectionField extends EditableFormField
|
||||
{
|
||||
$map = json_decode($this->SpamFieldSettings ?? '', true);
|
||||
if (empty($map)) {
|
||||
$map = array();
|
||||
$map = [];
|
||||
}
|
||||
|
||||
if (array_key_exists($mapSetting, $map ?? [])) {
|
||||
|
@ -14,19 +14,19 @@ class CommentSpamProtection extends Extension
|
||||
{
|
||||
public function alterCommentForm(&$form)
|
||||
{
|
||||
$form->enableSpamProtection(array(
|
||||
$form->enableSpamProtection([
|
||||
'name' => 'IsSpam',
|
||||
'mapping' => array(
|
||||
'mapping' => [
|
||||
'Name' => 'authorName',
|
||||
'Email' => 'authorEmail',
|
||||
'URL' => 'authorUrl',
|
||||
'Comment' => 'body',
|
||||
'ReturnURL' => 'contextUrl'
|
||||
),
|
||||
'checks' => array(
|
||||
],
|
||||
'checks' => [
|
||||
'spam',
|
||||
'profanity'
|
||||
)
|
||||
));
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class FormSpamProtectionExtension extends Extension
|
||||
*
|
||||
* @var array $mappable_fields
|
||||
*/
|
||||
private static $mappable_fields = array(
|
||||
private static $mappable_fields = [
|
||||
'id',
|
||||
'title',
|
||||
'body',
|
||||
@ -48,7 +48,7 @@ class FormSpamProtectionExtension extends Extension
|
||||
'authorUrl',
|
||||
'authorIp',
|
||||
'authorId'
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @config
|
||||
@ -88,7 +88,7 @@ class FormSpamProtectionExtension extends Extension
|
||||
* @throws LogicException when get_protector method returns NULL.
|
||||
* @return Object
|
||||
*/
|
||||
public function enableSpamProtection($options = array())
|
||||
public function enableSpamProtection($options = [])
|
||||
{
|
||||
|
||||
// captcha form field name (must be unique)
|
||||
|
Loading…
Reference in New Issue
Block a user