workbench_access.install in Workbench Access 8
Same filename and directory in other branches
Install, update and uninstall functions for the Workbench Access module.
File
workbench_access.installView source
<?php
/**
 * @file
 * Install, update and uninstall functions for the Workbench Access module.
 */
/**
 * Add the setting to deny access to unassigned content.
 */
function workbench_access_update_8001() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('workbench_access.settings');
  $config
    ->set('deny_on_empty', 0);
  $config
    ->save(TRUE);
}
/**
 * Update to new access scheme config entity.
 */
function workbench_access_update_8002() {
  // Stash this for later.
  \Drupal::state()
    ->set('workbench_access_original_configuration', \Drupal::config('workbench_access.settings'));
  // Alter it to the new format.
  $config = \Drupal::configFactory()
    ->getEditable('workbench_access.settings');
  foreach ([
    'scheme',
    'label',
    'plural_label',
    'fields',
    'parents',
  ] as $delete) {
    $config
      ->clear($delete);
  }
  $config
    ->save(TRUE);
}
/**
 * Create the new access scheme entity type.
 */
function workbench_access_update_8003() {
  $entity_manager = \Drupal::entityTypeManager();
  $update_manager = \Drupal::entityDefinitionUpdateManager();
  // Install 'access_scheme' config entity.
  $entity_manager
    ->clearCachedDefinitions();
  $type = $entity_manager
    ->getDefinition('access_scheme');
  $update_manager
    ->installEntityType($type);
}
/**
 * Create the new section association entity type.
 */
function workbench_access_update_8004() {
  $entity_manager = \Drupal::entityTypeManager();
  $update_manager = \Drupal::entityDefinitionUpdateManager();
  // Install 'section_association' content entity.
  $entity_manager
    ->clearCachedDefinitions();
  $type = $entity_manager
    ->getDefinition('section_association');
  $update_manager
    ->installEntityType($type);
}Functions
| Name   | Description | 
|---|---|
| workbench_access_update_8001 | Add the setting to deny access to unassigned content. | 
| workbench_access_update_8002 | Update to new access scheme config entity. | 
| workbench_access_update_8003 | Create the new access scheme entity type. | 
| workbench_access_update_8004 | Create the new section association entity type. | 
