phantomjs_capture.install in PhantomJS Capture 8
File
phantomjs_capture.install
View source
<?php
use Drupal\Component\Utility\Unicode;
function phantomjs_capture_install() {
$directory = file_default_scheme() . '://phantomjs';
$test_directory = file_default_scheme() . '://phantomjs/test';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS, TRUE);
file_prepare_directory($test_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS, TRUE);
}
function phantomjs_capture_requirements($phase) {
$requirements = [];
$enabled = _is_exec_enabled();
$url = "http://php.net/manual/en/function.exec.php";
if ($enabled) {
$message = t('The <a href=":url">exec()</a> command is available.', [
':url' => $url,
]);
}
else {
$message = t('The <a href=":url">exec()</a> command is not available or the user has no permission to use it, you will be unable to use the phantomjs binary.', [
':url' => $url,
]);
}
$requirements['phantomjs_capture'] = [
'title' => t('PhantomJS Capture'),
'value' => $message,
'severity' => $enabled ? REQUIREMENT_OK : REQUIREMENT_ERROR,
];
return $requirements;
}
function _is_exec_enabled() {
$safe_mode = ini_get('safe_mode');
if ($safe_mode && Unicode::strtolower($safe_mode) != 'off') {
return FALSE;
}
$disabled = explode(',', ini_get('disable_functions'));
return !in_array('exec', $disabled);
}