function WizardPluginBase::instantiateView

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php \Drupal\views\Plugin\views\wizard\WizardPluginBase::instantiateView()
  2. 10 core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php \Drupal\views\Plugin\views\wizard\WizardPluginBase::instantiateView()
  3. 11.x core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php \Drupal\views\Plugin\views\wizard\WizardPluginBase::instantiateView()

Instantiates a view object from form values.

Return value

\Drupal\views_ui\ViewUI The instantiated view UI object.

1 call to WizardPluginBase::instantiateView()
WizardPluginBase::validateView in core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php
Implements Drupal\views\Plugin\views\wizard\WizardInterface::validate().

File

core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php, line 687

Class

WizardPluginBase
Base class for Views wizard plugins.

Namespace

Drupal\views\Plugin\views\wizard

Code

protected function instantiateView($form, FormStateInterface $form_state) {
    // Build the basic view properties and create the view.
    $values = [
        'id' => $form_state->getValue('id'),
        'label' => $form_state->getValue('label'),
        'description' => $form_state->getValue('description'),
        'base_table' => $this->base_table,
        'langcode' => \Drupal::languageManager()->getDefaultLanguage()
            ->getId(),
    ];
    $view = View::create($values);
    // Build all display options for this view.
    $display_options = $this->buildDisplayOptions($form, $form_state);
    // Allow the fully built options to be altered. This happens before adding
    // the options to the view, so that once they are eventually added we will
    // be able to get all the overrides correct.
    $this->alterDisplayOptions($display_options, $form, $form_state);
    $this->addDisplays($view, $display_options, $form, $form_state);
    return new ViewUI($view);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.