Skip to content

Commit 7111770

Browse files
authored
Merge pull request #24 from lanfisis/feature/sylius-2
Sylius 2.0 support 🎉
2 parents 3e29349 + 4ec770f commit 7111770

File tree

118 files changed

+2593
-1731
lines changed

Some content is hidden

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

118 files changed

+2593
-1731
lines changed

.github/workflows/recipe.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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' ]
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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:

Makefile

Lines changed: 5 additions & 3 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.0.0
55
SYMFONY=cd ${APP_DIR} && symfony
66
COMPOSER=symfony composer
77
CONSOLE=${SYMFONY} console
@@ -78,6 +78,8 @@ setup_application:
7878
$(MAKE) apply_dist
7979
(cd ${APP_DIR} && ${COMPOSER} require --no-progress monsieurbiz/${PLUGIN_NAME}="*@dev")
8080
rm -rf ${APP_DIR}/var/cache
81+
mkdir -p ${APP_DIR}/public/media/gallery
82+
cp -r fixtures/gallery/* ${APP_DIR}/public/media/gallery
8183

8284

8385
${APP_DIR}/docker-compose.yaml:
@@ -136,13 +138,13 @@ test.container: ## Lint the symfony container
136138
${CONSOLE} lint:container
137139

138140
test.yaml: ## Lint the symfony Yaml files
139-
${CONSOLE} lint:yaml ../../src/Resources/config --parse-tags
141+
${CONSOLE} lint:yaml ../../config --parse-tags
140142

141143
test.schema: ## Validate MySQL Schema
142144
${CONSOLE} doctrine:schema:validate
143145

144146
test.twig: ## Validate Twig templates
145-
${CONSOLE} lint:twig --no-debug templates/ ../../src/Resources/views/
147+
${CONSOLE} lint:twig --no-debug templates/ ../../templates/
146148

147149
###
148150
### SYLIUS

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ This plugin adds a media manager to your images, videos and other files type fie
1313

1414
## Compatibility
1515

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

2222
## Installation
2323

@@ -97,6 +97,10 @@ Use `MonsieurBiz\SyliusMediaManagerPlugin\Form\Type\FaviconType`
9797

9898
Use `MonsieurBiz\SyliusMediaManagerPlugin\Form\Type\AudioType`
9999

100+
### All the previous file types
101+
102+
Use `MonsieurBiz\SyliusMediaManagerPlugin\Form\Type\FileType`
103+
100104
## Configuration
101105

102106
You can specify the default maximum file size allowed for the media manager by setting the `MONSIEURBIZ_SYLIUS_MEDIA_MANAGER_MAX_FILE_SIZE` environment variable.

UPGRADE-2.0.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# UPGRADE FROM `1.2` TO `2.0`
2+
3+
**Replace form type option name**
4+
5+
If you use one of the following options with Media Manager form type (`AudioType`, `FaviconType`, `ImageType`, `PdfType` or `VideoType`),
6+
you had to rename it as follows:
7+
8+
* `["file-type" => "TYPE"]` became `["file_type" => "TYPE"]`
9+
* `["filter-width" => INT]` became `["filter_width" => INT]]`
10+
11+
**Use new services**
12+
13+
`FileHelper` service has been split into dedicated services:
14+
* `FileRepositoryInterface` to list file from a folder or get one file by it path
15+
* `DirectoryOperatorInterface` where all directory operations takes place
16+
* `FileMetadataResolverInterface` for file types resolution
17+
* `FilePathResolverInterface` for absolute and relative path resolution
18+
* `FileValidatorInterface` for file validation
19+
20+
If you use `FileHelper` service, you need to inject one of the service above instead.

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
"description": "Add a media manager to your Sylius.",
66
"license": "MIT",
77
"require": {
8-
"php": "^8.1",
9-
"sylius/sylius": ">=1.12 <2.0"
8+
"php": "^8.2",
9+
"sylius/sylius": "~2.0.0",
10+
"phpdocumentor/reflection-docblock": "^5.6"
1011
},
1112
"require-dev": {
1213
"friendsofphp/php-cs-fixer": "^3.16",
@@ -36,7 +37,7 @@
3637
},
3738
"extra": {
3839
"branch-alias": {
39-
"dev-master": "1.1-dev"
40+
"dev-master": "2.0-dev"
4041
},
4142
"symfony": {
4243
"docker": false,

config/config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
imports:
2+
- { resource: 'images.yaml' }
3+
- { resource: 'twig_hooks.yaml' }
File renamed without changes.

config/services.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
parameters:
2+
monsieurbiz_sylius_media_manager.max_file_size.default: '%env(resolve:MONSIEURBIZ_SYLIUS_MEDIA_MANAGER_MAX_FILE_SIZE)%'
3+
monsieurbiz_sylius_media_manager.max_file_size.image: '%env(default:monsieurbiz_sylius_media_manager.max_file_size.default:resolve:MONSIEURBIZ_SYLIUS_MEDIA_MANAGER_MAX_FILE_SIZE_IMAGE)%'
4+
monsieurbiz_sylius_media_manager.max_file_size.audio: '%env(default:monsieurbiz_sylius_media_manager.max_file_size.default:resolve:MONSIEURBIZ_SYLIUS_MEDIA_MANAGER_MAX_FILE_SIZE_AUDIO)%'
5+
monsieurbiz_sylius_media_manager.max_file_size.video: '%env(default:monsieurbiz_sylius_media_manager.max_file_size.default:resolve:MONSIEURBIZ_SYLIUS_MEDIA_MANAGER_MAX_FILE_SIZE_VIDEO)%'
6+
monsieurbiz_sylius_media_manager.max_file_size.pdf: '%env(default:monsieurbiz_sylius_media_manager.max_file_size.default:resolve:MONSIEURBIZ_SYLIUS_MEDIA_MANAGER_MAX_FILE_SIZE_PDF)%'
7+
monsieurbiz_sylius_media_manager.max_file_size.favicon: '%env(default:monsieurbiz_sylius_media_manager.max_file_size.default:resolve:MONSIEURBIZ_SYLIUS_MEDIA_MANAGER_MAX_FILE_SIZE_FAVICON)%'
8+
monsieurbiz_sylius_media_manager.max_file_size.file: '%env(default:monsieurbiz_sylius_media_manager.max_file_size.default:resolve:MONSIEURBIZ_SYLIUS_MEDIA_MANAGER_MAX_FILE_SIZE_FILE)%'
9+
monsieurbiz_sylius_media_manager.liip_imagine.exclude_extensions:
10+
- 'svg'
11+
- 'ico'
12+
13+
services:
14+
_defaults:
15+
autowire: true
16+
autoconfigure: true
17+
public: false
18+
19+
MonsieurBiz\SyliusMediaManagerPlugin\:
20+
resource: '../src/*'
21+
exclude: '../src/{Model}'
22+
23+
# Decorator to allow us to have multiple data roots for svg images.
24+
MonsieurBiz\SyliusMediaManagerPlugin\Twig\Extension\FilterExtensionDecorator:
25+
decorates: 'liip_imagine.templating.filter_extension'
26+
arguments:
27+
$loaders: '%liip_imagine.loaders%'
28+
$publicDir: '%sylius_core.public_dir%'
29+
$excludeExtensions: '%monsieurbiz_sylius_media_manager.liip_imagine.exclude_extensions%'

0 commit comments

Comments
 (0)