Skip to content

Commit

Permalink
Merge pull request #82 from BitBagCommerce/feature/OP-134
Browse files Browse the repository at this point in the history
Sylius upgrade
  • Loading branch information
senghe authored Apr 25, 2023
2 parents 2967bcf + c40e75f commit 1ecaf51
Show file tree
Hide file tree
Showing 58 changed files with 393 additions and 160 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ on:

jobs:
tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}, Sylius ${{ matrix.sylius }}"
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"

strategy:
fail-fast: false
matrix:
php: [7.4, 8.0]
node: [14.18]
mysql: [5.7, 8.0]
sylius: ["~1.10.0", "~1.11.0"]
php: [ "8.0" ]
symfony: [ "^5.4", "^6.0" ]
sylius: [ "~1.11.0", "~1.12.0" ]
node: [ "^14.17.x" ]
mysql: [ "8.0" ]

exclude:
- sylius: "~1.11.0"
php: 7.4
- sylius: ~1.11.0
symfony: "^6.0"

env:
APP_ENV: test
Expand Down Expand Up @@ -94,6 +95,14 @@ jobs:
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-composer-
-
name: Restrict Symfony version
if: matrix.symfony != ''
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
composer config extra.symfony.require "${{ matrix.symfony }}"
-
name: Restrcting Sylius version
if: matrix.sylius != ''
Expand Down Expand Up @@ -131,7 +140,7 @@ jobs:
name: Prepare test application assets
run: |
(cd tests/Application && bin/console assets:install public -vvv)
(cd tests/Application && yarn build)
(cd tests/Application && yarn encore dev)
-
name: Prepare test application cache
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ This **open-source plugin was developed to help the Sylius community** and make

We work on stable, supported and up-to-date versions of packages. We recommend you to do the same.

| Package | Version |
| --- | --- |
| PHP | ^7.4 or ^8.0 |
| ext-json: | * |
| sylius/refund-plugin | ^1.0.0|
| sylius/resource-bundle | ^1.8 |
| sylius/sylius | ^1.10.0 or ^1.11.0 |
| symfony/messenger | ^4.4 |
| adyen/php-api-library | ^10.1 |
| Package | Version |
| --- |--------------------|
| PHP | ^8.0 |
| ext-json: | * |
| sylius/refund-plugin | ^1.0.0 |
| sylius/resource-bundle | ^1.8 |
| sylius/sylius | ^1.11.0 or ^1.12.0 |
| symfony/messenger | ^5.4 |
| adyen/php-api-library | ^10.1 |

----

Expand Down Expand Up @@ -155,6 +155,8 @@ $ cd tests/Application
$ bin/console assets:install -e test
$ bin/console doctrine:database:create -e test
$ bin/console doctrine:schema:create -e test
$ yarn install
$ yarn encore dev
$ bin/console server:run 127.0.0.1:8080 -e test
$ bin/phpunit
$ bin/behat
Expand Down
32 changes: 15 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
],
"license": "MIT",
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.0",
"adyen/php-api-library": "^11.0",
"composer/package-versions-deprecated": "^1.11",
"doctrine/annotations": "^1.14",
"nyholm/psr7": "^1.4",
"sylius-labs/doctrine-migrations-extra-bundle": "^0.1.4",
"psalm/plugin-symfony": "^4.0",
"sylius/refund-plugin": "~1.0.0 || ^1.1",
"sylius/resource-bundle": "^1.8",
"sylius/sylius": "^1.10.0 || ^1.11.0",
"symfony/messenger": "^4.4 || ^5.0",
"symfony/serializer": "^4.4 || ^5.0"
"sylius/sylius": "~1.11.0 || ~1.12.0",
"symfony/messenger": "^5.4 || ^6.0",
"symfony/serializer": "^5.4 || ^6.0",
"symfony/webpack-encore-bundle": "^1.14"
},
"require-dev": {
"behat/behat": "^3.6.1",
Expand All @@ -36,22 +37,19 @@
"lakion/mink-debug-extension": "^2.0.0",
"phpspec/phpspec": "^7.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "0.12.74",
"phpstan/phpstan-doctrine": "0.12.31",
"phpstan/phpstan": "0.12.90",
"phpstan/phpstan-doctrine": "0.12.39",
"phpstan/phpstan-strict-rules": "^0.12.0",
"phpstan/phpstan-webmozart-assert": "0.12.12",
"phpunit/phpunit": "^9.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"psalm/plugin-symfony": "^2.3",
"sensiolabs/security-checker": "^6.0",
"symfony/browser-kit": "^4.4",
"symfony/debug-bundle": "^4.4 || ^5.0",
"symfony/dotenv": "^4.4 || ^5.0",
"symfony/intl": "^4.4 || ^5.0",
"symfony/web-profiler-bundle": "^4.4 || ^5.0",
"symfony/web-server-bundle": "^4.4 || ^5.0",
"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",
"symplify/easy-coding-standard": "^9.3, !=9.3.27",
"vimeo/psalm": "^4.4.1"
"vimeo/psalm": "^4.4.1 || ^5.0.0"
},
"config": {
"sort-packages": true,
Expand Down
20 changes: 14 additions & 6 deletions doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ monolog:
- adyen
```

8. Copy Sylius templates overridden by plug-in to your templates directory (`templates/bundles/`):
8. Configure config/packages/webpack_encore.yaml
```yaml
builds:
*: *
shop: '%kernel.project_dir%/public/build/shop'
admin: '%kernel.project_dir%/public/build/admin'
```

9. Copy Sylius templates overridden by plug-in to your templates directory (`templates/bundles/`):

```
mkdir -p templates/bundles/SyliusAdminBundle/
Expand All @@ -68,27 +76,27 @@ cp -R vendor/bitbag/sylius-adyen-plugin/tests/Application/templates/bundles/Syli
cp -R vendor/bitbag/sylius-adyen-plugin/tests/Application/templates/bundles/SyliusShopBundle/* templates/bundles/SyliusShopBundle/
```

9. Execute migrations
10. Execute migrations

```
bin/console doctrine:migrations:migrate
```
10. Install assets
11. Install assets
```
bin/console assets:install
```
11. Clear cache
12. Clear cache
```
bin/console cache:clear
```
**Note:** If you are running it on production, add the `-e prod` flag to this command.
12. [Obtain Adyen credentials and configure the payment method](configuration.md)
13. [Obtain Adyen credentials and configure the payment method](configuration.md)
13. If you want to access the log page, visit /adyen/log.
14. If you want to access the log page, visit /adyen/log.
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
parameters:
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false

excludes_analyse:
# Makes PHPStan crash
Expand Down
3 changes: 0 additions & 3 deletions src/Bus/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ final class Dispatcher implements DispatcherInterface
{
use HandleTrait;

/** @var MessageBusInterface */
private $messageBus;

/** @var PaymentCommandFactoryInterface */
private $commandFactory;

Expand Down
13 changes: 10 additions & 3 deletions src/Callback/PreserveOrderTokenUponRedirectionCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,29 @@
namespace BitBag\SyliusAdyenPlugin\Callback;

use Sylius\Component\Core\Model\OrderInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

class PreserveOrderTokenUponRedirectionCallback
{
public const NON_FINALIZED_CART_SESSION_KEY = '_ADYEN_PAYMENT_IN_PROGRESS';

/** @var SessionInterface */
/** @var ?SessionInterface */
private $session;

public function __construct(SessionInterface $session)
public function __construct(RequestStack $session)
{
$this->session = $session;
if (null == $session->getMainRequest()) {
return;
}
$this->session = $session->getSession();
}

public function __invoke(OrderInterface $order): void
{
if (null === $this->session) {
return;
}
$tokenValue = $order->getTokenValue();

if (null === $tokenValue) {
Expand Down
1 change: 0 additions & 1 deletion src/Controller/Shop/AdyenDetailsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public function __construct(

public function __invoke(Request $request, string $code): Response
{
/** @var ?string $referenceId */
$referenceId = $request->query->get(self::REFERENCE_ID_KEY);

if (null === $referenceId) {
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/BitBagSyliusAdyenExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getConfiguration(array $config, ContainerBuilder $container): Co
return new Configuration();
}

public function getAlias()
public function getAlias(): string
{
return 'bitbag_sylius_adyen';
}
Expand Down
9 changes: 3 additions & 6 deletions src/Processor/PaymentResponseProcessor/AbstractProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ abstract class AbstractProcessor implements ProcessorInterface

public const FLASH_ERROR = 'error';

/** @var TranslatorInterface|null */
protected $translator;
protected ?TranslatorInterface $translator;

protected function isResultCodeSupportedForPayment(?PaymentInterface $payment, array $resultCodes): bool
{
Expand Down Expand Up @@ -52,11 +51,9 @@ protected function addFlash(
if (null !== $this->translator) {
$message = $this->translator->trans($message);
}

/**
* @var Session $session
*/
/** @var Session $session */
$session = $request->getSession();

$session->getFlashBag()->add($type, $message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Sylius\Component\Core\Model\PaymentInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

final class FallbackResponseProcessor extends AbstractProcessor
{
Expand All @@ -21,9 +22,10 @@ final class FallbackResponseProcessor extends AbstractProcessor
/** @var UrlGeneratorInterface */
private $urlGenerator;

public function __construct(UrlGeneratorInterface $urlGenerator)
public function __construct(UrlGeneratorInterface $urlGenerator, TranslatorInterface $translator)
{
$this->urlGenerator = $urlGenerator;
$this->translator = $translator;
}

public function accepts(Request $request, ?PaymentInterface $payment): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function denormalize(
}

public function supportsDenormalization(
$data,
string $type,
mixed $data,
?string $type,
string $format = null
): bool {
return
Expand Down Expand Up @@ -90,14 +90,11 @@ public function normalize(
return $result;
}

/**
* @param mixed $data
*/
public function supportsNormalization(
$data,
string $format = null,
mixed $data,
?string $format = null,
array $context = []
) {
): bool {
return
$data instanceof NotificationItemData
&& !isset($context[$this->getNormalizationMarking($data)])
Expand Down
16 changes: 8 additions & 8 deletions src/Resolver/Order/PaymentCheckoutOrderResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Order\Context\CartContextInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Sylius\Component\Order\Repository\OrderRepositoryInterface;
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
Expand All @@ -26,13 +26,12 @@ final class PaymentCheckoutOrderResolver implements PaymentCheckoutOrderResolver
/** @var CartContextInterface */
private $cartContext;

/** @var RepositoryInterface */
private $orderRepository;
private OrderRepositoryInterface $orderRepository;

public function __construct(
RequestStack $requestStack,
CartContextInterface $cartContext,
RepositoryInterface $orderRepository
OrderRepositoryInterface $orderRepository
) {
$this->requestStack = $requestStack;
$this->cartContext = $cartContext;
Expand Down Expand Up @@ -65,10 +64,11 @@ private function getCurrentOrder(): ?OrderInterface
if (null === $tokenValue) {
return null;
}
/**
* @psalm-suppress MixedReturnStatement
*/
return $this->orderRepository->findOneBy(['tokenValue' => $tokenValue]);

/** @var OrderInterface $order */
$order = $this->orderRepository->findOneBy(['tokenValue' => $tokenValue]);

return $order;
}

public function resolve(): OrderInterface
Expand Down
Loading

0 comments on commit 1ecaf51

Please sign in to comment.