function CommentManagerInterface::forbiddenMessage

Same name in other branches
  1. 8.9.x core/modules/comment/src/CommentManagerInterface.php \Drupal\comment\CommentManagerInterface::forbiddenMessage()
  2. 10 core/modules/comment/src/CommentManagerInterface.php \Drupal\comment\CommentManagerInterface::forbiddenMessage()
  3. 11.x core/modules/comment/src/CommentManagerInterface.php \Drupal\comment\CommentManagerInterface::forbiddenMessage()

Provides a message if posting comments is forbidden.

If authenticated users can post comments, a message is returned that prompts the anonymous user to log in (or register, if applicable) that redirects to entity comment form. Otherwise, no message is returned.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to which comments are attached to.

string $field_name: The field name on the entity to which comments are attached to.

Return value

string HTML for a "you can't post comments" notice.

1 method overrides CommentManagerInterface::forbiddenMessage()
CommentManager::forbiddenMessage in core/modules/comment/src/CommentManager.php
Provides a message if posting comments is forbidden.

File

core/modules/comment/src/CommentManagerInterface.php, line 60

Class

CommentManagerInterface
Comment manager contains common functions to manage comment fields.

Namespace

Drupal\comment

Code

public function forbiddenMessage(EntityInterface $entity, $field_name);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.