Symfony2: EasyAdminbundle + StofDoctrineExtensionsBundle + VichUploaderBundle

334 views Asked by At

I have a project using EasyAdminBundle for administration. In one Entity called "Post" I have the fields "title", "image" and "post" which I would like to track about changes. The property "image" only stores the filename of the image - the full upload process is managed by VichUploaderBundle.

How / Where can I mesh that the old image file does not get deleted on change because it will used for history?

1

There are 1 answers

1
K-Phoen On

When you define your mappings, there is a way to tell VichUploaderBundle that it should not automatically delete old files:

Here is a sample mapping configuration taken from the bundle's documentation:

vich_uploader:
    db_driver: orm
    mappings:
        product_image:
            uri_prefix:         /images/products
            upload_destination: %kernel.root_dir%/../web/images/products
            inject_on_load:     false
            # this prevents the file from being deleted on update
            delete_on_update:   false
            # this prevents the file from being deleted when the
            # entity itself is deleted
            delete_on_remove:   true