sonata-project / SonataMediaBundle
Showing 15 of 29 files from the diff.

@@ -36,8 +36,6 @@
Loading
36 36
use Twig\Environment;
37 37
38 38
/**
39 -
 * @final since sonata-project/media-bundle 3.21.0
40 -
 *
41 39
 * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
42 40
 */
43 41
class MediaBlockService extends AbstractBlockService

@@ -115,7 +115,7 @@
Loading
115 115
                        'Quantity' => \count($normalizedPaths),
116 116
                        'Items' => $normalizedPaths,
117 117
                    ],
118 -
                    'CallerReference' => $this->getCallerReference($normalizedPaths),
118 +
                    'CallerReference' => $this->getCallerReference(),
119 119
                ],
120 120
            ]);
121 121
            $status = $result->get('Invalidation')['Status'];
@@ -126,7 +126,7 @@
Loading
126 126
127 127
            return $result->get('Invalidation')['Id'];
128 128
        } catch (CloudFrontException $ex) {
129 -
            throw new \RuntimeException(sprintf('Unable to flush paths "%s".', implode('", "', $paths), 0, $ex));
129 +
            throw new \RuntimeException(sprintf('Unable to flush paths "%s".', implode('", "', $paths)), 0, $ex);
130 130
        }
131 131
    }
132 132
@@ -151,16 +151,14 @@
Loading
151 151
    }
152 152
153 153
    /**
154 -
     * Generates a valid caller reference from given paths regardless its order.
154 +
     * Generates a caller reference.
155 155
     *
156 -
     * @phpstan-param list<string> $paths
156 +
     * @see https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_InvalidationBatch.html.
157 157
     *
158 -
     * @return string a md5 representation
158 +
     * NEXT_MAJOR: Generate the reference based on the `MediaInterface::getUpdatedAt()` property for the given media.
159 159
     */
160 -
    private function getCallerReference(array $paths): string
160 +
    private function getCallerReference(): string
161 161
    {
162 -
        sort($paths);
163 -
164 -
        return md5(implode(',', $paths));
162 +
        return (string) time();
165 163
    }
166 164
}

@@ -155,8 +155,7 @@
Loading
155 155
            ->addIdentifier('name')
156 156
            ->add('description')
157 157
            ->add('enabled')
158 -
            ->add('size')
159 -
        ;
158 +
            ->add('size');
160 159
    }
161 160
162 161
    protected function configureFormFields(FormMapper $formMapper): void

@@ -88,8 +88,7 @@
Loading
88 88
            // NEXT_MAJOR: Change Gallery key to `form_group.gallery` and update translations files.
89 89
            ->with('Gallery', ['class' => 'col-md-9'])->end()
90 90
            // NEXT_MAJOR: Change Options key to `form_group.options` and update translations files.
91 -
            ->with('Options', ['class' => 'col-md-3'])->end()
92 -
        ;
91 +
            ->with('Options', ['class' => 'col-md-3'])->end();
93 92
94 93
        $context = $this->getPersistentParameter('context');
95 94
@@ -127,8 +126,7 @@
Loading
127 126
                    'link_parameters' => ['context' => $context],
128 127
                    'admin_code' => 'sonata.media.admin.gallery_item',
129 128
                ])
130 -
            ->end()
131 -
        ;
129 +
            ->end();
132 130
    }
133 131
134 132
    protected function configureListFields(ListMapper $listMapper): void
@@ -137,8 +135,7 @@
Loading
137 135
            ->addIdentifier('name')
138 136
            ->add('enabled', 'boolean', ['editable' => true])
139 137
            ->add('context', 'trans', ['catalogue' => 'SonataMediaBundle'])
140 -
            ->add('defaultFormat', 'trans', ['catalogue' => 'SonataMediaBundle'])
141 -
        ;
138 +
            ->add('defaultFormat', 'trans', ['catalogue' => 'SonataMediaBundle']);
142 139
    }
143 140
144 141
    protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
@@ -148,7 +145,6 @@
Loading
148 145
            ->add('enabled')
149 146
            ->add('context', null, [
150 147
                'show_filter' => false,
151 -
            ])
152 -
        ;
148 +
            ]);
153 149
    }
154 150
}

@@ -27,7 +27,6 @@
Loading
27 27
            ->add('name')
28 28
            ->add('providerReference')
29 29
            ->add('enabled')
30 -
            ->add('context')
31 -
        ;
30 +
            ->add('context');
32 31
    }
33 32
}

@@ -49,7 +49,6 @@
Loading
49 49
            ->subcompile($this->getNode('format'))
50 50
            ->raw(', ')
51 51
            ->subcompile($this->getNode('attributes'))
52 -
            ->raw(");\n")
53 -
        ;
52 +
            ->raw(");\n");
54 53
    }
55 54
}

@@ -35,9 +35,6 @@
Loading
35 35
use Symfony\Component\Validator\Constraints\NotBlank;
36 36
use Symfony\Component\Validator\Constraints\NotNull;
37 37
38 -
/**
39 -
 * @final since sonata-project/media-bundle 3.21.0
40 -
 */
41 38
class FileProvider extends BaseProvider implements FileProviderInterface
42 39
{
43 40
    protected $allowedExtensions;

@@ -48,8 +48,7 @@
Loading
48 48
        $datagridMapper
49 49
            ->add('width')
50 50
            ->add('height')
51 -
            ->add('contentType')
52 -
        ;
51 +
            ->add('contentType');
53 52
54 53
        $providers = [];
55 54

@@ -45,8 +45,7 @@
Loading
45 45
                'link_parameters' => $link_parameters,
46 46
            ])
47 47
            ->add('enabled', null, ['required' => false])
48 -
            ->add('position', HiddenType::class)
49 -
        ;
48 +
            ->add('position', HiddenType::class);
50 49
    }
51 50
52 51
    protected function configureListFields(ListMapper $listMapper): void
@@ -55,7 +54,6 @@
Loading
55 54
            ->add('media')
56 55
            ->add('gallery')
57 56
            ->add('position')
58 -
            ->add('enabled')
59 -
        ;
57 +
            ->add('enabled');
60 58
    }
61 59
}

@@ -47,7 +47,6 @@
Loading
47 47
            ->subcompile($this->getNode('media'))
48 48
            ->raw(', ')
49 49
            ->subcompile($this->getNode('format'))
50 -
            ->raw(");\n")
51 -
        ;
50 +
            ->raw(");\n");
52 51
    }
53 52
}

@@ -80,8 +80,7 @@
Loading
80 80
                        ->replaceArgument(1, new Reference($config['filesystem']))
81 81
                        ->replaceArgument(2, new Reference($config['cdn']))
82 82
                        ->replaceArgument(3, new Reference($config['generator']))
83 -
                        ->replaceArgument(4, new Reference($config['thumbnail']))
84 -
                    ;
83 +
                        ->replaceArgument(4, new Reference($config['thumbnail']));
85 84
86 85
                    if ($config['resizer']) {
87 86
                        $definition->addMethodCall('setResizer', [new Reference($config['resizer'])]);

@@ -172,13 +172,11 @@
Loading
172 172
        $container->getDefinition('sonata.media.provider.image')
173 173
            ->replaceArgument(5, array_map('strtolower', $config['providers']['image']['allowed_extensions']))
174 174
            ->replaceArgument(6, $config['providers']['image']['allowed_mime_types'])
175 -
            ->replaceArgument(7, new Reference($config['providers']['image']['adapter']))
176 -
        ;
175 +
            ->replaceArgument(7, new Reference($config['providers']['image']['adapter']));
177 176
178 177
        $container->getDefinition('sonata.media.provider.file')
179 178
            ->replaceArgument(5, $config['providers']['file']['allowed_extensions'])
180 -
            ->replaceArgument(6, $config['providers']['file']['allowed_mime_types'])
181 -
        ;
179 +
            ->replaceArgument(6, $config['providers']['file']['allowed_mime_types']);
182 180
183 181
        $container->getDefinition('sonata.media.provider.youtube')->replaceArgument(8, $config['providers']['youtube']['html5']);
184 182
    }
@@ -295,8 +293,7 @@
Loading
295 293
        // add the default configuration for the server cdn
296 294
        if ($container->hasDefinition('sonata.media.cdn.server') && isset($config['cdn']['server'])) {
297 295
            $container->getDefinition('sonata.media.cdn.server')
298 -
                ->replaceArgument(0, $config['cdn']['server']['path'])
299 -
            ;
296 +
                ->replaceArgument(0, $config['cdn']['server']['path']);
300 297
        } else {
301 298
            $container->removeDefinition('sonata.media.cdn.server');
302 299
        }
@@ -306,8 +303,7 @@
Loading
306 303
                ->replaceArgument(0, $config['cdn']['panther']['path'])
307 304
                ->replaceArgument(1, $config['cdn']['panther']['username'])
308 305
                ->replaceArgument(2, $config['cdn']['panther']['password'])
309 -
                ->replaceArgument(3, $config['cdn']['panther']['site_id'])
310 -
            ;
306 +
                ->replaceArgument(3, $config['cdn']['panther']['site_id']);
311 307
        } else {
312 308
            $container->removeDefinition('sonata.media.cdn.panther');
313 309
        }
@@ -344,8 +340,7 @@
Loading
344 340
        if ($container->hasDefinition('sonata.media.cdn.fallback') && isset($config['cdn']['fallback'])) {
345 341
            $container->getDefinition('sonata.media.cdn.fallback')
346 342
                ->replaceArgument(0, new Reference($config['cdn']['fallback']['master']))
347 -
                ->replaceArgument(1, new Reference($config['cdn']['fallback']['fallback']))
348 -
            ;
343 +
                ->replaceArgument(1, new Reference($config['cdn']['fallback']['fallback']));
349 344
        } else {
350 345
            $container->removeDefinition('sonata.media.cdn.fallback');
351 346
        }
@@ -360,8 +355,7 @@
Loading
360 355
        if ($container->hasDefinition('sonata.media.adapter.filesystem.local') && isset($config['filesystem']['local'])) {
361 356
            $container->getDefinition('sonata.media.adapter.filesystem.local')
362 357
                ->addArgument($config['filesystem']['local']['directory'])
363 -
                ->addArgument($config['filesystem']['local']['create'])
364 -
            ;
358 +
                ->addArgument($config['filesystem']['local']['create']);
365 359
        } else {
366 360
            $container->removeDefinition('sonata.media.adapter.filesystem.local');
367 361
        }
@@ -378,8 +372,7 @@
Loading
378 372
                    'passive' => $config['filesystem']['ftp']['passive'],
379 373
                    'create' => $config['filesystem']['ftp']['create'],
380 374
                    'mode' => $config['filesystem']['ftp']['mode'],
381 -
                ])
382 -
            ;
375 +
                ]);
383 376
        } else {
384 377
            $container->removeDefinition('sonata.media.adapter.filesystem.ftp');
385 378
            $container->removeDefinition('sonata.media.filesystem.ftp');
@@ -390,8 +383,7 @@
Loading
390 383
            $container->getDefinition('sonata.media.adapter.filesystem.s3')
391 384
                ->replaceArgument(0, new Reference('sonata.media.adapter.service.s3'))
392 385
                ->replaceArgument(1, $config['filesystem']['s3']['bucket'])
393 -
                ->replaceArgument(2, ['create' => $config['filesystem']['s3']['create'], 'region' => $config['filesystem']['s3']['region'], 'directory' => $config['filesystem']['s3']['directory'], 'ACL' => $config['filesystem']['s3']['acl']])
394 -
            ;
386 +
                ->replaceArgument(2, ['create' => $config['filesystem']['s3']['create'], 'region' => $config['filesystem']['s3']['region'], 'directory' => $config['filesystem']['s3']['directory'], 'ACL' => $config['filesystem']['s3']['acl']]);
395 387
396 388
            $container->getDefinition('sonata.media.metadata.amazon')
397 389
                ->replaceArgument(0, [
@@ -400,8 +392,7 @@
Loading
400 392
                        'encryption' => $config['filesystem']['s3']['encryption'],
401 393
                        'meta' => $config['filesystem']['s3']['meta'],
402 394
                        'cache_control' => $config['filesystem']['s3']['cache_control'],
403 -
                ])
404 -
            ;
395 +
                ]);
405 396
406 397
            $arguments = [
407 398
                'region' => $config['filesystem']['s3']['region'],
@@ -429,8 +420,7 @@
Loading
429 420
        if ($container->hasDefinition('sonata.media.adapter.filesystem.replicate') && isset($config['filesystem']['replicate'])) {
430 421
            $container->getDefinition('sonata.media.adapter.filesystem.replicate')
431 422
                ->replaceArgument(0, new Reference($config['filesystem']['replicate']['master']))
432 -
                ->replaceArgument(1, new Reference($config['filesystem']['replicate']['slave']))
433 -
            ;
423 +
                ->replaceArgument(1, new Reference($config['filesystem']['replicate']['slave']));
434 424
        } else {
435 425
            $container->removeDefinition('sonata.media.adapter.filesystem.replicate');
436 426
            $container->removeDefinition('sonata.media.filesystem.replicate');
@@ -439,8 +429,7 @@
Loading
439 429
        if ($container->hasDefinition('sonata.media.adapter.filesystem.mogilefs') && isset($config['filesystem']['mogilefs'])) {
440 430
            $container->getDefinition('sonata.media.adapter.filesystem.mogilefs')
441 431
                ->replaceArgument(0, $config['filesystem']['mogilefs']['domain'])
442 -
                ->replaceArgument(1, $config['filesystem']['mogilefs']['hosts'])
443 -
            ;
432 +
                ->replaceArgument(1, $config['filesystem']['mogilefs']['hosts']);
444 433
        } else {
445 434
            $container->removeDefinition('sonata.media.adapter.filesystem.mogilefs');
446 435
            $container->removeDefinition('sonata.media.filesystem.mogilefs');
@@ -457,8 +446,7 @@
Loading
457 446
            }
458 447
            $container->getDefinition('sonata.media.adapter.filesystem.opencloud.connection')
459 448
                ->replaceArgument(0, $config['filesystem'][$settings]['url'])
460 -
                ->replaceArgument(1, $config['filesystem'][$settings]['secret'])
461 -
                ;
449 +
                ->replaceArgument(1, $config['filesystem'][$settings]['secret']);
462 450
            $container->getDefinition('sonata.media.adapter.filesystem.opencloud')
463 451
                ->replaceArgument(1, $config['filesystem'][$settings]['containerName'])
464 452
                ->replaceArgument(2, $config['filesystem'][$settings]['create_container']);
@@ -477,8 +465,7 @@
Loading
477 465
        if ($config['pixlr']['enabled']) {
478 466
            $container->getDefinition('sonata.media.extra.pixlr')
479 467
                ->replaceArgument(0, $config['pixlr']['referrer'])
480 -
                ->replaceArgument(1, $config['pixlr']['secret'])
481 -
            ;
468 +
                ->replaceArgument(1, $config['pixlr']['secret']);
482 469
        } else {
483 470
            $container->removeDefinition('sonata.media.extra.pixlr');
484 471
        }

@@ -189,7 +189,7 @@
Loading
189 189
                    'Quantity' => \count($normalizedPaths),
190 190
                    'Items' => $normalizedPaths,
191 191
                ],
192 -
                'CallerReference' => $this->getCallerReference($normalizedPaths),
192 +
                'CallerReference' => $this->getCallerReference(),
193 193
            ]);
194 194
195 195
            $status = $result->get('Status');
@@ -200,7 +200,7 @@
Loading
200 200
201 201
            return $result->get('Id');
202 202
        } catch (CloudFrontException $ex) {
203 -
            throw new \RuntimeException(sprintf('Unable to flush paths "%s".', implode('", "', $paths), 0, $ex));
203 +
            throw new \RuntimeException(sprintf('Unable to flush paths "%s".', implode('", "', $paths)), 0, $ex);
204 204
        }
205 205
    }
206 206
@@ -265,14 +265,14 @@
Loading
265 265
    }
266 266
267 267
    /**
268 -
     * Generates a valid caller reference from given paths regardless its order.
268 +
     * Generates a caller reference.
269 269
     *
270 -
     * @return string a md5 representation
270 +
     * @see https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_InvalidationBatch.html.
271 +
     *
272 +
     * NEXT_MAJOR: Generate the reference based on the `MediaInterface::getUpdatedAt()` property for the given media.
271 273
     */
272 -
    protected function getCallerReference(array $paths)
274 +
    protected function getCallerReference()
273 275
    {
274 -
        sort($paths);
275 -
276 -
        return md5(implode(',', $paths));
276 +
        return (string) time();
277 277
    }
278 278
}

@@ -68,8 +68,7 @@
Loading
68 68
                        ->scalarNode('constraint')->defaultValue(true)->end()
69 69
                    ->end()
70 70
                ->end()
71 -
            ->end()
72 -
        ;
71 +
            ->end();
73 72
74 73
        $this->addContextsSection($node);
75 74
        $this->addCdnSection($node);
@@ -126,8 +125,7 @@
Loading
126 125
                        ->end()
127 126
                    ->end()
128 127
                ->end()
129 -
            ->end()
130 -
        ;
128 +
            ->end();
131 129
    }
132 130
133 131
    private function addCdnSection(ArrayNodeDefinition $node): void
@@ -177,8 +175,7 @@
Loading
177 175
                        ->end()
178 176
                    ->end()
179 177
                ->end()
180 -
            ->end()
181 -
        ;
178 +
            ->end();
182 179
    }
183 180
184 181
    private function addFilesystemSection(ArrayNodeDefinition $node): void
@@ -332,8 +329,7 @@
Loading
332 329
                        ->end()
333 330
                    ->end()
334 331
                ->end()
335 -
            ->end()
336 -
        ;
332 +
            ->end();
337 333
    }
338 334
339 335
    private function addProvidersSection(ArrayNodeDefinition $node): void
@@ -440,8 +436,7 @@
Loading
440 436
                        ->end()
441 437
                    ->end()
442 438
                ->end()
443 -
            ->end()
444 -
        ;
439 +
            ->end();
445 440
    }
446 441
447 442
    private function addExtraSection(ArrayNodeDefinition $node): void
@@ -457,8 +452,7 @@
Loading
457 452
                        ->scalarNode('referrer')->defaultValue('Sonata Media')->end()
458 453
                    ->end()
459 454
                ->end()
460 -
            ->end()
461 -
        ;
455 +
            ->end();
462 456
    }
463 457
464 458
    private function addModelSection(ArrayNodeDefinition $node): void
@@ -472,11 +466,9 @@
Loading
472 466
                        ->scalarNode('gallery')->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\Gallery')->end()
473 467
                        ->scalarNode('gallery_item')->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\GalleryItem')->end()
474 468
                        ->scalarNode('category')->defaultValue('Application\\Sonata\\ClassificationBundle\\Entity\\Category')->end()
475 -
                        ->end()
476 469
                    ->end()
477 470
                ->end()
478 -
            ->end()
479 -
        ;
471 +
            ->end();
480 472
    }
481 473
482 474
    private function addHttpClientSection(ArrayNodeDefinition $node): void
@@ -496,8 +488,7 @@
Loading
496 488
                        ->end()
497 489
                    ->end()
498 490
                ->end()
499 -
            ->end()
500 -
        ;
491 +
            ->end();
501 492
    }
502 493
503 494
    private function addResizerSection(ArrayNodeDefinition $node): void
@@ -527,8 +518,7 @@
Loading
527 518
                        ->scalarNode('default')->defaultValue('sonata.media.resizer.simple')->end()
528 519
                    ->end()
529 520
                ->end()
530 -
            ->end()
531 -
        ;
521 +
            ->end();
532 522
    }
533 523
534 524
    private function addAdapterSection(ArrayNodeDefinition $node): void
@@ -541,8 +531,7 @@
Loading
541 531
                        ->scalarNode('default')->defaultValue('sonata.media.adapter.image.gd')->end()
542 532
                    ->end()
543 533
                ->end()
544 -
            ->end()
545 -
        ;
534 +
            ->end();
546 535
    }
547 536
548 537
    /**

@@ -49,7 +49,6 @@
Loading
49 49
            ->subcompile($this->getNode('format'))
50 50
            ->raw(', ')
51 51
            ->subcompile($this->getNode('attributes'))
52 -
            ->raw(");\n")
53 -
        ;
52 +
            ->raw(");\n");
54 53
    }
55 54
}
Files Complexity Coverage
src 1,345 59.46%
Project Totals (128 files) 1345 59.46%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading