public function MailhandlerComment::invoke in Mailhandler 8
File
- mailhandler_comment/src/Plugin/inmail/Handler/MailhandlerComment.php, line 73
Class
- MailhandlerComment
- Message handler that supports posting comments via email.
Namespace
Drupal\mailhandler_comment\Plugin\inmail\Handler
Code
public function invoke(MimeMessageInterface $message, ProcessorResultInterface $processor_result) {
try {
$result = $processor_result
->getAnalyzerResult();
if (!$result
->hasContext('entity_type') || $result
->getContext('entity_type')
->getContextValue()['entity_type'] != 'comment') {
return;
}
$comment = $this
->createComment($message, $result);
$processor_result
->log('CommentHandler', '@comment has been created by @user.', [
'@comment' => $comment
->label(),
'@user' => $comment
->getAuthorName(),
]);
} catch (\Exception $e) {
$processor_result
->log('CommentHandler', $e
->getMessage());
}
}