You are here

function samlauth_post_update_add_view_samlauth_map in SAML Authentication 8.3

Same name and namespace in other branches
  1. 4.x samlauth.post_update.php \samlauth_post_update_add_view_samlauth_map()

Imports new view for authmap entries.

File

./samlauth.post_update.php, line 15
Post update functions for the samlauth module.

Code

function samlauth_post_update_add_view_samlauth_map() {
  if (\Drupal::moduleHandler()
    ->moduleExists('views') && !View::load('samlauth_map')) {
    $module_path = \Drupal::moduleHandler()
      ->getModule('samlauth')
      ->getPath();
    $file_storage = new FileStorage($module_path . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY);
    $view = \Drupal::entityTypeManager()
      ->getStorage('view')
      ->create($file_storage
      ->read('views.view.samlauth_map'));
    $view
      ->save();
  }
}