You are here

function hook_workbench_access_scheme_update_alter in Workbench Access 8

Converts scheme settings to use the AccessScheme entity type.

Parameters

array $settings: An array of settings for the plugin. Likely empty. Be certain to only act on your plugin scheme.

Drupal\Core\Config\Config $config: Current data object for Workbench Access configuration.

Return value

No return value. Modify $settings by reference to match the array defined by your plugin's implementation of AccessControlHierarchyInterface::defaultConfiguration().

1 function implements hook_workbench_access_scheme_update_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

workbench_access_hooks_workbench_access_scheme_update_alter in tests/modules/workbench_access_hooks/workbench_access_hooks.module
Implements hook_workbench_access_scheme_update_alter().
2 invocations of hook_workbench_access_scheme_update_alter()
UpdatePathTest::testUpdatePath in tests/src/Functional/UpdatePathTest.php
Tests workbench_access_update_8002, 8003(), and 8004().
workbench_access_post_update_convert_to_scheme in ./workbench_access.post_update.php
Convert configuration into a scheme.

File

./workbench_access.api.php, line 25
API documentation for Workbench Access.

Code

function hook_workbench_access_scheme_update_alter(array &$settings, Config $config) {
  if ($config
    ->get('scheme') === 'my_plugin_scheme') {
    $fields = [];
    foreach ($config
      ->get('fields') as $entity_type => $field_info) {
      foreach (array_filter($field_info) as $bundle => $field_name) {
        $fields[] = [
          'entity_type' => $entity_type,
          'bundle' => $bundle,
          'field' => $field_name,
        ];
      }
    }
    $settings = [
      'my_scheme_type' => array_values($config
        ->get('parents')),
      'fields' => $fields,
    ];
  }
}