Skip to content

Instantly share code, notes, and snippets.

@derhasi
Created June 8, 2016 08:25
Show Gist options
  • Save derhasi/2bdd3f920e5dd1046845836ded3e3a5f to your computer and use it in GitHub Desktop.
Save derhasi/2bdd3f920e5dd1046845836ded3e3a5f to your computer and use it in GitHub Desktop.
Add Drupal Project key to every .info file
<?php
/**
* @var SplFileInfo $path
* @var SplFileInfo $file
*/
foreach(new DirectoryIterator(__DIR__ . '/sites/all/modules/contrib') as $path) {
$projectname = $path->getFilename();
echo $path->getPathname() . "\n";
foreach (new DirectoryIterator($path->getPathname()) as $file) {
if ($file->isDir()) {
continue;
}
if ($file->getExtension() == 'info') {
if (file_put_contents($file->getPathname(), sprintf("\nproject = \"%s\"", $projectname), FILE_APPEND)) {
echo sprintf('Added project name "%s" to "%s"' . "\n", $projectname, $file->getPathname());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment