From 1c6ba12da0a4c28b2f84e45126281c3aac57b637 Mon Sep 17 00:00:00 2001 From: Scott Earnest <73367195+searnest-e3@users.noreply.github.com> Date: Tue, 9 Aug 2022 07:56:37 -0600 Subject: [PATCH] ApiClient to get composer packages in V2 format. --- lib/ApiClient.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ApiClient.php b/lib/ApiClient.php index 641bfb84..e0a9deed 100755 --- a/lib/ApiClient.php +++ b/lib/ApiClient.php @@ -125,6 +125,11 @@ public function getClientId() $versionInfo = ""; $packages = json_decode(file_get_contents(__DIR__ . "/../../../../vendor/composer/installed.json"), true); + // Composer V2 has "packages" key at the top level with the packages. + if (array_key_exists('packages', $packages)) { + $packages = $packages['packages']; + } + foreach ($packages as $package) { if (isset($package['name']) && strcmp($package['name'], "cybersource/rest-client-php") == 0) {