Skip to content

Commit

Permalink
Add support for Symfony 6.x (#127)
Browse files Browse the repository at this point in the history
This commit patches AddToCartListener to resolve an error caused by running
this plugin on Symfony 6.x:

    [Symfony\Component\HttpKernel\Exception\BadRequestHttpException]
    Input value "sylius_add_to_cart" contains a non-scalar value

See: https://github.com/symfony/symfony/blob/6.0/UPGRADE-6.0.md#httpfoundation

> Retrieving non-scalar values using InputBag::get() will throw
> BadRequestException (use InputBag::all() instead to retrieve an array)

Additionally, this commit drops support for Symfony 4.x, as Sylius itself no
longer supports 4.x.

Co-authored-by: Mark Dain <mark.dain@futurenet.com>
  • Loading branch information
ancarda and Mark Dain authored Mar 1, 2023
1 parent d736b21 commit 919e80d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"phpunit/phpunit": "^9.5",
"sensiolabs/security-checker": "^6.0",
"sylius-labs/coding-standard": "^4.0",
"symfony/browser-kit": "^4.4 || ^5.4",
"symfony/debug-bundle": "^4.4 || ^5.4",
"symfony/dotenv": "^4.4 || ^5.4",
"symfony/intl": "^4.4 || ^5.4",
"symfony/web-profiler-bundle": "^4.4 || ^5.4",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/intl": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
"symfony/webpack-encore-bundle": "^1.15",
"vimeo/psalm": "4.7.1",
"mamazu/documentation-validator": "dev-master",
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/AddToCartListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function addItemToCart(ResourceControllerEvent $event): void
public function getCustomerOptionsFromRequest(Request $request): array
{
/** @var array $addToCart */
$addToCart = $request->request->get('sylius_add_to_cart');
$addToCart = $request->request->all('sylius_add_to_cart');

if (!isset($addToCart['customer_options'])) {
return [];
Expand Down

0 comments on commit 919e80d

Please sign in to comment.