mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
refactor #14919 Use Symfony HTTP Client in place of Guzzle 6 by default and provide Guzzle 7 support (coldic3)
This PR was merged into the 1.13 branch. Discussion ---------- | Q | A | |-----------------|--------------------------------------------------------------| | Branch? | 1.13 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Related tickets | fixes https://github.com/Sylius/Sylius/issues/14671 | License | MIT | TODO: - [x] upgrade file - [x] Symfony HTTP Client support - [x] Guzzle 6 support (legacy) - [x] Guzzle 7 support Commits -------352b7464c1Replace Guzzle with Symfony HTTP Clientb15cd4c1dbUse Http\Client\HttpClient service instead of HttplugClient explicitlyd0d5db1bfb[Admin] Improve deprecations in NotificationController238472d99d[Composer] Fix dependencies69ed3e7b47[Maintenance] Fix HTTP Client deprecations77652769e3Use Psr\Http\Client\ClientInterface service ID in place of psr18.http_clientcad50787e2Drop Guzzle adapters to support both Guzzle 6 and 7
This commit is contained in:
commit
69fd052829
20 changed files with 324 additions and 59 deletions
|
|
@ -44,6 +44,7 @@
|
|||
}
|
||||
}
|
||||
```
|
||||
|
||||
1. Not passing `Sylius\Component\Core\Checker\ProductVariantLowestPriceDisplayCheckerInterface`
|
||||
to `Sylius\Component\Core\Calculator\ProductVariantPriceCalculator`
|
||||
as a first argument is deprecated.
|
||||
|
|
@ -65,3 +66,35 @@
|
|||
Subsequently, the `sylius_product_variant_prices` twig function is deprecated, use `sylius_product_variants_map` instead.
|
||||
|
||||
To add more data per variant create a service implementing the `Sylius\Component\Core\Provider\ProductVariantMap\ProductVariantMapProviderInterface` and tag it with `sylius.product_variant_data_map_provider`.
|
||||
|
||||
1. Using Guzzle 6 has been deprecated in favor of Symfony HTTP Client. If you want to still use Guzzle 6 or Guzzle 7,
|
||||
you need to install `composer require php-http/guzzle6-adapter` or `composer require php-http/guzzle7-adapter`
|
||||
depending on your Guzzle version.
|
||||
Subsequently, you need to register the adapter as a `Psr\Http\Client\ClientInterface` service as the following:
|
||||
```yaml
|
||||
services:
|
||||
Psr\Http\Client\ClientInterface:
|
||||
class: Http\Adapter\Guzzle7\Client # for Guzzle 6 use Http\Adapter\Guzzle6\Client instead
|
||||
```
|
||||
|
||||
1. The constructor of `Sylius\Bundle\AdminBundle\Controller\NotificationController` has been changed:
|
||||
|
||||
```diff
|
||||
public function __construct(
|
||||
- private ClientInterface $client,
|
||||
- private MessageFactory $messageFactory,
|
||||
+ private ClientInterface|DeprecatedClientInterface $client,
|
||||
+ private RequestFactoryInterface|MessageFactory $requestFactory,
|
||||
private string $hubUri,
|
||||
private string $environment,
|
||||
+ private ?StreamFactoryInterface $streamFactory = null,
|
||||
) {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
1. The `sylius.http_message_factory` service has been deprecated. Use `Psr\Http\Message\RequestFactoryInterface` instead.
|
||||
|
||||
1. The `sylius.http_client` has become an alias to `psr18.http_client` service.
|
||||
|
||||
1. The `sylius.payum.http_client` has become a service ID of newly created `Sylius\Bundle\PayumBundle\HttpClient\HttpClient`.
|
||||
|
|
|
|||
|
|
@ -23,12 +23,15 @@
|
|||
"Behat\\Testwork\\Tester\\Setup\\Teardown",
|
||||
"Doctrine\\DBAL\\Platforms\\MySqlPlatform",
|
||||
"Doctrine\\DBAL\\Platforms\\MySQLPlatform",
|
||||
"Http\\Client\\HttpClient",
|
||||
"HWI\\Bundle\\OAuthBundle\\Connect\\AccountConnectorInterface",
|
||||
"HWI\\Bundle\\OAuthBundle\\OAuth\\Response\\UserResponseInterface",
|
||||
"HWI\\Bundle\\OAuthBundle\\Security\\Core\\User\\OAuthAwareUserProviderInterface",
|
||||
"League\\Flysystem\\FilesystemOperator",
|
||||
"Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface",
|
||||
"PHPUnit\\Framework\\ExpectationFailedException",
|
||||
"Psr\\Http\\Message\\RequestFactoryInterface",
|
||||
"Psr\\Http\\Message\\StreamFactoryInterface",
|
||||
"Stripe\\Stripe"
|
||||
],
|
||||
"php-core-extensions" : [
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
"friendsofphp/proxy-manager-lts": "^1.0.7",
|
||||
"friendsofsymfony/rest-bundle": "^3.0",
|
||||
"gedmo/doctrine-extensions": "^3.2",
|
||||
"guzzlehttp/guzzle": "^6.5",
|
||||
"guzzlehttp/guzzle": "^6.5 || ^7.0",
|
||||
"guzzlehttp/psr7": "^1.8",
|
||||
"jms/serializer-bundle": "^4.2",
|
||||
"knplabs/gaufrette": "^0.10 || ^0.11",
|
||||
|
|
@ -59,12 +59,15 @@
|
|||
"league/flysystem-bundle": "^2.4",
|
||||
"lexik/jwt-authentication-bundle": "^2.11",
|
||||
"liip/imagine-bundle": "^2.10",
|
||||
"nyholm/psr7": "^1.6",
|
||||
"pagerfanta/pagerfanta": "^3.0",
|
||||
"payum/payum": "^1.7.2",
|
||||
"payum/payum-bundle": "^2.5",
|
||||
"php-http/guzzle6-adapter": "^2.0",
|
||||
"php-http/httplug": "^2.4",
|
||||
"php-http/message-factory": "^1.0",
|
||||
"psr/cache": "^2.0",
|
||||
"psr/http-client": "^1.0",
|
||||
"psr/http-message": "^1.0",
|
||||
"psr/log": "^2.0",
|
||||
"ramsey/uuid": "^4.0",
|
||||
"sonata-project/block-bundle": "^4.2",
|
||||
|
|
@ -97,6 +100,7 @@
|
|||
"symfony/finder": "^5.4.21 || ^6.0",
|
||||
"symfony/form": "^5.4.21 || ^6.0",
|
||||
"symfony/framework-bundle": "^5.4.21 || ^6.0",
|
||||
"symfony/http-client": "^5.4.21 || ^6.0",
|
||||
"symfony/http-foundation": "^5.4.21 || ^6.0",
|
||||
"symfony/http-kernel": "^5.4.21 || ^6.0",
|
||||
"symfony/intl": "^5.4.21 || ^6.0",
|
||||
|
|
|
|||
21
config/packages/nyholm_psr7.yaml
Normal file
21
config/packages/nyholm_psr7.yaml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
services:
|
||||
# Register nyholm/psr7 services for autowiring with PSR-17 (HTTP factories)
|
||||
Psr\Http\Message\RequestFactoryInterface: '@nyholm.psr7.psr17_factory'
|
||||
Psr\Http\Message\ResponseFactoryInterface: '@nyholm.psr7.psr17_factory'
|
||||
Psr\Http\Message\ServerRequestFactoryInterface: '@nyholm.psr7.psr17_factory'
|
||||
Psr\Http\Message\StreamFactoryInterface: '@nyholm.psr7.psr17_factory'
|
||||
Psr\Http\Message\UploadedFileFactoryInterface: '@nyholm.psr7.psr17_factory'
|
||||
Psr\Http\Message\UriFactoryInterface: '@nyholm.psr7.psr17_factory'
|
||||
|
||||
# Register nyholm/psr7 services for autowiring with HTTPlug factories
|
||||
Http\Message\MessageFactory: '@nyholm.psr7.httplug_factory'
|
||||
Http\Message\RequestFactory: '@nyholm.psr7.httplug_factory'
|
||||
Http\Message\ResponseFactory: '@nyholm.psr7.httplug_factory'
|
||||
Http\Message\StreamFactory: '@nyholm.psr7.httplug_factory'
|
||||
Http\Message\UriFactory: '@nyholm.psr7.httplug_factory'
|
||||
|
||||
nyholm.psr7.psr17_factory:
|
||||
class: Nyholm\Psr7\Factory\Psr17Factory
|
||||
|
||||
nyholm.psr7.httplug_factory:
|
||||
class: Nyholm\Psr7\Factory\HttplugFactory
|
||||
|
|
@ -14,8 +14,8 @@ declare(strict_types=1);
|
|||
namespace spec\Sylius\Behat\Service\Mocker;
|
||||
|
||||
use Mockery\MockInterface;
|
||||
use Payum\Core\Bridge\Guzzle\HttpClient;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
|
||||
use Sylius\Behat\Service\Mocker\Mocker;
|
||||
use Sylius\Behat\Service\Mocker\MockerInterface;
|
||||
|
|
@ -39,13 +39,13 @@ final class MockerSpec extends ObjectBehavior
|
|||
|
||||
function it_mocks_given_service($container)
|
||||
{
|
||||
$container->mock('sylius.payum.http_client', HttpClient::class)->shouldBeCalled();
|
||||
$container->mock('sylius.payum.http_client', ClientInterface::class)->shouldBeCalled();
|
||||
|
||||
$this->mockService('sylius.payum.http_client', HttpClient::class);
|
||||
$this->mockService('sylius.payum.http_client', ClientInterface::class);
|
||||
}
|
||||
|
||||
function it_mocks_collaborator()
|
||||
{
|
||||
$this->mockCollaborator(HttpClient::class)->shouldHaveType(MockInterface::class);
|
||||
$this->mockCollaborator(ClientInterface::class)->shouldHaveType(MockInterface::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,49 +13,67 @@ declare(strict_types=1);
|
|||
|
||||
namespace Sylius\Bundle\AdminBundle\Controller;
|
||||
|
||||
use GuzzleHttp\ClientInterface;
|
||||
use GuzzleHttp\ClientInterface as DeprecatedClientInterface;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Http\Message\MessageFactory;
|
||||
use Nyholm\Psr7\Stream;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
use Sylius\Bundle\CoreBundle\SyliusCoreBundle;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
final class NotificationController
|
||||
{
|
||||
private Uri $hubUri;
|
||||
|
||||
public function __construct(
|
||||
private ClientInterface $client,
|
||||
private MessageFactory $messageFactory,
|
||||
string $hubUri,
|
||||
private ClientInterface|DeprecatedClientInterface $client,
|
||||
private RequestFactoryInterface|MessageFactory $requestFactory,
|
||||
private string $hubUri,
|
||||
private string $environment,
|
||||
private ?StreamFactoryInterface $streamFactory = null,
|
||||
) {
|
||||
$this->hubUri = new Uri($hubUri);
|
||||
if (!$client instanceof ClientInterface) {
|
||||
trigger_deprecation('sylius/admin-bundle', '1.13', 'Using a service that does not implement "%s" as a 1st argument of "%s" constructor is deprecated and will be prohibited in 2.0.', ClientInterface::class, self::class);
|
||||
}
|
||||
|
||||
if (!$requestFactory instanceof RequestFactoryInterface) {
|
||||
trigger_deprecation('sylius/admin-bundle', '1.13', 'Using a service that does not implement "%s" as a 2nd argument of "%s" constructor is deprecated and will be prohibited in 2.0.', RequestFactoryInterface::class, self::class);
|
||||
}
|
||||
|
||||
if (null === $streamFactory) {
|
||||
trigger_deprecation('sylius/admin-bundle', '1.13', 'Not passing a service that implements "%s" as a 5th argument of "%s" constructor is deprecated and will be prohibited in 2.0.', StreamFactoryInterface::class, self::class);
|
||||
}
|
||||
}
|
||||
|
||||
public function getVersionAction(Request $request): JsonResponse
|
||||
{
|
||||
$content = [
|
||||
$content = json_encode([
|
||||
'version' => SyliusCoreBundle::VERSION,
|
||||
'hostname' => $request->getHost(),
|
||||
'locale' => $request->getLocale(),
|
||||
'user_agent' => $request->headers->get('User-Agent'),
|
||||
'environment' => $this->environment,
|
||||
];
|
||||
]);
|
||||
|
||||
$headers = ['Content-Type' => 'application/json'];
|
||||
|
||||
$hubRequest = $this->messageFactory->createRequest(
|
||||
Request::METHOD_GET,
|
||||
$this->hubUri,
|
||||
$headers,
|
||||
json_encode($content),
|
||||
);
|
||||
$hubRequest = $this->requestFactory
|
||||
->createRequest(Request::METHOD_GET, $this->hubUri)
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->withBody(
|
||||
null === $this->streamFactory
|
||||
? Stream::create($content)
|
||||
: $this->streamFactory->createStream($content)
|
||||
)
|
||||
;
|
||||
|
||||
try {
|
||||
$hubResponse = $this->client->send($hubRequest, ['verify' => false]);
|
||||
} catch (GuzzleException) {
|
||||
if ($this->client instanceof DeprecatedClientInterface) {
|
||||
$hubResponse = $this->client->send($hubRequest, ['verify' => false]);
|
||||
} else {
|
||||
$hubResponse = $this->client->sendRequest($hubRequest);
|
||||
}
|
||||
} catch (ClientExceptionInterface|GuzzleException) {
|
||||
return new JsonResponse('', JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,9 @@
|
|||
<tag name="twig.extension" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.http_client" class="GuzzleHttp\Client" public="false" />
|
||||
<service id="sylius.http_message_factory" class="Http\Message\MessageFactory\GuzzleMessageFactory" public="false" />
|
||||
<service id="sylius.http_client" alias="Psr\Http\Client\ClientInterface" public="false" />
|
||||
<service id="sylius.http_message_factory" class="Http\Message\MessageFactory\GuzzleMessageFactory" public="false">
|
||||
<deprecated package="sylius/admin-bundle" version="1.13">The "%service_id%" service is deprecated since 1.13 and will be removed in 2.0. Use "Psr\Http\Message\RequestFactoryInterface" instead.</deprecated>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -90,9 +90,10 @@
|
|||
|
||||
<service id="sylius.controller.admin.notification" class="Sylius\Bundle\AdminBundle\Controller\NotificationController" public="true">
|
||||
<argument type="service" id="sylius.http_client" />
|
||||
<argument type="service" id="sylius.http_message_factory" />
|
||||
<argument type="service" id="Psr\Http\Message\RequestFactoryInterface" />
|
||||
<argument type="string">%sylius.admin.notification.uri%</argument>
|
||||
<argument type="string">%kernel.environment%</argument>
|
||||
<argument type="service" id="Psr\Http\Message\StreamFactoryInterface" />
|
||||
</service>
|
||||
|
||||
<service id="Sylius\Bundle\AdminBundle\Controller\RemoveCatalogPromotionAction" public="true">
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Sylius\Bundle\AdminBundle\Tests\Controller;
|
||||
|
||||
use GuzzleHttp\ClientInterface;
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use Http\Message\MessageFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
|
@ -21,8 +20,10 @@ use Prophecy\Argument;
|
|||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Prophecy\Prophecy\ProphecyInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Sylius\Bundle\AdminBundle\Controller\NotificationController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
|
@ -34,22 +35,33 @@ final class NotificationControllerTest extends TestCase
|
|||
|
||||
private ObjectProphecy $client;
|
||||
|
||||
private ObjectProphecy $legacyClient;
|
||||
|
||||
private ObjectProphecy $requestFactory;
|
||||
|
||||
private ObjectProphecy $messageFactory;
|
||||
|
||||
private ObjectProphecy $streamFactory;
|
||||
|
||||
private NotificationController $controller;
|
||||
|
||||
private NotificationController $legacyController;
|
||||
|
||||
private static string $hubUri = 'www.doesnotexist.test.com';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
/** @test */
|
||||
public function it_returns_an_empty_json_response_upon_client_exception(): void
|
||||
{
|
||||
$this->messageFactory->createRequest(Argument::any(), Argument::cetera())
|
||||
->willReturn($this->prophesize(RequestInterface::class)->reveal())
|
||||
;
|
||||
$requestInterface = $this->prophesize(RequestInterface::class);
|
||||
$streamInterface = $this->prophesize(StreamInterface::class);
|
||||
|
||||
$this->client->send(Argument::cetera())->willThrow(ConnectException::class);
|
||||
$this->streamFactory->createStream(Argument::cetera())->willReturn($streamInterface);
|
||||
|
||||
$this->requestFactory->createRequest(Argument::cetera())->willReturn($requestInterface);
|
||||
$requestInterface->withHeader('Content-Type', 'application/json')->willReturn($requestInterface);
|
||||
$requestInterface->withBody($streamInterface)->willReturn($requestInterface);
|
||||
|
||||
$this->client->sendRequest(Argument::cetera())->willThrow(ConnectException::class);
|
||||
|
||||
$emptyResponse = $this->controller->getVersionAction(new Request());
|
||||
|
||||
|
|
@ -59,14 +71,38 @@ final class NotificationControllerTest extends TestCase
|
|||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @legacy This test will be removed in Sylius 2.0.
|
||||
*/
|
||||
public function it_returns_an_empty_json_response_upon_client_exception_deprecated(): void
|
||||
{
|
||||
$requestInterface = $this->prophesize(RequestInterface::class);
|
||||
|
||||
$this->messageFactory->createRequest(Argument::cetera())->willReturn($requestInterface);
|
||||
$requestInterface->withHeader('Content-Type', 'application/json')->willReturn($requestInterface);
|
||||
$requestInterface->withBody(Argument::any())->willReturn($requestInterface);
|
||||
|
||||
$this->legacyClient->send(Argument::cetera())->willThrow(ConnectException::class);
|
||||
|
||||
$emptyResponse = $this->legacyController->getVersionAction(new Request());
|
||||
|
||||
$this->assertEquals(JsonResponse::HTTP_NO_CONTENT, $emptyResponse->getStatusCode());
|
||||
$this->assertEquals('""', $emptyResponse->getContent());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_returns_json_response_from_client_on_success(): void
|
||||
{
|
||||
$content = json_encode(['version' => '9001']);
|
||||
|
||||
$this->messageFactory->createRequest(Argument::any(), Argument::cetera())
|
||||
->willReturn($this->prophesize(RequestInterface::class)->reveal())
|
||||
;
|
||||
$requestInterface = $this->prophesize(RequestInterface::class);
|
||||
$streamInterface = $this->prophesize(StreamInterface::class);
|
||||
|
||||
$this->streamFactory->createStream(Argument::cetera())->willReturn($streamInterface);
|
||||
|
||||
$this->requestFactory->createRequest(Argument::cetera())->willReturn($requestInterface);
|
||||
$requestInterface->withHeader('Content-Type', 'application/json')->willReturn($requestInterface);
|
||||
$requestInterface->withBody($streamInterface)->willReturn($requestInterface);
|
||||
|
||||
/** @var ProphecyInterface|StreamInterface $stream */
|
||||
$stream = $this->prophesize(StreamInterface::class);
|
||||
|
|
@ -76,7 +112,7 @@ final class NotificationControllerTest extends TestCase
|
|||
$externalResponse = $this->prophesize(ResponseInterface::class);
|
||||
$externalResponse->getBody()->willReturn($stream->reveal());
|
||||
|
||||
$this->client->send(Argument::cetera())->willReturn($externalResponse->reveal());
|
||||
$this->client->sendRequest(Argument::cetera())->willReturn($externalResponse->reveal());
|
||||
|
||||
$response = $this->controller->getVersionAction(new Request());
|
||||
|
||||
|
|
@ -84,13 +120,55 @@ final class NotificationControllerTest extends TestCase
|
|||
$this->assertEquals($content, $response->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @legacy This test will be removed in Sylius 2.0.
|
||||
*/
|
||||
public function it_returns_json_response_from_client_on_success_deprecated(): void
|
||||
{
|
||||
$content = json_encode(['version' => '9001']);
|
||||
|
||||
$requestInterface = $this->prophesize(RequestInterface::class);
|
||||
|
||||
$this->messageFactory->createRequest(Argument::cetera())->willReturn($requestInterface);
|
||||
$requestInterface->withHeader('Content-Type', 'application/json')->willReturn($requestInterface);
|
||||
$requestInterface->withBody(Argument::any())->willReturn($requestInterface);
|
||||
|
||||
/** @var ProphecyInterface|StreamInterface $stream */
|
||||
$stream = $this->prophesize(StreamInterface::class);
|
||||
$stream->getContents()->willReturn($content);
|
||||
|
||||
/** @var ProphecyInterface|ResponseInterface $externalResponse */
|
||||
$externalResponse = $this->prophesize(ResponseInterface::class);
|
||||
$externalResponse->getBody()->willReturn($stream->reveal());
|
||||
|
||||
$this->legacyClient->send(Argument::cetera())->willReturn($externalResponse->reveal());
|
||||
|
||||
$response = $this->legacyController->getVersionAction(new Request());
|
||||
|
||||
$this->assertEquals(JsonResponse::HTTP_OK, $response->getStatusCode());
|
||||
$this->assertEquals($content, $response->getContent());
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->client = $this->prophesize(ClientInterface::class);
|
||||
$this->client = $this->prophesize(\Psr\Http\Client\ClientInterface::class);
|
||||
$this->legacyClient = $this->prophesize(\GuzzleHttp\ClientInterface::class);
|
||||
$this->requestFactory = $this->prophesize(RequestFactoryInterface::class);
|
||||
$this->messageFactory = $this->prophesize(MessageFactory::class);
|
||||
$this->streamFactory = $this->prophesize(StreamFactoryInterface::class);
|
||||
|
||||
$this->controller = new NotificationController(
|
||||
$this->client->reveal(),
|
||||
$this->requestFactory->reveal(),
|
||||
self::$hubUri,
|
||||
'environment',
|
||||
$this->streamFactory->reveal(),
|
||||
);
|
||||
|
||||
$this->legacyController = new NotificationController(
|
||||
$this->legacyClient->reveal(),
|
||||
$this->messageFactory->reveal(),
|
||||
self::$hubUri,
|
||||
'environment',
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@
|
|||
"symfony/browser-kit": "^5.4.21 || ^6.0",
|
||||
"symfony/debug-bundle": "^5.4.21 || ^6.0",
|
||||
"symfony/dotenv": "^5.4.21 || ^6.0",
|
||||
"symfony/http-client": "^5.4.21 || ^6.0",
|
||||
"symfony/webpack-encore-bundle": "^1.15",
|
||||
"theofidry/alice-data-fixtures": "^1.4"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ imports:
|
|||
- { resource: "@SyliusCoreBundle/Resources/config/app/state_machine.yml" }
|
||||
- { resource: "@SyliusCoreBundle/Resources/config/app/fixtures.yml" }
|
||||
- { resource: "@SyliusCoreBundle/Resources/config/app/messenger.yaml" }
|
||||
- { resource: "@SyliusCoreBundle/Resources/config/app/nyholm_psr7.yaml" }
|
||||
- { resource: "@SyliusCoreBundle/Resources/config/app/doctrine_migrations.yaml" }
|
||||
|
||||
parameters:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
services:
|
||||
# Register nyholm/psr7 services for autowiring with PSR-17 (HTTP factories)
|
||||
Psr\Http\Message\RequestFactoryInterface: '@nyholm.psr7.psr17_factory'
|
||||
Psr\Http\Message\ResponseFactoryInterface: '@nyholm.psr7.psr17_factory'
|
||||
Psr\Http\Message\ServerRequestFactoryInterface: '@nyholm.psr7.psr17_factory'
|
||||
Psr\Http\Message\StreamFactoryInterface: '@nyholm.psr7.psr17_factory'
|
||||
Psr\Http\Message\UploadedFileFactoryInterface: '@nyholm.psr7.psr17_factory'
|
||||
Psr\Http\Message\UriFactoryInterface: '@nyholm.psr7.psr17_factory'
|
||||
|
||||
# Register nyholm/psr7 services for autowiring with HTTPlug factories
|
||||
Http\Message\MessageFactory: '@nyholm.psr7.httplug_factory'
|
||||
Http\Message\RequestFactory: '@nyholm.psr7.httplug_factory'
|
||||
Http\Message\ResponseFactory: '@nyholm.psr7.httplug_factory'
|
||||
Http\Message\StreamFactory: '@nyholm.psr7.httplug_factory'
|
||||
Http\Message\UriFactory: '@nyholm.psr7.httplug_factory'
|
||||
|
||||
nyholm.psr7.psr17_factory:
|
||||
class: Nyholm\Psr7\Factory\Psr17Factory
|
||||
|
||||
nyholm.psr7.httplug_factory:
|
||||
class: Nyholm\Psr7\Factory\HttplugFactory
|
||||
|
|
@ -35,6 +35,7 @@
|
|||
"knplabs/knp-gaufrette-bundle": "^0.7 || ^0.8",
|
||||
"league/flysystem-bundle": "^2.4",
|
||||
"liip/imagine-bundle": "^2.10",
|
||||
"nyholm/psr7": "^1.6",
|
||||
"sonata-project/block-bundle": "^4.2",
|
||||
"sylius-labs/association-hydrator": "^1.1 || ^1.2",
|
||||
"sylius-labs/doctrine-migrations-extra-bundle": "^0.1.4 || ^0.2",
|
||||
|
|
|
|||
30
src/Sylius/Bundle/PayumBundle/HttpClient/HttpClient.php
Normal file
30
src/Sylius/Bundle/PayumBundle/HttpClient/HttpClient.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Bundle\PayumBundle\HttpClient;
|
||||
|
||||
use Payum\Core\HttpClientInterface;
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
final class HttpClient implements HttpClientInterface
|
||||
{
|
||||
public function __construct(private ClientInterface $client)
|
||||
{
|
||||
}
|
||||
|
||||
public function send(RequestInterface $request)
|
||||
{
|
||||
return $this->client->sendRequest($request);
|
||||
}
|
||||
}
|
||||
|
|
@ -28,10 +28,9 @@
|
|||
<services>
|
||||
<defaults public="true" />
|
||||
|
||||
<service id="sylius.payum.http_client" class="Payum\Core\HttpClientInterface">
|
||||
<factory class="Payum\Core\Bridge\Guzzle\HttpClientFactory" method="create" />
|
||||
<service id="sylius.payum.http_client" class="Sylius\Bundle\PayumBundle\HttpClient\HttpClient">
|
||||
<argument type="service" id="Psr\Http\Client\ClientInterface" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.form_registry.payum_gateway_config" class="Sylius\Bundle\ResourceBundle\Form\Registry\FormTypeRegistry" />
|
||||
</services>
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@
|
|||
"php": "^8.0",
|
||||
"payum/payum": "^1.7.2",
|
||||
"payum/payum-bundle": "^2.5",
|
||||
"php-http/guzzle6-adapter": "^2.0",
|
||||
"sylius/core": "^1.12",
|
||||
"sylius/currency": "^1.12",
|
||||
"sylius/order-bundle": "^1.12",
|
||||
"sylius/payment-bundle": "^1.12",
|
||||
"sylius/resource-bundle": "^1.9"
|
||||
"sylius/resource-bundle": "^1.9",
|
||||
"php-http/httplug": "^2.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "^7.2",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace spec\Sylius\Bundle\PayumBundle\HttpClient;
|
||||
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use Payum\Core\HttpClientInterface;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Sylius\Bundle\PayumBundle\HttpClient\HttpClient;
|
||||
|
||||
final class HttpClientSpec extends ObjectBehavior
|
||||
{
|
||||
function let(ClientInterface $client): void
|
||||
{
|
||||
$this->beConstructedWith($client);
|
||||
}
|
||||
|
||||
function it_is_initializable(): void
|
||||
{
|
||||
$this->shouldHaveType(HttpClient::class);
|
||||
}
|
||||
|
||||
function it_implements_http_client_interface(): void
|
||||
{
|
||||
$this->shouldImplement(HttpClientInterface::class);
|
||||
}
|
||||
|
||||
function it_sends_a_request(
|
||||
ClientInterface $client,
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response
|
||||
): void {
|
||||
$client->sendRequest($request)->willReturn($response);
|
||||
|
||||
$this->send($request)->shouldReturn($response);
|
||||
}
|
||||
}
|
||||
|
|
@ -55,7 +55,6 @@
|
|||
"require-dev": {
|
||||
"hwi/oauth-bundle": "^1.1 || ^2.0@beta",
|
||||
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
|
||||
"php-http/guzzle6-adapter": "^2.0",
|
||||
"phpspec/phpspec": "^7.2",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"symfony/dependency-injection": "^5.4.21 || ^6.0",
|
||||
|
|
|
|||
|
|
@ -28,10 +28,12 @@
|
|||
"require": {
|
||||
"php": "^8.0",
|
||||
"enshrined/svg-sanitize": "^0.16",
|
||||
"guzzlehttp/guzzle": "^6.5 || ^7.0",
|
||||
"knplabs/gaufrette": "^0.10 || ^0.11",
|
||||
"league/flysystem": "^2.4",
|
||||
"payum/payum": "^1.7.2",
|
||||
"php-http/guzzle6-adapter": "^2.0",
|
||||
"psr/http-client": "^1.0",
|
||||
"psr/http-message": "^1.0",
|
||||
"sylius/addressing": "^1.12",
|
||||
"sylius/attribute": "^1.12",
|
||||
"sylius/channel": "^1.12",
|
||||
|
|
@ -50,6 +52,7 @@
|
|||
"sylius/taxation": "^1.12",
|
||||
"sylius/taxonomy": "^1.12",
|
||||
"sylius/user": "^1.12",
|
||||
"symfony/http-client": "^5.4.21 || ^6.0",
|
||||
"symfony/http-foundation": "^5.4.21 || ^6.0",
|
||||
"symfony/mime": "^5.4.21 || ^6.0",
|
||||
"symfony/string": "^5.4.21 || ^6.0",
|
||||
|
|
|
|||
21
symfony.lock
21
symfony.lock
|
|
@ -367,6 +367,18 @@
|
|||
"nikic/php-parser": {
|
||||
"version": "v4.6.0"
|
||||
},
|
||||
"nyholm/psr7": {
|
||||
"version": "1.6",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
"version": "1.0",
|
||||
"ref": "0cd4d2d0e7f646fda75f9944f747a56e6ed13d4c"
|
||||
},
|
||||
"files": [
|
||||
"config/packages/nyholm_psr7.yaml"
|
||||
]
|
||||
},
|
||||
"openlss/lib-array2xml": {
|
||||
"version": "1.0.0"
|
||||
},
|
||||
|
|
@ -394,21 +406,12 @@
|
|||
"phar-io/version": {
|
||||
"version": "2.0.1"
|
||||
},
|
||||
"php-http/guzzle6-adapter": {
|
||||
"version": "v1.1.1"
|
||||
},
|
||||
"php-http/httplug": {
|
||||
"version": "v1.1.0"
|
||||
},
|
||||
"php-http/message": {
|
||||
"version": "1.7.0"
|
||||
},
|
||||
"php-http/message-factory": {
|
||||
"version": "v1.0.2"
|
||||
},
|
||||
"php-http/promise": {
|
||||
"version": "v1.0.0"
|
||||
},
|
||||
"phparkitect/phparkitect": {
|
||||
"version": "0.2.9"
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue