Skip to content

Commit 69dd857

Browse files
committed
chore(upgrade): add upgrade documentation
1 parent 5450ac1 commit 69dd857

File tree

4 files changed

+83
-30
lines changed

4 files changed

+83
-30
lines changed

docs/_nav.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525
- [Api Platform](bundle/api-platform.md)
2626
- [Migrate existing application](bundle/migrate.md)
2727
- [Debugging](bundle/debugging.md)
28-
- [Upgrading to 9.0](upgrading-9.0.md)
28+
- [Upgrading](upgrading/upgrading-10.0.md)
29+
- [Upgrading to 9.0](upgrading/upgrading-9.0.md)
2930
- [Contributing](contributing.md)

docs/mapping/transformer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class UrlTransformer implements PropertyTransformerInterface, PropertyTransforme
135135
{
136136
}
137137

138-
public function supports(TypesMatching $types, SourcePropertyMetadata $source, TargetPropertyMetadata $target, MapperMetadata $mapperMetadata): bool
138+
public function supports(SourcePropertyMetadata $source, TargetPropertyMetadata $target, MapperMetadata $mapperMetadata): bool
139139
{
140140
return $source->type->isIdentifiedBy(TypeIdentifier::INT && $source->property === 'id' && $target->property === 'url';
141141
}

docs/upgrading/upgrading-10.0.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Upgrading to 10.0
2+
3+
10.0 is major release of AutoMapper. It aims at supporting the new [`TypeInfo` Component](https://symfony.com/doc/current/components/type_info.html) of Symfony
4+
5+
There is little change between 9.X and 10.0 version, but they are still a BC break so it need a major version.
6+
7+
## Custom Transformers
8+
9+
If you were using the `PropertyTransformerSupportInterface` interface, its signature has changed to use the new `TypeInfo` component.
10+
11+
Before:
12+
13+
```php
14+
class MyTransformer implements PropertyTransformerSupportInterface
15+
{
16+
public function supports(TypesMatching $types, SourcePropertyMetadata $source, TargetPropertyMetadata $target, MapperMetadata $mapperMetadata): bool
17+
{
18+
// ...
19+
}
20+
}
21+
```
22+
23+
After:
24+
25+
```php
26+
class MyTransformer implements PropertyTransformerSupportInterface
27+
{
28+
public function supports(SourcePropertyMetadata $source, TargetPropertyMetadata $target, MapperMetadata $mapperMetadata): bool
29+
{
30+
// ...
31+
}
32+
}
33+
```
34+
35+
There is no more `TypesMatching` argument, you can get the source and target types from the `SourcePropertyMetadata` and `TargetPropertyMetadata` arguments,
36+
which are instance of `Symfony\Component\TypeInfo\Type` class.
37+
38+
```php
39+
class MyTransformer implements PropertyTransformerSupportInterface
40+
{
41+
public function supports(SourcePropertyMetadata $source, TargetPropertyMetadata $target, MapperMetadata $mapperMetadata): bool
42+
{
43+
if ($source->type->isNullable()) {
44+
return false;
45+
}
46+
47+
// ...
48+
}
49+
}
50+
```
51+
52+
See the [transformers documentation](../mapping/transformer.md#creating-a-custom-transformer) for more information.
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
# Upgrading from 8.x to 9.0
2-
3-
9.0 is major release of AutoMapper. It brings a lot of new features and improvements. We recommend first [to check
4-
the new documentation](./index.md) to see if the new features are useful for your project.
5-
6-
If you upgrade from 8.x to 9.0, you will need to make some changes to your code, but most of existing behavior should
7-
still work.
8-
9-
## Bundle
10-
11-
If you use the bundle, it is now integrated in the main package. You can remove the `jolicode/automapper-bundle` package from your
12-
`composer.json` file.
13-
14-
Then you have to use the new namespace for the bundle:
15-
16-
```php
17-
use AutoMapper\Symfony\Bundle\AutoMapperBundle;
18-
```
19-
20-
You will also need to update the bundle configuration, see the [bundle documentation](./bundle/configuration.md) for more
21-
information.
22-
23-
## Custom Transformers
24-
25-
The `CustomPropertyTransformerInterface` and `CustomModelTransformerInterface` have been removed in favor of the
26-
`PropertyTransformerInterface` interface handling both case.
27-
28-
See the [transformers documentation](./mapping/transformer.md#creating-a-custom-transformer) for more information.
1+
# Upgrading to 10.0
2+
3+
9.0 is major release of AutoMapper. It brings a lot of new features and improvements. We recommend first [to check
4+
the new documentation](../index.md) to see if the new features are useful for your project.
5+
6+
If you upgrade from 8.x to 9.0, you will need to make some changes to your code, but most of existing behavior should
7+
still work.
8+
9+
## Bundle
10+
11+
If you use the bundle, it is now integrated in the main package. You can remove the `jolicode/automapper-bundle` package from your
12+
`composer.json` file.
13+
14+
Then you have to use the new namespace for the bundle:
15+
16+
```php
17+
use AutoMapper\Symfony\Bundle\AutoMapperBundle;
18+
```
19+
20+
You will also need to update the bundle configuration, see the [bundle documentation](../bundle/configuration.md) for more
21+
information.
22+
23+
## Custom Transformers
24+
25+
The `CustomPropertyTransformerInterface` and `CustomModelTransformerInterface` have been removed in favor of the
26+
`PropertyTransformerInterface` interface handling both case.
27+
28+
See the [transformers documentation](../mapping/transformer.md#creating-a-custom-transformer) for more information.

0 commit comments

Comments
 (0)