From 839b32eff08d07f43dc2432789f5dd29a81df454 Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Tue, 3 Dec 2024 08:11:15 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20discourage=20annotations=20in=20?= =?UTF-8?q?the=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 1 - docs/configuration_reference.md | 2 +- docs/known_issues.md | 10 ++-- docs/usage.md | 97 ++------------------------------- 4 files changed, 10 insertions(+), 100 deletions(-) diff --git a/composer.json b/composer.json index e5ab58d0..776051d5 100644 --- a/composer.json +++ b/composer.json @@ -59,7 +59,6 @@ "yoast/phpunit-polyfills": "^2.0" }, "suggest": { - "doctrine/annotations": "If you use doctrine/doctrine-bundle >2.7, this package is required to use annotations", "doctrine/doctrine-bundle": "For integration with Doctrine", "doctrine/mongodb-odm-bundle": "For integration with Doctrine ODM", "doctrine/orm": "For integration with Doctrine ORM", diff --git a/docs/configuration_reference.md b/docs/configuration_reference.md index 1fcb6e60..46cc654a 100644 --- a/docs/configuration_reference.md +++ b/docs/configuration_reference.md @@ -12,7 +12,7 @@ vich_uploader: metadata: auto_detection: true cache: file - type: attribute # or annotation + type: attribute mappings: products: uri_prefix: /uploads # uri prefix to resource diff --git a/docs/known_issues.md b/docs/known_issues.md index 596fc592..ef3d4969 100644 --- a/docs/known_issues.md +++ b/docs/known_issues.md @@ -133,9 +133,9 @@ metadata is joined with the file during the upload. To summarize, [Gaufrette support for metadata is flawed](https://github.com/KnpLabs/Gaufrette/issues/108) (see issue [GH-163](https://github.com/dustin10/VichUploaderBundle/issues/163)). -## Doctrine/annotations package required when using doctrine-bundle >= 2.8 +## Doctrine/annotations package required when using annotations and doctrine-bundle >= 2.8 -If your project is using `doctrine-bundle:>=2.8`, you must require `doctrine/annotations` package from -your project as it is not required in `doctrine-bundle` anymore from this version. -This bundle is using a `Reader` interface from this package in order to work for both annotations -and attributes mapping. +If your project uses annotations and `doctrine-bundle:>=2.8`, you must require the `doctrine/annotations` +package from your project, as it is not required in `doctrine-bundle` anymore from this version. +This bundle uses a `Reader` interface from this package in order to work for both attributes and annotations +mapping, but annotations are deprecated and will be removed in the future. diff --git a/docs/usage.md b/docs/usage.md index e17dedb3..9608a52b 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -153,100 +153,11 @@ class Product } ``` -Or, with annotations : - -``` php -imageFile = $imageFile; - - if (null !== $imageFile) { - // It is required that at least one field changes if you are using doctrine - // otherwise the event listeners won't be called and the file is lost - $this->updatedAt = new \DateTimeImmutable(); - } - } - - public function getImageFile(): ?File - { - return $this->imageFile; - } - - public function setImageName(?string $imageName): void - { - $this->imageName = $imageName; - } - - public function getImageName(): ?string - { - return $this->imageName; - } - - public function setImageSize(?int $imageSize): void - { - $this->imageSize = $imageSize; - } +**Note:** - public function getImageSize(): ?int - { - return $this->imageSize; - } -} -``` +> This bundle also supports annotations, but the attribute syntax is recommended. +> If you look for examples about annotations mapping, please refer to an older +> version of the documentation. Alternatively you can use `Vich\UploaderBundle\Entity\File` embeddable for storing file info in your ORM entity: