acsf_sj.install in Acquia Cloud Site Factory Connector 8.2
Same filename and directory in other branches
Provides requirements for installing the ACSF Scheduled Jobs module.
File
acsf_sj/acsf_sj.installView source
<?php
/**
* @file
* Provides requirements for installing the ACSF Scheduled Jobs module.
*/
use Symfony\Component\Process\Process;
/**
* Implements hook_requirements().
*/
function acsf_sj_requirements($phase) {
$requirements = [];
if ($phase == 'install' || $phase == 'runtime') {
$binary_path = _acsf_sj_install_get_sjadd_path();
if ($binary_path == NULL) {
$requirements['acsf_sj_sjadd'] = [
'title' => 'ACSF SJ binary',
'severity' => REQUIREMENT_WARNING,
'description' => 'The installation path for the ACSF SJ binary cannot be determined.',
];
}
elseif (!is_executable($binary_path)) {
$requirements['acsf_sj_sjadd'] = [
'title' => 'ACSF SJ binary validation',
'severity' => REQUIREMENT_WARNING,
'description' => "{$binary_path} is not executable.",
];
}
else {
$process = new Process($binary_path);
$success = FALSE;
$message = '';
try {
$process
->run();
$stdout = $process
->getOutput();
$stderr = $process
->getErrorOutput();
if (strpos($stderr, "Usage: {$binary_path}") !== FALSE) {
$success = TRUE;
}
else {
$message = 'exit code: ' . $process
->getExitCode() . "\nstdout: {$stdout}\nstderr: {$stderr}";
}
} catch (\Exception $e) {
$message = $e
->getMessage();
$success = FALSE;
}
if (!$success) {
$requirements['acsf_sj_sjadd_execution'] = [
'title' => 'ACSF SJ sjadd execution',
'severity' => REQUIREMENT_WARNING,
'description' => 'The binary "sjadd" cannot be executed: ' . $message,
];
}
}
}
return $requirements;
}
/**
* Returns the path to the sjadd binary.
*
* @return string|null
* Returns sjadd path if $HOME exists, NULL otherwise.
*/
function _acsf_sj_install_get_sjadd_path() {
return isset($_ENV['HOME']) ? $_ENV['HOME'] . '/acquia_sj/sjadd' : NULL;
}
Functions
Name | Description |
---|---|
acsf_sj_requirements | Implements hook_requirements(). |
_acsf_sj_install_get_sjadd_path | Returns the path to the sjadd binary. |