diff options
Diffstat (limited to 'src/controller')
| -rw-r--r-- | src/controller/MaintenanceController.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/controller/MaintenanceController.php b/src/controller/MaintenanceController.php index 3b804fc..fca45f1 100644 --- a/src/controller/MaintenanceController.php +++ b/src/controller/MaintenanceController.php | |||
| @@ -5,6 +5,7 @@ declare(strict_types=1); | |||
| 5 | 5 | ||
| 6 | use Doctrine\ORM\EntityManager; | 6 | use Doctrine\ORM\EntityManager; |
| 7 | use App\Entity\log; | 7 | use App\Entity\log; |
| 8 | use Symfony\Component\Process\Exception\ProcessFailedException; | ||
| 8 | 9 | ||
| 9 | class MaintenanceController | 10 | class MaintenanceController |
| 10 | { | 11 | { |
| @@ -47,4 +48,22 @@ class MaintenanceController | |||
| 47 | } | 48 | } |
| 48 | die; | 49 | die; |
| 49 | } | 50 | } |
| 51 | |||
| 52 | static public function getLastDump(EntityManager $entityManager): void | ||
| 53 | { | ||
| 54 | try{ | ||
| 55 | $file_path = Backup::mySQLdump($entityManager); | ||
| 56 | header('Content-Type: application/octet-stream'); // signifie fichier quelconque, du binaire quoi! | ||
| 57 | header('Content-Disposition: attachment; filename="' . basename($file_path) . '"'); // pour provoquer un téléchargement et non pour afficher | ||
| 58 | header('Content-Length: ' . filesize($file_path)); // peut servir côté client (barre de progression...) | ||
| 59 | readfile($file_path); | ||
| 60 | die; | ||
| 61 | } | ||
| 62 | // exeptions lancées dans Backup::mySQLdump | ||
| 63 | catch(ProcessFailedException $e){ // pas d'info $e pour le client | ||
| 64 | header('Location: ' . new URL(['page' => 'maintenance', 'error' => '500'])); | ||
| 65 | die; | ||
| 66 | } | ||
| 67 | die; | ||
| 68 | } | ||
| 50 | } \ No newline at end of file | 69 | } \ No newline at end of file |
