Skip to content

Commit b29172a

Browse files
committed
📝 Expand upgrade notes and fix some docs
1 parent 6e1cf1a commit b29172a

6 files changed

Lines changed: 15 additions & 11 deletions

File tree

UPGRADE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22

33
## Breaking Changes
44

5+
* Minimum PHP version raised from `^8.1` to `^8.3`.
6+
* Minimum Symfony version raised: support for `5.4` and `7.0`-`7.3` has been dropped. Symfony `6.4`, `7.4` and `8.0` are now required.
57
* The deprecated `Vich\UploaderBundle\Mapping\Annotation` namespace has been removed. Use `Vich\UploaderBundle\Mapping\Attribute` instead.
68
* The deprecated `AnnotationInterface` has been removed. Use `AttributeInterface` instead.
9+
* Support for annotations has been removed entirely). Use PHP attributes instead.
710
* `AttributeReader` deprecated methods have been removed: use `getClassAttribute()` instead of `getClassAnnotation()`, `getPropertyAttribute()` instead of `getPropertyAnnotation()`.
11+
* `NamerInterface::name()` and `DirectoryNamerInterface::directoryName()` parameter type widened from `object` to `object|array`. Custom namers that type-hint the parameter as `object` must update their signature to match.
12+
* `PropertyMappingResolverInterface::resolve()` (and the `PropertyMappingResolver` implementation) now returns `PropertyMappingInterface` instead of the concrete `PropertyMapping` class. Code that type-hints against `PropertyMapping` directly should switch to `PropertyMappingInterface`.
13+
* Several internal classes are now `final` and are only meant to be extended through interfaces: `PropertyMapping`, `PropertyMappingFactory`, `MetadataReader` and `AttributeReader`. New interfaces are provided as extension points: `PropertyMappingInterface`, `PropertyMappingFactoryInterface`, `MetadataReaderInterface` and `UploadHandlerInterface`. Code that extended or mocked these concrete classes should depend on the corresponding interface instead.
814

915
# Upgrading from v2.8 to v2.9
1016

docs/configuration_reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ vich_uploader:
2121
directory_namer: ~ # specify a directory namer service for this entity, null default
2222
delete_on_remove: true # determine whether to delete file upon removal of entity
2323
erase_fields: true # set to false if you have non-nullable fields for mapping
24-
delete_on_update: true # determine wheter to delete the file upon update of entity
24+
delete_on_update: true # determine whether to delete the file upon update of entity
2525
inject_on_load: false # determine whether to inject a File instance upon load
2626
namer_keep_extension: false # force namers to keep original file extension
2727
# WARNING: Always validate file extensions when set to true to prevent security risks!

docs/directory_namer/howto/create_a_custom_directory_namer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ vich_uploader:
2323
## That was it!
2424
2525
Check out the docs for information on how to use the bundle! [Return to the
26-
index.](/docs/index.md)
26+
index.](../../index.md)

docs/events/howto/remove_files_asynchronously.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,4 @@ class RemoveFileEventSubscriber implements EventSubscriberInterface
116116

117117
## That was it!
118118

119-
Check out the docs for information on how to use the bundle! [Return to the index.](/docs/index.md)
119+
Check out the docs for information on how to use the bundle! [Return to the index.](../../index.md)

docs/file_namer/howto/create_a_custom_file_namer.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ free to get any information from it to create the name, or inject any other
77
service you require.
88

99
> [!NOTE]
10-
> The `name` method in the interface accepts only objects, but your namer should accept both
11-
> objects and arrays. The interface method signature will be fixed in the next major version.
1210
> The name returned should include the file extension as well. This can easily
1311
> be retrieved from the `UploadedFile` instance using the `getExtension` or `guessExtension`
1412
> depending on what version of PHP you are running.
@@ -22,12 +20,12 @@ Here's a simple example:
2220

2321
namespace App\Naming;
2422

25-
use Vich\UploaderBundle\Mapping\PropertyMapping;
23+
use Vich\UploaderBundle\Mapping\PropertyMappingInterface;
2624
use Vich\UploaderBundle\Naming\NamerInterface;
2725

2826
class MyNamer implements NamerInterface
2927
{
30-
public function name(object|array $object, PropertyMapping $mapping): string
28+
public function name(object|array $object, PropertyMappingInterface $mapping): string
3129
{
3230
$file = $mapping->getFile($object);
3331
$originalName = $file->getClientOriginalName();
@@ -48,7 +46,7 @@ implement the `Vich\UploaderBundle\Naming\ConfigurableInterface`:
4846

4947
namespace App\Naming;
5048

51-
use Vich\UploaderBundle\Mapping\PropertyMapping;
49+
use Vich\UploaderBundle\Mapping\PropertyMappingInterface;
5250
use Vich\UploaderBundle\Naming\ConfigurableInterface;
5351
use Vich\UploaderBundle\Naming\NamerInterface;
5452

@@ -65,7 +63,7 @@ class MyConfigurableNamer implements NamerInterface, ConfigurableInterface
6563
$this->prefix = $options['prefix'] ?? $this->prefix;
6664
}
6765

68-
public function name(object|array $object, PropertyMapping $mapping): string
66+
public function name(object|array $object, PropertyMappingInterface $mapping): string
6967
{
7068
$file = $mapping->getFile($object);
7169
$extension = $this->getExtensionWithOption($file, $this->keepExtension);
@@ -107,4 +105,4 @@ Where `App\Naming\MyNamer` is the configured service class.
107105
## That was it!
108106

109107
Check out the docs for information on how to use the bundle! [Return to the
110-
index.](/docs/index.md)
108+
index.](../../index.md)

docs/symfony_support_policy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ You can also check [supported versions of PHP](//php.net/supported-versions.php)
1919
## That was it!
2020

2121
Check out the docs for information on how to use the bundle! [Return to the
22-
index.](/docs/index.md)
22+
index.](index.md)

0 commit comments

Comments
 (0)