Vichuploaderbundle: About UploadableField in a Doctrine Embeddable class

Created on 30 Apr 2018  路  7Comments  路  Source: dustin10/VichUploaderBundle

| Q | A
| -------------------------- | -----
| Bug report? | yes
| Feature request? | yes
| BC Break report? | no
| Symfony version | 4.0.8
| VichUploaderBundle version | 1.8.2

Hi, thanks for your work on this bundle! It's really useful.

However, I just handle a non-usual case with @Vich\UploadableField inside a @ORM\Embeddable() class. This class is embedded in some of other classic Entities in my application. Everything, for display, works. But, when I try to edit file (image in my case) in EasyAdmin (1.17.12), properly configured, none of my @Vich\UploadableField properties are updated.

I've debug the bundle, to find why Embeddable properties flagged as UploadableField were not listed as uploadableField in the MetadataReader. The only thing I've found is that this reader cannot understand the Embeddable behaviour, because it's not a Doctrine Metadata Reader. Is there any way to mix JMS\MetadataReader and Doctrine\ClassMetadata to fix this bug, and add support for Embeddable UploadableField properties?

Thanks a lot!

EDIT: may be this bug fix on symfony/maker-bundle can help us to fix the bug: https://github.com/symfony/maker-bundle/pull/164/files#diff-1eecb8f832b5aae76ee86af10e507715

Awaiting PR Bug

All 7 comments

See #350

Hi @garak, the #350 is close. That is why I opened a new ticket, with more details about my debug trip.

So, did you see #350?

Yes, I read all comments. So, in my case I've 3 Embedded properties that point to my Embeddable class which contains one UploadableField. I can't proxify 3 properties to one. Your trick works only for 1 Embedded property.

So, that is why I opened this issue

@garak @dustin10 It's been planned to support Embedded/Embeddable annotation as I see the comment here https://github.com/dustin10/VichUploaderBundle/blob/master/Metadata/Driver/AnnotationDriver.php#L49

What about adding additional option to UploadableField annotation like fileObjectProperty to use it in PropertyAccessor calls, then mapping might look like so:

    /**
     * @var File
     *
     * @ORM\Embedded(class="App\Entity\Embeddable\File")
     * @Vich\UploadableField(mapping="level_map_image", fileNameProperty="mapImage.name", fileObjectProperty="mapImage.file")
     */
    private $mapImage;

Feel free to propose a PR

Was this page helpful?
0 / 5 - 0 ratings