-
Notifications
You must be signed in to change notification settings - Fork 8
/
workbench_access.api.php
42 lines (39 loc) · 1.16 KB
/
workbench_access.api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
use Drupal\Core\Config\Config;
/**
* @file
* API documentation for Workbench Access.
*/
/**
* Converts scheme settings to use the AccessScheme entity type.
*
* @param array $settings
* An array of settings for the plugin. Likely empty. Be certain to only act
* on your plugin scheme.
*
* @param Drupal\Core\Config\Config $config
* Current data object for Workbench Access configuration.
*
* @return
* No return value. Modify $settings by reference to match the array defined
* by your plugin's implementation of
* AccessControlHierarchyInterface::defaultConfiguration().
*/
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,
];
}
}