function entityconnect_requirements in Entity connect 7
Same name and namespace in other branches
- 7.2 entityconnect.install \entityconnect_requirements()
Implements hook_requirements().
File
- ./
entityconnect.install, line 11 - Install, update & uninstall functions for the Entity Connect module.
Code
function entityconnect_requirements($phase) {
$requirements = array();
switch ($phase) {
case 'install':
$t = get_t();
$path = drupal_get_path('module', 'entityconnect') . '/entityconnect.info';
$info = drupal_parse_info_file($path);
$requirements['entityconnect'] = array();
$requirements['entityconnect']['title'] = $info['name'];
$requirements['entityconnect']['value'] = $info['version'];
// At least one of the following modules is required in order for
// entityconnect to function properly.
$singularly_required_modules = array(
'entityreference',
'node_reference',
'user_reference',
);
// If this module is being installed as part of a Drupal installation,
// check for the existence of required modules without relying on the
// "module_exists()" function, which will always return false for these
// modules during a Drupal installation.
if (drupal_installation_attempted()) {
$files = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\\.info$/', 'modules', 'name', 0);
foreach ($singularly_required_modules as $module_name) {
if (isset($files[$module_name])) {
$requirements['entityconnect']['severity'] = REQUIREMENT_OK;
break;
}
}
}
else {
foreach ($singularly_required_modules as $module_name) {
if (module_exists($module_name)) {
$requirements['entityconnect']['severity'] = REQUIREMENT_OK;
break;
}
}
}
if (!isset($requirements['entityconnect']['severity'])) {
$requirements['entityconnect']['severity'] = REQUIREMENT_ERROR;
$requirements['entityconnect']['description'] = $t('Neither Entityreference nor References module is installed or activated.
Entityconnect needs at least one of those modules to work.');
}
break;
}
return $requirements;
}