You are here

workbench_access.api.php in Workbench Access 8

Same filename and directory in other branches
  1. 7 workbench_access.api.php

API documentation for Workbench Access.

File

workbench_access.api.php
View source
<?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,
    ];
  }
}

Functions

Namesort descending Description
hook_workbench_access_scheme_update_alter Converts scheme settings to use the AccessScheme entity type.