name => 'csv', self::csvWithoutAttachment->name => 'csv sans pièces jointes', self::pdf->name => 'pdf', ]; /** * Bootstrap color class to use for the export buttons. * * @return string */ public function class(): string { return match ($this) { self::csv, self::csvWithoutAttachment => 'success', self::pdf => 'danger', default => 'primary', }; } /** * Font Awesome picto to use for the export buttons. * * @return string */ public function picto(): string { return match ($this) { self::csv, self::csvWithoutAttachment => 'fa-solid fa-file-csv', self::pdf => 'fa-solid fa-file-pdf', default => 'fa-solid fa-file', }; } /** * File headers to use when the exported file is return with StreamedResponse. * * @return array */ public function fileHeaders(): array { return match ($this) { self::csv, self::csvWithoutAttachment => [ 'Content-Type' => 'text/csv', 'Content-Disposition' => 'attachment; filename="export.csv"', ], default => [], }; } /** * Export file name. * * @return string */ public function fileName(): string { return match ($this) { self::csv, self::csvWithoutAttachment => 'export.csv', self::pdf => 'export.pdf', }; } }