Skip to content
Snippets Groups Projects
Commit 1c5277fc authored by Matt Jones's avatar Matt Jones
Browse files

Merge branch '3343783-drupal-10-compatibility' into '3.x'

Issue #3343783: Drupal 10 compatibility

See merge request !6
parents 218cf5dc 018a5377
No related branches found
No related tags found
No related merge requests found
Pipeline #21053 skipped
......@@ -11,7 +11,7 @@
"source": "http://cgit.drupalcode.org/sparkpost"
},
"require": {
"php-http/guzzle6-adapter": "^1.1",
"php-http/guzzle7-adapter": "^1.0",
"sparkpost/sparkpost": "^2.0"
}
}
......@@ -2,7 +2,7 @@ name: "Sparkpost Requeue"
type: module
description: "Requeue failed Sparpost messages"
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^10
package: Sparkpost
configure: sparkpost_requeue.settings_form
dependencies:
......
......@@ -2,6 +2,6 @@ name: Sparkpost
type: module
description: Integrates Drupal site with Sparkpost - transactional mail service.
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^10
package: Sparkpost
configure: sparkpost.settings_form
......@@ -5,7 +5,6 @@ namespace Drupal\sparkpost;
use Drupal\Core\Config\ConfigFactory;
use GuzzleHttp\Client;
use SparkPost\SparkPost;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
/**
* Client service that sends the mails.
......@@ -14,6 +13,10 @@ use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
*/
class ClientService implements ClientServiceInterface {
const GUZZLE6_ADAPTER = '\Http\Adapter\Guzzle6\Client';
const GUZZLE7_ADAPTER = '\Http\Adapter\Guzzle7\Client';
/**
* Regex for parsing email.
*/
......@@ -41,12 +44,28 @@ class ClientService implements ClientServiceInterface {
$this->configFactory = $configFactory;
}
/**
* Get the http client adapter class.
*
* Class is different depending on the version
* of php guzzle adapter library.
*
* @return string
*/
protected function getHttpClientAdapterClass() {
if (class_exists(static::GUZZLE6_ADAPTER)) {
return static::GUZZLE6_ADAPTER;
}
return static::GUZZLE7_ADAPTER;
}
/**
* {@inheritdoc}
*/
public function getClient() {
$config = $this->configFactory->get('sparkpost.settings');
$httpClient = new GuzzleAdapter($this->client);
$http_client_class = $this->getHttpClientAdapterClass();
$httpClient = new $http_client_class($this->client);
$options = [
'key' => $config->get('api_key'),
];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment