Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doctrine/form Integration bundle #378

Open
Nemo64 opened this issue Apr 25, 2020 · 1 comment
Open

doctrine/form Integration bundle #378

Nemo64 opened this issue Apr 25, 2020 · 1 comment

Comments

@Nemo64
Copy link

Nemo64 commented Apr 25, 2020

I was (or actually still am) searching for a nice uploading process within a symfony project. I tried this bundle and thought the implementations are awesome, especially the orphanage. But I miss a lot of other aspects which is fine, this bundle does 1 thing really well instead of all the things only partially.

I see 4 areas necessary for a seamless file handling in a symfony multipage application:

  1. A form type that can add/remove/show one or multiple files
  2. Handling of asynchronous uploads (this is what this bundle does) because input type file feels massively outdated
  3. Attaching files to existing data like doctrine entities
  4. Cleanup after entity deletion

This bundle is really good at 2. but does not touch 1, 3 or 4, that's all left to the individual project.

the VichUploader Bundle handles 3 and 4 but both not really elegant as it is really verbose in entity handling and cleanup only works when entities are deleted directly. There is no check to delete files of which the entity is removed. The Vich uploader bundle also relies on the symfony FileType for uploads which isn't great.

what am I suggesting?

I would like to have a doctrine and a form integration based around this uploader bundle.

doctrine integration

My idea is to create a FileReference doctrine entity that simply has 2 fields.

  • The mapping name
  • The file identifier

When the entity is persisted/flushed, then the file must be moved from the orphanage to the actual storage. When the entity is deleted, the file must be deleted as well. There also needs to be a cleanup process to delete files that are no longer referenced.

Building a model like this allows to add one or many file references to any entity simply by using a relation. No magic mapping required.

form integration

Now this is heavily related to the doctrine integration. Simply plopping something like a DropzoneType into any form that uploads one or multiple files to the orphanage and adds FileReference's into a Model would be awesome.

The html part woud just add the identifiers into the form and a data mapper would map those to the correct uploader mapping. The doctrine bundle would move the files into the real storage.

By heavily using mapping of this uploader bundle, this could be entirely storage agnostic.

why am I bringing this up?

What I describe here is a lot of work and those are just ideas i had while researching. So I thought I share those ideas here to discuss. Who knows, maybe everything i described is already possible with other bundles I just haven't found.

Maybe we can even collaborate here.

@bytehead
Copy link
Member

Hey Marco

Thank you for your contribution!
We do like the idea but our time to work on this is quite limited at the moment 🙈

We'll keep an eye on this and as soon as we had time to look closer, we can discuss our points further over here.

Feel free to add more comments or adapt parts if you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants