function _media_entity_fix_dependencies in Media entity 8.2
Helper function to rename config dependencies.
Parameters
string $dependency_type: The type of the dependency, such as "module" or "config".
string $dependency_id: The name of the dependency to be updated.
callable $map: A callback to be passed to array_map() to actually perform the config name substitution.
1 call to _media_entity_fix_dependencies()
- media_entity_update_8201 in ./
media_entity.install - Replace Media Entity with Media.
File
- ./
media_entity.install, line 100 - Install, uninstall and update hooks for Media entity module.
Code
function _media_entity_fix_dependencies($dependency_type, $dependency_id, callable $map) {
$dependents = \Drupal::service('config.manager')
->findConfigEntityDependents($dependency_type, [
$dependency_id,
]);
$key = 'dependencies.' . $dependency_type;
foreach (array_keys($dependents) as $config) {
$config = \Drupal::configFactory()
->getEditable($config);
$dependencies = $config
->get($key);
if (is_array($dependencies)) {
$config
->set($key, array_map($map, $dependencies))
->save();
}
}
}