Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,10 @@ indent_size = 4
indent_style = space
indent_size = 2

[phpspec.yml{,.dist}]
indent_style = space
indent_size = 4

[phpstan.neon]
indent_style = space
indent_size = 4

[phpunit.xml{,.dist}]
indent_style = space
indent_size = 4
indent_size = 4
36 changes: 17 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ on:
jobs:
tests:
runs-on: ubuntu-latest

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

strategy:
fail-fast: false
matrix:
php: [ "8.1", "8.2", "8.3" ]
symfony: [ "^5.4", "^6.4" ]
sylius: [ "^1.14"]
php: [ "8.2", "8.3" ]
symfony: [ "^6.4", "^7.3" ]
sylius: [ "^2.0", "^2.1" ]
node: [ "20.x" ]
mysql: [ "8.0" ]
env:
Expand All @@ -35,7 +35,7 @@ jobs:
with:
php-version: "${{ matrix.php }}"
extensions: intl
tools: symfony, composer-require-checker, composer-unused, flex
tools: composer-require-checker, composer-unused, flex, symfony
coverage: none

- name: Setup Node
Expand All @@ -61,9 +61,6 @@ jobs:
- name: Run Chrome Headless
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 &

- name: Run webserver
run: (cd tests/Application && symfony server:start --port=8080 --dir=public --daemon)

- name: Validate composer.json
run: composer validate --ansi --strict

Expand Down Expand Up @@ -107,22 +104,23 @@ jobs:
key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}-yarn-

- name: Install JS dependencies
run: (cd tests/Application && yarn install)
run: yarn install --cwd vendor/sylius/test-application

- name: Prepare test application database
run: |
(cd tests/Application && bin/console doctrine:database:create -vvv)
(cd tests/Application && bin/console doctrine:schema:create -vvv)
vendor/bin/console doctrine:database:create -vvv
vendor/bin/console doctrine:migrations:migrate --no-interaction -vvv
- name: Prepare test application assets
run: |
(cd tests/Application && bin/console assets:install public -vvv)
(cd tests/Application && yarn build:prod)
vendor/bin/console assets:install -vvv
yarn --cwd vendor/sylius/test-application build:prod
- name: Prepare test application cache
run: (cd tests/Application && bin/console cache:warmup -vvv)
run: vendor/bin/console cache:warmup -vvv

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

- name: Run Coding Standard
run: vendor/bin/ecs check
Expand All @@ -134,20 +132,20 @@ jobs:
run: composer-unused

- name: Validate database schema
run: (cd tests/Application && bin/console doctrine:schema:validate)
run: vendor/bin/console doctrine:schema:validate

- name: Run PHPStan
run: vendor/bin/phpstan analyse

- name: Run Psalm
run: vendor/bin/psalm

- name: Run PHPSpec
run: vendor/bin/phpspec run --ansi -f progress --no-interaction

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

- name: Run webserver
run: symfony server:start --port=8080 --daemon

- name: Run Behat
run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun

Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
/vendor/
/var/
/node_modules/
/composer.lock

/etc/build/*
!/etc/build/.gitignore

/tests/Application/yarn.lock
/tests/TestApplication/.env.local
/tests/TestApplication/.env.test.local
/tests/TestApplication/.env.*.local

/.phpunit.result.cache
/behat.yml
/phpspec.yml
/phpunit.xml
/docker-compose.override.yml
/compose.override.yaml

.phpunit.result.cache
2 changes: 1 addition & 1 deletion .php-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.2
8.3
59 changes: 16 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@

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

![Subscription process for configurable product](subscriprion_process.gif)

![Subscription for simple product](simple_product.png)
![Subscription for simple product](docs/product.png)

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

![See the apposite section in the my account](my_account_section.png)
![See the apposite section in the my account](docs/my_account_section.png)

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

![See the apposite section in the admin account](admin_account_section.png)
![See the apposite section in the admin account](docs/admin_account_section.png)

## Requirements

* PHP `^8.1`
* Sylius `^1.14`
* PHP `^8.2`
* Sylius `^2.0`

## Installation

Expand Down Expand Up @@ -63,29 +61,7 @@ bin/console assets:install
bin/console sylius:theme:assets:install
```

6. Install the plugin JS assets by adding the source to your webpack configuration:

```js
// Shop config
Encore.setOutputPath('public/build/shop/')
.setPublicPath('/build/shop')
.addEntry('shop-entry', './vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/private/entry.js')
.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
.disableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
.enableVersioning(Encore.isProduction())
.enablePostCssLoader()
.enableSassLoader()
```

7. Run yarn build:

```bash
bin/console yarn:build
```

8. Clear cache:
6. Clear cache:

```bash
bin/console cache:clear
Expand Down Expand Up @@ -126,17 +102,20 @@ To contribute to this plugin clone this repository, create a branch for your fea

```bash
composer install
(cd tests/Application && yarn install)
(cd tests/Application && yarn build)
(cd tests/Application && APP_ENV=test bin/console assets:install public)
(cd vendor/sylius/test-application && yarn install)
(cd vendor/sylius/test-application && yarn build)
vendor/bin/console assets:install

docker-compose up -d # only if you haven't mysql and mailhog installed locally

(cd tests/Application && APP_ENV=test bin/console doctrine:database:create)
(cd tests/Application && APP_ENV=test bin/console doctrine:schema:create)
```
vendor/bin/console doctrine:database:create
vendor/bin/console doctrine:migrations:migrate -n
# Optionally load data fixtures
vendor/bin/console sylius:fixtures:load -n

To be able to setup a plugin's database, remember to configure you database credentials in `tests/Application/.env` and `tests/Application/.env.test`.
symfony server:ca:install
symfony server:start -d
```

### Running plugin tests

Expand All @@ -146,12 +125,6 @@ To be able to setup a plugin's database, remember to configure you database cred
vendor/bin/phpunit
```

#### PHPSpec

```bash
vendor/bin/phpspec run
```

#### Behat (non-JS scenarios)

```bash
Expand Down
79 changes: 79 additions & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# UPGRADE 4.x TO 5.0

## Version Support

- Removed support for Sylius 1.12
- Added support for Sylius 2.0 and 2.1
- PHP 8.2+ required
- Symfony 6.4+ or 7.3+ required

## Removed Classes

- `src/Twig/AvailabilityExtension.php`
- `src/Twig/AvailabilityRuntime.php`

## Removed Templates

- `templates/_javascript.html.twig`
- `templates/_addSubscription.html.twig`
- `templates/productSubscriptionForm.html.twig`
- `templates/_configurableButton.html.twig`

## New Classes

- `src/Twig/Component/AddNotificationComponent.php` - LiveComponent replacing old Twig extension
- `src/Factory/SubscriptionFactory.php`
- `src/Processor/SubscriptionProcessor.php`

## Changed Classes

### SubscriptionController

```diff
namespace Webgriffe\SyliusBackInStockNotificationPlugin\Controller;

final class SubscriptionController extends AbstractController
{
public function __construct(
- private ChannelContextInterface $channelContext,
private TranslatorInterface $translator,
- private CustomerContextInterface $customerContext,
- private AvailabilityCheckerInterface $availabilityChecker,
- private ProductVariantRepositoryInterface $productVariantRepository,
- private SenderInterface $sender,
- private LocaleContextInterface $localeContext,
private SubscriptionRepositoryInterface $backInStockNotificationRepository,
- private FactoryInterface $backInStockNotificationFactory,
) {
}
```

### AlertCommand

```diff
namespace Webgriffe\SyliusBackInStockNotificationPlugin\Command;

- use Symfony\Component\Console\Command\Command;

+ use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;

- final class AlertCommand extends Command
+ #[AsCommand(
+ name: 'webgriffe:back-in-stock-notification:alert',
+ description: 'Send an email to the user if the product is returned in stock',
+ )]
+ final class AlertCommand extends Command
{
- protected function configure(): void
- {
- $this
- ->setName('webgriffe:back-in-stock-notification:alert')
- ->setDescription('Send an email to the user if the product is returned in stock');
- }
}
```

## Asset Changes

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.
Binary file removed admin_account_section.png
Binary file not shown.
4 changes: 4 additions & 0 deletions assets/admin/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"controllers": [],
"entrypoints": []
}
4 changes: 4 additions & 0 deletions assets/shop/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"controllers": [],
"entrypoints": []
}
File renamed without changes.
4 changes: 2 additions & 2 deletions behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ default:
show_auto: false

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

FriendsOfBehat\VariadicExtension: ~

Expand Down
45 changes: 0 additions & 45 deletions bin/create_node_symlink.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
ports:
- 3306:3306

mailhog:
mailpit:
ports:
- "8025:8025"
- "1025:1025"
Loading
Loading