Skip to content

Commit 335ccef

Browse files
authored
Revert "Version 3.x : No live component and multi upload"
1 parent c3658f5 commit 335ccef

File tree

123 files changed

+2843
-156539
lines changed

Some content is hidden

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

123 files changed

+2843
-156539
lines changed

.github/copilot-instructions.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copilot Instructions for SyliusMediaManagerPlugin
2+
3+
## General Guidelines
4+
- Follow the Sylius 2.x and Symfony 7.x best practices for PHP code.
5+
- Use strict types and type hints wherever possible.
6+
- All new code must be PSR-12 compliant and pass PHPStan and ECS checks.
7+
- Use dependency injection for all services and avoid using service locators.
8+
- Write clear, concise, and well-documented code.
9+
- Use English for all code comments, variable names, and documentation.
10+
11+
## Commit Messages
12+
- Use clear, descriptive commit messages in English.
13+
- Reference related issues or tickets when applicable.
14+
15+
## Pull Requests
16+
- Ensure all checks pass before requesting review.
17+
- Provide a clear description of the changes and testing steps.
18+
19+
---
20+
21+
For more details, refer to the project README and Sylius/Symfony documentation.

.github/workflows/recipe.yaml

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

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

88
jobs:
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php: ['8.2', '8.3']
17+
php: [ '8.2', '8.3' ]
1818
sylius: [ '~2.0.0', '~2.1.0' ]
1919

2020
steps:

.github/workflows/tests.yaml

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

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

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

2020
env:
2121
SYMFONY_ARGS: --no-tls

.php-cs-fixer.dist.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
->setRiskyAllowed(true)
3535
->setRules([
3636
'@DoctrineAnnotation' => true,
37-
'@PHP7x1Migration' => true,
38-
'@PHP7x1Migration:risky' => true,
39-
'@PHPUnit6x0Migration:risky' => true,
37+
'@PHP71Migration' => true,
38+
'@PHP71Migration:risky' => true,
39+
'@PHPUnit60Migration:risky' => true,
4040
'@Symfony' => true,
4141
'@Symfony:risky' => true,
4242
'align_multiline_comment' => [
@@ -254,7 +254,7 @@
254254
'trim_array_spaces' => true,
255255
'type_declaration_spaces' => true,
256256
'unary_operator_spaces' => true,
257-
'modifier_keywords' => [
257+
'visibility_required' => [
258258
'elements' => [
259259
'const',
260260
'property',

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,17 @@ setup_application:
7272
(cd ${APP_DIR} && ${COMPOSER} config --no-plugins allow-plugins true)
7373
(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"]')
7474
(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
75+
# Temporary fix for Sylius 2.1
76+
(cd ${APP_DIR} && ${COMPOSER} require --no-install --no-scripts --no-progress api-platform/state)
77+
# End Temporary fix for Sylius 2.1
7578
$(MAKE) ${APP_DIR}/.php-version
7679
$(MAKE) ${APP_DIR}/php.ini
7780
(cd ${APP_DIR} && ${COMPOSER} install --no-interaction)
7881
$(MAKE) apply_dist
7982
(cd ${APP_DIR} && ${COMPOSER} require --no-progress monsieurbiz/${PLUGIN_NAME}="*@dev")
8083
rm -rf ${APP_DIR}/var/cache
84+
mkdir -p ${APP_DIR}/public/media/gallery
85+
cp -r fixtures/gallery/* ${APP_DIR}/public/media/gallery
8186

8287

8388
${APP_DIR}/docker-compose.yaml:
@@ -136,13 +141,13 @@ test.container: ## Lint the symfony container
136141
${CONSOLE} lint:container
137142

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

141146
test.schema: ## Validate MySQL Schema
142147
${CONSOLE} doctrine:schema:validate
143148

144149
test.twig: ## Validate Twig templates
145-
${CONSOLE} lint:twig --no-debug templates/ ../../src/Resources/views/
150+
${CONSOLE} lint:twig --no-debug templates/ ../../templates/
146151

147152
###
148153
### SYLIUS

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99

1010
This plugin adds a media manager to your images, videos and other files type fields in Sylius.
1111

12-
![Demo of the media manager](docs/images/demo.gif)
12+
![Example of field display](docs/images/media-manager-product-medias.png)
13+
![Example of image listing](docs/images/media-manager-images.png)
14+
![Example of PDF listing](docs/images/media-manager-pdfs.png)
1315

1416
## Compatibility
1517

16-
| Sylius Version | PHP Version |
17-
|----------------|-----------------|
18-
| 2.0, 2.1 | 8.2 - 8.3 |
18+
| Sylius Version | PHP Version |
19+
|----------------|-------------|
20+
| 2.0, 2,1 | 8.2 - 8.3 |
1921

20-
ℹ️ For Sylius 1.x, see our [1.x branch](/tree/1.x) and all 1.x releases.
22+
ℹ️ For Sylius 1.x, see our [1.x branch](https://github.com/monsieurbiz/SyliusMediaManagerPlugin/tree/1.x) and all 1.x releases.
2123

2224
## Installation
2325

@@ -48,7 +50,7 @@ return [
4850
];
4951
```
5052

51-
Copy the plugin configuration files in your `config` folder: https://github.com/monsieurbiz/symfony-recipes/tree/master/monsieurbiz/sylius-media-manager-plugin/3.0/config
53+
Copy the plugin configuration files in your `config` folder: https://github.com/monsieurbiz/symfony-recipes/tree/master/monsieurbiz/sylius-media-manager-plugin/1.0/config
5254

5355
Add these variables to your `.env` :
5456

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

98100
Use `MonsieurBiz\SyliusMediaManagerPlugin\Form\Type\AudioType`
99101

102+
### All the previous file types
103+
104+
Use `MonsieurBiz\SyliusMediaManagerPlugin\Form\Type\FileType`
105+
100106
## Configuration
101107

102108
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: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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.
21+
22+
**Config**
23+
24+
Change the file `config/packages/monsieurbiz_media_manager_plugin.yaml` with this content :
25+
26+
```yaml
27+
imports:
28+
- { resource: "@MonsieurBizSyliusMediaManagerPlugin/config/config.yaml" }
29+
30+
liip_imagine:
31+
loaders:
32+
sylius_image:
33+
filesystem:
34+
data_root:
35+
- "%sylius_core.public_dir%/media" # Add media folder
36+
37+
twig:
38+
form_themes: ['@MonsieurBizSyliusMediaManagerPlugin/form/_theme.html.twig']
39+
```
40+
41+
**Remove old route file**
42+
43+
Remove the file `config/routes/monsieurbiz_media_manager_plugin.yaml`

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": "~2.0"
8+
"php": "^8.2",
9+
"sylius/sylius": "~2.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": "3.0-dev"
40+
"dev-master": "2.0-dev"
4041
},
4142
"symfony": {
4243
"docker": false,

config/config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
imports:
2+
- { resource: 'images.yaml' }
3+
- { resource: 'twig_hooks.yaml' }
4+
5+
parameters:
6+
env(MONSIEURBIZ_SYLIUS_MEDIA_MANAGER_PAGINATION_ITEMS_PER_PAGE): 20
7+
monsieurbiz_sylius_media_manager.pagination.items_per_page: '%env(int:MONSIEURBIZ_SYLIUS_MEDIA_MANAGER_PAGINATION_ITEMS_PER_PAGE)%'

0 commit comments

Comments
 (0)