Skip to content

Commit 3df6064

Browse files
authored
Merge pull request #458 from BitBagCommerce/feature/add-sylius-1.12-support
Feature/add sylius 1.12 support
2 parents 533fbdc + d05bf38 commit 3df6064

95 files changed

Lines changed: 472 additions & 601 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",
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: 11 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;
@@ -46,14 +47,14 @@ final class ImportDataAction
4647
public function __construct(
4748
ImportProcessorInterface $importProcessor,
4849
FormFactoryInterface $formFactory,
49-
FlashBagInterface $flashBag,
50+
RequestStack $requestStack,
5051
FormErrorsFlashHelperInterface $formErrorsFlashHelper,
5152
TranslatorInterface $translator,
5253
Environment $twig
5354
) {
5455
$this->importProcessor = $importProcessor;
5556
$this->formFactory = $formFactory;
56-
$this->flashBag = $flashBag;
57+
$this->requestStack = $requestStack;
5758
$this->formErrorsFlashHelper = $formErrorsFlashHelper;
5859
$this->translator = $translator;
5960
$this->twig = $twig;
@@ -71,13 +72,16 @@ public function __invoke(Request $request): Response
7172
/** @var UploadedFile $file */
7273
$file = $form->get('file')->getData();
7374
$resourceName = $request->get('resourceName');
75+
/** @var Session $session */
76+
$session = $this->requestStack->getSession();
77+
$flashBag = $session->getFlashBag();
7478

7579
try {
7680
$this->importProcessor->process($resourceName, $file->getPathname());
7781

78-
$this->flashBag->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'));
7983
} catch (ImportFailedException $exception) {
80-
$this->flashBag->set('error', $exception->getMessage());
84+
$flashBag->set('error', $exception->getMessage());
8185
}
8286
} else {
8387
$this->formErrorsFlashHelper->addFlashErrors($form);

src/Controller/Helper/FormErrorsFlashHelper.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
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 */
21-
private $flashBag;
20+
/** @var RequestStack */
21+
private $requestStack;
2222

2323
/** @var TranslatorInterface */
2424
private $translator;
2525

26-
public function __construct(FlashBagInterface $flashBag, TranslatorInterface $translator)
26+
public function __construct(RequestStack $requestStack, TranslatorInterface $translator)
2727
{
28-
$this->flashBag = $flashBag;
28+
$this->requestStack = $requestStack;
2929
$this->translator = $translator;
3030
}
3131

@@ -43,6 +43,7 @@ public function addFlashErrors(FormInterface $form): void
4343

4444
$message = $this->translator->trans('bitbag_sylius_cms_plugin.ui.form_was_submitted_with_errors') . ' ' . rtrim(implode(' ', $errors));
4545

46-
$this->flashBag->set('error', $message);
46+
$session = $this->requestStack->getSession()->getFlashBag();
47+
$session->set('error', $message);
4748
}
4849
}

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: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,22 @@
1515
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1616
use Symfony\Component\HttpFoundation\RedirectResponse;
1717
use Symfony\Component\HttpFoundation\Request;
18+
use Symfony\Component\HttpFoundation\RequestStack;
1819
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
19-
use Symfony\Component\HttpFoundation\Session\SessionInterface;
2020
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
2121
use Symfony\Component\HttpKernel\KernelEvents;
2222
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
2323

2424
final class ResourceDeleteSubscriber implements EventSubscriberInterface
2525
{
26-
/** @var UrlGeneratorInterface */
27-
private $router;
26+
private UrlGeneratorInterface $router;
2827

29-
/** @var SessionInterface */
30-
private $session;
28+
private RequestStack $requestStack;
3129

32-
public function __construct(UrlGeneratorInterface $router, SessionInterface $session)
30+
public function __construct(UrlGeneratorInterface $router, RequestStack $requestStack)
3331
{
3432
$this->router = $router;
35-
$this->session = $session;
33+
$this->requestStack = $requestStack;
3634
}
3735

3836
public static function getSubscribedEvents(): array
@@ -49,7 +47,7 @@ public function onResourceDelete(ExceptionEvent $event): void
4947
return;
5048
}
5149

52-
if (!$event->isMasterRequest() || 'html' !== $event->getRequest()->getRequestFormat()) {
50+
if (!$event->isMainRequest() || 'html' !== $event->getRequest()->getRequestFormat()) {
5351
return;
5452
}
5553

@@ -70,8 +68,9 @@ public function onResourceDelete(ExceptionEvent $event): void
7068
return;
7169
}
7270

71+
$session = $this->requestStack->getSession();
7372
/** @var FlashBagInterface $flashBag */
74-
$flashBag = $this->session->getBag('flashes');
73+
$flashBag = $session->getBag('flashes');
7574
$flashBag->add('error', [
7675
'message' => 'sylius.resource.delete_error',
7776
'parameters' => ['%resource%' => $resourceName],

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)