Skip to content
Snippets Groups Projects
sophron.install 835 B
Newer Older

/**
 * @file
 * Sophron - MIME types management API.
 */

declare(strict_types=1);

/**
 * Implements hook_requirements().
 */
function sophron_requirements(string $phase) {
  if ($phase === 'runtime') {
    return \Drupal::service('sophron.mime_map.manager')->requirements($phase);
  }
  return [];
}

/**
 * Convert map commands to named schema.
 */
function sophron_update_8001() {
  $config = \Drupal::configFactory()->getEditable('sophron.settings');
  $commands = $config->get('map_commands');
  $converted_commands = [];
  foreach ($commands as $command) {
    $converted_command = [];
    $converted_command['method'] ??= $command[0];
    $converted_command['arguments'] ??= $command[1] ?? [];
    $converted_commands[] = $converted_command;
  }
  $config->set('map_commands', $converted_commands);
  $config->save();
}