Skip to content

Commit d20ca91

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

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

core/file-upload.md

Lines changed: 9 additions & 11 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,7 +408,9 @@ 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

411415
/**
412416
* {@inheritdoc}
@@ -452,17 +456,11 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
452456

453457
final class UploadedFileDenormalizer implements DenormalizerInterface
454458
{
455-
/**
456-
* {@inheritdoc}
457-
*/
458459
public function denormalize($data, string $type, string $format = null, array $context = []): UploadedFile
459460
{
460461
return $data;
461462
}
462463

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

0 commit comments

Comments
 (0)