Skip to content

Commit 95e427f

Browse files
committed
remove a deprecation in upload docs
1 parent c15749d commit 95e427f

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

core/file-upload.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ to make it look like this.
2525

2626
```yaml
2727
# api/config/packages/vich_uploader.yaml
28+
2829
vich_uploader:
2930
db_driver: orm
3031
metadata:
@@ -34,7 +35,7 @@ vich_uploader:
3435
uri_prefix: /media
3536
upload_destination: '%kernel.project_dir%/public/media'
3637
# Will rename uploaded files using a uniqueid as a prefix.
37-
namer: Vich\UploaderBundle\Naming\OrignameNamer
38+
namer: Vich\UploaderBundle\Naming\SmartUniqueNamer
3839
```
3940
4041
## Uploading to a Dedicated Resource
@@ -53,6 +54,7 @@ The `MediaObject` resource is implemented like this:
5354
```php
5455
<?php
5556
// api/src/Entity/MediaObject.php
57+
5658
namespace App\Entity;
5759
5860
use ApiPlatform\Metadata\ApiProperty;
@@ -109,7 +111,7 @@ class MediaObject
109111
#[Groups(['media_object:read'])]
110112
public ?string $contentUrl = null;
111113
112-
#[Vich\UploadableField(mapping: "media_object", fileNameProperty: "filePath")]
114+
#[Vich\UploadableField(mapping: 'media_object', fileNameProperty: 'filePath')]
113115
#[Assert\NotNull(groups: ['media_object_create'])]
114116
public ?File $file = null;
115117
@@ -172,12 +174,11 @@ A [normalizer](serialization.md#normalization) could be used to set the `content
172174
namespace App\Serializer;
173175
174176
use App\Entity\MediaObject;
175-
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
176177
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
177178
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
178179
use Vich\UploaderBundle\Storage\StorageInterface;
179180
180-
final class MediaObjectNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface
181+
final class MediaObjectNormalizer implements NormalizerAwareInterface
181182
{
182183
use NormalizerAwareTrait;
183184
@@ -246,6 +247,7 @@ We first need to edit our Book resource, and add a new property called `image`.
246247
```php
247248
<?php
248249
// api/src/Entity/Book.php
250+
249251
namespace App\Entity;
250252

251253
use ApiPlatform\Metadata\ApiResource;
@@ -406,11 +408,10 @@ final class MultipartDecoder implements DecoderInterface
406408
{
407409
public const FORMAT = 'multipart';
408410

409-
public function __construct(private RequestStack $requestStack) {}
411+
public function __construct(private RequestStack $requestStack)
412+
{
413+
}
410414

411-
/**
412-
* {@inheritdoc}
413-
*/
414415
public function decode(string $data, string $format, array $context = []): ?array
415416
{
416417
$request = $this->requestStack->getCurrentRequest();
@@ -427,9 +428,6 @@ final class MultipartDecoder implements DecoderInterface
427428
}, $request->request->all()) + $request->files->all();
428429
}
429430

430-
/**
431-
* {@inheritdoc}
432-
*/
433431
public function supportsDecoding(string $format): bool
434432
{
435433
return self::FORMAT === $format;
@@ -452,17 +450,11 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
452450

453451
final class UploadedFileDenormalizer implements DenormalizerInterface
454452
{
455-
/**
456-
* {@inheritdoc}
457-
*/
458453
public function denormalize($data, string $type, string $format = null, array $context = []): UploadedFile
459454
{
460455
return $data;
461456
}
462457

463-
/**
464-
* {@inheritdoc}
465-
*/
466458
public function supportsDenormalization($data, $type, $format = null): bool
467459
{
468460
return $data instanceof UploadedFile;

0 commit comments

Comments
 (0)