function config_perms_update_8201 in Custom Permissions 8.2
Updates the paths to its entities.
File
- ./
config_perms.install, line 6
Code
function config_perms_update_8201() {
$config_factory = \Drupal::configFactory();
/** @var \Drupal\Core\Path\PathValidator $path_validator */
$path_validator = \Drupal::service('path.validator');
foreach ($config_factory
->listAll('config_perms.custom_perms_entity.') as $custom_perm) {
/** @var \Drupal\Core\Config\Config $custom_perm */
$custom_perm = $config_factory
->getEditable($custom_perm);
$paths = config_perms_parse_path($custom_perm
->get('path'));
$perm_routes = [];
foreach ($paths as $path) {
if ($path && ($route = $path_validator
->getUrlIfValidWithoutAccessCheck($path))) {
$perm_routes[] = $route
->getRouteName();
}
}
$perm_routes = config_perms_parse_path($perm_routes);
if (empty($perm_routes)) {
continue;
}
$custom_perm
->set('route', $perm_routes);
$custom_perm
->clear('path');
$custom_perm
->save();
}
}