function git_deploy_requirements in Git Deploy 7
Same name and namespace in other branches
- 8.2 git_deploy.install \git_deploy_requirements()
- 6.2 git_deploy.install \git_deploy_requirements()
- 6 git_deploy.install \git_deploy_requirements()
- 7.2 git_deploy.install \git_deploy_requirements()
Implements hook_requirements().
File
- ./
git_deploy.install, line 21 - Checks that site can get version information with Git.
Code
function git_deploy_requirements($phase) {
$requirements = array();
// Check for glip library.
if (module_exists('libraries')) {
$glip_path = libraries_get_path('glip') . '/lib/glip.php';
}
else {
$glip_path = variable_get('git_deploy_glip_path', 'sites/all/libraries/glip') . '/lib/glip.php';
}
$file_exists = file_exists($glip_path);
switch ($phase) {
case 'runtime':
if ($file_exists) {
// Check for glip library assertion bug.
try {
set_error_handler('git_deploy_glip_bug');
require_once $glip_path;
$author = new GitCommitStamp();
// This should be parsed without errors if PHP assertions are enabled.
$author
->unserialize('name <mail> 0 +0000');
} catch (ErrorException $e) {
$requirements['git_deploy_assert'] = array(
'title' => t('Assertions'),
'value' => t('Disabled'),
'description' => t('The glip library required by this version of Git Deploy uses PHP assertions for checking commit dates.'),
'severity' => REQUIREMENT_WARNING,
);
// Try to find the reason for the error.
if (version_compare(PHP_VERSION, '7', '<') && !ini_get('assert.active')) {
$directive = '<a href="https://php.net/manual/en/info.configuration.php#ini.assert.active">assert.active</a>';
}
elseif (ini_get('zend.assertions') != 1) {
$directive = '<a href="https://php.net/manual/en/ini.core.php#ini.zend.assertions">zend.assertions</a>';
}
// If we know the reason for the error, tell the user how to fix it.
if (isset($directive)) {
$requirements['git_deploy_assert']['description'] .= ' ' . t('Set !directive to 1 and reload PHP.', array(
'!directive' => $directive,
));
}
} finally {
restore_error_handler();
}
}
case 'install':
$requirements['git_deploy_glip'] = array(
'title' => t('glip library'),
'value' => $file_exists ? t('glip library exists.') : t('Git Deploy requires the glip library to function properly. The simplest way to install glip is by using using the Drush command <code>drush git-deploy-download</code>. Alternatively it can be acquired by methods found in <a href="!readme">README.txt</a>.', array(
'!readme' => url(drupal_get_path('module', 'git_deploy') . '/README.txt'),
)),
'description' => $file_exists ? '' : t('The glip library must be present to use Git Deploy.'),
'severity' => $file_exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
);
break;
}
return $requirements;
}