Skip to content

Commit 7bd5ea3

Browse files
author
Maxime
authored
Merge pull request #11 from delyriand/feature/sylius-2-0
Sylius 2.X support 🎉 (2.0 and 2.1)
2 parents 0ffd2cd + a94b46d commit 7bd5ea3

Some content is hidden

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

48 files changed

+388
-313
lines changed

.github/workflows/recipe.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Flex Recipe
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ $default-branch ]
66
pull_request:
77

88
jobs:
@@ -14,8 +14,8 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php: ['8.1', '8.2', '8.3']
18-
sylius: ["~1.13.0", "1.14.0"]
17+
php: [ '8.2', '8.3' ]
18+
sylius: [ '~2.0.0', '~2.0.1' ]
1919

2020
steps:
2121
- name: Setup PHP
@@ -61,13 +61,14 @@ jobs:
6161
- name: Make sure to install the required version of Sylius
6262
working-directory: ./sylius
6363
run: |
64-
composer require --no-install --no-scripts --no-progress sylius/sylius="${{ matrix.sylius }}"
64+
composer require --no-install --no-scripts --no-progress --no-update sylius/sylius="${{ matrix.sylius }}"
6565
6666
- name: Setup some requirements
6767
working-directory: ./sylius
6868
run: |
6969
composer config --no-plugins allow-plugins true
7070
composer config --no-plugins extra.symfony.allow-contrib true
71+
composer config --no-plugins extra.symfony.require "7.2.*"
7172
composer config --no-plugins secure-http false
7273
composer config --no-plugins --unset platform.php
7374
composer config --no-plugins extra.symfony.docker false

.github/workflows/security.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
php: ['8.1', '8.2', '8.3']
16+
php: ['8.2', '8.3']
1717

1818
steps:
1919
- uses: actions/checkout@v3

.github/workflows/tests.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Tests
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ $default-branch ]
66
pull_request:
77

88
jobs:
@@ -14,7 +14,8 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php: ['8.1', '8.2', '8.3']
17+
php: [ '8.2', '8.3' ]
18+
node: [ '20' ]
1819

1920
env:
2021
SYMFONY_ARGS: --no-tls
@@ -25,7 +26,7 @@ jobs:
2526
- uses: actions/checkout@v2
2627
- uses: actions/setup-node@v2
2728
with:
28-
node-version: '14'
29+
node-version: ${{ matrix.node }}
2930
- name: Setup PHP
3031
uses: shivammathur/setup-php@v2
3132
with:

.php-cs-fixer.dist.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
declare(strict_types=1);
1313

14+
use PhpCsFixer\UnsupportedPhpVersionAllowedConfigInterface;
15+
1416
$header = <<<'HEADER'
1517
This file is part of Monsieur Biz' Contact Request plugin for Sylius.
1618
@@ -267,4 +269,8 @@
267269
->setFinder($finder)
268270
;
269271

272+
if ($config instanceof UnsupportedPhpVersionAllowedConfigInterface) {
273+
$config->setUnsupportedPhpVersionAllowed(true);
274+
}
275+
270276
return $config;

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.DEFAULT_GOAL := help
22
SHELL=/bin/bash
33
APP_DIR=tests/Application
4-
SYLIUS_VERSION=1.14.0
4+
SYLIUS_VERSION=2.1.0
55
SYMFONY=cd ${APP_DIR} && symfony
66
COMPOSER=symfony composer
77
CONSOLE=${SYMFONY} console
@@ -70,10 +70,11 @@ setup_application:
7070
rm -f ${APP_DIR}/yarn.lock
7171
(cd ${APP_DIR} && ${COMPOSER} config repositories.plugin '{"type": "path", "url": "../../"}')
7272
(cd ${APP_DIR} && ${COMPOSER} config extra.symfony.allow-contrib true)
73+
(cd ${APP_DIR} && ${COMPOSER} config extra.symfony.require "7.2.*")
7374
(cd ${APP_DIR} && ${COMPOSER} config minimum-stability dev)
7475
(cd ${APP_DIR} && ${COMPOSER} config --no-plugins allow-plugins true)
7576
(cd ${APP_DIR} && ${COMPOSER} config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]')
76-
(cd ${APP_DIR} && ${COMPOSER} require --no-install --no-scripts --no-progress sylius/sylius="~${SYLIUS_VERSION}") # Make sure to install the required version of sylius because the sylius-standard has a soft constraint
77+
(cd ${APP_DIR} && ${COMPOSER} require --no-install --no-scripts --no-progress --no-update sylius/sylius="~${SYLIUS_VERSION}") # Make sure to install the required version of sylius because the sylius-standard has a soft constraint
7778
$(MAKE) ${APP_DIR}/.php-version
7879
$(MAKE) ${APP_DIR}/php.ini
7980
(cd ${APP_DIR} && ${COMPOSER} install --no-interaction)

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ This plugin allows you to customize the contact page on the front-end of your Sy
1414

1515
## Compatibility
1616

17-
| Sylius Version | PHP Version |
18-
|----------------|-----------------|
19-
| 1.13 | 8.1 - 8.2 - 8.3 |
20-
| 1.14 | 8.1 - 8.2 - 8.3 |
17+
| Sylius Version | PHP Version |
18+
|----------------|-------------|
19+
| 2.0, 2.1 | 8.2 - 8.3 |
20+
21+
22+
ℹ️ For Sylius 1.x, see our [1.x branch](https://github.com/monsieurbiz/SyliusContactRequestPlugin/tree/1.x) and all 1.x releases.
2123

2224
## Installation
2325

@@ -79,14 +81,22 @@ sylius_shop_contact_request:
7981
_locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$
8082
methods: [GET, POST]
8183
defaults:
82-
_controller: sylius.controller.shop.contact::requestAction
84+
_controller: sylius_shop.controller.contact::requestAction
8385
_sylius:
8486
redirect: sylius_shop_homepage
85-
template: '@MonsieurBizSyliusContactRequestPlugin/Shop/ContactRequest/request.html.twig'
87+
template: '@MonsieurBizSyliusContactRequestPlugin/shop/contact/contact_request.html.twig'
8688
```
8789

8890
This is the same as Sylius route configuration instead of the template key which is overridden to use the plugin template.
8991

92+
Copy the override template in your template directory to display name, company and phone number in the contact email:
93+
94+
```bash
95+
cp -Rv vendor/monsieurbiz/sylius-contact-request-plugin/src/Resources/templates/* templates/
96+
```
97+
98+
Then you can customize the template as you want.
99+
90100
## Contributing
91101

92102
You can find a way to run the plugin without effort in the file [DEVELOPMENT.md](./DEVELOPMENT.md).

UPGRADE-2.0.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# UPGRADE FROM `1.2` TO `2.0`
2+
3+
- Service controller has changed from `sylius.controller.shop.contact` to `sylius_shop.controller.contact`, particularly in the `sylius_shop_contact_request` route in `config/routes/sylius_shop_contact_request_override.yaml`.
4+
- Template path has changed from `@MonsieurBizSyliusContactRequestPlugin/Shop/ContactRequest/request.html.twig` to `@MonsieurBizSyliusContactRequestPlugin/shop/contact/contact_request.html.twig`, particularly in the `sylius_shop_contact_request` route in `config/routes/sylius_shop_contact_request_override.yaml`.
5+
- Replace translation prefix from `monsieurbiz.contact_request.` to `monsieurbiz_contact_request.` for the context "messages".
6+
- Replace translation prefix from `monsieurbiz.contact_request.` to `monsieurbiz_contact_request.contact.` for the context "validators".

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"description": "Add a contact request plugin to your Sylius.",
66
"license": "MIT",
77
"require": {
8-
"php": "^8.1",
9-
"sylius/sylius": ">=1.13 <2.0",
10-
"monsieurbiz/sylius-settings-plugin": "^1.2.0",
11-
"monsieurbiz/sylius-rich-editor-plugin": "^2.8.0"
8+
"php": "^8.2",
9+
"sylius/sylius": "~2.0",
10+
"monsieurbiz/sylius-settings-plugin": "^2.0.1",
11+
"monsieurbiz/sylius-rich-editor-plugin": "^3.0"
1212
},
1313
"require-dev": {
1414
"friendsofphp/php-cs-fixer": "^3.16",
@@ -30,15 +30,15 @@
3030
"cache:clear": "symfony-cmd",
3131
"assets:install %PUBLIC_DIR%": "symfony-cmd"
3232
},
33-
"phpcs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --using-cache=no",
33+
"phpcs": "php-cs-fixer fix --using-cache=no",
3434
"phpstan": "phpstan analyse -c phpstan.neon src/",
3535
"phpmd": "phpmd --exclude Migrations/* src/ ansi phpmd.xml",
3636
"phpunit": "phpunit",
3737
"phpspec": "phpspec run"
3838
},
3939
"extra": {
4040
"branch-alias": {
41-
"dev-master": "1.1-dev"
41+
"dev-master": "2.0-dev"
4242
},
4343
"symfony": {
4444
"docker": false,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Monsieur Biz' Contact Request plugin for Sylius.
5+
*
6+
* (c) Monsieur Biz <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE.txt
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace App\Context\Channel\RequestBased;
15+
16+
use Sylius\Component\Channel\Context\RequestBased\RequestResolverInterface;
17+
use Sylius\Component\Channel\Model\ChannelInterface;
18+
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
19+
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
20+
use Symfony\Component\HttpFoundation\Request;
21+
22+
#[AutoconfigureTag('sylius.context.channel.request_based.resolver')]
23+
final class HostnameAndPortBasedRequestResolver implements RequestResolverInterface
24+
{
25+
public function __construct(private ChannelRepositoryInterface $channelRepository)
26+
{
27+
}
28+
29+
public function findChannel(Request $request): ?ChannelInterface
30+
{
31+
return $this->channelRepository->findOneEnabledByHostname($request->getHost() . ':' . $request->getPort());
32+
}
33+
}

docs/images/admin-list.png

261 KB
Loading

0 commit comments

Comments
 (0)