Skip to content

Commit 5fae1f5

Browse files
author
Maxime
authored
Merge pull request #9 from delyriand/feature/sylius-2-0
Sylius 2.0 and 2.1 support 🎉
2 parents 74604ca + 7376780 commit 5fae1f5

File tree

214 files changed

+2290
-1217
lines changed

Some content is hidden

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

214 files changed

+2290
-1217
lines changed

.github/workflows/recipe.yaml

Lines changed: 3 additions & 3 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.12.0", "~1.13.0", "1.14.0"]
17+
php: ['8.2', '8.3']
18+
sylius: ['~2.0.0', '~2.1.0']
1919

2020
steps:
2121
- name: Setup PHP

.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' Blog 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: 1 addition & 1 deletion
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

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
This plugin adds a blog to your Sylius project. It allows you to create blog articles, tags and authors.
99

10-
## Compatibility
10+
![List of article in a Sylius blog](images/blog_front.png)
1111

1212
## Compatibility
1313

1414
| Sylius Version | PHP Version |
1515
|----------------|-----------------|
16-
| 1.12 | 8.1 - 8.2 - 8.3 |
17-
| 1.13 | 8.1 - 8.2 - 8.3 |
18-
| 1.14 | 8.1 - 8.2 - 8.3 |
16+
| 2.0, 2.1 | 8.2 - 8.3 |
17+
18+
ℹ️ For Sylius 1.x, see our [1.x branch](https://github.com/monsieurbiz/SyliusBlogPlugin/tree/1.x) and all 1.x releases.
1919

2020
## Installation
2121

@@ -28,7 +28,7 @@ composer config --no-plugins --json extra.symfony.endpoint '["https://api.github
2828
Install the plugin via composer:
2929

3030
```bash
31-
composer require monsieurbiz/sylius-blog-plugin:dev-master
31+
composer require monsieurbiz/sylius-blog-plugin
3232
```
3333

3434
<!-- The section on the flex recipe will be displayed when the flex recipe will be available on contrib repo
@@ -66,6 +66,21 @@ And finally, update your database:
6666
bin/console doctrine:migrations:migrate
6767
```
6868

69+
## Type of posts
70+
71+
![List of article in a Sylius admin](images/blog_admin.png)
72+
73+
This plugin allows you to create 2 types of posts:
74+
- **Blog articles**: These are the main content of your blog, where you can write detailed posts.
75+
- **Case studies**: These are more focused posts that showcase specific projects or achievements.
76+
77+
Case studies are disabled by default. You can enable them by setting the env var `MONSIEURBIZ_SYLIUS_BLOG_ENABLE_CASE_STUDIES` to `true` in your `.env` file:
78+
79+
```dotenv
80+
MONSIEURBIZ_SYLIUS_BLOG_ENABLE_CASE_STUDIES=true
81+
```
82+
83+
The structure of the code allows you to easily add new types of posts in the future if needed.
6984

7085
## License
7186

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"description": "Add blog features on Sylius application.",
66
"license": "MIT",
77
"require": {
8-
"php": "^8.1",
9-
"sylius/sylius": ">=1.12 <2.0",
10-
"monsieurbiz/sylius-rich-editor-plugin": "^2.8",
11-
"monsieurbiz/sylius-media-manager-plugin": "^1.1"
8+
"php": "^8.2",
9+
"sylius/sylius": "~2.0",
10+
"monsieurbiz/sylius-rich-editor-plugin": "^3.0",
11+
"monsieurbiz/sylius-media-manager-plugin": "^2.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.0-dev"
41+
"dev-master": "2.0-dev"
4242
},
4343
"symfony": {
4444
"docker": false,

dist/.env.dev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
SYLIUS_FIXTURES_HOSTNAME=${SYMFONY_DEFAULT_ROUTE_HOST:-localhost}
2+
MONSIEURBIZ_SYLIUS_BLOG_ENABLE_CASE_STUDIES=true
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' Blog 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+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Monsieur Biz' Blog 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\Form\Extension;
15+
16+
use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\RichEditorType;
17+
use Sylius\Bundle\ProductBundle\Form\Type\ProductTranslationType;
18+
use Symfony\Component\Form\AbstractTypeExtension;
19+
use Symfony\Component\Form\FormBuilderInterface;
20+
21+
class ProductTypeExtension extends AbstractTypeExtension
22+
{
23+
public function buildForm(FormBuilderInterface $builder, array $options): void
24+
{
25+
$builder->remove('description');
26+
$builder->add('description', RichEditorType::class, [
27+
'required' => false,
28+
'label' => 'sylius.form.product.description',
29+
'locale' => $builder->getName(),
30+
]);
31+
}
32+
33+
public static function getExtendedTypes(): iterable
34+
{
35+
return [ProductTranslationType::class];
36+
}
37+
}

0 commit comments

Comments
 (0)