<?php
namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Vich\UploaderBundle\Event\Event;
class UpdateFileTimestampSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
'vich_uploader.post_upload' => 'onPostUpload',
];
}
public function onPostUpload(Event $event): void
{
$mapping = $event->getMapping(); // Mapeo de VichUploader
$file = $mapping->getFile($event->getObject()); // Archivo subido
if ($file) {
// Actualiza la fecha de modificación del archivo
touch($file->getPathname());
}
}
}