diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index 9986c88..e2b4946 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -7,18 +7,21 @@ build:
tests:
override:
- php-scrutinizer-run
- -
- command: phpcs-run
- use_website_config: true
- js-scrutinizer-run
tests: true
+ environment:
+ php:
+ version: '8.0'
+
filter:
excluded_paths:
- 'tests/*'
- 'features/*'
+
checks:
php: true
javascript: true
+
coding_style:
php:
spaces:
diff --git a/UPGRADE-1.3.md b/UPGRADE-1.3.md
deleted file mode 100644
index 9fd4141..0000000
--- a/UPGRADE-1.3.md
+++ /dev/null
@@ -1,28 +0,0 @@
-# UPGRADE FROM `v1.2.X` TO `v1.3.0`
-
-## Application
-
-* Run `composer require sylius/sylius:~1.3.0 --no-update`
-
-* Add the following code in your `behat.yml(.dist)` file:
-
- ```yaml
- default:
- extensions:
- FriendsOfBehat\SymfonyExtension:
- env_file: ~
- ```
-
-* Incorporate changes from the following files into plugin's test application:
-
- * [`tests/Application/package.json`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/package.json) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-726e1353c14df7d91379c0dea6b30eef))
- * [`tests/Application/.babelrc`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/.babelrc) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-a2527d9d8ad55460b2272274762c9386))
- * [`tests/Application/.eslintrc.js`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/.eslintrc.js) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-396c8c412b119deaa7dd84ae28ae04ca))
-
-* Update PHP and JS dependencies by running `composer update` and `(cd tests/Application && yarn upgrade)`
-
-* Clear cache by running `(cd tests/Application && bin/console cache:clear)`
-
-* Install assets by `(cd tests/Application && bin/console assets:install web)` and `(cd tests/Application && yarn build)`
-
-* optionally, remove the build for PHP 7.1. in `.travis.yml`
diff --git a/UPGRADE-1.4.md b/UPGRADE-1.4.md
deleted file mode 100644
index dc84cad..0000000
--- a/UPGRADE-1.4.md
+++ /dev/null
@@ -1,86 +0,0 @@
-# UPGRADE FROM `v1.3.X` TO `v1.4.0`
-
-First step is upgrading Sylius with composer
-
-- `composer require sylius/sylius:~1.4.0`
-
-### Test application database
-
-#### Migrations
-
-If you provide migrations with your plugin, take a look at following changes:
-
-* Change base `AbstractMigration` namespace to `Doctrine\Migrations\AbstractMigration`
-* Add `: void` return types to both `up` and `down` functions
-
-#### Schema update
-
-If you don't use migrations, just run `(cd tests/Application && bin/console doctrine:schema:update --force)` to update the test application's database schema.
-
-### Dotenv
-
-* `composer require symfony/dotenv:^4.2 --dev`
-* Follow [Symfony dotenv update guide](https://symfony.com/doc/current/configuration/dot-env-changes.html) to incorporate required changes in `.env` files structure. Remember - they should be done on `tests/Application/` level! Optionally, you can take a look at [corresponding PR](https://github.com/Sylius/PluginSkeleton/pull/156/) introducing these changes in **PluginSkeleton** (this PR also includes changes with Behat - see below)
-
-Don't forget to clear the cache (`tests/Application/bin/console cache:clear`) to be 100% everything is loaded properly.
-
----
-
-### Behat
-
-If you're using Behat and want to be up-to-date with our configuration
-
-* Update required extensions with `composer require friends-of-behat/symfony-extension:^2.0 friends-of-behat/page-object-extension:^0.3 --dev`
-* Remove extensions that are not needed yet with `composer remove friends-of-behat/context-service-extension friends-of-behat/cross-container-extension friends-of-behat/service-container-extension --dev`
-* Update your `behat.yml` - look at the diff [here](https://github.com/Sylius/Sylius-Standard/pull/322/files#diff-7bde54db60a6e933518d8b61b929edce)
-* Add `SymfonyExtensionBundle` to your `tests/Application/config/bundles.php`:
- ```php
- return [
- //...
- FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true],
- ];
- ```
-* If you use our Travis CI configuration, follow [these changes](https://github.com/Sylius/PluginSkeleton/pull/156/files#diff-354f30a63fb0907d4ad57269548329e3) introduced in `.travis.yml` file
-* Create `tests/Application/config/services_test.yaml` file with the following code and add these your own Behat services as well:
- ```yaml
- imports:
- - { resource: "../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" }
- ```
-* Remove all `__symfony__` prefixes in your Behat services
-* Remove all `` tags from your Behat services
-* Make your Behat services public by default with ``
-* Change `contexts_services ` in your suite definitions to `contexts`
-* Take a look at [SymfonyExtension UPGRADE guide](https://github.com/FriendsOfBehat/SymfonyExtension/blob/master/UPGRADE-2.0.md) if you have any more problems
-
-### Phpstan
-
-* Fix the container XML path parameter in the `phpstan.neon` file as done [here](https://github.com/Sylius/PluginSkeleton/commit/37fa614dbbcf8eb31b89eaf202b4bd4d89a5c7b3)
-
-# UPGRADE FROM `v1.2.X` TO `v1.4.0`
-
-Firstly, check out the [PluginSkeleton 1.3 upgrade guide](https://github.com/Sylius/PluginSkeleton/blob/1.4/UPGRADE-1.3.md) to update Sylius version step by step.
-To upgrade to Sylius 1.4 follow instructions from [the previous section](https://github.com/Sylius/PluginSkeleton/blob/1.4/UPGRADE-1.4.md#upgrade-from-v13x-to-v140) with following changes:
-
-### Doctrine migrations
-
-* Change namespaces of copied migrations to `Sylius\Migrations`
-
-### Dotenv
-
-* These changes are not required, but can be done as well, if you've changed application directory structure in `1.2.x` to `1.3` update
-
-### Behat
-
-* Add `\FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle()` to your bundles lists in `tests/Application/AppKernel.php` (preferably only in `test` environment)
-* Import Sylius Behat services in `tests/Application/config/config_test.yml` and your own Behat services as well:
- ```yaml
- imports:
- - { resource: "../../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" }
- ```
-* Specify test application's kernel path in `behat.yml`:
- ```yaml
- FriendsOfBehat\SymfonyExtension:
- kernel:
- class: AppKernel
- path: tests/Application/app/AppKernel.php
- ```
diff --git a/behat.yml.dist b/behat.yml.dist
index 525270e..ac8ed5f 100644
--- a/behat.yml.dist
+++ b/behat.yml.dist
@@ -1,22 +1,29 @@
+
imports:
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml
- tests/Behat/Resources/suites.yml
default:
extensions:
- Lakion\Behat\MinkDebugExtension:
+ DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~
+
+ FriendsOfBehat\MinkDebugExtension:
directory: etc/build
clean_start: false
screenshot: true
Behat\MinkExtension:
files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/"
- base_url: "http://localhost:8080/"
+ base_url: "https://127.0.0.1:8080/"
default_session: symfony
- javascript_session: chrome
+ javascript_session: chrome_headless
sessions:
symfony:
symfony: ~
+ chrome_headless:
+ chrome:
+ api_url: http://127.0.0.1:9222
+ validate_certificate: false
chrome:
selenium2:
browser: chrome
@@ -30,6 +37,8 @@ default:
- "start-fullscreen"
- "start-maximized"
- "no-sandbox"
+ extra_capabilities:
+ unexpectedAlertBehaviour: accept
firefox:
selenium2:
browser: firefox
diff --git a/composer.json b/composer.json
index 5fbb8f7..01ed913 100644
--- a/composer.json
+++ b/composer.json
@@ -4,57 +4,77 @@
"keywords": ["sylius", "sylius-plugin"],
"description": "This plugin provides 'send notification when product is available' feature for products out of stock.",
"license": "MIT",
- "version": "1.0.0",
"require": {
- "php": "^7.2",
-
- "sylius/sylius": "^1.4"
+ "php": "^7.4 || ^8.0 || ^8.1",
+ "sylius/sylius": "^1.10 || 1.11"
},
"require-dev": {
- "behat/behat": "^3.4",
- "behat/mink": "^1.7@dev",
- "behat/mink-browserkit-driver": "^1.3",
- "behat/mink-extension": "^2.2",
- "behat/mink-selenium2-driver": "^1.3",
+ "behat/behat": "^3.6.1",
+ "behat/mink-selenium2-driver": "^1.4",
+ "dmore/behat-chrome-extension": "^1.3",
+ "dmore/chrome-mink-driver": "^2.7",
+ "friends-of-behat/mink": "^1.8",
+ "friends-of-behat/mink-browserkit-driver": "^1.4",
+ "friends-of-behat/mink-debug-extension": "^2.0.0",
+ "friends-of-behat/mink-extension": "^2.4",
"friends-of-behat/page-object-extension": "^0.3",
"friends-of-behat/suite-settings-extension": "^1.0",
- "friends-of-behat/symfony-extension": "^2.0",
- "friends-of-behat/variadic-extension": "^1.1",
- "lakion/mink-debug-extension": "^1.2.3",
- "phpspec/phpspec": "^5.0",
- "phpstan/phpstan-doctrine": "^0.10",
- "phpstan/phpstan-shim": "^0.10",
- "phpstan/phpstan-webmozart-assert": "^0.10",
- "phpunit/phpunit": "^6.5",
- "sensiolabs/security-checker": "^5.0",
- "sylius-labs/coding-standard": "^2.0",
- "symfony/browser-kit": "^3.4|^4.1",
- "symfony/debug-bundle": "^3.4|^4.1",
- "symfony/dotenv": "^4.2",
- "symfony/intl": "^3.4|^4.1",
- "symfony/web-profiler-bundle": "^3.4|^4.1",
- "symfony/web-server-bundle": "^3.4|^4.1"
+ "friends-of-behat/symfony-extension": "^2.1",
+ "friends-of-behat/variadic-extension": "^1.3",
+ "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev",
+ "phpspec/phpspec": "^7.0",
+ "phpstan/extension-installer": "^1.0",
+ "phpstan/phpstan": "0.12.99",
+ "phpstan/phpstan-doctrine": "0.12.33",
+ "phpstan/phpstan-strict-rules": "^0.12.0",
+ "phpstan/phpstan-webmozart-assert": "0.12.12",
+ "phpunit/phpunit": "^9.5",
+ "sensiolabs/security-checker": "^6.0",
+ "sylius-labs/coding-standard": "^4.0",
+ "symfony/browser-kit": "^5.4",
+ "symfony/debug-bundle": "^5.4",
+ "symfony/dotenv": "^5.4",
+ "symfony/intl": "^5.4",
+ "symfony/web-profiler-bundle": "^5.4",
+ "vimeo/psalm": "4.23.0",
+ "polishsymfonycommunity/symfony-mocker-container": "^1.0"
},
- "conflict": {
- "symfony/symfony": "4.1.8",
- "symfony/browser-kit": "4.1.8",
- "symfony/dependency-injection": "4.1.8",
- "symfony/dom-crawler": "4.1.8",
- "symfony/routing": "4.1.8"
+ "config": {
+ "sort-packages": true,
+ "allow-plugins": {
+ "dealerdirect/phpcodesniffer-composer-installer": true,
+ "symfony/thanks": true,
+ "phpstan/extension-installer": true
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.11-dev"
+ }
},
- "prefer-stable": true,
"autoload": {
"psr-4": {
- "Workouse\\AvailabilityNotifierPlugin\\": "src/",
- "Tests\\Workouse\\AvailabilityNotifierPlugin\\": "tests/"
+ "Workouse\\AvailabilityNotifierPlugin\\": "src/"
}
},
"autoload-dev": {
- "classmap": ["tests/Application/Kernel.php"]
+ "psr-4": {
+ "Workouse\\AvailabilityNotifierPlugin\\": "src/",
+ "Tests\\Workouse\\AvailabilityNotifierPlugin\\": "tests/"
+ },
+ "classmap": [
+ "tests/Application/Kernel.php"
+ ]
},
- "extra": {
- "branch-alias": {
- "dev-master": "1.5-dev"
- }
+ "scripts": {
+ "post-install-cmd": [
+ "php bin/create_node_symlink.php"
+ ],
+ "post-update-cmd": [
+ "php bin/create_node_symlink.php"
+ ],
+ "post-create-project-cmd": [
+ "php bin/create_node_symlink.php"
+ ]
}
}
diff --git a/src/Controller/AvailabilityNotifierController.php b/src/Controller/AvailabilityNotifierController.php
index 5422bb8..2aa9828 100644
--- a/src/Controller/AvailabilityNotifierController.php
+++ b/src/Controller/AvailabilityNotifierController.php
@@ -20,6 +20,7 @@
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Validator\ValidatorInterface;
+use Twig\Environment;
use Workouse\AvailabilityNotifierPlugin\Entity\AvailabilityNotifier;
use Workouse\AvailabilityNotifierPlugin\Entity\AvailabilityNotifierInterface;
use Workouse\AvailabilityNotifierPlugin\Form\Type\AvailabilityNotifierType;
@@ -58,7 +59,7 @@ class AvailabilityNotifierController
private $validator;
public function __construct(
- TwigEngine $templatingEngine,
+ Environment $templatingEngine,
FormFactoryInterface $formFactory,
CustomerRepositoryInterface $customerRepository,
FactoryInterface $customerFactory,
@@ -85,9 +86,11 @@ public function indexAction($productId): Response
{
$form = $this->formFactory->create(AvailabilityNotifierType::class);
- return $this->templatingEngine->renderResponse(
- '@WorkouseAvailabilityNotifierPlugin/_outOfStock.html.twig',
- ['form' => $form->createView(), 'productId' => $productId]
+ return new Response(
+ $this->templatingEngine->render(
+ '@WorkouseAvailabilityNotifierPlugin/_outOfStock.html.twig',
+ ['form' => $form->createView(), 'productId' => $productId]
+ )
);
}
@@ -175,12 +178,14 @@ public function adminIndexAction($productId): Response
'status' => false,
]));
- return $this->templatingEngine->renderResponse(
- '@WorkouseAvailabilityNotifierPlugin/Admin/_waiting_customers.html.twig',
- [
- 'availabilityNotifiers' => $availabilityNotifiers,
- 'availabilityNotifiersTotal' => $availabilityNotifiersTotal,
- ]
+ return new Response(
+ $this->templatingEngine->render(
+ '@WorkouseAvailabilityNotifierPlugin/Admin/_waiting_customers.html.twig',
+ [
+ 'availabilityNotifiers' => $availabilityNotifiers,
+ 'availabilityNotifiersTotal' => $availabilityNotifiersTotal,
+ ]
+ )
);
}
}
diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php
index c78dd4c..8134584 100644
--- a/src/DependencyInjection/Configuration.php
+++ b/src/DependencyInjection/Configuration.php
@@ -4,8 +4,15 @@
namespace Workouse\AvailabilityNotifierPlugin\DependencyInjection;
+use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
+use Workouse\AvailabilityNotifierPlugin\Entity\AvailabilityNotifier;
+use Workouse\AvailabilityNotifierPlugin\Form\Type\AvailabilityNotifierType;
+use Workouse\AvailabilityNotifierPlugin\Repository\AvailabilityNotifierRepository;
+use Sylius\Component\Resource\Factory\Factory;
+use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
+use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
final class Configuration implements ConfigurationInterface
{
@@ -14,14 +21,43 @@ final class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder(): TreeBuilder
{
- $treeBuilder = new TreeBuilder('acme_sylius_example_plugin');
+ $treeBuilder = new TreeBuilder('workouse_availability_notifier'); // FIX
if (\method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
- $rootNode = $treeBuilder->root('acme_sylius_example_plugin');
+ $rootNode = $treeBuilder->root('workouse_availability_notifier');
}
+ $rootNode
+ ->addDefaultsIfNotSet()
+ ->children()
+ ->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end()
+ ->arrayNode('resources')
+ ->addDefaultsIfNotSet()
+ ->children()
+ ->arrayNode('availability_notifier')
+ ->addDefaultsIfNotSet()
+ ->children()
+ ->variableNode('options')->end()
+ ->arrayNode('classes')
+ ->addDefaultsIfNotSet()
+ ->children()
+ ->scalarNode('model')->defaultValue(AvailabilityNotifier::class)->cannotBeEmpty()->end()
+ ->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
+ ->scalarNode('repository')->defaultValue(AvailabilityNotifierRepository::class)->cannotBeEmpty()->end()
+ ->scalarNode('factory')->defaultValue(Factory::class)->end()
+ ->scalarNode('form')->defaultValue(AvailabilityNotifierType::class)->cannotBeEmpty()->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ;
+
return $treeBuilder;
}
+
}
diff --git a/src/DependencyInjection/WorkouseAvailabilityNotifierExtension.php b/src/DependencyInjection/WorkouseAvailabilityNotifierExtension.php
index 7a45776..61df7a2 100644
--- a/src/DependencyInjection/WorkouseAvailabilityNotifierExtension.php
+++ b/src/DependencyInjection/WorkouseAvailabilityNotifierExtension.php
@@ -4,20 +4,24 @@
namespace Workouse\AvailabilityNotifierPlugin\DependencyInjection;
+use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\DependencyInjection\Extension\Extension;
+use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
-final class WorkouseAvailabilityNotifierExtension extends Extension
+final class WorkouseAvailabilityNotifierExtension extends AbstractResourceExtension
{
/**
* {@inheritdoc}
*/
- public function load(array $config, ContainerBuilder $container): void
+ public function load(array $configs, ContainerBuilder $container): void
{
+ $config = $this->processConfiguration($this->getConfiguration([], $container), $configs);
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
+
+ $this->registerResources('workouse_availability_notifier', $config['driver'], $config['resources'], $container);
}
}
diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml
index 28d6d90..2f8643b 100644
--- a/src/Resources/config/services.yml
+++ b/src/Resources/config/services.yml
@@ -1,15 +1,18 @@
+parameters:
+ workouse_availability_notifier_plugin.model.availability_notifier.class: \Workouse\AvailabilityNotifierPlugin\Entity\AvailabilityNotifier
+
services:
workouse_availability_notifier_plugin.controller.availability_notifier:
class: Workouse\AvailabilityNotifierPlugin\Controller\AvailabilityNotifierController
public: true
arguments:
- - '@templating'
+ - '@twig'
- '@form.factory'
- '@sylius.repository.customer'
- '@sylius.factory.customer'
- '@doctrine.orm.default_entity_manager'
- - '@workouse_availability_notifier_plugin.factory.availability_notifier'
- - '@workouse_availability_notifier_plugin.repository.availability_notifier'
+ - '@workouse_availability_notifier.factory.availability_notifier'
+ - '@workouse_availability_notifier.repository.availability_notifier'
- '@sylius.repository.product'
- '@security.helper'
- '@validator'
@@ -27,7 +30,7 @@ services:
workouse_availability_notifier_plugin:
class: Workouse\AvailabilityNotifierPlugin\EventListener\AvailabilityNotifierListener
arguments:
- - '@workouse_availability_notifier_plugin.repository.availability_notifier'
+ - '@workouse_availability_notifier.repository.availability_notifier'
- '@sylius.email_sender'
- '@doctrine.orm.default_entity_manager'
tags:
@@ -37,7 +40,7 @@ services:
workouse_availability_notifier_plugin.block_event_listener.shop.layout.javascripts:
class: Sylius\Bundle\UiBundle\Block\BlockEventListener
arguments:
- - "@@WorkouseAvailabilityNotifierPlugin/Resources/views/_javascripts.html.twig"
+ - "@@WorkouseAvailabilityNotifierPlugin/_javascripts.html.twig"
tags:
- { name: kernel.event_listener, event: sonata.block.event.sylius.shop.layout.javascripts, method: onBlockEvent }
diff --git a/src/Resources/views/_javascripts.html.twig b/src/Resources/views/_javascripts.html.twig
index 7f85955..96c81cc 100644
--- a/src/Resources/views/_javascripts.html.twig
+++ b/src/Resources/views/_javascripts.html.twig
@@ -1 +1 @@
-{% include 'SyliusUiBundle::_javascripts.html.twig' with {'path': 'bundles/workouseavailabilitynotifierplugin/js/notifier.js'} %}
+{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/workouseavailabilitynotifierplugin/js/notifier.js'} %}