diff --git a/core/modules/comment/src/Plugin/views/row/CommentRow.php b/core/modules/comment/src/Plugin/views/row/CommentRow.php deleted file mode 100644 index 5256b56..0000000 --- a/core/modules/comment/src/Plugin/views/row/CommentRow.php +++ /dev/null @@ -1,56 +0,0 @@ - TRUE); - $options['view_mode']['default'] = 'full'; - return $options; - } - - /** - * {@inheritdoc} - */ - public function buildOptionsForm(&$form, FormStateInterface $form_state) { - parent::buildOptionsForm($form, $form_state); - - $form['links'] = array( - '#type' => 'checkbox', - '#title' => t('Display links'), - '#default_value' => $this->options['links'], - ); - } - - /** - * {@inheritdoc} - */ - public function render($row) { - $build = parent::render($row); - if (!$this->options['links']) { - unset($build['links']); - } - return $build; - } - -} diff --git a/core/modules/comment/src/Plugin/views/row/Rss.php b/core/modules/comment/src/Plugin/views/row/Rss.php index d24eefe..50354fb 100644 --- a/core/modules/comment/src/Plugin/views/row/Rss.php +++ b/core/modules/comment/src/Plugin/views/row/Rss.php @@ -32,7 +32,6 @@ protected function defineOptions() { $options = parent::defineOptions(); $options['view_mode'] = array('default' => 'default'); - $options['links'] = array('default' => FALSE, 'bool' => TRUE); return $options; } @@ -46,11 +45,6 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#options' => $this->options_form_summary_options(), '#default_value' => $this->options['view_mode'], ); - $form['links'] = array( - '#type' => 'checkbox', - '#title' => t('Display links'), - '#default_value' => $this->options['links'], - ); } public function preRender($result) { @@ -134,14 +128,8 @@ public function render($row) { $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $comment->rss_namespaces); } - // Hide the links if desired. - if (!$this->options['links']) { - hide($build['links']); - } - if ($view_mode != 'title') { - // We render comment contents and force links to be last. - $build['links']['#weight'] = 1000; + // We render comment contents. $item_text .= drupal_render($build); } diff --git a/core/modules/comment/src/Tests/CommentLinksTest.php b/core/modules/comment/src/Tests/CommentLinksTest.php index bc4f60d..e73a237 100644 --- a/core/modules/comment/src/Tests/CommentLinksTest.php +++ b/core/modules/comment/src/Tests/CommentLinksTest.php @@ -10,6 +10,7 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\comment\CommentInterface; +use Drupal\entity\Entity\EntityViewDisplay; /** * Basic comment links tests to ensure markup present. @@ -42,16 +43,7 @@ class CommentLinksTest extends CommentTestBase { public static $modules = array('views'); /** - * Tests comment links. - * - * The output of comment links depends on various environment conditions: - * - Various Comment module configuration settings, user registration - * settings, and user access permissions. - * - Whether the user is authenticated or not, and whether any comments exist. - * - * To account for all possible cases, this test creates permutations of all - * possible conditions and tests the expected appearance of comment links in - * each environment. + * Tests that comment links are output and can be hidden. */ public function testCommentLinks() { // Bartik theme alters comment links, so use a different theme. @@ -112,6 +104,27 @@ public function testCommentLinks() { } $this->assertLink('Add new comment'); } + + // Make sure we can hide node links. + entity_get_display('node', $this->node->bundle(), 'default') + ->removeComponent('links') + ->save(); + $this->drupalGet($this->node->url()); + $this->assertNoLink('1 comment'); + $this->assertNoLink('Add new comment'); + + // Visit the full node, make sure there are links for the comment. + $this->drupalGet($this->node->url()); + $this->assertText($comment->getSubject()); + $this->assertLink('Reply'); + + // Make sure we can hide comment links. + entity_get_display('comment', 'comment', 'default') + ->removeComponent('links') + ->save(); + $this->drupalGet($this->node->url()); + $this->assertText($comment->getSubject()); + $this->assertNoLink('Reply'); } } diff --git a/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_field_filters.yml b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_field_filters.yml index 692c5d5..cc8bc8e 100644 --- a/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_field_filters.yml +++ b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_field_filters.yml @@ -63,8 +63,7 @@ display: row: type: 'entity:comment' options: - links: true - view_mode: full + view_mode: default rendering_language: translation_language_renderer relationships: node: diff --git a/core/modules/node/src/Plugin/views/row/NodeRow.php b/core/modules/node/src/Plugin/views/row/NodeRow.php index c79691f..c8cd7c0 100644 --- a/core/modules/node/src/Plugin/views/row/NodeRow.php +++ b/core/modules/node/src/Plugin/views/row/NodeRow.php @@ -7,7 +7,6 @@ namespace Drupal\node\Plugin\views\row; -use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\row\EntityRow; /** @@ -31,22 +30,7 @@ protected function defineOptions() { $options['view_mode']['default'] = 'teaser'; - $options['links'] = array('default' => TRUE, 'bool' => TRUE); - return $options; } - /** - * {@inheritdoc} - */ - public function buildOptionsForm(&$form, FormStateInterface $form_state) { - parent::buildOptionsForm($form, $form_state); - - $form['links'] = array( - '#type' => 'checkbox', - '#title' => t('Display links'), - '#default_value' => $this->options['links'], - ); - } - } diff --git a/core/modules/node/src/Plugin/views/row/Rss.php b/core/modules/node/src/Plugin/views/row/Rss.php index 206489c..820f9fb 100644 --- a/core/modules/node/src/Plugin/views/row/Rss.php +++ b/core/modules/node/src/Plugin/views/row/Rss.php @@ -40,7 +40,6 @@ protected function defineOptions() { $options = parent::defineOptions(); $options['view_mode'] = array('default' => 'default'); - $options['links'] = array('default' => FALSE, 'bool' => TRUE); return $options; } @@ -147,14 +146,8 @@ public function render($row) { $this->view->style_plugin->namespaces += $xml_rdf_namespaces; } - // Hide the links if desired. - if (!$this->options['links']) { - hide($build['links']); - } - if ($display_mode != 'title') { - // We render node contents and force links to be last. - $build['links']['#weight'] = 1000; + // We render node contents. $item_text .= drupal_render($build); } diff --git a/core/modules/node/src/Tests/NodeLinksTest.php b/core/modules/node/src/Tests/NodeLinksTest.php new file mode 100644 index 0000000..f3873f5 --- /dev/null +++ b/core/modules/node/src/Tests/NodeLinksTest.php @@ -0,0 +1,46 @@ +drupalCreateNode(array( + 'type' => 'article', + 'promote' => NODE_PROMOTED, + )); + + // Links are displayed by default. + $this->drupalGet('node'); + $this->assertText($node->getTitle()); + $this->assertLink('Read more'); + + // Hide links. + entity_get_display('node', 'article', 'teaser') + ->removeComponent('links') + ->save(); + + $this->drupalGet('node'); + $this->assertText($node->getTitle()); + $this->assertNoLink('Read more'); + } +} diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 3294836..8b21373 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -247,11 +247,6 @@ function views_preprocess_node(&$variables) { $variables['page'] = FALSE; } } - - // Allow to alter comments and links based on the settings in the row plugin. - if (!empty($variables['view']->rowPlugin) && $variables['view']->rowPlugin->getPluginId() == 'entity:node') { - node_row_node_view_preprocess_node($variables); - } } /**