Skip to content

Commit

Permalink
Merge pull request #21 from maximehuran/feature/1.14
Browse files Browse the repository at this point in the history
  • Loading branch information
maximehuran authored Jan 21, 2025
2 parents 963559d + 1b09afc commit 84d4593
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 36 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,8 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.0', '8.1', '8.2']
sylius: ["~1.11.0", "~1.12.0", "~1.13.0"]
exclude:
- php: '8.2'
sylius: '~1.11.0'
- php: '8.0'
sylius: '~1.12.0'
- php: '8.0'
sylius: '~1.13.0'
php: ['8.1', '8.2', '8.3']
sylius: ["~1.12.0", "~1.13.0", "1.14.0"]

steps:
- name: Setup PHP
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2']
php: ['8.1', '8.2', '8.3']

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2']
php: ['8.1', '8.2', '8.3']

env:
SYMFONY_ARGS: --no-tls
Expand Down
2 changes: 1 addition & 1 deletion .php-version.dist
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.2
8.3
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.DEFAULT_GOAL := help
SHELL=/bin/bash
APP_DIR=tests/Application
SYLIUS_VERSION=1.13.0
SYLIUS_VERSION=1.14.0
SYMFONY=cd ${APP_DIR} && symfony
COMPOSER=symfony composer
CONSOLE=${SYMFONY} console
export COMPOSE_PROJECT_NAME=media-manager
PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin
COMPOSE=docker-compose
COMPOSE=docker compose
YARN=yarn

###
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ This plugin adds a media manager to your images, videos and other files type fie

## Compatibility

| Sylius Version | PHP Version |
|---|---|
| 1.11 | 8.0 - 8.1 |
| 1.12 | 8.1 - 8.2 |
| 1.13 | 8.1 - 8.2 |
| Sylius Version | PHP Version |
|----------------|-----------------|
| 1.12 | 8.1 - 8.2 - 8.3 |
| 1.13 | 8.1 - 8.2 - 8.3 |
| 1.14 | 8.1 - 8.2 - 8.3 |

## Installation

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"description": "Add a media manager to your Sylius.",
"license": "MIT",
"require": {
"php": "^8.0",
"sylius/sylius": ">=1.11 <1.14"
"php": "^8.1",
"sylius/sylius": ">=1.11 <2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.16",
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/CannotReadCurrentFolderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class CannotReadCurrentFolderException extends Exception
public function __construct(string $path)
{
$this->path = $path;
parent::__construct(sprintf('Current folder cannot be opened `%s`', $path));
parent::__construct(\sprintf('Current folder cannot be opened `%s`', $path));
}

public function getPath(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/CannotReadFolderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class CannotReadFolderException extends Exception
public function __construct(string $path)
{
$this->path = $path;
parent::__construct(sprintf('Folder cannot be opened `%s`', $path));
parent::__construct(\sprintf('Folder cannot be opened `%s`', $path));
}

public function getPath(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FileNotCreatedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(string $filename, string $errorMessage)
{
$this->filename = $filename;
$this->errorMessage = $errorMessage;
parent::__construct(sprintf('File `%s` couldn\'t be created. Error : %s', $filename, $errorMessage));
parent::__construct(\sprintf('File `%s` couldn\'t be created. Error : %s', $filename, $errorMessage));
}

public function getFilename(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FileNotDeletedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class FileNotDeletedException extends Exception
public function __construct(string $filename)
{
$this->filename = $filename;
parent::__construct(sprintf('File `%s` couldn\'t be deleted', $filename));
parent::__construct(\sprintf('File `%s` couldn\'t be deleted', $filename));
}

public function getFilename(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FileNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class FileNotFoundException extends Exception
public function __construct(string $path)
{
$this->path = $path;
parent::__construct(sprintf('File not found `%s`', $path));
parent::__construct(\sprintf('File not found `%s`', $path));
}

public function getPath(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FileTooBigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(string $filename, int $size, int $maxAllowedSizeByte
$this->maxAllowedSizeBytes = $maxAllowedSizeBytes;
$this->maxAllowedSize = $maxAllowedSize;
parent::__construct(
sprintf(
\sprintf(
'File `%s` couldn\'t be created. File size %s is bigger than %s bytes. (%s)',
$filename,
$size,
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FolderNotCreatedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class FolderNotCreatedException extends Exception
public function __construct(string $folder)
{
$this->folder = $folder;
parent::__construct(sprintf('Folder `%s` couldn\'t be created', $folder));
parent::__construct(\sprintf('Folder `%s` couldn\'t be created', $folder));
}

public function getFolder(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FolderNotDeletedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class FolderNotDeletedException extends Exception
public function __construct(string $folder)
{
$this->folder = $folder;
parent::__construct(sprintf('Folder `%s` couldn\'t be deleted', $folder));
parent::__construct(\sprintf('Folder `%s` couldn\'t be deleted', $folder));
}

public function getFolder(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FolderNotRenamedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class FolderNotRenamedException extends Exception
public function __construct(string $folder)
{
$this->folder = $folder;
parent::__construct(sprintf('Folder `%s` couldn\'t be renamed', $folder));
parent::__construct(\sprintf('Folder `%s` couldn\'t be renamed', $folder));
}

public function getFolder(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidMimeTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(array $allowedMimeTypes, string $mimeType)
$this->allowedMimeTypes = $allowedMimeTypes;
$this->mimeType = $mimeType;

parent::__construct(sprintf(
parent::__construct(\sprintf(
'Invalid mime type. Excepted one of %s, `%s` given',
implode(', ', $allowedMimeTypes),
$mimeType
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(string $type, array $allowedTypes)
$this->type = $type;
$this->allowedTypes = $allowedTypes;

parent::__construct(sprintf('Invalid type `%s`, allowed types : %s', $type, implode(', ', $allowedTypes)));
parent::__construct(\sprintf('Invalid type `%s`, allowed types : %s', $type, implode(', ', $allowedTypes)));
}

public function getType(): string
Expand Down
4 changes: 2 additions & 2 deletions src/Helper/FileHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ public function upload(UploadedFile $file, string $path, ?string $folder = null)
$fileName = mb_strtolower($fileName, 'UTF-8');

// Build final path and loop if the file already exists
$finalName = sprintf('%s.%s', $fileName, $extension);
$finalName = \sprintf('%s.%s', $fileName, $extension);
$filePath = $this->getFullPath($path) . '/' . $finalName;
$count = 1;
while (file_exists($filePath)) {
$finalName = sprintf('%s_%d.%s', $fileName, $count++, $extension);
$finalName = \sprintf('%s_%d.%s', $fileName, $count++, $extension);
$filePath = $this->getFullPath($path) . '/' . $finalName;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Twig/Extension/FilterExtensionDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function filter(
$dataRoots = $this->loaders['default']['filesystem']['data_root'] ?? ['/media/image/'];

foreach (array_unique($dataRoots) as $imagePath) {
if (!$this->canImageBeFiltered($path) && file_exists(sprintf('%s/%s', $imagePath, $path))) {
return str_replace($this->publicDir, '', sprintf('%s/%s', $imagePath, $path));
if (!$this->canImageBeFiltered($path) && file_exists(\sprintf('%s/%s', $imagePath, $path))) {
return str_replace($this->publicDir, '', \sprintf('%s/%s', $imagePath, $path));
}
}

Expand Down

0 comments on commit 84d4593

Please sign in to comment.