You are here

public function RoleSplitFilter::filterDelete in Config Role Split 8

File

src/Plugin/ConfigFilter/RoleSplitFilter.php, line 95

Class

RoleSplitFilter
Provides a RoleSplitFilter.

Namespace

Drupal\config_role_split\Plugin\ConfigFilter

Code

public function filterDelete($name, $delete) {
  if (!$this
    ->isManagedRole($name)) {
    return parent::filterDelete($name, $delete);
  }
  if (in_array($this
    ->getPluginProperty('mode', 'split'), [
    'fork',
    'exclude',
  ])) {

    // We do not remove the role, this may lead to roles not being removed
    // when they should be because there is still a filter that manages it
    // even though the role was deleted from the active storage.
    // To solve this we would have to inject the active storage and perform an
    // exists($name) call on it to see if it should be kept.
    return FALSE;
  }
  return $delete;
}