Skip to content

Commit

Permalink
Merge 4.x into 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI committed Oct 31, 2021
2 parents 9a594a8 + f4e3c50 commit 44af5c6
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 229 deletions.
32 changes: 32 additions & 0 deletions UPGRADE-3.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ UPGRADE 3.x
UPGRADE FROM 3.x to 3.x
=======================

### Deprecate PantherPortal CDN

PantherPortal CDN no longer exists.

### Deprecate `null` media value on Twig functions

Our custom twig functions (`sonata_media`, `sonata_thumbnail` and `sonata_path`) used to accept a null value and produce an empty result.
Expand All @@ -18,6 +22,34 @@ This command was introduced a long time ago to migrate from array to json. Make

This class is deprecated because it is dead code. If you use it, please use `ProviderDataTransformer` instead.

### Deprecated using `master` and `slave` words in configuration

Before:

```yaml
sonata_media:
cdn:
fallback:
master: sonata.media.cdn.cloudfront
filesystem:
replicate:
master: sonata.media.adapter.filesystem.s3
slave: sonata.media.adapter.filesystem.local
```

After:

```yaml
sonata_media:
cdn:
fallback:
primary: sonata.media.cdn.cloudfront
filesystem:
replicate:
primary: sonata.media.adapter.filesystem.s3
secondary: sonata.media.adapter.filesystem.local
```

UPGRADE FROM 3.33 to 3.34
=========================

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Available services
- ``sonata.media.filesystem.local``: The local filesystem (default)
- ``sonata.media.filesystem.ftp``: FTP
- ``sonata.media.filesystem.s3``: Amazon S3
- ``sonata.media.filesystem.replicate``: Replicate file to a master and to a slave
- ``sonata.media.filesystem.replicate``: Replicate file to a primary and a secondary

- CDN

Expand Down
6 changes: 3 additions & 3 deletions docs/reference/advanced_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Full configuration options:
version:
fallback:
master: sonata.media.cdn.panther
primary: sonata.media.cdn.panther
fallback: sonata.media.cdn.server
filesystem:
Expand Down Expand Up @@ -113,8 +113,8 @@ Full configuration options:
key1: value1 #any amount of metas(sent as x-amz-meta-key1 = value1)
replicate:
master: sonata.media.adapter.filesystem.s3
slave: sonata.media.adapter.filesystem.local
primary: sonata.media.adapter.filesystem.s3
secondary: sonata.media.adapter.filesystem.local
providers:
file:
Expand Down
100 changes: 0 additions & 100 deletions src/CDN/PantherPortal.php

This file was deleted.

18 changes: 3 additions & 15 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,6 @@ private function addCdnSection(ArrayNodeDefinition $node): void
->end()
->end()

->arrayNode('panther')
->children()
->scalarNode('path')
->info('e.g. http://domain.pantherportal.com/uploads/media')
->isRequired()
->end()
->scalarNode('site_id')->isRequired()->end()
->scalarNode('password')->isRequired()->end()
->scalarNode('username')->isRequired()->end()
->end()
->end()

->arrayNode('cloudfront')
->children()
->scalarNode('path')
Expand All @@ -181,7 +169,7 @@ private function addCdnSection(ArrayNodeDefinition $node): void

->arrayNode('fallback')
->children()
->scalarNode('master')->isRequired()->end()
->scalarNode('primary')->isRequired()->end()
->scalarNode('fallback')->isRequired()->end()
->end()
->end()
Expand Down Expand Up @@ -271,8 +259,8 @@ private function addFilesystemSection(ArrayNodeDefinition $node): void

->arrayNode('replicate')
->children()
->scalarNode('master')->isRequired()->end()
->scalarNode('slave')->isRequired()->end()
->scalarNode('primary')->isRequired()->end()
->scalarNode('secondary')->isRequired()->end()
->end()
->end()
->end()
Expand Down
20 changes: 3 additions & 17 deletions src/DependencyInjection/SonataMediaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use Sonata\Doctrine\Mapper\Builder\OptionsBuilder;
use Sonata\Doctrine\Mapper\DoctrineCollector;
use Sonata\MediaBundle\CDN\CloudFrontVersion3;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -191,16 +190,6 @@ public function configureCdnAdapter(ContainerBuilder $container, array $config):
$container->removeDefinition('sonata.media.cdn.server');
}

if ($container->hasDefinition('sonata.media.cdn.panther') && isset($config['cdn']['panther'])) {
$container->getDefinition('sonata.media.cdn.panther')
->replaceArgument(0, $config['cdn']['panther']['path'])
->replaceArgument(1, $config['cdn']['panther']['username'])
->replaceArgument(2, $config['cdn']['panther']['password'])
->replaceArgument(3, $config['cdn']['panther']['site_id']);
} else {
$container->removeDefinition('sonata.media.cdn.panther');
}

if ($container->hasDefinition('sonata.media.cdn.cloudfront') && isset($config['cdn']['cloudfront'])) {
$cloudFrontConfig = [];

Expand All @@ -217,13 +206,10 @@ public function configureCdnAdapter(ContainerBuilder $container, array $config):
'secret' => $config['cdn']['cloudfront']['secret'],
];

$cloudFrontClass = CloudFrontVersion3::class;

$container->getDefinition('sonata.media.cdn.cloudfront.client')
->replaceArgument(0, $cloudFrontConfig);

$container->getDefinition('sonata.media.cdn.cloudfront')
->setClass($cloudFrontClass)
->replaceArgument(0, new Reference('sonata.media.cdn.cloudfront.client'))
->replaceArgument(1, $config['cdn']['cloudfront']['distribution_id'])
->replaceArgument(2, $config['cdn']['cloudfront']['path']);
Expand All @@ -234,7 +220,7 @@ public function configureCdnAdapter(ContainerBuilder $container, array $config):

if ($container->hasDefinition('sonata.media.cdn.fallback') && isset($config['cdn']['fallback'])) {
$container->getDefinition('sonata.media.cdn.fallback')
->replaceArgument(0, new Reference($config['cdn']['fallback']['master']))
->replaceArgument(0, new Reference($config['cdn']['fallback']['primary']))
->replaceArgument(1, new Reference($config['cdn']['fallback']['fallback']));
} else {
$container->removeDefinition('sonata.media.cdn.fallback');
Expand Down Expand Up @@ -316,8 +302,8 @@ public function configureFilesystemAdapter(ContainerBuilder $container, array $c

if ($container->hasDefinition('sonata.media.adapter.filesystem.replicate') && isset($config['filesystem']['replicate'])) {
$container->getDefinition('sonata.media.adapter.filesystem.replicate')
->replaceArgument(0, new Reference($config['filesystem']['replicate']['master']))
->replaceArgument(1, new Reference($config['filesystem']['replicate']['slave']));
->replaceArgument(0, new Reference($config['filesystem']['replicate']['primary']))
->replaceArgument(1, new Reference($config['filesystem']['replicate']['secondary']));
} else {
$container->removeDefinition('sonata.media.adapter.filesystem.replicate');
$container->removeDefinition('sonata.media.filesystem.replicate');
Expand Down
8 changes: 2 additions & 6 deletions src/Resources/config/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
use Imagine\Gd\Imagine as GdImagine;
use Imagine\Gmagick\Imagine as GmagickImagine;
use Imagine\Imagick\Imagine as ImagickImagine;
use Sonata\MediaBundle\CDN\CloudFrontVersion3;
use Sonata\MediaBundle\CDN\Fallback;
use Sonata\MediaBundle\CDN\PantherPortal;
use Sonata\MediaBundle\CDN\Server;
use Sonata\MediaBundle\Resizer\CropResizer;
use Sonata\MediaBundle\Resizer\SimpleResizer;
Expand Down Expand Up @@ -61,14 +61,10 @@
->set('sonata.media.cdn.server', Server::class)
->args([''])

->set('sonata.media.cdn.panther', PantherPortal::class)
->args(['', '', '', ''])

->set('sonata.media.cdn.cloudfront.client', CloudFrontClient::class)
->args([[]])

// The class for "sonata.media.cdn.cloudfront" service is set dynamically at `SonataMediaExtension`
->set('sonata.media.cdn.cloudfront')
->set('sonata.media.cdn.cloudfront', CloudFrontVersion3::class)
->args(['', '', ''])

->set('sonata.media.cdn.fallback', Fallback::class)
Expand Down
67 changes: 0 additions & 67 deletions tests/CDN/PantherPortalTest.php

This file was deleted.

0 comments on commit 44af5c6

Please sign in to comment.