From 48e356fc9cd14c1941deab818a68ee7cc895a8b8 Mon Sep 17 00:00:00 2001 From: kGablo Date: Mon, 29 Jul 2024 15:35:55 +0200 Subject: [PATCH] Fixed package version info --- CHANGELOG.MD | 6 ++++++ tpay.php | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index b8f3319..1e242ed 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.9.4] + +### Fixed + +- Fixed package version info + ## [1.9.3] ### Added diff --git a/tpay.php b/tpay.php index c9df47c..c9a0317 100644 --- a/tpay.php +++ b/tpay.php @@ -141,7 +141,7 @@ public function __construct() { $this->name = 'tpay'; $this->tab = 'payments_gateways'; - $this->version = '1.9.3'; + $this->version = '1.9.4'; $this->author = 'Krajowy Integrator Płatności S.A.'; $this->need_instance = 0; $this->ps_versions_compliancy = [ @@ -190,7 +190,7 @@ public function buildInfo(): string "prestashop:%s|tpay-prestashop:%s|tpay-openapi-php:%s|PHP:%s", $this->getPrestaVersion(), $this->version, - \Composer\InstalledVersions::getPrettyVersion('tpay-com/tpay-openapi-php'), + $this->getPackageVersion(), phpversion() ); } @@ -481,4 +481,16 @@ private function getAuthTokenCacheKey() )) ); } + + private function getPackageVersion(): string + { + $dir = __DIR__ . '/composer.json'; + if (file_exists($dir)) { + $composerJson = json_decode(file_get_contents($dir), true)['require'] ?? []; + + return $composerJson['tpay-com/tpay-openapi-php']; + } + + return 'n/a'; + } }