Skip to content

Instantly share code, notes, and snippets.

@markfullmer
Last active March 21, 2024 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markfullmer/cf700027e2ef8c112ac1c5c353bce762 to your computer and use it in GitHub Desktop.
Save markfullmer/cf700027e2ef8c112ac1c5c353bce762 to your computer and use it in GitHub Desktop.
Make all Drupal modules nominally Drupal 11 compatible
<?php
// @codingStandardsIgnoreFile
// NOTE: THIS CAN BE ACHIEVED WITH drupal/backward_compatibility
function find_info_files($dir) {
$root = scandir($dir);
$result = [];
foreach ($root as $value) {
if ($value === '.' || $value === '..') {
continue;
}
if (is_file("$dir/$value")) {
if (str_ends_with($value, '.info.yml')) {
$file = file_get_contents("$dir/$value");
$drupal11_file = preg_replace('/(core_version_requirement:) (.*)/', '$1 ^11', $file);
file_put_contents("$dir/$value", $drupal11_file);
$result[]="$dir/$value";
}
continue;
}
// Recurse.
foreach (find_info_files("$dir/$value") as $value) {
$result[]=$value;
}
}
return $result;
}
$webroot = 'web/';
$modules = find_info_files($webroot . "modules");
print_r($modules);
$profiles = find_info_files($webroot . "profiles/custom");
print_r($profiles);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment