You are here

function _config_selector_ui_test_create_new_view in Configuration selector 8.2

Same name and namespace in other branches
  1. 8 tests/modules/config_selector_ui_test/config_selector_ui_test.install \_config_selector_ui_test_create_new_view()

Creates a new view based on the supplied params.

Parameters

string $new_id: The new view ID.

string $feature: The Configuration Selector feature to add it to.

string $description: The description text.

int $priority: The priority.

bool $status: The status.

array $view_data: The complete data for the view.

Return value

\Drupal\views\ViewEntityInterface The new view entity.

1 call to _config_selector_ui_test_create_new_view()
config_selector_ui_test_install in tests/modules/config_selector_ui_test/config_selector_ui_test.install
Implements hook_install().

File

tests/modules/config_selector_ui_test/config_selector_ui_test.install, line 43
The Configuration Selector UI Test module install methods.

Code

function _config_selector_ui_test_create_new_view($new_id, $feature, $description, $priority, $status, array $view_data) {
  $view_storage = \Drupal::entityTypeManager()
    ->getStorage('view');
  $view_data['id'] = $new_id;

  // Make life simple for testing and ensure the views are removed on uninstall.
  $view_data['dependencies']['enforced']['module'] = [
    'config_selector_ui_test',
  ];

  /** @var \Drupal\views\ViewEntityInterface $view */
  $view = $view_storage
    ->createFromStorageRecord($view_data);
  $view
    ->setStatus($status);
  $view
    ->setThirdPartySetting('config_selector', 'feature', $feature);
  $view
    ->setThirdPartySetting('config_selector', 'priority', $priority);
  $view
    ->set('label', $new_id);
  $view
    ->set('description', $description);
  $view
    ->save();
  return $view;
}