function fb_autopost_requirements in Facebook Autopost 7
Implements hook_requirements().
File
- ./
fb_autopost.install, line 11 - Install file to support fb_autopost.module
Code
function fb_autopost_requirements($phase) {
$requirements = array();
// Ensure translations don't break at install time.
$t = get_t();
// Disable these checks at install time, because failure then causes more
// problems due to module dependencies and Drupal's poor handling of
// requirement errors.
if ($phase != 'runtime') {
return $requirements;
}
// Check for the presence of facebook-php-sdk library
// given that we are in the runtime phase we can assume that
// drupal has been fully loaded and we can use libraries helpers.
$machine = 'facebook-php-sdk';
$requirements[$machine] = array(
'title' => $t('Facebook PHP SDK'),
);
$lib_path = libraries_get_path($machine);
if (file_exists($lib_path . '/src/facebook.php')) {
// Inform that the library has been found and what is the version of it
// If there is no such file or we cannot find the version.
$warning_data = array(
'description' => $t('The Facebook PHP SDK library has been found but we could not verify the version.'),
'severity' => REQUIREMENT_WARNING,
);
if (!file_exists($lib_path . '/src/base_facebook.php')) {
$requirements[$machine] += $warning_data;
}
else {
require_once $lib_path . '/src/base_facebook.php';
// The file has been found, now check the version of it.
$matches = array();
// Facebook PHP SDK contains a constant in base_facebook.php with the
// version.
$version = BaseFacebook::VERSION;
if (!empty($version)) {
// Set the requirement OK.
$requirements[$machine] += array(
'value' => $version,
'severity' => REQUIREMENT_OK,
);
}
else {
// If there is no information about the version return a warning.
$requirements += $warning_data;
}
}
}
else {
// Set a requirement error.
$requirements[$machine] += array(
'severity' => REQUIREMENT_ERROR,
'description' => $t('The Facebook PHP SDK library has not been installed. Please clone the git repository or download the library in the common library paths from !link.', array(
'!link' => l($t('here'), 'https://github.com/facebook/facebook-php-sdk'),
)),
);
}
return $requirements;
}