You are here

public function Menu::onDependencyRemoval in Workbench Access 8

Informs the plugin that a dependency of the scheme will be deleted.

@todo https://www.drupal.org/node/2579743 make part of a generic interface.

Parameters

array $dependencies: An array of dependencies that will be deleted keyed by dependency type.

Return value

bool TRUE if the workflow settings have been changed, FALSE if not.

Overrides AccessControlHierarchyBase::onDependencyRemoval

See also

\Drupal\Core\Config\ConfigEntityInterface::onDependencyRemoval()

File

src/Plugin/AccessControlHierarchy/Menu.php, line 329

Class

Menu
Defines a hierarchy based on a Menu.

Namespace

Drupal\workbench_access\Plugin\AccessControlHierarchy

Code

public function onDependencyRemoval(array $dependencies) {
  $bundles = array_diff($this->configuration['bundles'], array_reduce($dependencies['config'], function (array $carry, $item) {
    if (!$item instanceof NodeTypeInterface) {
      return $carry;
    }
    $carry[] = $item
      ->id();
    return $carry;
  }, []));
  $menus = array_diff($this->configuration['menus'], array_reduce($dependencies['config'], function (array $carry, $item) {
    if (!$item instanceof NodeTypeInterface) {
      return $carry;
    }
    $carry[] = $item
      ->id();
    return $carry;
  }, []));
  $changed = $menus != $this->configuration['menus'] || $bundles != $this->configuration['bundles'];
  $this->configuration['menus'] = $menus;
  $this->configuration['bundles'] = $bundles;
  return $changed;
}