public function Role::onDependencyRemoval in Workbench Email 8
Same name and namespace in other branches
- 2.x src/Plugin/RecipientType/Role.php \Drupal\workbench_email\Plugin\RecipientType\Role::onDependencyRemoval()
 
Informs the plugin that a dependency of the recipient type 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 template settings have been changed.
Overrides RecipientTypeBase::onDependencyRemoval
See also
\Drupal\Core\Config\ConfigEntityInterface::onDependencyRemoval()
File
- src/
Plugin/ RecipientType/ Role.php, line 129  
Class
- Role
 - Provides a recipient type of user role.
 
Namespace
Drupal\workbench_email\Plugin\RecipientTypeCode
public function onDependencyRemoval(array $dependencies) {
  $removed_roles = array_reduce($dependencies['config'], function (array $carry, $item) {
    if (!$item instanceof RoleInterface) {
      return $carry;
    }
    $carry[] = $item
      ->id();
    return $carry;
  }, []);
  if ($removed_roles && array_intersect($removed_roles, $this
    ->getRoles())) {
    $this
      ->setRoles(array_diff($this
      ->getRoles(), $removed_roles));
    return TRUE;
  }
  return FALSE;
}