Drupal 8  8.0.2
CommentController Class Reference
Inheritance diagram for CommentController:

Public Member Functions

 __construct (HttpKernelInterface $http_kernel, CommentManagerInterface $comment_manager, EntityManagerInterface $entity_manager)
 
 commentApprove (CommentInterface $comment)
 
 commentPermalink (Request $request, CommentInterface $comment)
 
 commentPermalinkTitle (CommentInterface $comment)
 
 redirectNode (EntityInterface $node)
 
 getReplyForm (Request $request, EntityInterface $entity, $field_name, $pid=NULL)
 
 replyFormAccess (EntityInterface $entity, $field_name, $pid=NULL)
 
 renderNewCommentsNodeLinks (Request $request)
 

Static Public Member Functions

static create (ContainerInterface $container)
 

Protected Attributes

 $httpKernel
 
 $commentManager
 
 $entityManager
 

Detailed Description

Controller for the comment entity.

See Also
.

Constructor & Destructor Documentation

__construct ( HttpKernelInterface  $http_kernel,
CommentManagerInterface  $comment_manager,
EntityManagerInterface  $entity_manager 
)

Constructs a CommentController object.

Parameters
\Symfony\Component\HttpKernel\HttpKernelInterface$http_kernelHTTP kernel to handle requests.
\Drupal\comment\CommentManagerInterface$comment_managerThe comment manager service.
\Drupal\Core\Entity\EntityManagerInterface$entity_managerThe entity manager service.

References Drupal\entityManager().

Here is the call graph for this function:

Member Function Documentation

commentApprove ( CommentInterface  $comment)

Publishes the specified comment.

Parameters
\Drupal\comment\CommentInterface$commentA comment entity.
Returns
. Redirects to the permalink URL for this comment.

References CommentInterface\permalink(), EntityInterface\save(), CommentInterface\setPublished(), and t().

Here is the call graph for this function:

commentPermalink ( Request  $request,
CommentInterface  $comment 
)

Redirects comment links to the correct page depending on comment settings.

Since comments are paged there is no way to guarantee which page a comment appears on. Comment paging and threading settings may be changed at any time. With threaded comments, an individual comment may move between pages as comments can be added either before or after it in the overall discussion. Therefore we use a central routing function for comment links, which calculates the page number based on current comment settings and returns the full comment view with the pager set dynamically.

Parameters
\Symfony\Component\HttpFoundation\Request$requestThe request of the page.
\Drupal\comment\CommentInterface$commentA comment entity.
Returns
The comment listing set to the page on which the comment appears.
Exceptions
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException

References Drupal\entityManager(), CommentInterface\getCommentedEntity(), and CommentInterface\getFieldName().

Here is the call graph for this function:

commentPermalinkTitle ( CommentInterface  $comment)

The _title_callback for the page that renders the comment permalink.

Parameters
\Drupal\comment\CommentInterface$commentThe current comment.
Returns
string The translated comment subject.

References Drupal\entityManager().

Here is the call graph for this function:

static create ( ContainerInterface  $container)
static

{}

getReplyForm ( Request  $request,
EntityInterface  $entity,
  $field_name,
  $pid = NULL 
)

Form constructor for the comment reply form.

There are several cases that have to be handled, including:

  • replies to comments
  • replies to entities
Parameters
\Symfony\Component\HttpFoundation\Request$requestThe current request object.
\Drupal\Core\Entity\EntityInterface$entityThe entity this comment belongs to.
string$field_nameThe field_name to which the comment belongs.
int$pid(optional) Some comments are replies to other comments. In those cases, $pid is the parent comment's comment ID. Defaults to NULL.
Returns
array| An associative array containing:
  • An array for rendering the entity or parent comment.
    • comment_entity: If the comment is a reply to the entity.
    • comment_parent: If the comment is a reply to another comment.
  • comment_form: The comment form as a renderable array.
Exceptions
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException

References Drupal\currentUser(), Drupal\entityManager(), CommentItemInterface\HIDDEN, and t().

Here is the call graph for this function:

redirectNode ( EntityInterface  $node)

Redirects legacy node links to the new path.

Parameters
\Drupal\Core\Entity\EntityInterface$nodeThe node object identified by the legacy URL.
Returns
Redirects user to new url.
Exceptions
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
renderNewCommentsNodeLinks ( Request  $request)

Returns a set of nodes' last read timestamps.

Parameters
\Symfony\Component\HttpFoundation\Request$requestThe request of the page.
Returns
The JSON response.
Exceptions
\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
replyFormAccess ( EntityInterface  $entity,
  $field_name,
  $pid = NULL 
)

Access check for the reply form.

Parameters
\Drupal\Core\Entity\EntityInterface$entityThe entity this comment belongs to.
string$field_nameThe field_name to which the comment belongs.
int$pid(optional) Some comments are replies to other comments. In those cases, $pid is the parent comment's comment ID. Defaults to NULL.
Returns
An access result
Exceptions
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException

Load the parent comment.

References AccessResult\allowedIfHasPermission(), and Drupal\currentUser().

Here is the call graph for this function:


The documentation for this class was generated from the following file: