Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ObjectMapper] Class-Level Transformation with wrong Source class #60827

Closed
@issamkhadiri1989

Description

@issamkhadiri1989

Symfony version(s) affected

7.3.0

Description

When using the ObjectMapper using Class-Level Transformation, I faced an issue related to the source instance.

According to the doc https://symfony.com/doc/current/object_mapper.html#class-level-transformation, the $source argument should be an instance of App/DTO/LegacyUserData but it is not the case. It is actually a App/Entity/User. Due to this, I always receive the following error :

Warning: Undefined property: App\Entity\User::$userId

Image

How to reproduce

To reproduce the issue :

create a src/DTO/LegacyUserData.php DTO

Image

create an entity class src/Entity/User.php

Image

in a controller, we can do

Image

using XDEBUG here is the result

Image

Am I doing something wrong ?

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions