Skip to content

Instantly share code, notes, and snippets.

@grom358 grom358/generate_dep.php
Last active Aug 29, 2015

Embed
What would you like to do?
Generate dependency listing for install profile
<?php
/**
* Root directory of Drupal installation.
*/
define('DRUPAL_ROOT', getcwd());
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$files = system_rebuild_module_data();
function dep_resolve($modules, $module_name, &$resolved, &$unresolved) {
$unresolved[$module_name] = TRUE;
$node = $modules[$module_name];
$requires = array_keys($node->requires);
usort($requires, 'strnatcmp');
foreach ($requires as $edge) {
if (!array_key_exists($edge, $resolved)) {
if (array_key_exists($edge, $unresolved)) {
//throw new \Exception('Circular reference detected: ' . $module_name . ' -> ' . $edge);
}
else {
dep_resolve($modules, $edge, $resolved, $unresolved);
}
}
}
$resolved[$module_name] = $modules[$module_name];
unset($unresolved[$module_name]);
}
$resolved = array();
$unresolved = array();
dep_resolve($files, 'uq_school', $resolved, $unresolved);
$required = drupal_required_modules();
$order = array();
foreach ($resolved as $module) {
$order[] = $module->name;
}
$order = array_diff($order, $required, array('wysiwyg'));
foreach ($order as $module) {
echo 'dependencies[] = ', $module, PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.