function composer_manager_requirements in Composer Manager 6
Same name and namespace in other branches
- 8 composer_manager.install \composer_manager_requirements()
- 6.2 composer_manager.install \composer_manager_requirements()
- 7.2 composer_manager.install \composer_manager_requirements()
- 7 composer_manager.install \composer_manager_requirements()
Implements hook_requirements().
File
- ./
composer_manager.install, line 35 - Install, update, and uninstall functions for the Composer Manager module.
Code
function composer_manager_requirements($phase) {
if ('runtime' != $phase) {
return array();
}
$t = get_t();
$file_dir = variable_get('composer_manager_file_dir', file_directory_path() . '/composer');
$vendor_dir = composer_manager_vendor_dir();
$requirements = array(
'composer_manager' => array(
'title' => $t('Composer Manager'),
),
);
// Change the message slightly if we are on the package status page.
if ('admin/settings/composer-manager' == $_GET['q']) {
$instructions = $t('Run <code>drush composer-json-rebuild</code> on the command line or submit the <em>Rebuild composer.json file</em> button on this page to build the file.');
}
else {
$instructions = $t('Run <code>drush composer-json-rebuild</code> on the command line or submit the <em>Rebuild composer.json file</em> button on the <a href="@url">package status page</a> to build the file.', array(
'@url' => url('admin/settings/composer-manager'),
));
}
if (!file_exists($file_dir . '/composer.json')) {
$requirements['composer_manager']['value'] = $t('Missing composer.json file');
$requirements['composer_manager']['description'] = $t('The composer.json file was not found.') . '<br/>' . $instructions;
$requirements['composer_manager']['severity'] = REQUIREMENT_ERROR;
}
elseif (!json_decode(@file_get_contents($file_dir . '/composer.json'))) {
$requirements['composer_manager']['value'] = $t('Invalid composer.json file');
$requirements['composer_manager']['description'] = $t('The composer.json file is invalid.') . '<br/>' . $instructions;
$requirements['composer_manager']['severity'] = REQUIREMENT_ERROR;
}
elseif (!file_exists($vendor_dir . '/autoload.php')) {
$requirements['composer_manager']['value'] = $t('Dependencies not installed');
$args = array(
'!command' => 'install',
'@url' => url('http://drupal.org/project/composer_manager', array(
'absolute' => TRUE,
)),
);
$requirements['composer_manager']['description'] = $t('Composer\'s <code>!command</code> command must be run to generate the autoloader and install the required packages.<br/>Refer to the instructions on the <a href="@url" target="_blank">Composer Manager project page</a> for installing packages.', $args);
$requirements['composer_manager']['severity'] = REQUIREMENT_ERROR;
}
elseif ($packages = composer_manager_packages_to_install()) {
$requirements['composer_manager']['value'] = $t('Dependencies not installed');
$args = array(
'@packages' => join(', ', $packages),
'@url' => url('http://drupal.org/project/composer_manager', array(
'absolute' => TRUE,
)),
);
$requirements['composer_manager']['description'] = $t('The following packages must be installed: @packages<br/>Refer to the instructions on the <a href="@url" target="_blank">Composer Manager project page</a> for updating packages.', $args);
$requirements['composer_manager']['severity'] = REQUIREMENT_ERROR;
}
else {
$requirements['composer_manager']['value'] = $t('Dependencies installed');
$requirements['composer_manager']['description'] = $t('Visit the <a href="@url">package status page</a> to view the status of individual packages.', array(
'@url' => url('admin/settings/composer-manager'),
));
$requirements['composer_manager']['severity'] = REQUIREMENT_OK;
}
return $requirements;
}