You are here

public function RoleSplitFilter::filterRead in Config Role Split 8

1 call to RoleSplitFilter::filterRead()
RoleSplitFilter::filterReadMultiple in src/Plugin/ConfigFilter/RoleSplitFilter.php

File

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

Class

RoleSplitFilter
Provides a RoleSplitFilter.

Namespace

Drupal\config_role_split\Plugin\ConfigFilter

Code

public function filterRead($name, $data) {
  if (!$this
    ->isManagedRole($name)) {
    return parent::filterRead($name, $data);
  }
  $id = $data['id'];
  switch ($this
    ->getPluginProperty('mode', 'split')) {
    case 'split':
    case 'fork':

      // Merge the permissions.
      $data['permissions'] = $this
        ->mergePermissions($data['permissions'], $this
        ->getPermissions($id));
      break;
    case 'exclude':

      // Remove the permissions when reading.
      $data['permissions'] = array_diff($data['permissions'], $this
        ->getPermissions($id));
      sort($data['permissions']);
      break;
  }
  return $data;
}