Skip to content

Commit 6947625

Browse files
Wojdylaklruozzi9
authored andcommitted
Bump to Sylius 2.0
1 parent 9dd4cb0 commit 6947625

74 files changed

Lines changed: 760 additions & 633 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: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
php: [ "8.1", "8.2", "8.3" ]
22-
symfony: [ "^5.4", "^6.4" ]
23-
sylius: [ "^1.14"]
21+
php: [ "8.2", "8.3" ]
22+
symfony: [ "^6.4", "^7.3" ]
23+
sylius: [ "^2.0", "^2.1" ]
2424
node: [ "20.x" ]
2525
mysql: [ "8.0" ]
2626
env:
@@ -58,12 +58,6 @@ jobs:
5858
- name: Install certificates
5959
run: symfony server:ca:install || true
6060

61-
- name: Run Chrome Headless
62-
run: google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 &
63-
64-
- name: Run webserver
65-
run: (cd tests/Application && symfony server:start --port=8080 --dir=public --daemon)
66-
6761
- name: Validate composer.json
6862
run: composer validate --ansi --strict
6963

@@ -107,22 +101,23 @@ jobs:
107101
key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}
108102
restore-keys: |
109103
${{ runner.os }}-node-${{ matrix.node }}-yarn-
104+
110105
- name: Install JS dependencies
111-
run: (cd tests/Application && yarn install)
106+
run: yarn install --cwd vendor/sylius/test-application
112107

113108
- name: Prepare test application database
114109
run: |
115-
(cd tests/Application && bin/console doctrine:database:create -vvv)
116-
(cd tests/Application && bin/console doctrine:schema:create -vvv)
110+
vendor/bin/console doctrine:database:create -vvv
111+
vendor/bin/console doctrine:migrations:migrate --no-interaction -vvv
117112
- name: Prepare test application assets
118113
run: |
119-
(cd tests/Application && bin/console assets:install public -vvv)
120-
(cd tests/Application && yarn build:prod)
114+
vendor/bin/console assets:install -vvv
115+
yarn --cwd vendor/sylius/test-application build:prod
121116
- name: Prepare test application cache
122-
run: (cd tests/Application && bin/console cache:warmup -vvv)
117+
run: vendor/bin/console cache:warmup -vvv
123118

124119
- name: Load fixtures in test application
125-
run: (cd tests/Application && bin/console sylius:fixtures:load -n)
120+
run: vendor/bin/console sylius:fixtures:load -n
126121

127122
- name: Run Coding Standard
128123
run: vendor/bin/ecs check
@@ -139,15 +134,18 @@ jobs:
139134
- name: Run PHPStan
140135
run: vendor/bin/phpstan analyse
141136

142-
- name: Run Psalm
143-
run: vendor/bin/psalm
144-
145137
- name: Run PHPSpec
146138
run: vendor/bin/phpspec run --ansi -f progress --no-interaction
147139

148140
- name: Run PHPUnit
149141
run: vendor/bin/phpunit --colors=always
150142

143+
- name: Run Chrome Headless
144+
run: google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 &
145+
146+
- name: Run webserver
147+
run: symfony server:start --port=8080 --dir=public --daemon
148+
151149
- name: Run Behat
152150
run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun
153151

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
/vendor/
2+
/var/
23
/node_modules/
34
/composer.lock
45

56
/etc/build/*
67
!/etc/build/.gitignore
78

8-
/tests/Application/yarn.lock
9+
/tests/TestApplication/.env.local
10+
/tests/TestApplication/.env.test.local
11+
/tests/TestApplication/.env.*.local
912

1013
/.phpunit.result.cache
1114
/behat.yml

README.md

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,20 @@
1414

1515
### Subscribe to get a Notification when a product return in stock
1616

17-
![Subscription process for configurable product](subscriprion_process.gif)
18-
19-
![Subscription for simple product](simple_product.png)
17+
![Subscription for simple product](docs/product.png)
2018

2119
### View your subscriptions in the apposite section of your account
2220

23-
![See the apposite section in the my account](my_account_section.png)
21+
![See the apposite section in the my account](docs/my_account_section.png)
2422

2523
### View your client subscriptions in the apposite admin section
2624

27-
![See the apposite section in the admin account](admin_account_section.png)
25+
![See the apposite section in the admin account](docs/admin_account_section.png)
2826

2927
## Requirements
3028

31-
* PHP `^8.1`
32-
* Sylius `^1.14`
29+
* PHP `^8.2`
30+
* Sylius `^2.0`
3331

3432
## Installation
3533

@@ -63,29 +61,7 @@ bin/console assets:install
6361
bin/console sylius:theme:assets:install
6462
```
6563

66-
6. Install the plugin JS assets by adding the source to your webpack configuration:
67-
68-
```js
69-
// Shop config
70-
Encore.setOutputPath('public/build/shop/')
71-
.setPublicPath('/build/shop')
72-
.addEntry('shop-entry', './vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/private/entry.js')
73-
.addEntry('webgriffe-sylius-back-in-stock-notification-entry', './vendor/webgriffe/sylius-back-in-stock-notification-plugin/public/js/back-in-stock-notification.js') // The line to add
74-
.disableSingleRuntimeChunk()
75-
.cleanupOutputBeforeBuild()
76-
.enableSourceMaps(!Encore.isProduction())
77-
.enableVersioning(Encore.isProduction())
78-
.enablePostCssLoader()
79-
.enableSassLoader()
80-
```
81-
82-
7. Run yarn build:
83-
84-
```bash
85-
bin/console yarn:build
86-
```
87-
88-
8. Clear cache:
64+
6. Clear cache:
8965

9066
```bash
9167
bin/console cache:clear

UPGRADE-5.0.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# UPGRADE 4.x TO 5.0
2+
3+
## Version Support
4+
5+
- Removed support for Sylius 1.12
6+
- Added support for Sylius 2.0 and 2.1
7+
- PHP 8.2+ required
8+
- Symfony 6.4+ or 7.3+ required
9+
10+
## Removed Classes
11+
12+
- `src/Twig/AvailabilityExtension.php`
13+
- `src/Twig/AvailabilityRuntime.php`
14+
15+
## Removed Templates
16+
17+
- `templates/_javascript.html.twig`
18+
- `templates/_addSubscription.html.twig`
19+
- `templates/productSubscriptionForm.html.twig`
20+
- `templates/_configurableButton.html.twig`
21+
22+
## New Classes
23+
24+
- `src/Twig/Component/AddNotificationComponent.php` - LiveComponent replacing old Twig extension
25+
- `src/Factory/SubscriptionFactory.php`
26+
- `src/Processor/SubscriptionProcessor.php`
27+
28+
## Changed Classes
29+
30+
### SubscriptionController
31+
32+
```diff
33+
namespace Webgriffe\SyliusBackInStockNotificationPlugin\Controller;
34+
35+
final class SubscriptionController extends AbstractController
36+
{
37+
public function __construct(
38+
- private ChannelContextInterface $channelContext,
39+
private TranslatorInterface $translator,
40+
- private CustomerContextInterface $customerContext,
41+
- private AvailabilityCheckerInterface $availabilityChecker,
42+
- private ProductVariantRepositoryInterface $productVariantRepository,
43+
- private SenderInterface $sender,
44+
- private LocaleContextInterface $localeContext,
45+
private SubscriptionRepositoryInterface $backInStockNotificationRepository,
46+
- private FactoryInterface $backInStockNotificationFactory,
47+
) {
48+
}
49+
```
50+
51+
### AlertCommand
52+
53+
```diff
54+
namespace Webgriffe\SyliusBackInStockNotificationPlugin\Command;
55+
56+
- use Symfony\Component\Console\Command\Command;
57+
58+
+ use Symfony\Component\Console\Attribute\AsCommand;
59+
use Symfony\Component\Console\Command\Command;
60+
61+
- final class AlertCommand extends Command
62+
+ #[AsCommand(
63+
+ name: 'webgriffe:back-in-stock-notification:alert',
64+
+ description: 'Send an email to the user if the product is returned in stock',
65+
+ )]
66+
+ final class AlertCommand extends Command
67+
{
68+
- protected function configure(): void
69+
- {
70+
- $this
71+
- ->setName('webgriffe:back-in-stock-notification:alert')
72+
- ->setDescription('Send an email to the user if the product is returned in stock');
73+
- }
74+
}
75+
```
76+
77+
## Asset Changes
78+
79+
JavaScript file `assets/shop/back-in-stock-notification.js` has been removed. The plugin now uses LiveComponent architecture where form handling and interactions are managed directly by the `AddNotificationComponent` instead of external JavaScript files.

admin_account_section.png

-144 KB
Binary file not shown.

assets/admin/controllers.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"controllers": [],
3+
"entrypoints": []
4+
}

tests/Application/config/api_platform/.gitignore renamed to assets/admin/entrypoint.js

File renamed without changes.

assets/shop/controllers.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"controllers": [],
3+
"entrypoints": []
4+
}

tests/Application/config/secrets/dev/.gitignore renamed to assets/shop/entrypoint.js

File renamed without changes.

behat.yml.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ default:
1919
screenshot: true
2020

2121
Behat\MinkExtension:
22-
files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/"
22+
files_path: "%paths.base%/vendor/sylius/test-application/fixtures/"
2323
base_url: "https://127.0.0.1:8080/"
2424
default_session: symfony
2525
javascript_session: chromedriver
@@ -49,9 +49,9 @@ default:
4949
show_auto: false
5050

5151
FriendsOfBehat\SymfonyExtension:
52-
bootstrap: tests/Application/config/bootstrap.php
52+
bootstrap: vendor/sylius/test-application/config/bootstrap.php
5353
kernel:
54-
class: Tests\Webgriffe\SyliusBackInStockNotificationPlugin\Application\Kernel
54+
class: Sylius\TestApplication\Kernel
5555

5656
FriendsOfBehat\VariadicExtension: ~
5757

0 commit comments

Comments
 (0)