You are here

function bibcite_entity_update_8010 in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/bibcite_entity.install \bibcite_entity_update_8010()

Update bibcite views permissions.

File

modules/bibcite_entity/bibcite_entity.install, line 366
Module installation hooks implementation.

Code

function bibcite_entity_update_8010() {
  $config_factory = \Drupal::configFactory();

  // Update contributor admin view.
  $config = $config_factory
    ->getEditable('views.view.bibcite_contributor_admin');
  if ($displays = $config
    ->get('display')) {
    foreach ($displays as $name => $display) {
      if (isset($display['display_options']['access'])) {
        $displays[$name]['display_options']['access']['type'] = 'perm';
        $displays[$name]['display_options']['access']['options']['perm'] = 'administer bibcite_contributor';
      }
    }
    $config
      ->set('display', $displays);
    $config
      ->save(TRUE);
  }

  // Update keyword admin view.
  $config = $config_factory
    ->getEditable('views.view.bibcite_keyword_admin');
  if ($displays = $config
    ->get('display')) {
    foreach ($displays as $name => $display) {
      if (isset($display['display_options']['access'])) {
        $displays[$name]['display_options']['access']['type'] = 'perm';
        $displays[$name]['display_options']['access']['options']['perm'] = 'administer bibcite_keyword';
      }
    }
    $config
      ->set('display', $displays);
    $config
      ->save(TRUE);
  }

  // Update reference admin view.
  $config = $config_factory
    ->getEditable('views.view.bibcite_reference_admin');
  if ($displays = $config
    ->get('display')) {
    foreach ($displays as $name => $display) {
      if (isset($display['display_options']['access'])) {
        $displays[$name]['display_options']['access']['type'] = 'perm';
        $displays[$name]['display_options']['access']['options']['perm'] = 'administer bibcite_reference';
      }
    }
    $config
      ->set('display', $displays);
    $config
      ->save(TRUE);
  }
}