Last active
March 21, 2024 20:40
-
-
Save markfullmer/cf700027e2ef8c112ac1c5c353bce762 to your computer and use it in GitHub Desktop.
Make all Drupal modules nominally Drupal 11 compatible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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