Skip to content

Commit

Permalink
Merge branch 'sonata-project:4.x' into block-transformer-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lemorragia authored Aug 30, 2024
2 parents bfea0db + 28eb711 commit ad38beb
Show file tree
Hide file tree
Showing 38 changed files with 130 additions and 120 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [4.14.0](https://github.com/sonata-project/SonataMediaBundle/compare/4.13.0...4.14.0) - 2024-08-27
### Added
- [[#2461](https://github.com/sonata-project/SonataMediaBundle/pull/2461)] Support for psr/http-message 2 ([@VincentLanglet](https://github.com/VincentLanglet))

### Fixed
- [[#2455](https://github.com/sonata-project/SonataMediaBundle/pull/2455)] Symfony 7.1 deprecation about `Symfony\Component\HttpKernel\DependencyInjection\Extension` usage ([@VincentLanglet](https://github.com/VincentLanglet))
- [[#2452](https://github.com/sonata-project/SonataMediaBundle/pull/2452)] Remove format restriction on `FileThumbnail` service ([@VincentLanglet](https://github.com/VincentLanglet))

## [4.13.0](https://github.com/sonata-project/SonataMediaBundle/compare/4.12.0...4.13.0) - 2024-03-17
### Added
- [[#2448](https://github.com/sonata-project/SonataMediaBundle/pull/2448)] Compatibility with ORM 3 ([@dmaicher](https://github.com/dmaicher))
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"nyholm/psr7": "^1.4",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"psr/http-message": "^1.0 || ^2.0",
"psr/log": "^2.0 || ^3.0",
"sonata-project/doctrine-extensions": "^1.13 || ^2.0",
"sonata-project/form-extensions": "^1.4 || ^2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Action/MediaDownloadAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __invoke(Request $request, $id, string $format = MediaProviderIn
$media = $this->mediaManager->find($id);

if (null === $media) {
throw new NotFoundHttpException(sprintf('unable to find the media with the id : %s', $id));
throw new NotFoundHttpException(\sprintf('unable to find the media with the id : %s', $id));
}

if (!$this->pool->getDownloadStrategy($media)->isGranted($media, $request)) {
Expand Down
8 changes: 4 additions & 4 deletions src/CDN/CloudFrontVersion3.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct(

public function getPath(string $relativePath, bool $isFlushable = false): string
{
return sprintf('%s/%s', $this->path, ltrim($relativePath, '/'));
return \sprintf('%s/%s', $this->path, ltrim($relativePath, '/'));
}

public function flushByString(string $string): string
Expand Down Expand Up @@ -115,7 +115,7 @@ public function flushPaths(array $paths): string
}

if (!\in_array($status, self::AVAILABLE_STATUSES, true)) {
throw new \RuntimeException(sprintf('Unable to determine the flush status from the given response: "%s".', $status));
throw new \RuntimeException(\sprintf('Unable to determine the flush status from the given response: "%s".', $status));
}

$id = $invalidation['Id'] ?? null;
Expand All @@ -126,7 +126,7 @@ public function flushPaths(array $paths): string

return $id;
} catch (CloudFrontException $ex) {
throw new \RuntimeException(sprintf('Unable to flush paths "%s".', implode('", "', $paths)), 0, $ex);
throw new \RuntimeException(\sprintf('Unable to flush paths "%s".', implode('", "', $paths)), 0, $ex);
}
}

Expand All @@ -148,7 +148,7 @@ public function getFlushStatus(string $identifier): int

throw new \RuntimeException('Unable to determine the flush status from the given response.');
} catch (CloudFrontException $ex) {
throw new \RuntimeException(sprintf('Unable to retrieve flush status for identifier %s.', $identifier), 0, $ex);
throw new \RuntimeException(\sprintf('Unable to retrieve flush status for identifier %s.', $identifier), 0, $ex);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/CDN/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(string $path)

public function getPath(string $relativePath, bool $isFlushable = false): string
{
return sprintf('%s/%s', $this->path, ltrim($relativePath, '/'));
return \sprintf('%s/%s', $this->path, ltrim($relativePath, '/'));
}

public function flushByString(string $string): string
Expand Down
6 changes: 3 additions & 3 deletions src/Command/AddMassMediaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private function getFilePointer(InputInterface $input, OutputInterface $output)
$filePointer = fopen($file, 'r');

if (false === $filePointer) {
throw new \RuntimeException(sprintf('The provided CSV file %s could not be opened', $file));
throw new \RuntimeException(\sprintf('The provided CSV file %s could not be opened', $file));
}

return $filePointer;
Expand All @@ -120,9 +120,9 @@ private function insertMedia(array $data, OutputInterface $output): void

try {
$this->mediaManager->save($media);
$output->writeln(sprintf(' > %s - %s', $media->getId() ?? '', $media->getName() ?? ''));
$output->writeln(\sprintf(' > %s - %s', $media->getId() ?? '', $media->getName() ?? ''));
} catch (\Exception $e) {
$output->writeln(sprintf('<error>%s</error> : %s', $e->getMessage(), json_encode($data, \JSON_THROW_ON_ERROR)));
$output->writeln(\sprintf('<error>%s</error> : %s', $e->getMessage(), json_encode($data, \JSON_THROW_ON_ERROR)));
}
}
}
2 changes: 1 addition & 1 deletion src/Command/AddMediaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$context = $input->getArgument('context');
$binaryContent = $input->getArgument('binaryContent');

$output->writeln(sprintf('Add a new media - context: %s, provider: %s, content: %s', $context, $provider, $binaryContent));
$output->writeln(\sprintf('Add a new media - context: %s, provider: %s, content: %s', $context, $provider, $binaryContent));

$media = $this->mediaManager->create();
$media->setBinaryContent($binaryContent);
Expand Down
14 changes: 7 additions & 7 deletions src/Command/CleanMediaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
throw new \RuntimeException('Unable to find upload directory, did you configure it?');
}

$output->writeln(sprintf('<info>Scanning upload directory: %s</info>', $baseDirectory));
$output->writeln(\sprintf('<info>Scanning upload directory: %s</info>', $baseDirectory));

foreach ($this->mediaPool->getContexts() as $contextName => $context) {
if (!$filesystem->exists($baseDirectory.'/'.$contextName)) {
$output->writeln(sprintf("<info>'%s' does not exist</info>", $baseDirectory.'/'.$contextName));
$output->writeln(\sprintf("<info>'%s' does not exist</info>", $baseDirectory.'/'.$contextName));

continue;
}

$output->writeln(sprintf('<info>Context: %s</info>', $contextName));
$output->writeln(\sprintf('<info>Context: %s</info>', $contextName));

$files = $finder->files()->in($baseDirectory.'/'.$contextName);

Expand All @@ -82,7 +82,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

if (!$this->mediaExists($filename, $contextName)) {
if ($dryRun) {
$output->writeln(sprintf("<info>'%s' is orphanend</info>", $filename));
$output->writeln(\sprintf("<info>'%s' is orphanend</info>", $filename));
} else {
try {
$realPath = $file->getRealPath();
Expand All @@ -91,13 +91,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$filesystem->remove($realPath);
}

$output->writeln(sprintf("<info>'%s' was successfully removed</info>", $filename));
$output->writeln(\sprintf("<info>'%s' was successfully removed</info>", $filename));
} catch (IOException $ioe) {
$output->writeln(sprintf('<error>%s</error>', $ioe->getMessage()));
$output->writeln(\sprintf('<error>%s</error>', $ioe->getMessage()));
}
}
} elseif ($verbose) {
$output->writeln(sprintf("'%s' found", $filename));
$output->writeln(\sprintf("'%s' found", $filename));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/FixMediaContextCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$defaultContext = $this->contextManager->find($context);

if (null === $defaultContext) {
$output->writeln(sprintf(" > default context for '%s' is missing, creating one", $context));
$output->writeln(\sprintf(" > default context for '%s' is missing, creating one", $context));
$defaultContext = $this->contextManager->create();
$defaultContext->setId($context);
$defaultContext->setName(ucfirst($context));
Expand Down
8 changes: 4 additions & 4 deletions src/Command/RefreshMetadataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'context' => $context,
]);

$this->log($output, sprintf(
$this->log($output, \sprintf(
'Loaded %s medias for generating thumbs (provider: %s, context: %s)',
\count($medias),
$provider->getName(),
$context
));

foreach ($medias as $media) {
$this->log($output, sprintf(
$this->log($output, \sprintf(
'Refresh media %s - %s',
$media->getName() ?? '',
$media->getId() ?? ''
Expand All @@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
try {
$provider->updateMetadata($media, false);
} catch (\Exception $e) {
$this->log($output, sprintf(
$this->log($output, \sprintf(
'<error>Unable to update metadata, media: %s - %s </error>',
$media->getId() ?? '',
$e->getMessage()
Expand All @@ -91,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
try {
$this->mediaManager->save($media);
} catch (\Exception $e) {
$this->log($output, sprintf(
$this->log($output, \sprintf(
'<error>Unable saving media, media: %s - %s </error>',
$media->getId() ?? '',
$e->getMessage()
Expand Down
10 changes: 5 additions & 5 deletions src/Command/RemoveThumbsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$batchOffset
);
} catch (\Exception $e) {
$this->log($output, sprintf('Error: %s', $e->getMessage()));
$this->log($output, \sprintf('Error: %s', $e->getMessage()));

break;
}
Expand All @@ -98,7 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$totalMediasCount += $batchMediasCount;
$this->log($output, sprintf(
$this->log($output, \sprintf(
'Loaded %s medias (batch #%d, offset %d) for removing thumbs (provider: %s, format: %s)',
$batchMediasCount,
$batchCounter,
Expand All @@ -120,7 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

$this->log($output, sprintf('Done (total medias processed: %s).', $totalMediasCount));
$this->log($output, \sprintf('Done (total medias processed: %s).', $totalMediasCount));

return 0;
}
Expand Down Expand Up @@ -181,7 +181,7 @@ private function getFormat(InputInterface $input, OutputInterface $output, Media

private function processMedia(OutputInterface $output, MediaInterface $media, MediaProviderInterface $provider, string $context, string $format): bool
{
$this->log($output, sprintf(
$this->log($output, \sprintf(
'Deleting thumbs for %s - %s',
$media->getName() ?? '',
$media->getId() ?? ''
Expand All @@ -194,7 +194,7 @@ private function processMedia(OutputInterface $output, MediaInterface $media, Me

$provider->removeThumbnails($media, $format);
} catch (\Exception $e) {
$this->log($output, sprintf(
$this->log($output, \sprintf(
'<error>Unable to remove thumbnails, media: %s - %s </error>',
$media->getId() ?? '',
$e->getMessage()
Expand Down
12 changes: 6 additions & 6 deletions src/Command/SyncThumbsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$batchOffset
);
} catch (\Exception $e) {
$this->log($output, sprintf('Error: %s', $e->getMessage()));
$this->log($output, \sprintf('Error: %s', $e->getMessage()));

break;
}
Expand All @@ -102,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$totalMediasCount += $batchMediasCount;
$this->log($output, sprintf(
$this->log($output, \sprintf(
'Loaded %s medias (batch #%d, offset %d) for generating thumbs (provider: %s, context: %s)',
$batchMediasCount,
$batchCounter,
Expand Down Expand Up @@ -130,14 +130,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

$this->log($output, sprintf('Done (total medias processed: %s).', $totalMediasCount));
$this->log($output, \sprintf('Done (total medias processed: %s).', $totalMediasCount));

return 0;
}

private function processMedia(OutputInterface $output, MediaInterface $media, MediaProviderInterface $provider): bool
{
$this->log($output, sprintf(
$this->log($output, \sprintf(
'Generating thumbs for %s - %s',
$media->getName() ?? '',
$media->getId() ?? ''
Expand All @@ -146,7 +146,7 @@ private function processMedia(OutputInterface $output, MediaInterface $media, Me
try {
$provider->removeThumbnails($media);
} catch (\Exception $e) {
$this->log($output, sprintf(
$this->log($output, \sprintf(
'<error>Unable to remove old thumbnails, media: %s - %s </error>',
$media->getId() ?? '',
$e->getMessage()
Expand All @@ -158,7 +158,7 @@ private function processMedia(OutputInterface $output, MediaInterface $media, Me
try {
$provider->generateThumbnails($media);
} catch (\Exception $e) {
$this->log($output, sprintf(
$this->log($output, \sprintf(
'<error>Unable to generate new thumbnails, media: %s - %s </error>',
$media->getId() ?? '',
$e->getMessage()
Expand Down
14 changes: 7 additions & 7 deletions src/Command/UpdateCdnStatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'cdnIsFlushable' => true,
]);

$this->log($output, sprintf('Loaded %s media for CDN status update (provider: %s, context: %s)', \count($medias), $provider->getName(), $context));
$this->log($output, \sprintf('Loaded %s media for CDN status update (provider: %s, context: %s)', \count($medias), $provider->getName(), $context));

foreach ($medias as $media) {
$cdn = $provider->getCdn();
$flushIdentifier = $media->getCdnFlushIdentifier();

$this->log($output, sprintf(
$this->log($output, \sprintf(
'Refresh CDN status for media "%s" (%s) ',
$media->getName() ?? '',
$media->getId() ?? ''
Expand Down Expand Up @@ -118,15 +118,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int

if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
if ($previousStatus === $cdnStatus) {
$this->log($output, sprintf('No changes (%u)', $cdnStatus));
$this->log($output, \sprintf('No changes (%u)', $cdnStatus));
} elseif (CDNInterface::STATUS_OK === $cdnStatus) {
$this->log($output, sprintf('<info>Flush completed</info> (%u => %u)', $previousStatus ?? 'null', $cdnStatus));
$this->log($output, \sprintf('<info>Flush completed</info> (%u => %u)', $previousStatus ?? 'null', $cdnStatus));
} else {
$this->log($output, sprintf('Updated status (%u => %u)', $previousStatus ?? 'null', $cdnStatus));
$this->log($output, \sprintf('Updated status (%u => %u)', $previousStatus ?? 'null', $cdnStatus));
}
}
} catch (\Throwable $e) {
$this->log($output, sprintf(
$this->log($output, \sprintf(
'<error>Unable update CDN status, media: %s - %s </error>',
$media->getId() ?? '',
$e->getMessage()
Expand All @@ -138,7 +138,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
try {
$this->mediaManager->save($media);
} catch (\Throwable $e) {
$this->log($output, sprintf(
$this->log($output, \sprintf(
'<error>Unable to update medium: %s - %s </error>',
$media->getId() ?? '',
$e->getMessage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private function applyFormats(ContainerBuilder $container, array $config): void
$definition = $container->getDefinition($id);

foreach ($context['formats'] as $format => $formatConfig) {
$definition->addMethodCall('addFormat', [sprintf('%s_%s', $name, $format), $formatConfig]);
$definition->addMethodCall('addFormat', [\sprintf('%s_%s', $name, $format), $formatConfig]);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/SonataMediaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ public function load(array $configs, ContainerBuilder $container): void
}

if (!\array_key_exists($config['default_context'], $config['contexts'])) {
throw new \InvalidArgumentException(sprintf('SonataMediaBundle - Invalid default context : %s, available : %s', $config['default_context'], json_encode(array_keys($config['contexts']), \JSON_THROW_ON_ERROR)));
throw new \InvalidArgumentException(\sprintf('SonataMediaBundle - Invalid default context : %s, available : %s', $config['default_context'], json_encode(array_keys($config['contexts']), \JSON_THROW_ON_ERROR)));
}

$loader->load(sprintf('%s.php', $config['db_driver']));
$loader->load(\sprintf('%s.php', $config['db_driver']));

if (isset($bundles['SonataAdminBundle'])) {
$loader->load('controllers.php');
$loader->load(sprintf('%s_admin.php', $config['db_driver']));
$loader->load(\sprintf('%s_admin.php', $config['db_driver']));

$sonataRoles = [];
if (isset($this->sonataAdminConfig['security']['role_admin'])) {
Expand Down
Loading

0 comments on commit ad38beb

Please sign in to comment.