protected static function SocialApiImplementerInstaller::readPackages in Social API 3.x
Same name and namespace in other branches
- 8.2 src/Utility/SocialApiImplementerInstaller.php \Drupal\social_api\Utility\SocialApiImplementerInstaller::readPackages()
- 8 src/Utility/SocialApiImplementerInstaller.php \Drupal\social_api\Utility\SocialApiImplementerInstaller::readPackages()
Reads and parses Drupal installed.json.
Return value
array|bool Parsed installed.json if the file could be read and parsed. False otherwise.
1 call to SocialApiImplementerInstaller::readPackages()
- SocialApiImplementerInstaller::checkLibrary in src/
Utility/ SocialApiImplementerInstaller.php - Checks the library required by an implementer.
File
- src/
Utility/ SocialApiImplementerInstaller.php, line 76
Class
- SocialApiImplementerInstaller
- Provides utilities for implementer installation.
Namespace
Drupal\social_api\UtilityCode
protected static function readPackages() {
// Make this test compatible with either regular installs.
// Check whether DRUPAL_ROOT is the actual website filesystem root or /web/
// subdirectory in case of composer drupal-scaffold.
$base_dir = is_dir(DRUPAL_ROOT . '/vendor') ? DRUPAL_ROOT : dirname(DRUPAL_ROOT);
$file_uri = $base_dir . '/vendor/composer/installed.json';
if (file_exists($file_uri)) {
$filedata = file_get_contents($file_uri);
if ($filedata) {
$json = json_decode($filedata, TRUE);
if ($json !== NULL) {
return $json;
}
}
}
return FALSE;
}