public static function SocialApiImplementerInstaller::checkLibrary in Social API 8.2
Same name and namespace in other branches
- 8 src/Utility/SocialApiImplementerInstaller.php \Drupal\social_api\Utility\SocialApiImplementerInstaller::checkLibrary()
- 3.x src/Utility/SocialApiImplementerInstaller.php \Drupal\social_api\Utility\SocialApiImplementerInstaller::checkLibrary()
Checks the library required by an implementer.
Parameters
string $machine_name: The module machine name.
string $name: The module name.
string $library: The library machine name.
float $min_version: The min version required.
float $max_version: The max version required.
Return value
array Requirements messages.
File
- src/
Utility/ SocialApiImplementerInstaller.php, line 27
Class
- SocialApiImplementerInstaller
- Provides utilities for implementer installation.
Namespace
Drupal\social_api\UtilityCode
public static function checkLibrary($machine_name, $name, $library, $min_version, $max_version) {
$sdk_found = FALSE;
$requirements = [];
$json = self::readPackages();
if ($json) {
// Loops through installed packages and check that the SDK version is OK.
foreach ($json as $package) {
if ($package['name'] == $library) {
$sdk_found = TRUE;
if ($package['version_normalized'] < $min_version || $package['version_normalized'] > $max_version) {
$requirements[$machine_name] = [
'description' => t("@name could not be installed because an incompatible version of @library was detected. Please read the installation instructions.", [
'@name' => $name,
'@library' => $library,
]),
'severity' => REQUIREMENT_ERROR,
];
}
break;
}
}
// SDK was not found in installed.json.
if (!$sdk_found) {
$requirements[$machine_name] = [
'description' => t("@name could not be installed because @library was not found. @name must be installed using Composer. Please read the installation instructions.", [
'@name' => $name,
'@library' => $library,
]),
'severity' => REQUIREMENT_ERROR,
];
}
}
else {
$requirements[$machine_name] = [
'description' => t('@name could not be installed: installed.json could not be read.', [
'@name' => $name,
]),
'severity' => REQUIREMENT_ERROR,
];
}
return $requirements;
}