Closed infoliv closed 2 years ago
You can just store the Glide server config that you use for the middleware in Configure
and then read the same config in your event listener and create a new server instance yourself.
Now I can get the server instance this way, thanks ! (But the cacheDelete() is not working with me... it returns true but the directory is not deleted...)
Well you'll have to figure it out yourself why the deletion not working :).
Now I can get the server instance this way, thanks ! (But the cacheDelete() is not working with me... it returns true but the directory is not deleted...)
Did you manage to solve? Can you show an example?
@impronta48 In bootstrap :
Configure::write('ADmad/Glide.server', [
// Path or League\Flysystem adapter instance to read images from.
// http://glide.thephpleague.com/1.0/config/source-and-cache/
'source' => WWW_ROOT,
// Path or League\Flysystem adapter instance to write cached images to.
'cache' => WWW_ROOT . 'files' . DS . 'cache',
// URL part to be omitted from source path. Defaults to "/images/"
// http://glide.thephpleague.com/1.0/config/source-and-cache/#set-a-base-url
'base_url' => '/images/',
// Response class for serving images. If unset (default) an instance of
// \ADmad\Glide\Response\PsrResponseFactory() will be used.
// http://glide.thephpleague.com/1.0/config/responses/
'response' => null,
]);
EventManager::instance()
->on(
'FileManager.Fichiers.afterDelete',
function (Event $event) {
$server = \League\Glide\ServerFactory::create(Configure::read('ADmad/Glide.server'));
$file = $event->getData('file');
$server->deleteCache(Configure::read('ADmad/Glide.server.base_url') . $file->url);
}
);
Thank you for this plugin !
However I'm looking for a way to delete Glide cache...
My plugin
FileManager
triggers an event 'afterDelete' when the image file is deleted :and I want to catch the event in bootstrap of my application to delete the cache of the image :
But I don't know how to get the Glide Server instance ?
Would it be possible to had a way to get server instance or a functionality to delete Glide cache ?