Skip to content

Commit 13a35b5

Browse files
authored
Merge pull request #1556 from endelwar/remove-annotation-namespace
Remove deprecated Annotation namespace
2 parents 4001450 + e1232a9 commit 13a35b5

24 files changed

Lines changed: 82 additions & 91 deletions

.github/workflows/build.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
php-version: 8.3
1919
- run: |
20-
composer require --no-update doctrine/annotations:"^2.0" liip/imagine-bundle:"^2.13" phpstan/phpstan:"^2"
20+
composer require --no-update liip/imagine-bundle:"^2.13" phpstan/phpstan:"^2"
2121
composer install --ignore-platform-reqs
2222
XDEBUG_MODE=off vendor/bin/phpstan
2323
cs-fixer:
@@ -110,7 +110,6 @@ jobs:
110110
with:
111111
php-version: ${{ matrix.php }}
112112
extensions: mongodb-stable, pdo_sqlite
113-
- run: composer require --no-update doctrine/annotations:^1.14
114113
- run: |
115114
composer global config --no-plugins allow-plugins.symfony/flex true
116115
composer global require --no-interaction --no-progress symfony/flex:^2.8

UPGRADE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
1+
# Upgrading from v2.9 to v3.0
2+
3+
## Breaking Changes
4+
5+
* The deprecated `Vich\UploaderBundle\Mapping\Annotation` namespace has been removed. Use `Vich\UploaderBundle\Mapping\Attribute` instead.
6+
* The deprecated `AnnotationInterface` has been removed. Use `AttributeInterface` instead.
7+
* `AttributeReader` deprecated methods have been removed: use `getClassAttribute()` instead of `getClassAnnotation()`, `getPropertyAttribute()` instead of `getPropertyAnnotation()`.
8+
19
# Upgrading from v2.8 to v2.9
210

11+
## Deprecations
12+
13+
* The `Vich\UploaderBundle\Mapping\Annotation` namespace is deprecated. Replace it with `Vich\UploaderBundle\Mapping\Attribute`;
14+
The old namespace will be removed in version 3.0.
15+
* `AttributeReader` methods: replace `*Annotation()` with `*Attribute()` (e.g., `getClassAnnotation()``getClassAttribute()`).
16+
17+
## New Features
18+
319
* New `namer_keep_extension` configuration option to force namers to preserve original file extension.
420
* Custom namers using `namer_keep_extension: true` must implement `ConfigurableInterface`.
521

config/mapping.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Metadata\Driver\FileLocator;
88
use Metadata\MetadataFactory;
99
use Vich\UploaderBundle\Metadata\CacheWarmer;
10-
use Vich\UploaderBundle\Metadata\Driver\AnnotationDriver;
10+
use Vich\UploaderBundle\Metadata\Driver\AttributeDriver;
1111
use Vich\UploaderBundle\Metadata\Driver\AttributeReader;
1212
use Vich\UploaderBundle\Metadata\Driver\XmlDriver;
1313
use Vich\UploaderBundle\Metadata\Driver\YamlDriver;
@@ -27,7 +27,7 @@
2727
$services->set('vich_uploader.metadata.attribute_reader', AttributeReader::class);
2828

2929
// drivers
30-
$services->set('vich_uploader.metadata_driver.annotation', AnnotationDriver::class)
30+
$services->set('vich_uploader.metadata_driver.attribute', AttributeDriver::class)
3131
->arg('$reader', service('vich_uploader.metadata.reader'))
3232
->arg('$managerRegistryList', null); // replaced by compiler pass
3333

docs/known_issues.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace App\Entity;
7373
7474
use Doctrine\ORM\Mapping as ORM;
7575
use Symfony\Component\HttpFoundation\File\File;
76-
use Vich\UploaderBundle\Mapping\Annotation as Vich;
76+
use Vich\UploaderBundle\Mapping\Attribute as Vich;
7777
7878
#[ORM\Entity]
7979
#[Vich\Uploadable]

docs/usage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ namespace App\Entity;
8383
8484
use Doctrine\ORM\Mapping as ORM;
8585
use Symfony\Component\HttpFoundation\File\File;
86-
use Vich\UploaderBundle\Mapping\Annotation as Vich;
86+
use Vich\UploaderBundle\Mapping\Attribute as Vich;
8787
8888
#[ORM\Entity]
8989
#[Vich\Uploadable]
@@ -168,7 +168,7 @@ namespace App\Entity;
168168
use Doctrine\ORM\Mapping as ORM;
169169
use Symfony\Component\HttpFoundation\File\File;
170170
use Vich\UploaderBundle\Entity\File as EmbeddedFile;
171-
use Vich\UploaderBundle\Mapping\Annotation as Vich;
171+
use Vich\UploaderBundle\Mapping\Attribute as Vich;
172172
173173
#[ORM\Entity]
174174
#[Vich\Uploadable]

docs/validators/file_required.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ It validates that either an existing file is present or a new file has been uplo
66
## Basic Usage
77

88
```php
9-
use Vich\UploaderBundle\Mapping\Annotation as Vich;
9+
use Vich\UploaderBundle\Mapping\Attribute as Vich;
1010
use Vich\UploaderBundle\Validator\Constraints as VichAssert;
1111

1212
#[Vich\Uploadable]

src/DependencyInjection/Compiler/RegisterMappingDriversPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function process(ContainerBuilder $container): void
3030
}
3131

3232
if (\count($managers) > 0) {
33-
$drivers[] = $container->getDefinition('vich_uploader.metadata_driver.annotation')
33+
$drivers[] = $container->getDefinition('vich_uploader.metadata_driver.attribute')
3434
->replaceArgument('$managerRegistryList', $managers);
3535
}
3636

src/DependencyInjection/VichUploaderExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function load(array $configs, ContainerBuilder $container): void
5353

5454
$this->loadServicesFiles($container, $config);
5555
$this->registerMetadataDirectories($container, $config);
56-
$this->registerAnnotationStrategy($container, $config);
56+
$this->registerAttributeStrategy($container);
5757
$this->registerCacheStrategy($container, $config);
5858

5959
$this->registerListeners($container, $config);
@@ -136,9 +136,9 @@ protected function registerMetadataDirectories(ContainerBuilder $container, arra
136136
;
137137
}
138138

139-
protected function registerAnnotationStrategy(ContainerBuilder $container, array $config): void
139+
protected function registerAttributeStrategy(ContainerBuilder $container): void
140140
{
141-
if (!$container->has('vich_uploader.metadata_driver.annotation')) {
141+
if (!$container->has('vich_uploader.metadata_driver.attribute')) {
142142
return;
143143
}
144144

@@ -173,7 +173,7 @@ protected function registerCacheStrategy(ContainerBuilder $container, array $con
173173

174174
protected function fixDbDriverConfig(array $config): array
175175
{
176-
// mapping with no declared db_driver use the top-level one
176+
// mapping with no declared db_driver, use the top-level one
177177
foreach ($config['mappings'] as &$mapping) {
178178
$mapping['db_driver'] = $mapping['db_driver'] ?: $config['db_driver'];
179179
}

src/Mapping/Annotation/Uploadable.php

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Vich\UploaderBundle\Mapping\Attribute;
4+
5+
use Vich\UploaderBundle\Mapping\AttributeInterface;
6+
7+
#[\Attribute(\Attribute::TARGET_CLASS)]
8+
final class Uploadable implements AttributeInterface
9+
{
10+
}

0 commit comments

Comments
 (0)