plugin/reservation/Controller/API/ResourceController.php
public function exportResourcesAction(Request $request)
    {
        $resources = $this->decodeIdsString($request, 'FormaLibre\ReservationBundle\Entity\Resource');

        $response = new StreamedResponse(function () use ($resources) {
            $file = fopen('php://output', 'w');
            fputcsv($file, [
                'resourceType.name',
                'id',
                'name',
                'maxTimeReservation',
                'description',
                'localization',
                'quantity',
                'color',
            ], ';', '"');

            foreach ($resources as $resource) {
                if (!empty($resource)) {
                    $resourceType = $resource->getResourceType();
                    $data = [
                        $resourceType->getName(),
                        $resource->getUuid(),
                        $resource->getName(),
                        $resource->getMaxTimeReservation(),
                        $resource->getDescription(),
                        $resource->getLocalisation(),
                        $resource->getQuantity(),
                        $resource->getColor(),
                    ];
                    fputcsv($file, $data, ';', '"');
                }
            }
            fclose($file);
        });
        $response->headers->set('Content-Transfer-Encoding', 'octet-stream');
        $response->headers->set('Content-Type', 'application/force-download');
        $response->headers->set('Content-Disposition', 'attachment; filename="resources.csv"');
        $response->headers->set('Content-Type', 'application/csv; charset=utf-8');
        $response->headers->set('Connection', 'close');
        $response->send();

        return $response;
    }
public function exportResourcesAction(Request $request)
    {
        $resources = $this->decodeIdsString($request, 'FormaLibre\ReservationBundle\Entity\Resource');

        $response = new StreamedResponse(function () use ($resources) {
            $file = fopen('php://output', 'w');
            fputcsv($file, [
                'resourceType.name',
                'id',
                'name',
                'maxTimeReservation',
                'description',
                'localization',
                'quantity',
                'color',
            ], ';', '"');

            foreach ($resources as $resource) {
                if (!empty($resource)) {
                    $resourceType = $resource->getResourceType();
                    $data = [
                        $resourceType->getName(),
                        $resource->getUuid(),
                        $resource->getName(),
                        $resource->getMaxTimeReservation(),
                        $resource->getDescription(),
                        $resource->getLocalisation(),
                        $resource->getQuantity(),
                        $resource->getColor(),
                    ];
                    fputcsv($file, $data, ';', '"');
                }
            }
            fclose($file);
        });
        $response->headers->set('Content-Transfer-Encoding', 'octet-stream');
        $response->headers->set('Content-Type', 'application/force-download');
        $response->headers->set('Content-Disposition', 'attachment; filename="resources.csv"');
        $response->headers->set('Content-Type', 'application/csv; charset=utf-8');
        $response->headers->set('Connection', 'close');
        $response->send();

        return $response;
    }
public function exportResourcesAction ( Request $ request ) { $ resources = $ this -> decodeIdsString ( $ request , 'FormaLibre\ReservationBundle\Entity\Resource' ) ; $ response = new StreamedResponse ( function ( ) use ( $ resources ) { $ file = fopen ( 'php://output' , 'w' ) ; fputcsv ( $ file , [ 'resourceType.name' , 'id' , 'name' , 'maxTimeReservation' , 'description' , 'localization' , 'quantity' , 'color' , ] , ';' , '"' ) ; foreach ( $ resources as $ resource ) { if ( ! empty ( $ resource ) ) { $ resourceType = $ resource -> getResourceType ( ) ; $ data = [ $ resourceType -> getName ( ) , $ resource -> getUuid ( ) , $ resource -> getName ( ) , $ resource -> getMaxTimeReservation ( ) , $ resource -> getDescription ( ) , $ resource -> getLocalisation ( ) , $ resource -> getQuantity ( ) , $ resource -> getColor ( ) , ] ; fputcsv ( $ file , $ data , ';' , '"' ) ; } } fclose ( $ file ) ; } ) ; $ response -> headers -> set ( 'Content-Transfer-Encoding' , 'octet-stream' ) ; $ response -> headers -> set ( 'Content-Type' , 'application/force-download' ) ; $ response -> headers -> set ( 'Content-Disposition' , 'attachment; filename="resources.csv"' ) ; $ response -> headers -> set ( 'Content-Type' , 'application/csv; charset=utf-8' ) ; $ response -> headers -> set ( 'Connection' , 'close' ) ; $ response -> send ( ) ; return $ response ; }
Exports resources.

@Route(
"/resources/export",
name="apiv2_reservationresource_export"
)
@Method("GET")

@return StreamedResponse
Exports resources .