Skip to content

Commit

Permalink
Fix serializer configuration in bundle (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
joelwurtz authored May 6, 2024
2 parents d8d480f + ee2f1f9 commit 553cf74
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [GH#114](https://github.com/jolicode/automapper/pull/114) Introducing Mapper Attribute
- [GH#117](https://github.com/jolicode/automapper/pull/117) Allow multiple source/target, allow overriding attribute with priority system

### Changed
- [GH#119](https://github.com/jolicode/automapper/pull/119) Change serializer configuration naming in Symfony Bundle

### Fixed
- [GH#109](https://github.com/jolicode/automapper/pull/109) Use AutoMapper exceptions
- [GH#115](https://github.com/jolicode/automapper/pull/115) Fix generating discriminator dependencies
Expand Down
6 changes: 3 additions & 3 deletions docs/bundle/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ automapper:
* `always` will generate the mappers at each request;
* `never` will generate them only if they don't exist;
* `on_change` will generate the mappers only if the source or target class has changed since the last generation;
* `serializer` (default: `true` if the symfony/serializer is available, false otherwise): A boolean which indicate
if we use the attribute of the symfony/serializer during the mapping, this only apply to the `#[Groups]`, `#[MaxDepth]`,
`#[Ignore]` and `#[DiscriminatorMap]` attributes;
* `serializer_attributes` (default: `true` if the symfony/serializer is available, false otherwise): A boolean which
indicate if we use the attribute of the symfony/serializer during the mapping, this only apply to the `#[Groups]`,
`#[MaxDepth]`, `#[Ignore]` and `#[DiscriminatorMap]` attributes;
* `api_platform` (default: `false`): A boolean which indicate if we use services from the api-platform/core package and
inject extra data (json ld) in the mappers when we map a Resource class to or from an array.
* `name_converter` (default: `null`): A service id which implement the `AdvancedNameConverterInterface` from the symfony/serializer,
Expand Down
2 changes: 1 addition & 1 deletion docs/bundle/migrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ automapper:

### Serializer attributes

If you have serializer attributes on your entity, you can also enabled the `serializer` option to use them.
If you have serializer attributes on your entity, you can also enabled the `serializer_attributes` option to use them.

```yaml
# config/packages/automapper.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function load(array $configs, ContainerBuilder $container): void
->addTag('automapper.transformer_factory', ['priority' => '-1004']);
}

if ($config['serializer']) {
if ($config['serializer_attributes']) {
if (!interface_exists(SerializerInterface::class)) {
throw new LogicException('The "symfony/serializer" component is required to use the "serializer" feature.');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->end()
->addDefaultsIfNotSet()
->end()
->booleanNode('serializer')->defaultValue(interface_exists(SerializerInterface::class))->end()
->booleanNode('serializer_attributes')->defaultValue(interface_exists(SerializerInterface::class))->end()
->booleanNode('api_platform')->defaultFalse()->end()
->scalarNode('name_converter')->defaultNull()->end()
->arrayNode('loader')
Expand Down

0 comments on commit 553cf74

Please sign in to comment.