-
Notifications
You must be signed in to change notification settings - Fork 254
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
Option to delete file on record deletion #362
Conversation
Just fyi, I only merge changes that do not decrease test coverage (including PHPCS!) and have the requisite docs. Happy to work towards that though :) |
* @param array $files the files being written out | ||
* @return array array of results | ||
*/ | ||
public function delete(array $files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need a test for this method as well.
This works now? |
Rather than mocking the DefaultWriter, we mock the responses from the filesystem to say that a delete has succeeded or failed. This will suffice for testing the proper responses from DefaultWriter::delete()
Mock underlying fileystem writes
@jorisvaesen does this work according to how you'd like it now? |
I did some testing and it seems to work as expected. |
Option to delete file on record deletion
Thanks for being patient! |
@jorisvaesen added you as a maintainer. Don't abuse your new role of course! I'm looking forward to your help in maintaining this plugin, especially considering the nice features you've worked on :) |
maybe it is a silly question but how can I delete additionally generated thumbnails with this feature? I thought I would just overwrite the delete method in the writerinterface but the passed array $files only has the path and not the filename, so I cant reference my thumbnail from there. |
I just did a quick and dirty solution to show the issue. MyOwnFileWriter.php
my solution obviously doesn't work when you have multiple files per entity but my MyOwnFileWriter is specific for my database so in my case there wont be an issue. |
@KingLoui since we cannot tell what your original urls will be - that isn't stored - your method is more or less what I would do.
The above might be better. |
For automating this, I was thinking to use the transformer. Create an extra function, let's say |
Maybe, though I'd have to see implementation/docs first. Also, requiring this in the interface would be a BC break, just fyi. |
Indeed. |
Sure. |
No description provided.