Skip to content
Snippets Groups Projects
Commit 09183ab6 authored by Damian Lee's avatar Damian Lee Committed by Tim Plunkett
Browse files

Issue #1804178 by damiankloip: Add views_create_view() wrapper function and...

Issue #1804178 by damiankloip: Add views_create_view() wrapper function and update view creation code in instantiate_plugin() method of WizardPluginBase.
parent c2874636
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -543,18 +543,19 @@ protected function build_sorts(&$form, &$form_state) {
/**
* Instantiates a view object from form values.
*
* @return Drupal\views\ViewExecutable
* The instantiated view object.
* @return Drupal\views_ui\ViewUI
* The instantiated view UI object.
*/
protected function instantiate_view($form, &$form_state) {
// Build the basic view properties.
$view = views_new_view();
$view->name = $form_state['values']['name'];
$view->human_name = $form_state['values']['human_name'];
$view->description = $form_state['values']['description'];
$view->tag = 'default';
$view->core = VERSION;
$view->base_table = $this->base_table;
// Build the basic view properties and create the view.
$values = array(
'name' => $form_state['values']['name'],
'human_name' => $form_state['values']['human_name'],
'description' => $form_state['values']['description'],
'base_table' => $this->base_table,
);
$view = views_create_view($values);
// Build all display options for this view.
$display_options = $this->build_display_options($form, $form_state);
......
......@@ -1516,7 +1516,7 @@ function views_get_enabled_display_extenders() {
/**
* Create an empty view to work with.
*
* @return Drupal\views\ViewExecutable
* @return Drupal\views\ViewStorage
* A fully formed, empty $view object. This object must be populated before
* it can be successfully saved.
*/
......@@ -1524,6 +1524,16 @@ function views_new_view() {
return entity_create('view', array());
}
/**
* Creates a view from an array of values.
*
* @return Drupal\views\ViewStorage
* A fully formed $view object with properties from the values passed in.
*/
function views_create_view(array $values = array()) {
return entity_create('view', $values);
}
/**
* Return a list of all views and display IDs that have a particular
* setting in their display's plugin settings.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment