Skip to content

Use php 8 attributes for Vich\UploadableBundle #1594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions core/file-upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ to make it look like this.
# api/config/packages/vich_uploader.yaml
vich_uploader:
db_driver: orm

metadata:
type: attribute
mappings:
media_object:
uri_prefix: /media
Expand Down Expand Up @@ -66,9 +67,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

/**
* @Vich\Uploadable
*/
#[Vich\Uploadable]
#[ORM\Entity]
#[ApiResource(
normalizationContext: ['groups' => ['media_object:read']],
Expand Down Expand Up @@ -109,9 +108,7 @@ class MediaObject
#[Groups(['media_object:read'])]
public ?string $contentUrl = null;

/**
* @Vich\UploadableField(mapping="media_object", fileNameProperty="filePath")
*/
#[Vich\UploadableField(mapping: "media_object", fileNameProperty: "filePath")]
#[Assert\NotNull(groups: ['media_object_create'])]
public ?File $file = null;

Expand Down