Issue #2345867 by olli, Gábor Hojtsy: Remove node_row_node_view_preprocess_node() and dead code in the comment views wizard

8.0.x
Nathaniel Catchpole 2014-12-02 10:17:39 +00:00
parent 20799cf991
commit 0f4bceb1fa
5 changed files with 4 additions and 88 deletions

View File

@ -54,44 +54,11 @@ class Comment extends WizardPluginBase {
*/
protected function rowStyleOptions() {
$options = array();
$options['comment'] = $this->t('comments');
$options['entity:comment'] = $this->t('comments');
$options['fields'] = $this->t('fields');
return $options;
}
/**
* {@inheritdoc}
*/
protected function pageDisplayOptions(array $form, FormStateInterface $form_state) {
$display_options = parent::pageDisplayOptions($form, $form_state);
$row_plugin = $form_state->getValue(array('page', 'style', 'row_plugin'));
$row_options = $form_state->getValue(array('page', 'style', 'row_options'), array());
$this->display_options_row($display_options, $row_plugin, $row_options);
return $display_options;
}
/**
* Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::blockDisplayOptions().
*/
protected function blockDisplayOptions(array $form, FormStateInterface $form_state) {
$display_options = parent::blockDisplayOptions($form, $form_state);
$row_plugin = $form_state->getValue(array('block', 'style', 'row_plugin'));
$row_options = $form_state->getValue(array('block', 'style', 'row_options'), array());
$this->display_options_row($display_options, $row_plugin, $row_options);
return $display_options;
}
/**
* Set the row style and row style plugins to the display_options.
*/
protected function display_options_row(&$display_options, $row_plugin, $row_options) {
switch ($row_plugin) {
case 'comment':
$display_options['row']['type'] = 'entity:comment';
break;
}
}
/**
* Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayOptions().
*/

View File

@ -68,7 +68,7 @@ class WizardTest extends WizardTestBase {
$options[] = $item->attributes()->value;
}
}
$expected_options = array('comment', 'fields');
$expected_options = array('entity:comment', 'fields');
$this->assertEqual($options, $expected_options);
$view['id'] = strtolower($this->randomMachineName(16));

View File

@ -21,17 +21,6 @@ function node_views_data_alter(&$data) {
);
}
/**
* Implements hook_preprocess_node().
*/
function node_row_node_view_preprocess_node(&$variables) {
$options = $variables['view']->rowPlugin->options;
if (!$options['links']) {
unset($variables['content']['links']);
}
}
/**
* Implements hook_views_wizard().
*/

View File

@ -22,7 +22,7 @@ class RowPluginTest extends NodeTestBase {
*
* @var array
*/
public static $modules = array('node', 'comment');
public static $modules = array('node');
/**
* Views used by this test.
@ -31,13 +31,6 @@ class RowPluginTest extends NodeTestBase {
*/
public static $testViews = array('test_node_row_plugin');
/**
* Contains all comments keyed by node used by the test.
*
* @var array
*/
protected $comments;
/**
* Contains all nodes used by this test.
*
@ -49,10 +42,8 @@ class RowPluginTest extends NodeTestBase {
parent::setUp();
$this->drupalCreateContentType(array('type' => 'article'));
// Create comment field on article.
$this->container->get('comment.manager')->addDefaultField('node', 'article');
// Create two nodes, with 5 comments on all of them.
// Create two nodes.
for ($i = 0; $i < 2; $i++) {
$this->nodes[] = $this->drupalCreateNode(
array(
@ -67,36 +58,6 @@ class RowPluginTest extends NodeTestBase {
)
);
}
foreach ($this->nodes as $node) {
for ($i = 0; $i < 5; $i++) {
$this->comments[$node->id()][] = $this->drupalCreateComment(array('entity_id' => $node->id()));
}
}
}
/**
* Helper function to create a random comment.
*
* @param array $settings
* (optional) An associative array of settings for the comment, as used in
* entity_create().
*
* @return \Drupal\comment\Entity\Comment
* Returns the created and saved comment.
*/
public function drupalCreateComment(array $settings = array()) {
$settings += array(
'subject' => $this->randomMachineName(),
'entity_id' => $settings['entity_id'],
'field_name' => 'comment',
'entity_type' => 'node',
'comment_body' => $this->randomMachineName(40),
);
$comment = entity_create('comment', $settings);
$comment->save();
return $comment;
}
/**

View File

@ -227,7 +227,6 @@ function views_theme($existing, $type, $theme, $path) {
* node portion of the theme registry.
*/
function views_preprocess_node(&$variables) {
\Drupal::moduleHandler()->loadInclude('node', 'views.inc');
// The 'view' attribute of the node is added in
// \Drupal\views\Plugin\views\row\EntityRow::preRender().
if (!empty($variables['node']->view) && $variables['node']->view->storage->id()) {