diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index 04e1291..3462a31 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -29,7 +29,7 @@ function comment_uninstall() { variable_del('comment_subject_field_' . $node_type); } - // Remove states. + // Remove state setting. Drupal::state()->delete('comment.node_comment_statistics_scale'); } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 973bccb..824d0b2 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -9,14 +9,12 @@ * book page, etc. */ -use Drupal\node\NodeTypeInterface; +use Drupal\Core\Entity\EntityInterface; +use Drupal\comment\CommentInterface; use Drupal\entity\Entity\EntityDisplay; use Drupal\file\Entity\File; -use Drupal\Core\Entity\EntityInterface; use Drupal\node\NodeInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpKernel\HttpKernelInterface; +use Drupal\node\NodeTypeInterface; /** * Comment is awaiting approval. @@ -78,8 +76,6 @@ */ const COMMENT_NODE_OPEN = 2; -use Drupal\comment\Entity\Comment; - /** * Implements hook_help(). */ @@ -118,7 +114,7 @@ function comment_entity_bundle_info() { /** * Entity URI callback. */ -function comment_uri(Comment $comment) { +function comment_uri(CommentInterface $comment) { return array( 'path' => 'comment/' . $comment->id(), 'options' => array('fragment' => 'comment-' . $comment->id()), @@ -417,9 +413,9 @@ function comment_get_recent($number = 10) { /** * Calculates the page number for the first new comment. * - * @param $num_comments + * @param int $num_comments * Number of comments. - * @param $new_replies + * @param int $new_replies * Number of new replies. * @param \Drupal\Core\Entity\EntityInterface $node * The first new comment node. @@ -690,9 +686,9 @@ function comment_add(EntityInterface $node, $pid = NULL) { * * @param \Drupal\Core\Entity\EntityInterface $node * The node whose comment(s) needs rendering. - * @param $mode + * @param int $mode * The comment display mode; COMMENT_MODE_FLAT or COMMENT_MODE_THREADED. - * @param $comments_per_page + * @param int $comments_per_page * The amount of comments to display per page. * * @return @@ -811,7 +807,7 @@ function comment_prepare_thread(&$comments) { // A counter that helps track how indented we are. $divs = 0; - foreach ($comments as $key => $comment) { + foreach ($comments as $key => &$comment) { if ($first_new && $comment->new->value != MARK_READ) { // Assign the anchor only for the first new comment. This avoids duplicate // id attributes on a page. @@ -832,7 +828,6 @@ function comment_prepare_thread(&$comments) { $divs--; } } - $comments[$key] = $comment; } // The final comment must close up some hanging divs @@ -842,10 +837,10 @@ function comment_prepare_thread(&$comments) { /** * Generates an array for rendering a comment. * - * @param Drupal\comment\Comment $comment + * @param \Drupal\comment\CommentInterface $comment * The comment object. * @param $view_mode - * View mode, e.g. 'full', 'teaser'... + * (optional) View mode, e.g. 'full', 'teaser'... Defaults to 'full'. * @param $langcode * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. @@ -853,14 +848,14 @@ function comment_prepare_thread(&$comments) { * @return * An array as expected by drupal_render(). */ -function comment_view(Comment $comment, $view_mode = 'full', $langcode = NULL) { +function comment_view(CommentInterface $comment, $view_mode = 'full', $langcode = NULL) { return entity_view($comment, $view_mode, $langcode); } /** * Adds reply, edit, delete, etc. links, depending on user permissions. * - * @param Drupal\comment\Comment $comment + * @param \Drupal\comment\CommentInterface $comment * The comment object. * @param \Drupal\Core\Entity\EntityInterface $node * The node the comment is attached to. @@ -868,7 +863,7 @@ function comment_view(Comment $comment, $view_mode = 'full', $langcode = NULL) { * @return * A structured array of links. */ -function comment_links(Comment $comment, EntityInterface $node) { +function comment_links(CommentInterface $comment, EntityInterface $node) { $links = array(); if ($node->comment->value == COMMENT_NODE_OPEN) { if ($comment->access('delete')) { @@ -930,8 +925,9 @@ function comment_links(Comment $comment, EntityInterface $node) { * @param $view_mode * View mode, e.g. 'full', 'teaser'... * @param $langcode - * A string indicating the language field values are to be shown in. If no - * language is provided the current content language is used. + * (optional) A string indicating the language field values are to be shown + * in. If no language is provided the current content language is used. + * Defaults to NULL. * * @return * An array in the format expected by drupal_render(). @@ -1309,11 +1305,10 @@ function comment_load($cid, $reset = FALSE) { /** * Gets the number of new comments for the current user and the specified node. * - * @param $nid + * @param int $nid * Node ID to count comments for. - * @param $timestamp - * Time to count from (defaults to time of last user access - * to node). + * @param int $timestamp + * Time to count from (defaults to time of last user access to node). * * @return * The number of new comments or FALSE if the user is not logged in. @@ -1347,9 +1342,9 @@ function comment_num_new($nid, $timestamp = 0) { * Count the number of comments which appear before the comment we want to * display, taking into account display settings and threading. * - * @param $cid + * @param int $cid * The comment ID. - * @param $node_type + * @param string $node_type * The node type of the comment's parent. * * @return @@ -1391,9 +1386,9 @@ function comment_get_display_ordinal($cid, $node_type) { * Finds the correct page number for a comment taking into account display * and paging settings. * - * @param $cid + * @param int $cid * The comment ID. - * @param $node_type + * @param string $node_type * The node type the comment is attached to. * * @return @@ -1408,9 +1403,9 @@ function comment_get_display_page($cid, $node_type) { /** * Generates a comment preview. * - * @param Drupal\comment\Comment $comment + * @param \Drupal\comment\CommentInterface $comment */ -function comment_preview(Comment $comment) { +function comment_preview(CommentInterface $comment) { global $user; $preview_build = array(); @@ -1472,10 +1467,13 @@ function comment_preprocess_block(&$variables) { * This helper handles anonymous authors in addition to registered comment * authors. * + * @param \Drupal\comment\CommentInterface $comment + * The comment to which the author replied. + * * @return \Drupal\user\Entity\User * A user account, for use with theme_username() or the user_picture template. */ -function comment_prepare_author(Comment $comment) { +function comment_prepare_author(CommentInterface $comment) { // The account has been pre-loaded by CommentRenderController::buildContent(). $account = $comment->uid->entity; if (empty($account->uid->value)) { diff --git a/core/modules/comment/comment.pages.inc b/core/modules/comment/comment.pages.inc index d193132..cbeec18 100644 --- a/core/modules/comment/comment.pages.inc +++ b/core/modules/comment/comment.pages.inc @@ -6,9 +6,7 @@ */ use Drupal\Core\Entity\EntityInterface; -use Drupal\comment\Entity\Comment; use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; /** * Form constructor for the comment reply form. diff --git a/core/modules/comment/comment.routing.yml b/core/modules/comment/comment.routing.yml index 7768cd0..558ad38 100644 --- a/core/modules/comment/comment.routing.yml +++ b/core/modules/comment/comment.routing.yml @@ -19,6 +19,7 @@ comment_permalink: _controller: '\Drupal\comment\Controller\CommentController::commentPermalink' requirements: _entity_access: 'comment.view' + comment_confirm_delete: pattern: '/comment/{comment}/delete' defaults: diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc index 66e2083..f98fb40 100644 --- a/core/modules/comment/comment.views.inc +++ b/core/modules/comment/comment.views.inc @@ -98,7 +98,7 @@ function comment_views_data() { 'help' => t('Hostname of user that posted the comment.'), 'field' => array( 'id' => 'standard', - ), + ), 'filter' => array( 'id' => 'string', ), @@ -115,7 +115,7 @@ function comment_views_data() { 'help' => t('E-mail of user that posted the comment. Will be empty if the author is a registered user.'), 'field' => array( 'id' => 'standard', - ), + ), 'filter' => array( 'id' => 'string', ), diff --git a/core/modules/comment/lib/Drupal/comment/CommentInterface.php b/core/modules/comment/lib/Drupal/comment/CommentInterface.php index 456b957..fb9c043 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentInterface.php +++ b/core/modules/comment/lib/Drupal/comment/CommentInterface.php @@ -24,4 +24,5 @@ * UrlGenerator::generateFromPath(). */ public function permalink(); + } diff --git a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php index 3dc7f2c..b1dece7 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php @@ -9,8 +9,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\DatabaseStorageControllerNG; -use Drupal\Component\Uuid\Uuid; -use LogicException; /** * Defines the controller class for comments. @@ -44,10 +42,9 @@ protected function buildQuery($ids, $revision_id = FALSE) { */ protected function attachLoad(&$records, $load_revision = FALSE) { // Prepare standard comment fields. - foreach ($records as $key => $record) { + foreach ($records as $key => &$record) { $record->name = $record->uid ? $record->registered_name : $record->name; $record->node_type = 'comment_node_' . $record->node_type; - $records[$key] = $record; } parent::attachLoad($records, $load_revision); } @@ -127,4 +124,5 @@ public function getChildCids(array $comments) { ->execute() ->fetchCol(); } + } diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index f7ee85b..518c807 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -8,7 +8,6 @@ namespace Drupal\comment\Controller; use Drupal\comment\CommentInterface; -use Drupal\comment\Entity\Comment; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Routing\UrlGeneratorInterface; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php index 59c122b..14bbc7c 100644 --- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php @@ -55,7 +55,7 @@ class Comment extends EntityNG implements CommentInterface { /** * The comment ID. * - * @todo Rename to 'id'. + * @todo Rename to 'id'. https://drupal.org/node/2031935 * * @var \Drupal\Core\Entity\Field\FieldInterface */ @@ -69,9 +69,9 @@ class Comment extends EntityNG implements CommentInterface { public $uuid; /** - * The parent comment ID if this is a reply to a comment. + * The parent comment ID if this is a reply to another comment. * - * @todo: Rename to 'parent_id'. + * @todo: Rename to 'parent_id'. https://drupal.org/node/2031931 * * @var \Drupal\Core\Entity\Field\FieldInterface */ diff --git a/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php b/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php index fd86ddf..df6f464 100644 --- a/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php +++ b/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php @@ -9,7 +9,6 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\EntityNGConfirmFormBase; -use Symfony\Component\HttpFoundation\Request; /** * Provides the comment delete confirmation form.