You are here

function _varbase_media_slick_media_fix_dependencies in Varbase Media 8.7

Same name and namespace in other branches
  1. 9.0.x varbase_media.install \_varbase_media_slick_media_fix_dependencies()

Helper function to rename slick_media config dependencies to slick.

Https://git.drupalcode.org/project/slick_media/-/blob/8.x-3.x/slick_media.install.

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 _varbase_media_slick_media_fix_dependencies()
varbase_media_update_8708 in ./varbase_media.install
Issue #3151898: Remove [Slick Media] module dependencies.

File

./varbase_media.install, line 450
Contains install and update for Varbase Media module.

Code

function _varbase_media_slick_media_fix_dependencies($dependency_type, $dependency_id, callable $map) {
  $dependents = \Drupal::service('config.manager')
    ->findConfigEntityDependents($dependency_type, [
    $dependency_id,
  ]);
  $key = 'dependencies.' . $dependency_type;
  $key2 = 'dependencies.enforced.' . $dependency_type;
  foreach (array_keys($dependents) as $name) {
    $config = \Drupal::configFactory()
      ->getEditable($name);
    $dependencies = $config
      ->get($key);
    if (is_array($dependencies)) {
      $config
        ->set($key, array_map($map, $dependencies));
    }
    $dependencies2 = $config
      ->get($key2);
    if (is_array($dependencies2)) {
      $config
        ->set($key2, array_map($map, $dependencies2));
    }
    $config
      ->save();
  }
}