Commit 7f6a95d2 authored by Tino Goratsch's avatar Tino Goratsch

Merge pull request #32 from ACP3/refactor/form-validation

Refactor/form validation
parents 4bbd7fb4 5e0d00ca
......@@ -7,7 +7,7 @@ use ACP3\Core;
* Class AbstractFormValidation
* @package ACP3\Core\Validation
*/
class AbstractFormValidation
abstract class AbstractFormValidation
{
/**
* @var \ACP3\Core\I18n\Translator
......@@ -30,4 +30,12 @@ class AbstractFormValidation
$this->translator = $translator;
$this->validator = $validator;
}
/**
* @param array $formData
*
* @throws Core\Exceptions\InvalidFormToken
* @throws Core\Exceptions\ValidationFailed
*/
abstract public function validate(array $formData);
}
\ No newline at end of file
......@@ -25,9 +25,9 @@ class Index extends Core\Modules\AdminController
*/
protected $articlesCache;
/**
* @var \ACP3\Modules\ACP3\Articles\Validation\FormValidation
* @var \ACP3\Modules\ACP3\Articles\Validation\AdminFormValidation
*/
protected $articlesValidator;
protected $adminFormValidation;
/**
* @var \ACP3\Modules\ACP3\Menus\Cache
*/
......@@ -50,19 +50,19 @@ class Index extends Core\Modules\AdminController
protected $menuItemFormFieldsHelper;
/**
* @param \ACP3\Core\Modules\Controller\AdminContext $context
* @param \ACP3\Core\Date $date
* @param \ACP3\Modules\ACP3\Articles\Model\ArticleRepository $articleRepository
* @param \ACP3\Modules\ACP3\Articles\Cache $articlesCache
* @param \ACP3\Modules\ACP3\Articles\Validation\FormValidation $articlesValidator
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
* @param \ACP3\Core\Modules\Controller\AdminContext $context
* @param \ACP3\Core\Date $date
* @param \ACP3\Modules\ACP3\Articles\Model\ArticleRepository $articleRepository
* @param \ACP3\Modules\ACP3\Articles\Cache $articlesCache
* @param \ACP3\Modules\ACP3\Articles\Validation\AdminFormValidation $adminFormValidation
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
*/
public function __construct(
Core\Modules\Controller\AdminContext $context,
Core\Date $date,
Articles\Model\ArticleRepository $articleRepository,
Articles\Cache $articlesCache,
Articles\Validation\FormValidation $articlesValidator,
Articles\Validation\AdminFormValidation $adminFormValidation,
Core\Helpers\FormToken $formTokenHelper)
{
parent::__construct($context);
......@@ -70,7 +70,7 @@ class Index extends Core\Modules\AdminController
$this->date = $date;
$this->articleRepository = $articleRepository;
$this->articlesCache = $articlesCache;
$this->articlesValidator = $articlesValidator;
$this->adminFormValidation = $adminFormValidation;
$this->formTokenHelper = $formTokenHelper;
}
......@@ -160,7 +160,7 @@ class Index extends Core\Modules\AdminController
protected function _createPost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
$this->articlesValidator->validate($formData);
$this->adminFormValidation->validate($formData);
$insertValues = [
'id' => '',
......@@ -278,10 +278,9 @@ class Index extends Core\Modules\AdminController
protected function _editPost(array $formData, $id)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $id) {
$this->articlesValidator->validate(
$formData,
sprintf(Articles\Helpers::URL_KEY_PATTERN, $id)
);
$this->adminFormValidation
->setUriAlias(sprintf(Articles\Helpers::URL_KEY_PATTERN, $id))
->validate($formData);
$updateValues = [
'start' => $this->date->toSQL($formData['start']),
......
......@@ -8,7 +8,7 @@ parameters:
articles.cache.fqdn: 'ACP3\Modules\ACP3\Articles\Cache'
articles.helpers.fqdn: 'ACP3\Modules\ACP3\Articles\Helpers'
articles.model.articlerepository.fqdn: 'ACP3\Modules\ACP3\Articles\Model\ArticleRepository'
articles.validator.fqdn: 'ACP3\Modules\ACP3\Articles\Validation\FormValidation'
articles.validator.fqdn: 'ACP3\Modules\ACP3\Articles\Validation\AdminFormValidation'
articles.validation.validation_rules.article_exists_validation_rule.fqdn: 'ACP3\Modules\ACP3\Articles\Validation\ValidationRules\ArticleExistsValidationRule'
articles.installer.schema.fqdn: 'ACP3\Modules\ACP3\Articles\Installer\Schema'
articles.installer.migration.fqdn: 'ACP3\Modules\ACP3\Articles\Installer\Migration'
......@@ -16,7 +16,13 @@ parameters:
services:
articles.controller.admin.index:
class: %articles.controller.admin.index.fqdn%
arguments: ['@core.context.admin', '@core.date', '@articles.model.articlerepository', '@articles.cache', '@articles.validator', '@core.helpers.formToken']
arguments:
- @core.context.admin
- @core.date
- @articles.model.articlerepository
- @articles.cache
- @articles.validator
- @core.helpers.formToken
calls:
- ['setMenusCache', ['@?menus.cache']]
- ['setManageMenuItemHelper', ['@?menus.helpers.managemenuitem']]
......@@ -25,7 +31,13 @@ services:
articles.controller.frontend.index:
class: %articles.controller.frontend.index.fqdn%
arguments: ['@core.context.frontend', '@core.date', '@core.pagination', '@core.helpers.pageBreaks', '@articles.model.articlerepository', '@articles.cache']
arguments:
- @core.context.frontend
- @core.date
- @core.pagination
- @core.helpers.pageBreaks
- @articles.model.articlerepository
- @articles.cache
articles.controller.sidebar.index:
class: %articles.controller.sidebar.index.fqdn%
......
......@@ -6,15 +6,19 @@ use ACP3\Modules\ACP3\Menus;
use ACP3\Modules\ACP3\Seo\Validation\ValidationRules\UriAliasValidationRule;
/**
* Class Validator
* Class AdminFormValidation
* @package ACP3\Modules\ACP3\Articles\Validation
*/
class FormValidation extends Core\Validation\AbstractFormValidation
class AdminFormValidation extends Core\Validation\AbstractFormValidation
{
/**
* @var \ACP3\Core\ACL
*/
protected $acl;
/**
* @var string
*/
protected $uriAlias = '';
/**
* Validator constructor.
......@@ -34,13 +38,21 @@ class FormValidation extends Core\Validation\AbstractFormValidation
}
/**
* @param array $formData
* @param string $uriAlias
* @param $uriAlias
*
* @throws Core\Exceptions\InvalidFormToken
* @throws Core\Exceptions\ValidationFailed
* @return $this
*/
public function setUriAlias($uriAlias)
{
$this->uriAlias = $uriAlias;
return $this;
}
/**
* @inheritdoc
*/
public function validate(array $formData, $uriAlias = '')
public function validate(array $formData)
{
$this->validator
->addConstraint(Core\Validation\ValidationRules\FormTokenValidationRule::NAME)
......@@ -78,7 +90,7 @@ class FormValidation extends Core\Validation\AbstractFormValidation
'field' => 'alias',
'message' => $this->translator->t('seo', 'alias_unallowed_characters_or_exists'),
'extra' => [
'path' => $uriAlias
'path' => $this->uriAlias
]
]);
if ($this->acl->hasPermission('admin/menus/items/create') === true && isset($formData['create']) === true) {
......
......@@ -20,33 +20,40 @@ class Index extends Core\Modules\AdminController
*/
protected $categoriesCache;
/**
* @var \ACP3\Modules\ACP3\Categories\Validation\FormValidation
* @var \ACP3\Modules\ACP3\Categories\Validation\AdminFormValidation
*/
protected $categoriesValidator;
protected $adminFormValidation;
/**
* @var \ACP3\Modules\ACP3\Categories\Validation\AdminSettingsFormValidation
*/
protected $adminSettingsFormValidation;
/**
* @var Core\Helpers\FormToken
*/
protected $formTokenHelper;
/**
* @param \ACP3\Core\Modules\Controller\AdminContext $context
* @param \ACP3\Modules\ACP3\Categories\Model\CategoryRepository $categoryRepository
* @param \ACP3\Modules\ACP3\Categories\Cache $categoriesCache
* @param \ACP3\Modules\ACP3\Categories\Validation\FormValidation $categoriesValidator
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
* @param \ACP3\Core\Modules\Controller\AdminContext $context
* @param \ACP3\Modules\ACP3\Categories\Model\CategoryRepository $categoryRepository
* @param \ACP3\Modules\ACP3\Categories\Cache $categoriesCache
* @param \ACP3\Modules\ACP3\Categories\Validation\AdminFormValidation $adminFormValidation
* @param \ACP3\Modules\ACP3\Categories\Validation\AdminSettingsFormValidation $adminSettingsFormValidation
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
*/
public function __construct(
Core\Modules\Controller\AdminContext $context,
Categories\Model\CategoryRepository $categoryRepository,
Categories\Cache $categoriesCache,
Categories\Validation\FormValidation $categoriesValidator,
Categories\Validation\AdminFormValidation $adminFormValidation,
Categories\Validation\AdminSettingsFormValidation $adminSettingsFormValidation,
Core\Helpers\FormToken $formTokenHelper)
{
parent::__construct($context);
$this->categoryRepository = $categoryRepository;
$this->categoriesCache = $categoriesCache;
$this->categoriesValidator = $categoriesValidator;
$this->adminFormValidation = $adminFormValidation;
$this->adminSettingsFormValidation = $adminSettingsFormValidation;
$this->formTokenHelper = $formTokenHelper;
}
......@@ -86,7 +93,10 @@ class Index extends Core\Modules\AdminController
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
$file = $this->request->getFiles()->get('picture');
$this->categoriesValidator->validate($formData, $file, $this->config->getSettings('categories'));
$this->adminFormValidation
->setFile($file)
->setSettings($this->config->getSettings('categories'))
->validate($formData);
$insertValues = [
'id' => '',
......@@ -197,7 +207,11 @@ class Index extends Core\Modules\AdminController
return $this->actionHelper->handleEditPostAction(function () use ($formData, $category, $id) {
$file = $this->request->getFiles()->get('picture');
$this->categoriesValidator->validate($formData, $file, $this->config->getSettings('categories'), $id);
$this->adminFormValidation
->setFile($file)
->setSettings($this->config->getSettings('categories'))
->setCategoryId($id)
->validate($formData);
$updateValues = [
'title' => Core\Functions::strEncode($formData['title']),
......@@ -293,7 +307,7 @@ class Index extends Core\Modules\AdminController
protected function _settingsPost(array $formData)
{
return $this->actionHelper->handleSettingsPostAction(function () use ($formData) {
$this->categoriesValidator->validateSettings($formData);
$this->adminSettingsFormValidation->validate($formData);
$data = [
'width' => (int)$formData['width'],
......
......@@ -3,7 +3,8 @@ parameters:
categories.cache.fqdn: 'ACP3\Modules\ACP3\Categories\Cache'
categories.helpers.fqdn: 'ACP3\Modules\ACP3\Categories\Helpers'
categories.model.categoryrepository.fqdn: 'ACP3\Modules\ACP3\Categories\Model\CategoryRepository'
categories.validator.fqdn: 'ACP3\Modules\ACP3\Categories\Validation\FormValidation'
categories.validator.fqdn: 'ACP3\Modules\ACP3\Categories\Validation\AdminFormValidation'
categories.validation.admin_settings_form_validation.fqdn: 'ACP3\Modules\ACP3\Categories\Validation\AdminSettingsFormValidation'
categories.validation.validation_rules.category_exists_validation_rule.fqdn: 'ACP3\Modules\ACP3\Categories\Validation\ValidationRules\CategoryExistsValidationRule'
categories.validation.validation_rules.duplicate_category_validation_rule.fqdn: 'ACP3\Modules\ACP3\Categories\Validation\ValidationRules\DuplicateCategoryValidationRule'
categories.installer.schema.fqdn: 'ACP3\Modules\ACP3\Categories\Installer\Schema'
......@@ -12,7 +13,13 @@ parameters:
services:
categories.controller.admin.index:
class: %categories.controller.admin.index.fqdn%
arguments: ['@core.context.admin', '@categories.model', '@categories.cache', '@categories.validator', '@core.helpers.formToken']
arguments:
- @core.context.admin
- @categories.model
- @categories.cache
- @categories.validator
- @categories.validation.admin_settings_form_validation
- @core.helpers.formToken
categories.model:
class: %categories.model.categoryrepository.fqdn%
......@@ -34,6 +41,10 @@ services:
class: %categories.validator.fqdn%
arguments: ['@core.lang', @core.validator, '@categories.model']
categories.validation.admin_settings_form_validation:
class: %categories.validation.admin_settings_form_validation.fqdn%
parent: core.validator.abstract
categories.validation.validation_rules.category_exists_validation_rule:
class: %categories.validation.validation_rules.category_exists_validation_rule.fqdn%
arguments: [@categories.helpers]
......
......@@ -6,15 +6,27 @@ use ACP3\Modules\ACP3\Categories\Model\CategoryRepository;
use ACP3\Modules\ACP3\Categories\Validation\ValidationRules\DuplicateCategoryValidationRule;
/**
* Class Validator
* Class AdminFormValidation
* @package ACP3\Modules\ACP3\Categories\Validation
*/
class FormValidation extends Core\Validation\AbstractFormValidation
class AdminFormValidation extends Core\Validation\AbstractFormValidation
{
/**
* @var \ACP3\Modules\ACP3\Categories\Model\CategoryRepository
*/
protected $categoryRepository;
/**
* @var array
*/
protected $file = [];
/**
* @var array
*/
protected $settings = [];
/**
* @var int
*/
protected $categoryId = 0;
/**
* Validator constructor.
......@@ -27,23 +39,49 @@ class FormValidation extends Core\Validation\AbstractFormValidation
Core\I18n\Translator $translator,
Core\Validation\Validator $validator,
CategoryRepository $categoryRepository
)
{
) {
parent::__construct($translator, $validator);
$this->categoryRepository = $categoryRepository;
}
/**
* @param array $formData
* @param null|array $file
* @param array $settings
* @param int|string $categoryId
* @param array $file
*
* @throws Core\Exceptions\InvalidFormToken
* @throws Core\Exceptions\ValidationFailed
* @return AdminFormValidation
*/
public function setFile($file)
{
$this->file = $file;
return $this;
}
/**
* @param array $settings
*
* @return AdminFormValidation
*/
public function setSettings($settings)
{
$this->settings = $settings;
return $this;
}
/**
* @param int $categoryId
*
* @return AdminFormValidation
*/
public function setCategoryId($categoryId)
{
$this->categoryId = $categoryId;
return $this;
}
/**
* @inheritdoc
*/
public function validate(array $formData, $file, array $settings, $categoryId = '')
public function validate(array $formData)
{
$this->validator
->addConstraint(Core\Validation\ValidationRules\FormTokenValidationRule::NAME)
......@@ -64,13 +102,13 @@ class FormValidation extends Core\Validation\AbstractFormValidation
->addConstraint(
Core\Validation\ValidationRules\PictureValidationRule::NAME,
[
'data' => $file,
'data' => $this->file,
'field' => 'picture',
'message' => $this->translator->t('categories', 'invalid_image_selected'),
'extra' => [
'width' => $settings['width'],
'height' => $settings['height'],
'filesize' => $settings['filesize'],
'width' => $this->settings['width'],
'height' => $this->settings['height'],
'filesize' => $this->settings['filesize'],
'required' => false
]
])
......@@ -81,8 +119,8 @@ class FormValidation extends Core\Validation\AbstractFormValidation
'field' => 'title',
'message' => $this->translator->t('categories', 'category_already_exists'),
'extra' => [
'module_id' => empty($categoryId) ? $formData['module'] : $this->categoryRepository->getModuleIdByCategoryId($categoryId),
'category_id' => $categoryId
'module_id' => empty($this->categoryId) ? $formData['module'] : $this->categoryRepository->getModuleIdByCategoryId($this->categoryId),
'category_id' => $this->categoryId
]
]);
......@@ -98,39 +136,4 @@ class FormValidation extends Core\Validation\AbstractFormValidation
$this->validator->validate();
}
/**
* @param array $formData
*
* @throws Core\Exceptions\InvalidFormToken
* @throws Core\Exceptions\ValidationFailed
*/
public function validateSettings(array $formData)
{
$this->validator
->addConstraint(Core\Validation\ValidationRules\FormTokenValidationRule::NAME)
->addConstraint(
Core\Validation\ValidationRules\IntegerValidationRule::NAME,
[
'data' => $formData,
'field' => 'width',
'message' => $this->translator->t('categories', 'invalid_image_width_entered')
])
->addConstraint(
Core\Validation\ValidationRules\IntegerValidationRule::NAME,
[
'data' => $formData,
'field' => 'height',
'message' => $this->translator->t('categories', 'invalid_image_height_entered')
])
->addConstraint(
Core\Validation\ValidationRules\IntegerValidationRule::NAME,
[
'data' => $formData,
'field' => 'filesize',
'message' => $this->translator->t('categories', 'invalid_image_filesize_entered')
]);
$this->validator->validate();
}
}
<?php
namespace ACP3\Modules\ACP3\Categories\Validation;
use ACP3\Core;
use ACP3\Core\Validation\AbstractFormValidation;
/**
* Class AdminSettingsFormValidation
* @package ACP3\Modules\ACP3\Categories\Validation
*/
class AdminSettingsFormValidation extends AbstractFormValidation
{
/**
* @inheritdoc
*/
public function validate(array $formData)
{
$this->validator
->addConstraint(Core\Validation\ValidationRules\FormTokenValidationRule::NAME)
->addConstraint(
Core\Validation\ValidationRules\IntegerValidationRule::NAME,
[
'data' => $formData,
'field' => 'width',
'message' => $this->translator->t('categories', 'invalid_image_width_entered')
])
->addConstraint(
Core\Validation\ValidationRules\IntegerValidationRule::NAME,
[
'data' => $formData,
'field' => 'height',
'message' => $this->translator->t('categories', 'invalid_image_height_entered')
])
->addConstraint(
Core\Validation\ValidationRules\IntegerValidationRule::NAME,
[
'data' => $formData,
'field' => 'filesize',
'message' => $this->translator->t('categories', 'invalid_image_filesize_entered')
]);
$this->validator->validate();
}
}
\ No newline at end of file
......@@ -18,9 +18,9 @@ class Details extends Core\Modules\AdminController
*/
protected $commentRepository;
/**
* @var \ACP3\Modules\ACP3\Comments\Validation\FormValidation
* @var \ACP3\Modules\ACP3\Comments\Validation\AdminFormValidation
*/
protected $commentsValidator;
protected $adminFormValidation;
/**
* @var \ACP3\Modules\ACP3\System\Model\ModuleRepository
*/
......@@ -35,23 +35,25 @@ class Details extends Core\Modules\AdminController
protected $emoticonsHelpers;
/**
* @param \ACP3\Core\Modules\Controller\AdminContext $context
* @param \ACP3\Modules\ACP3\Comments\Model\CommentRepository $commentRepository
* @param \ACP3\Modules\ACP3\Comments\Validation\FormValidation $commentsValidator
* @param \ACP3\Modules\ACP3\System\Model\ModuleRepository $systemModuleRepository
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
* Details constructor.
*
* @param \ACP3\Core\Modules\Controller\AdminContext $context
* @param \ACP3\Modules\ACP3\Comments\Model\CommentRepository $commentRepository
* @param \ACP3\Modules\ACP3\Comments\Validation\AdminFormValidation $adminFormValidation
* @param \ACP3\Modules\ACP3\System\Model\ModuleRepository $systemModuleRepository
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
*/
public function __construct(
Core\Modules\Controller\AdminContext $context,
Comments\Model\CommentRepository $commentRepository,
Comments\Validation\FormValidation $commentsValidator,
Comments\Validation\AdminFormValidation $adminFormValidation,
System\Model\ModuleRepository $systemModuleRepository,
Core\Helpers\FormToken $formTokenHelper)
{
parent::__construct($context);
$this->commentRepository = $commentRepository;
$this->commentsValidator = $commentsValidator;
$this->adminFormValidation = $adminFormValidation;
$this->systemModuleRepository = $systemModuleRepository;
$this->formTokenHelper = $formTokenHelper;
}
......@@ -219,7 +221,7 @@ class Details extends Core\Modules\AdminController
{
return $this->actionHelper->handleEditPostAction(
function () use ($formData, $comment, $id) {
$this->commentsValidator->validateEdit($formData);
$this->adminFormValidation->validate($formData);
$updateValues = [];
$updateValues['message'] = Core\Functions::strEncode($formData['message']);
......
......@@ -20,33 +20,35 @@ class Index extends Core\Modules\AdminController
*/
protected $commentRepository;
/**
* @var \ACP3\Modules\ACP3\Comments\Validation\FormValidation
* @var \ACP3\Modules\ACP3\Comments\Validation\AdminSettingsFormValidation
*/
protected $commentsValidator;
protected $adminSettingsFormValidation;
/**
* @var \ACP3\Core\Helpers\FormToken
*/
protected $formTokenHelper;
/**
* @param \ACP3\Core\Modules\Controller\AdminContext $context
* @param \ACP3\Core\Date $date
* @param \ACP3\Modules\ACP3\Comments\Model\CommentRepository $commentRepository
* @param \ACP3\Modules\ACP3\Comments\Validation\FormValidation $commentsValidator
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
* Index constructor.
*
* @param \ACP3\Core\Modules\Controller\AdminContext $context
* @param \ACP3\Core\Date $date
* @param \ACP3\Modules\ACP3\Comments\Model\CommentRepository $commentRepository
* @param \ACP3\Modules\ACP3\Comments\Validation\AdminSettingsFormValidation $adminSettingsFormValidation
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
*/
public function __construct(
Core\Modules\Controller\AdminContext $context,
Core\Date $date,
Comments\Model\CommentRepository $commentRepository,
Comments\Validation\FormValidation $commentsValidator,
Comments\Validation\AdminSettingsFormValidation $adminSettingsFormValidation,
Core\Helpers\FormToken $formTokenHelper)
{
parent::__construct($context);
$this->date = $date;
$this->commentRepository = $commentRepository;
$this->commentsValidator = $commentsValidator;
$this->adminSettingsFormValidation = $adminSettingsFormValidation;
$this->formTokenHelper = $formTokenHelper;
}
......@@ -142,7 +144,7 @@ class Index extends Core\Modules\AdminController
protected function _settingsPost(array $formData)
{
return $this->actionHelper->handleSettingsPostAction(function () use ($formData) {
$this->commentsValidator->validateSettings($formData);
$this->adminSettingsFormValidation->validate($formData);
$data = [
'dateformat' => Core\Functions::strEncode($formData['dateformat']),
......
......@@ -32,7 +32,7 @@ class Index extends Core\Modules\FrontendController
/**
* @var \ACP3\Modules\ACP3\Comments\Validation\FormValidation
*/
protected $commentsValidator;
protected $formValidation;
/**
* @var \ACP3\Modules\ACP3\Emoticons\Helpers
*/
......@@ -55,7 +55,7 @@ class Index extends Core\Modules\FrontendController
* @param \ACP3\Core\Date $date
* @param \ACP3\Core\Pagination $pagination
* @param \ACP3\Modules\ACP3\Comments\Model\CommentRepository $commentRepository
* @param \ACP3\Modules\ACP3\Comments\Validation\FormValidation $commentsValidator
* @param \ACP3\Modules\ACP3\Comments\Validation\FormValidation $formValidation
* @param \ACP3\Core\Helpers\FormToken $formTokenHelper
*/
public function __construct(
......@@ -63,7 +63,7 @@ class Index extends Core\Modules\FrontendController
Core\Date $date,
Core\Pagination $pagination,
Comments\Model\CommentRepository $commentRepository,
Comments\Validation\FormValidation $commentsValidator,
Comments\Validation\FormValidation $formValidation,
Core\Helpers\FormToken $formTokenHelper)
{
parent::__construct($context);
......@@ -71,7 +71,7 @@ class Index extends Core\Modules\FrontendController
$this->date = $date;
$this->pagination = $pagination;
$this->commentRepository = $commentRepository;
$this->commentsValidator = $commentsValidator;
$this->formValidation = $formValidation;
$this->formTokenHelper = $formTokenHelper;
}
......@@ -194,7 +194,9 @@ class Index extends Core\Modules\FrontendController
function () use ($formData, $module, $entryId) {
$ip = $this->request->getServer()->get('REMOTE_ADDR', '');
$this->commentsValidator->validateCreate($formData, $ip);
$this->formValidation
->setIpAddress($ip)
->validate($formData);
$insertValues = [