public function NodeViewBuilder::createView in Views Templates 8
Create a View. Don't save it.
Parameters
mixed $options: Options to create a view.
Return value
\Drupal\views\ViewEntityInterface Returns a view.
Overrides ViewsBuilderBase::createView
File
- tests/
modules/ views_templates_builder_test/ src/ Plugin/ ViewsTemplateBuilder/ NodeViewBuilder.php, line 24
Class
- NodeViewBuilder
- Test comment.
Namespace
Drupal\views_templates_builder_test\Plugin\ViewsTemplateBuilderCode
public function createView($options = NULL) {
$view = parent::createView($options);
$display_options = $view
->getDisplay('default');
$display_options['fields']['title']['id'] = 'title';
$display_options['fields']['title']['table'] = 'node_field_data';
$display_options['fields']['title']['field'] = 'title';
$display_options['fields']['title']['entity_type'] = 'node';
$display_options['fields']['title']['entity_field'] = 'title';
$display_options['fields']['title']['label'] = '';
$display_options['fields']['title']['alter']['alter_text'] = 0;
$display_options['fields']['title']['alter']['make_link'] = 0;
$display_options['fields']['title']['alter']['absolute'] = 0;
$display_options['fields']['title']['alter']['trim'] = 0;
$display_options['fields']['title']['alter']['word_boundary'] = 0;
$display_options['fields']['title']['alter']['ellipsis'] = 0;
$display_options['fields']['title']['alter']['strip_tags'] = 0;
$display_options['fields']['title']['alter']['html'] = 0;
$display_options['fields']['title']['hide_empty'] = 0;
$display_options['fields']['title']['empty_zero'] = 0;
$display_options['fields']['title']['settings']['link_to_entity'] = 1;
$display_options['fields']['title']['plugin_id'] = 'field';
// $executable = $view->getExecutable();
// Display: Master
// $default_display = $executable->newDisplay('default', 'Master',
// 'default');
$view
->addDisplay('page');
/*
foreach ($display_options['default'] as $option => $value) {
$master->setOption($option, $value);
}
*/
// $executable->save();
return $view;
}