Skip to content

Commit 25ab649

Browse files
mpysiakMichał Pysiak
authored andcommitted
Add support for Sylius 1.12
1 parent 8de0cbe commit 25ab649

93 files changed

Lines changed: 500 additions & 589 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,15 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
php: ["8.0", "7.4"]
25-
symfony: ["^4.4", "^5.2"]
26-
sylius: ["~1.9.0", "~1.10.0", "~1.11.0"]
27-
node: ["14.19"]
24+
php: ["8.0"]
25+
symfony: ["^5.4", "^6.0"]
26+
sylius: ["~1.11.0", "~1.12.0"]
27+
node: ["^14.17.x"]
2828
mysql: ["8.0"]
2929

3030
exclude:
31-
- sylius: ~1.9.0
32-
php: 8.0
33-
34-
- sylius: ~1.10.0
35-
symfony: ^4.4
36-
3731
- sylius: ~1.11.0
38-
php: 7.4
32+
symfony: "^6.0"
3933

4034
env:
4135
APP_ENV: test
@@ -132,6 +126,11 @@ jobs:
132126
restore-keys: |
133127
${{ runner.os }}-node-${{ matrix.node }}-yarn-
134128
129+
-
130+
name: Copy package.json.dist to package.json
131+
if: matrix.sylius != ''
132+
run: (cd tests/Application && cp package.json.\${{ matrix.sylius }}.dist package.json)
133+
135134
-
136135
name: Install JS dependencies
137136
run: |

.github/workflows/coding_standard.yml

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,17 @@ jobs:
1919
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"
2020

2121
strategy:
22-
fail-fast: false
23-
matrix:
24-
php: [7.4, 7.3, 8.0]
25-
symfony: [^4.4, ^5.2]
26-
sylius: [~1.8.0, ~1.9.0, ~1.10.0, ~1.11.0]
27-
node: [10.x]
28-
mysql: [5.7]
22+
fail-fast: false
23+
matrix:
24+
php: ["8.0"]
25+
symfony: ["^5.4", "^6.0"]
26+
sylius: ["~1.11.0", "~1.12.0"]
27+
node: ["^14.17.x"]
28+
mysql: ["8.0"]
2929

30-
exclude:
31-
-
32-
php: 7.3
33-
mysql: 8.0
34-
-
35-
sylius: ~1.8.0
36-
symfony: ^5.2
37-
-
38-
sylius: ~1.8.0
39-
php: 8.0
40-
-
41-
sylius: ~1.9.0
42-
php: 8.0
43-
-
44-
sylius: ~1.10.0
45-
php: 7.3
46-
47-
-
48-
sylius: ~1.11.0
49-
php: 7.3
50-
51-
-
52-
sylius: ~1.11.0
53-
php: 7.4
30+
exclude:
31+
- sylius: ~1.11.0
32+
symfony: "^6.0"
5433

5534
env:
5635
APP_ENV: test

composer.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"description": "CMS plugin for Sylius applications.",
1010
"license": "MIT",
1111
"require": {
12-
"php": "^7.3 || ^7.4 || ^8.0",
13-
"sylius/sylius": "~1.8.0 || ~1.9.0 || ~1.10.0 || ~1.11.0 || ~1.12.0",
12+
"php": "^8.0",
13+
"sylius/sylius": "~1.11.0 || ~1.12.0",
1414
"league/csv": "^9.1",
15-
"friendsofsymfony/ckeditor-bundle": "^1.1||^2.0",
15+
"friendsofsymfony/ckeditor-bundle": "^1.1 || ^2.0",
1616
"instaclick/php-webdriver": "^1.4",
1717
"symfony/webpack-encore-bundle": "^1.12"
1818
},
@@ -30,25 +30,25 @@
3030
"friends-of-behat/suite-settings-extension": "^1.0",
3131
"friends-of-behat/symfony-extension": "^2.1",
3232
"friends-of-behat/variadic-extension": "^1.3",
33-
"lchrusciel/api-test-case": "^4.1||^5.0",
34-
"friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev",
33+
"lchrusciel/api-test-case": "^4.1 || ^5.0",
3534
"phpspec/phpspec": "^7.0",
3635
"phpstan/extension-installer": "^1.0",
3736
"phpstan/phpstan": "0.12.99",
3837
"phpstan/phpstan-doctrine": "0.12.33",
3938
"phpstan/phpstan-strict-rules": "^0.12.0",
4039
"phpstan/phpstan-webmozart-assert": "0.12.12",
4140
"phpunit/phpunit": "^9.5",
42-
"sensiolabs/security-checker": "^6.0",
4341
"sylius-labs/coding-standard": "^4.0",
44-
"symfony/browser-kit": "^4.4 || ^5.2",
45-
"symfony/debug-bundle": "^4.4 || ^5.2",
46-
"symfony/dotenv": "^4.4 || ^5.2",
47-
"symfony/intl": "^4.4 || ^5.2",
48-
"symfony/web-profiler-bundle": "^4.4 || ^5.2",
49-
"vimeo/psalm": "4.7.1",
42+
"symfony/browser-kit": "^5.4 || ^6.0",
43+
"symfony/debug-bundle": "^5.4 || ^6.0",
44+
"symfony/dotenv": "^5.4 || ^6.0",
45+
"symfony/intl": "^5.4 || ^6.0",
46+
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
47+
"league/flysystem-bundle": "2.4.0",
48+
"sylius/mailer-bundle": "^1.8 || ^2.0@beta",
5049
"matthiasnoback/symfony-config-test": "^4.3",
51-
"polishsymfonycommunity/symfony-mocker-container": "^1.0"
50+
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
51+
"twig/twig": "^2.10.0"
5252
},
5353
"conflict": {
5454
"symfony/symfony": "4.1.8",

spec/MediaProvider/GenericProviderSpec.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@
1919

2020
final class GenericProviderSpec extends ObjectBehavior
2121
{
22-
public function let(
22+
function let(
2323
MediaUploaderInterface $uploader,
2424
Environment $twigEngine
2525
) {
2626
$this->beConstructedWith($uploader, $twigEngine, '@Template', '/media/');
2727
}
2828

29-
public function it_is_initializable(): void
29+
function it_is_initializable(): void
3030
{
3131
$this->shouldHaveType(GenericProvider::class);
3232
}
3333

34-
public function it_implements_provider_interface(): void
34+
function it_implements_provider_interface(): void
3535
{
3636
$this->shouldHaveType(ProviderInterface::class);
3737
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
* This file was created by developers working at BitBag
5+
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
6+
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7+
*/
8+
9+
declare(strict_types=1);
10+
11+
namespace spec\BitBag\SyliusCmsPlugin\MediaProvider;
12+
13+
use BitBag\SyliusCmsPlugin\Entity\MediaInterface;
14+
use BitBag\SyliusCmsPlugin\MediaProvider\GenericProvider;
15+
use BitBag\SyliusCmsPlugin\MediaProvider\ProviderInterface;
16+
use BitBag\SyliusCmsPlugin\Uploader\MediaUploaderInterface;
17+
use PhpSpec\ObjectBehavior;
18+
use Twig\Environment;
19+
20+
final class GenericProviderSpec extends ObjectBehavior
21+
{
22+
public function let(
23+
MediaUploaderInterface $uploader,
24+
Environment $twigEngine
25+
) {
26+
$this->beConstructedWith($uploader, $twigEngine, '@Template', '/media/');
27+
}
28+
29+
public function it_is_initializable(): void
30+
{
31+
$this->shouldHaveType(GenericProvider::class);
32+
}
33+
34+
public function it_implements_provider_interface(): void
35+
{
36+
$this->shouldHaveType(ProviderInterface::class);
37+
}
38+
39+
public function it_renders(MediaInterface $media, Environment $twigEngine): void
40+
{
41+
$twigEngine->render('@Template', ['media' => $media, 'config' => []])->willReturn('content');
42+
43+
$this->render($media, '@Template', ['config' => []])->shouldReturn('content');
44+
}
45+
46+
public function it_uploads(MediaInterface $media, MediaUploaderInterface $uploader): void
47+
{
48+
$uploader->upload($media, '/media/')->shouldNotBeCalled();
49+
}
50+
}

src/Controller/Action/Admin/ImportDataAction.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
use Symfony\Component\HttpFoundation\File\UploadedFile;
1919
use Symfony\Component\HttpFoundation\RedirectResponse;
2020
use Symfony\Component\HttpFoundation\Request;
21+
use Symfony\Component\HttpFoundation\RequestStack;
2122
use Symfony\Component\HttpFoundation\Response;
22-
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
23+
use Symfony\Component\HttpFoundation\Session\Session;
2324
use Symfony\Contracts\Translation\TranslatorInterface;
2425
use Twig\Environment;
2526

@@ -31,8 +32,8 @@ final class ImportDataAction
3132
/** @var FormFactoryInterface */
3233
private $formFactory;
3334

34-
/** @var FlashBagInterface */
35-
private $flashBag;
35+
/** @var RequestStack */
36+
private $requestStack;
3637

3738
/** @var FormErrorsFlashHelperInterface */
3839
private $formErrorsFlashHelper;
@@ -71,14 +72,16 @@ public function __invoke(Request $request): Response
7172
/** @var UploadedFile $file */
7273
$file = $form->get('file')->getData();
7374
$resourceName = $request->get('resourceName');
74-
$session = $this->requestStack->getSession()->getFlashBag();
75-
75+
/** @var Session $session */
76+
$session = $this->requestStack->getSession();
77+
$flashBag = $session->getFlashBag();
78+
7679
try {
7780
$this->importProcessor->process($resourceName, $file->getPathname());
7881

79-
$session->set('success', $this->translator->trans('bitbag_sylius_cms_plugin.ui.successfully_imported'));
82+
$flashBag->set('success', $this->translator->trans('bitbag_sylius_cms_plugin.ui.successfully_imported'));
8083
} catch (ImportFailedException $exception) {
81-
$session->set('error', $exception->getMessage());
84+
$flashBag->set('error', $exception->getMessage());
8285
}
8386
} else {
8487
$this->formErrorsFlashHelper->addFlashErrors($form);

src/Controller/Helper/FormErrorsFlashHelper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212

1313
use Symfony\Component\Form\FormError;
1414
use Symfony\Component\Form\FormInterface;
15-
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
15+
use Symfony\Component\HttpFoundation\RequestStack;
1616
use Symfony\Contracts\Translation\TranslatorInterface;
1717

1818
final class FormErrorsFlashHelper implements FormErrorsFlashHelperInterface
1919
{
20-
/** @var FlashBagInterface */
2120
private $requestStack;
2221

22+
/** @var RequestStack */
23+
2324
/** @var TranslatorInterface */
2425
private $translator;
2526

src/Controller/ResourceDataProcessingTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ trait ResourceDataProcessingTrait
1616
{
1717
private function getResourceInterface(Request $request): object
1818
{
19-
return null !== $request->get('id') && $this->repository->find($request->get('id')) ?
19+
return null !== $request->get('id') && null !== $this->repository->find($request->get('id')) ?
2020
$this->repository->find($request->get('id')) :
2121
$this->factory->createNew();
2222
}

src/EventListener/ResourceDeleteSubscriber.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@
1515
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1616
use Symfony\Component\HttpFoundation\RedirectResponse;
1717
use Symfony\Component\HttpFoundation\Request;
18+
use Symfony\Component\HttpFoundation\RequestStack;
19+
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
1820
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
1921
use Symfony\Component\HttpKernel\KernelEvents;
2022
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
21-
use Symfony\Component\HttpFoundation\RequestStack;
2223

2324
final class ResourceDeleteSubscriber implements EventSubscriberInterface
2425
{
25-
/** @var UrlGeneratorInterface */
26-
private $router;
26+
private UrlGeneratorInterface $router;
2727

28-
/** @var SessionInterface */
29-
private $requestStack;
28+
private RequestStack $requestStack;
3029

3130
public function __construct(UrlGeneratorInterface $router, RequestStack $requestStack)
3231
{
@@ -48,7 +47,7 @@ public function onResourceDelete(ExceptionEvent $event): void
4847
return;
4948
}
5049

51-
if (!$event->isMasterRequest() || 'html' !== $event->getRequest()->getRequestFormat()) {
50+
if (!$event->isMainRequest() || 'html' !== $event->getRequest()->getRequestFormat()) {
5251
return;
5352
}
5453

@@ -70,6 +69,7 @@ public function onResourceDelete(ExceptionEvent $event): void
7069
}
7170

7271
$session = $this->requestStack->getSession();
72+
/** @var FlashBagInterface $flashBag */
7373
$flashBag = $session->getBag('flashes');
7474
$flashBag->add('error', [
7575
'message' => 'sylius.resource.delete_error',

src/Resources/config/routing/admin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bitbag_sylius_cms_plugin_admin_ajax_generate_page_slug:
2626
path: /page/generate-slug
2727
methods: [GET]
2828
defaults:
29-
_controller: bitbag_sylius_cms_plugin.controller.page_slug:generateAction
29+
_controller: bitbag_sylius_cms_plugin.controller.page_slug::generateAction
3030

3131
bitbag_sylius_cms_plugin_admin_import_data:
3232
path: /import/{resourceName}

0 commit comments

Comments
 (0)