#ISSUE 3346218 Add a different message on edit comment
adding diffrent message on edit post result of a comment
Merge request reports
Activity
added 1 commit
- c2af7013 - Use "Your comment has been posted." message for new comments
392 393 $this->messenger()->addStatus($this->t('Your comment has been queued for review by site administrators and will be published after approval.')); 393 394 } 394 395 } 395 else { 396 elseif ($insert) { 396 397 $this->messenger()->addStatus($this->t('Your comment has been posted.')); 397 398 } 399 else { 400 $this->messenger()->addStatus($this->t('Your comment has been updated.')); 401 } changed this line in version 7 of the diff
added 1 commit
- 6fd3dc70 - Make getStatusMessage() method to get message but their is cache ,I think...
added 1 commit
- 17684add - I just figure out $this->entity->isNew() return valid response where as...
368 /** 369 * {@inheritdoc} 370 */ 371 protected function getStatusMessage($insert,$comment){ 372 if (!$comment->isPublished()) { 373 if (!$this->currentUser->hasPermission('administer comments')) { 374 return $this->messenger()->addStatus($this->t('Your comment has been queued for review by site administrators and will be published after approval.')); 375 } 376 } 377 if ($insert) { 378 return $this->messenger()->addStatus($this->t('Your comment has been posted.')); 379 } 380 else { 381 return $this->messenger()->addStatus($this->t('Your comment has been updated.')); 382 } 383 } - Comment on lines +371 to +383
Some suggested improvements:
- Adding typehints
- Removing else, which is the point of the method, to simplify the code
- Return a message rather than setting it on the messenger, leave that to the calling code
372 protected function getStatusMessage($insert,$comment){ 373 if (!$comment->isPublished()) { 374 if (!$this->currentUser->hasPermission('administer comments')) { 375 return $this->messenger()->addStatus($this->t('Your comment has been queued for review by site administrators and will be published after approval.')); 376 } 377 } 378 if ($insert) { 379 return $this->messenger()->addStatus($this->t('Your comment has been posted.')); 380 } 381 else { 382 return $this->messenger()->addStatus($this->t('Your comment has been updated.')); 383 } 384 } 372 protected function getStatusMessage(bool $insert, CommentInterface $comment): TranslatableMarkup { 373 if (!$comment->isPublished()) { 374 if (!$this->currentUser->hasPermission('administer comments')) { 375 return $this->t('Your comment has been queued for review by site administrators and will be published after approval.'); 376 } 377 return $this->t('The comment draft was updated.'); 378 } 379 if ($insert) { 380 return $this->t('Your comment has been posted.'); 381 } 382 return $this->t('Your comment has been updated.'); 383 } Edited by Lee Rowlands
386 402 'link' => Link::fromTextAndUrl(t('View'), $comment->toUrl()->setOption('fragment', 'comment-' . $comment->id()))->toString(), 387 403 ]); 388 404 389 // Explain the approval queue if necessary. 390 if (!$comment->isPublished()) { 391 if (!$this->currentUser->hasPermission('administer comments')) { 392 $this->messenger()->addStatus($this->t('Your comment has been queued for review by site administrators and will be published after approval.')); 393 } 394 } 395 else { 396 $this->messenger()->addStatus($this->t('Your comment has been posted.')); 397 } 405 $this->getStatusMessage($insert,$comment); changed this line in version 9 of the diff
366 366 $form_state->setRebuild(); 367 367 } 368 368 369 /** 370 * {@inheritdoc} 371 */ 372 protected function getStatusMessage(bool $insert, CommentInterface $comment) { changed this line in version 12 of the diff
added 117 commits
-
0b459903...f4fc5940 - 105 commits from branch
project:10.0.x
- f4fc5940...6e6fa822 - 2 earlier commits
- 0f0d686c - changes test case
- 776dc1e1 - change test in commentPreviewTest
- 9388e209 - Use "Your comment has been posted." message for new comments
- 71ff8da2 - Revert testUserDelete
- fc3068f0 - Make getStatusMessage() method to get message but their is cache ,I think...
- 73eb3e38 - I just figure out $this->entity->isNew() return valid response where as...
- 67649847 - refactor code of getStatusMessage
- 8b129d46 - Corrected Custome command Failed error
- ac85519d - CCF corrected
- f3dc82dd - added TranslatableMarkup
Toggle commit list-
0b459903...f4fc5940 - 105 commits from branch
Please register or sign in to reply