Skip to content

Commit

Permalink
[TASK] Make CommentFormFactory compatible with v12
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminkott committed May 22, 2023
1 parent ccd105e commit c61fb3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions Build/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ parameters:
- "#Casting to string something that's already string.#"
- "#Casting to int something that's already int.#"
- "#Casting to bool something that's already bool.#"
- "#^Call to an undefined method TYPO3\\\\CMS\\\\Extbase\\\\Validation\\\\Validator\\\\StringLengthValidator\\:\\:setOptions\\(\\)\\.$#"
- "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
- "#^Method TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\QueryInterface\\:\\:logicalAnd\\(\\) invoked with 2 parameters, 1 required\\.$#"
- "#^Method TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\QueryInterface\\:\\:logicalOr\\(\\) invoked with 2 parameters, 1 required\\.$#"
Expand Down
9 changes: 8 additions & 1 deletion Classes/Domain/Factory/CommentFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use T3G\AgencyPack\Blog\Domain\Finisher\CommentFormFinisher;
use T3G\AgencyPack\Blog\Domain\Validator\GoogleCaptchaValidator;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
Expand Down Expand Up @@ -90,7 +91,13 @@ public function build(array $configuration, string $prototypeName = null): FormD
$commentField = $page->createElement('comment', 'Textarea');
$commentField->setLabel((string) LocalizationUtility::translate('form.comment.comment', 'blog'));
$commentField->addValidator(GeneralUtility::makeInstance(NotEmptyValidator::class));
$commentField->addValidator(GeneralUtility::makeInstance(StringLengthValidator::class, ['minimum' => 5]));
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 12) {
$stringLengthValidator = GeneralUtility::makeInstance(StringLengthValidator::class, ['minimum' => 5]);
} else {
$stringLengthValidator = GeneralUtility::makeInstance(StringLengthValidator::class);
$stringLengthValidator->setOptions(['minimum' => 5]);
}
$commentField->addValidator($stringLengthValidator);

$explanationText = $page->createElement('explanation', 'StaticText');
$explanationText->setProperty('text', LocalizationUtility::translate('label.required.field', 'blog') . ' ' . LocalizationUtility::translate('label.required.field.explanation', 'blog'));
Expand Down

0 comments on commit c61fb3f

Please sign in to comment.