Skip to content

Commit 4f870b1

Browse files
committed
DD#3.0.0-dev: feat: Magento 2.4.5 and greater compatibility
Update guzzlehttp to 7.4 to match Magento 2.4.5
1 parent a0ab83c commit 4f870b1

File tree

5 files changed

+26
-41
lines changed

5 files changed

+26
-41
lines changed

.github/workflows/static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
env:
1313
extensions: bcmath, ctype, curl, dom, gd, hash, iconv, intl, mbstring, openssl, pdo_mysql, simplexml, soap, xsl, zip, libxml
1414
key: php-cache-v1 # can be any string, change to clear the extension cache.
15-
php-version: '7.3'
15+
php-version: '8.1'
1616
steps:
1717
- uses: actions/checkout@v2
1818

.github/workflows/testing.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ on:
88

99
jobs:
1010
run_tests:
11-
runs-on: ubuntu-18.04
11+
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
php-version: ['7.2', '7.3']
14+
php-version: ['8.1']
1515
env:
1616
extensions: bcmath, ctype, curl, dom, gd, hash, iconv, intl, mbstring, openssl, pdo_mysql, simplexml, soap, xsl, zip, libxml
1717
key: php-cache-v1 # can be any string, change to clear the extension cache.
@@ -46,8 +46,8 @@ jobs:
4646
with:
4747
php-version: ${{ matrix.php-version }}
4848
extensions: ${{ env.extensions }}
49-
coverage: xdebug2
50-
tools: composer:v1
49+
coverage: xdebug3
50+
tools: composer:v2
5151

5252
- name: Get Composer Cache Directory
5353
id: composer-cache
@@ -72,14 +72,14 @@ jobs:
7272
- name: Download magento
7373
id: download-magento
7474
run: |
75-
composer create-project --no-install --repository-url=https://repo.magento.com/ magento/project-community-edition=2.3.4 ./magento
75+
composer create-project --no-install --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.5 ./magento
7676
7777
- name: Add module under test
7878
id: add-module
7979
run: |
8080
cd magento
8181
composer require `jq -r .name ../composer.json` dev-${{ github.head_ref }} --prefer-source --no-update
82-
composer require skywire/m2-actions-workflow ^1.0.0 --prefer-source --no-update
82+
composer require skywire/m2-actions-workflow ^2.1 --prefer-source --no-update
8383
cd ../
8484
8585
- name: Install MySQL
@@ -89,9 +89,15 @@ jobs:
8989
mysql database: 'magento_integration_tests'
9090
mysql root password: 123123q
9191

92+
- name: Runs Elasticsearch
93+
uses: elastic/elastic-github-actions/elasticsearch@master
94+
with:
95+
stack-version: 7.17.6
96+
9297
- name: Install Dependencies
9398
run: |
9499
cd magento
100+
composer config --no-plugins allow-plugins.skywire/file-copy-plugin true
95101
composer install --no-interaction
96102
cd ../
97103

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"php": "^7.0|^7.1|^7.2|^7.3|^7.4|^8",
77
"magento/magento-composer-installer": "*",
88
"skywire/testframework":"*",
9-
"guzzlehttp/guzzle": "^6.3"
9+
"guzzlehttp/guzzle": "^7.4"
1010
},
1111
"type": "magento2-module",
1212
"repositories": {
@@ -22,5 +22,8 @@
2222
"psr-4": {
2323
"Skywire\\WordpressApi\\": "src"
2424
}
25+
},
26+
"config": {
27+
"allow-plugins": true
2528
}
2629
}

src/Model/Api/ApiAbstract.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88
namespace Skywire\WordpressApi\Model\Api;
99

1010

11+
use GuzzleHttp\Psr7\Message;
1112
use Magento\Framework\App\Config\ScopeConfigInterface;
1213
use Magento\Framework\DataObject;
1314
use Magento\Store\Model\ScopeInterface;
1415
use Magento\Store\Model\StoreManagerInterface;
1516
use Skywire\WordpressApi\Model\Data\Collection;
1617
use Skywire\WordpressApi\Model\Data\CollectionFactory;
1718

18-
use function GuzzleHttp\Psr7\parse_response;
19-
use function GuzzleHttp\Psr7\str;
20-
2119
/**
2220
* @package Skywire\WordpressApi\Model\Api
2321
* @author Skywire Tech Team <tech@skywire.co.uk>
@@ -124,8 +122,11 @@ protected function _createCollection(array $entityData)
124122
return $collection;
125123
}
126124

127-
protected function _populateApiData(array $data = [], $targetObject)
125+
protected function _populateApiData(array $data, $targetObject)
128126
{
127+
if(!$data) {
128+
return $targetObject;
129+
}
129130
foreach ($data as $key => $value) {
130131
if (is_array($value)) {
131132
$value = $this->_populateApiData($value, new DataObject());
@@ -151,7 +152,8 @@ protected abstract function _getRoute($id = '');
151152
*/
152153
protected function _parseRoute($id = '')
153154
{
154-
$apiPath = trim($this->scopeConfig->getValue('skywire_wordpress_api/api/path', ScopeInterface::SCOPE_STORE), '/');
155+
$apiPath = $this->scopeConfig->getValue('skywire_wordpress_api/api/path', ScopeInterface::SCOPE_STORE) ?? '';
156+
$apiPath = trim($apiPath, '/');
155157
$route = str_replace(':id', $id, $this->_getRoute());
156158
$route = trim($route, '/');
157159

@@ -170,7 +172,7 @@ protected function _request($route, $params = [])
170172
$cacheKey = $this->_getCacheKey($route, $params, $this->storeManager->getStore()->getCode());
171173
$cached = $this->cache->load($cacheKey);
172174
if ($cached) {
173-
return parse_response($cached);
175+
return Message::parseResponse($cached);
174176
}
175177

176178
$client = $this->getRestClient();
@@ -181,7 +183,7 @@ protected function _request($route, $params = [])
181183
throw new ApiException($e->getMessage(), $e->getCode(), $e);
182184
}
183185

184-
$this->cache->save(str($response), $cacheKey, [], $this->scopeConfig->getValue('skywire_wordpress_api/api/cache_ttl'));
186+
$this->cache->save(Message::toString($response), $cacheKey, [], $this->scopeConfig->getValue('skywire_wordpress_api/api/cache_ttl'));
185187

186188
return $response;
187189
}

src/composer.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)