Skip to content

Using Doctrine Proxies #88

Open
@RafaelKr

Description

@RafaelKr

I'm currently doing some performance improvements in my application. There is one place where I tried to do the following change:

- $this->mediaRepository->find($id)
+ $this->entityManager->getReference(App\Entity\Media::class, new Uuid($id))

But now when it tries to resolve the file location it crashes with File "entity/607513d81ba164604ee80eceebdf5eef7e9172ea/file/..." in filesystem "default" does not exist..

It happens because the DefaultFileLocationResolver uses the SHA-1 hash of the entity FQCN as described in https://rekalogika.dev/file-bundle/advanced/entity-association-internal
But when we use a Doctrine Reference we get a proxy object instead and the FQCN is Proxies\__CG__\App\Entity\Media instead of App\Entity\Media.

The real class name can be easily resolved via Doctrine\Common\Util\ClassUtils::getRealClass($object::class);, and if I use that at

it works.

I just wanted to ask if this is something you would like to support inside the library itself or if I should just create an own FileLocationResolver?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions