Skip to content

Commit 6fb0038

Browse files
authored
Merge pull request #1482 from garak/fix-docs
📝 discourage annotations in the docs
2 parents adf48d9 + 839b32e commit 6fb0038

File tree

4 files changed

+10
-100
lines changed

4 files changed

+10
-100
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"yoast/phpunit-polyfills": "^2.0"
6060
},
6161
"suggest": {
62-
"doctrine/annotations": "If you use doctrine/doctrine-bundle >2.7, this package is required to use annotations",
6362
"doctrine/doctrine-bundle": "For integration with Doctrine",
6463
"doctrine/mongodb-odm-bundle": "For integration with Doctrine ODM",
6564
"doctrine/orm": "For integration with Doctrine ORM",

docs/configuration_reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ vich_uploader:
1212
metadata:
1313
auto_detection: true
1414
cache: file
15-
type: attribute # or annotation
15+
type: attribute
1616
mappings:
1717
products:
1818
uri_prefix: /uploads # uri prefix to resource

docs/known_issues.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ metadata is joined with the file during the upload.
133133
To summarize, [Gaufrette support for metadata is flawed](https://github.com/KnpLabs/Gaufrette/issues/108)
134134
(see issue [GH-163](https://github.com/dustin10/VichUploaderBundle/issues/163)).
135135

136-
## Doctrine/annotations package required when using doctrine-bundle >= 2.8
136+
## Doctrine/annotations package required when using annotations and doctrine-bundle >= 2.8
137137

138-
If your project is using `doctrine-bundle:>=2.8`, you must require `doctrine/annotations` package from
139-
your project as it is not required in `doctrine-bundle` anymore from this version.
140-
This bundle is using a `Reader` interface from this package in order to work for both annotations
141-
and attributes mapping.
138+
If your project uses annotations and `doctrine-bundle:>=2.8`, you must require the `doctrine/annotations`
139+
package from your project, as it is not required in `doctrine-bundle` anymore from this version.
140+
This bundle uses a `Reader` interface from this package in order to work for both attributes and annotations
141+
mapping, but annotations are deprecated and will be removed in the future.

docs/usage.md

Lines changed: 4 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -153,100 +153,11 @@ class Product
153153
}
154154
```
155155

156-
Or, with annotations :
157-
158-
``` php
159-
<?php
160-
161-
namespace App\Entity;
162-
163-
use Doctrine\ORM\Mapping as ORM;
164-
use Symfony\Component\HttpFoundation\File\File;
165-
use Vich\UploaderBundle\Mapping\Annotation as Vich;
166-
167-
/**
168-
* @ORM\Entity
169-
* @Vich\Uploadable
170-
*/
171-
class Product
172-
{
173-
/**
174-
* @ORM\Id
175-
* @ORM\Column()
176-
* @ORM\GeneratedValue(strategy="AUTO")
177-
*/
178-
private ?int $id = null;
179-
180-
// ... other fields
181-
182-
/**
183-
* NOTE: This is not a mapped field of entity metadata, just a simple property.
184-
*
185-
* @Vich\UploadableField(mapping="products", fileNameProperty="imageName", size="imageSize")
186-
*/
187-
private ?File $imageFile;
188-
189-
/**
190-
* @ORM\Column(nullable="true")
191-
*/
192-
private ?string $imageName = null;
193-
194-
/**
195-
* @ORM\Column(nullable="true")
196-
*/
197-
private ?int $imageSize = null;
198-
199-
/**
200-
* @ORM\Column(nullable="true")
201-
*/
202-
private ?\DateTimeImmutable $updatedAt = null;
203-
204-
/**
205-
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
206-
* of 'UploadedFile' is injected into this setter to trigger the update. If this
207-
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
208-
* must be able to accept an instance of 'File' as the bundle will inject one here
209-
* during Doctrine hydration.
210-
*
211-
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
212-
*/
213-
public function setImageFile(?File $imageFile = null): void
214-
{
215-
$this->imageFile = $imageFile;
216-
217-
if (null !== $imageFile) {
218-
// It is required that at least one field changes if you are using doctrine
219-
// otherwise the event listeners won't be called and the file is lost
220-
$this->updatedAt = new \DateTimeImmutable();
221-
}
222-
}
223-
224-
public function getImageFile(): ?File
225-
{
226-
return $this->imageFile;
227-
}
228-
229-
public function setImageName(?string $imageName): void
230-
{
231-
$this->imageName = $imageName;
232-
}
233-
234-
public function getImageName(): ?string
235-
{
236-
return $this->imageName;
237-
}
238-
239-
public function setImageSize(?int $imageSize): void
240-
{
241-
$this->imageSize = $imageSize;
242-
}
156+
**Note:**
243157

244-
public function getImageSize(): ?int
245-
{
246-
return $this->imageSize;
247-
}
248-
}
249-
```
158+
> This bundle also supports annotations, but the attribute syntax is recommended.
159+
> If you look for examples about annotations mapping, please refer to an older
160+
> version of the documentation.
250161

251162
Alternatively you can use `Vich\UploaderBundle\Entity\File` embeddable for storing file info in your ORM entity:
252163

0 commit comments

Comments
 (0)