public function RoleSplitFilter::filterWrite in Config Role Split 8
File
- src/
Plugin/ ConfigFilter/ RoleSplitFilter.php, line 48
Class
- RoleSplitFilter
- Provides a RoleSplitFilter.
Namespace
Drupal\config_role_split\Plugin\ConfigFilterCode
public function filterWrite($name, array $data) {
if (!$this
->isManagedRole($name)) {
return parent::filterWrite($name, $data);
}
$id = $data['id'];
switch ($this
->getPluginProperty('mode', 'split')) {
case 'split':
// Remove the permissions when exporting.
$data['permissions'] = array_diff($data['permissions'], $this
->getPermissions($data['id']));
sort($data['permissions']);
break;
case 'fork':
// Remove the permissions from exporting that are not already exported.
$permissions = array_diff($this
->getPermissions($id), $this
->getSourcePermissions($id));
$data['permissions'] = array_diff($data['permissions'], $permissions);
sort($data['permissions']);
break;
case 'exclude':
// Add the permissions from the config if they are already exported.
$permissions = array_intersect($this
->getPermissions($id), $this
->getSourcePermissions($id));
$data['permissions'] = $this
->mergePermissions($data['permissions'], $permissions);
break;
}
return $data;
}