From 4fe6ed298014759ced325854c61afd2de914e03d Mon Sep 17 00:00:00 2001 From: Pavel Usachev Date: Thu, 20 Jul 2023 19:39:20 +0300 Subject: [PATCH 1/2] Magento 2.4.6 Compatibility - removed Zend classes - added Laminas classes instead Zend --- Gateway/Http/Client/Adapter/Rest.php | 22 +++++++++++----------- Gateway/Http/Client/ResponseFactory.php | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Gateway/Http/Client/Adapter/Rest.php b/Gateway/Http/Client/Adapter/Rest.php index c75d663..190e39c 100644 --- a/Gateway/Http/Client/Adapter/Rest.php +++ b/Gateway/Http/Client/Adapter/Rest.php @@ -18,9 +18,9 @@ namespace OnTap\MasterCard\Gateway\Http\Client\Adapter; use Magento\Framework\HTTP\Adapter\Curl; -use Zend_Http_Client; -use Zend_Uri_Exception; -use Zend_Uri_Http; +use Laminas\Http\Request; +use Laminas\Uri\Exception\InvalidUriException; +use Laminas\Uri\UriInterface; class Rest extends Curl { @@ -28,17 +28,17 @@ class Rest extends Curl * Send request to the remote server * * @param string $method - * @param Zend_Uri_Http|string $url + * @param UriInterface|string $url * @param string $httpVer * @param array $headers * @param string $body * @return string Request as text - * @throws Zend_Uri_Exception + * @throws InvalidUriException */ public function write($method, $url, $httpVer = '1.1', $headers = [], $body = '') { - if ($url instanceof Zend_Uri_Http) { - $url = $url->getUri(); + if ($url instanceof UriInterface) { + $url = (string)$url; } $this->_applyConfig(); @@ -47,15 +47,15 @@ public function write($method, $url, $httpVer = '1.1', $headers = [], $body = '' curl_setopt($this->_getResource(), CURLOPT_URL, $url); curl_setopt($this->_getResource(), CURLOPT_RETURNTRANSFER, true); - if ($method == Zend_Http_Client::POST) { + if ($method == Request::POST) { curl_setopt($this->_getResource(), CURLOPT_POST, true); curl_setopt($this->_getResource(), CURLOPT_POSTFIELDS, $body); $headers[] = 'Content-Length: ' . strlen($body); - } elseif ($method == Zend_Http_Client::PUT) { - curl_setopt($this->_getResource(), CURLOPT_CUSTOMREQUEST, Zend_Http_Client::PUT); + } elseif ($method == Request::PUT) { + curl_setopt($this->_getResource(), CURLOPT_CUSTOMREQUEST, Request::PUT); curl_setopt($this->_getResource(), CURLOPT_POSTFIELDS, $body); $headers[] = 'Content-Length: ' . strlen($body); - } elseif ($method == Zend_Http_Client::GET) { + } elseif ($method == Request::GET) { curl_setopt($this->_getResource(), CURLOPT_HTTPGET, true); } diff --git a/Gateway/Http/Client/ResponseFactory.php b/Gateway/Http/Client/ResponseFactory.php index f04a804..066f818 100644 --- a/Gateway/Http/Client/ResponseFactory.php +++ b/Gateway/Http/Client/ResponseFactory.php @@ -17,18 +17,18 @@ namespace OnTap\MasterCard\Gateway\Http\Client; -use Zend_Http_Response; +use Laminas\Http\Response; class ResponseFactory { /** - * Create a new Zend_Http_Response object from a string + * Create a new Response object from a string * * @param string $response - * @return Zend_Http_Response + * @return Response */ public function create($response) { - return Zend_Http_Response::fromString($response); + return Response::fromString($response); } } From 15ee59ced6ab534c543fcf3fb18ad0e187b3456c Mon Sep 17 00:00:00 2001 From: Pavel Usachev Date: Thu, 20 Jul 2023 20:18:24 +0300 Subject: [PATCH 2/2] Magento 2.4.6 Compatibility - fixed constants --- Gateway/Http/Client/Adapter/Rest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gateway/Http/Client/Adapter/Rest.php b/Gateway/Http/Client/Adapter/Rest.php index 190e39c..20d2bc8 100644 --- a/Gateway/Http/Client/Adapter/Rest.php +++ b/Gateway/Http/Client/Adapter/Rest.php @@ -47,15 +47,15 @@ public function write($method, $url, $httpVer = '1.1', $headers = [], $body = '' curl_setopt($this->_getResource(), CURLOPT_URL, $url); curl_setopt($this->_getResource(), CURLOPT_RETURNTRANSFER, true); - if ($method == Request::POST) { + if ($method == Request::METHOD_POST) { curl_setopt($this->_getResource(), CURLOPT_POST, true); curl_setopt($this->_getResource(), CURLOPT_POSTFIELDS, $body); $headers[] = 'Content-Length: ' . strlen($body); - } elseif ($method == Request::PUT) { - curl_setopt($this->_getResource(), CURLOPT_CUSTOMREQUEST, Request::PUT); + } elseif ($method == Request::METHOD_PUT) { + curl_setopt($this->_getResource(), CURLOPT_CUSTOMREQUEST, Request::METHOD_PUT); curl_setopt($this->_getResource(), CURLOPT_POSTFIELDS, $body); $headers[] = 'Content-Length: ' . strlen($body); - } elseif ($method == Request::GET) { + } elseif ($method == Request::METHOD_GET) { curl_setopt($this->_getResource(), CURLOPT_HTTPGET, true); }