diff --git a/phpcs.xml.dist b/phpcs.xml.dist index fa589da..d834f9a 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -6,17 +6,5 @@ - - - - - - - - - - - - - \ No newline at end of file + diff --git a/src/Extensions/CommentsExtension.php b/src/Extensions/CommentsExtension.php index ed827fb..cccf53c 100644 --- a/src/Extensions/CommentsExtension.php +++ b/src/Extensions/CommentsExtension.php @@ -157,13 +157,16 @@ class CommentsExtension extends DataExtension // Check if enabled setting should be cms configurable if ($this->owner->getCommentsOption('enabled_cms')) { - $options->push(new CheckboxField('ProvideComments', _t('SilverStripe\\Comments\\Model\\Comment.ALLOWCOMMENTS', 'Allow Comments'))); + $options->push(CheckboxField::create('ProvideComments', _t( + 'SilverStripe\\Comments\\Model\\Comment.ALLOWCOMMENTS', + 'Allow Comments' + ))); } // Check if we should require users to login to comment if ($this->owner->getCommentsOption('require_login_cms')) { $options->push( - new CheckboxField( + CheckboxField::create( 'CommentsRequireLogin', _t('Comments.COMMENTSREQUIRELOGIN', 'Require login to comment') ) @@ -180,16 +183,23 @@ class CommentsExtension extends DataExtension // Check if moderation should be enabled via cms configurable if ($this->owner->getCommentsOption('require_moderation_cms')) { - $moderationField = new DropdownField('ModerationRequired', _t(__CLASS__ . '.COMMENTMODERATION', 'Comment Moderation'), array( - 'None' => _t(__CLASS__ . '.MODERATIONREQUIRED_NONE', 'No moderation required'), - 'Required' => _t(__CLASS__ . '.MODERATIONREQUIRED_REQUIRED', 'Moderate all comments'), - 'NonMembersOnly' => _t( - __CLASS__ . '.MODERATIONREQUIRED_NONMEMBERSONLY', - 'Only moderate non-members' + $moderationField = DropdownField::create( + 'ModerationRequired', + _t( + __CLASS__ . '.COMMENTMODERATION', + 'Comment Moderation' ), - )); + [ + 'None' => _t(__CLASS__ . '.MODERATIONREQUIRED_NONE', 'No moderation required'), + 'Required' => _t(__CLASS__ . '.MODERATIONREQUIRED_REQUIRED', 'Moderate all comments'), + 'NonMembersOnly' => _t( + __CLASS__ . '.MODERATIONREQUIRED_NONMEMBERSONLY', + 'Only moderate non-members' + ), + ] + ); if ($fields->hasTabSet()) { - $fields->addFieldsToTab('Root.Settings', $moderationField); + $fields->addFieldToTab('Root.Settings', $moderationField); } else { $fields->push($moderationField); } diff --git a/src/Forms/CommentForm.php b/src/Forms/CommentForm.php index 9cae509..cd82fa0 100644 --- a/src/Forms/CommentForm.php +++ b/src/Forms/CommentForm.php @@ -44,18 +44,27 @@ class CommentForm extends Form // Email EmailField::create( 'Email', - _t('SilverStripe\\Comments\\Controllers\\CommentingController.EMAILADDRESS', 'Your email address (will not be published)') + _t( + 'SilverStripe\\Comments\\Controllers\\CommentingController.EMAILADDRESS', + 'Your email address (will not be published)' + ) ) ->setCustomValidationMessage($emailRequired) ->setAttribute('data-msg-required', $emailRequired) ->setAttribute('data-msg-email', $emailInvalid) ->setAttribute('data-rule-email', true), // Url - TextField::create('URL', _t('SilverStripe\\Comments\\Controllers\\CommentingController.WEBSITEURL', 'Your website URL')) + TextField::create('URL', _t( + 'SilverStripe\\Comments\\Controllers\\CommentingController.WEBSITEURL', + 'Your website URL' + )) ->setAttribute('data-msg-url', $urlInvalid) ->setAttribute('data-rule-url', true), // Comment - TextareaField::create('Comment', _t('SilverStripe\\Comments\\Controllers\\CommentingController.COMMENTS', 'Comments')) + TextareaField::create('Comment', _t( + 'SilverStripe\\Comments\\Controllers\\CommentingController.COMMENTS', + 'Comments' + )) ->setCustomValidationMessage($commentRequired) ->setAttribute('data-msg-required', $commentRequired) ),