Skip to content

[ObjectMapper] no mapping on proxies? #62786

@Fipschen

Description

@Fipschen

Symfony version(s) affected

7.4

Description

Hi there,

I think there's a little problem on mapping on proxies. In the past I had sometimes the problem, that the mapper doesn't work on existing entities. Now I think, I had found the problem: mapping to an proxy class.

How to reproduce

$melder = $this->melderRepos->findOneBy([
    'turnier'   =>  $this->turnierOeffService->getTurnier(),
    'user'      =>  $this->loginSessionService->getUser(), ]);
    
if (!($melder instanceof Melder))
{
        $melder = (new Melder)
                ->setTurnier($this->turnierOeffService->getTurnier())
                ->setTyp(MelderTyp::VereinExtern)
                ->setUser($this->loginSessionService->getUser());
}
        
dump($melderDTO);
$this->objectMapper->map($melderDTO, $melder);
dump($melder);

If the $melder is an proxy class, the mapping doesn't work.
I wanted to check that but unfortunately I was unable to disable the proxy to confirm that.

Possible Solution

I'm not able to find a solution.

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