Skip to content

Commit

Permalink
TASK: Adjust logging for Neos 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellienert committed Oct 16, 2019
1 parent 994ac99 commit aaf92dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Classes/Finishers/SpamDetectionFinisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
*/

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Log\SystemLoggerInterface;
use Neos\Flow\Log\Utility\LogEnvironment;
use Neos\Form\Core\Model\AbstractFinisher;
use Psr\Log\LoggerInterface;

class SpamDetectionFinisher extends AbstractFinisher
{
Expand All @@ -28,7 +29,7 @@ class SpamDetectionFinisher extends AbstractFinisher

/**
* @Flow\Inject
* @var SystemLoggerInterface
* @var LoggerInterface
*/
protected $logger;

Expand All @@ -54,14 +55,14 @@ protected function executeInternal()

if ($isSpam) {
$formRuntime->getFormState()->setFormValue('spamDetected', $isSpam);
$this->logger->log(sprintf('The submitted form was detected as spam, as the honeypot form field %s was filled.', implode(', ', $filledOutHoneypotFields)), LOG_INFO);
$this->logger->info(sprintf('The submitted form was detected as spam, as the honeypot form field %s was filled.', implode(', ', $filledOutHoneypotFields)), LogEnvironment::fromMethodName(__METHOD__));

$formRuntime->getFormState()->setFormValue('spamMarker', '[SPAM]');
$formRuntime->getFormState()->setFormValue('spamFilledOutHoneypotFields', implode(', ', $filledOutHoneypotFields));

if ($this->cancelSubsequentFinishersOnSpamDetection) {
$this->finisherContext->cancel();
$this->logger->log('Subsequent finishers are cancelled due to spam detection.', LOG_INFO);
$this->logger->info('Subsequent finishers are cancelled due to spam detection.', LogEnvironment::fromMethodName(__METHOD__));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"license": "MIT",
"require": {
"neos/neos": ">3.0",
"neos/neos": "^4.1",
"neos/form-builder": "*",
"neos/form-fusionrenderer": "*"
},
Expand Down

0 comments on commit aaf92dd

Please sign in to comment.