Commit 21747d4f authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

[FIX] Page de validation non ajoutée aux rapports d'activités en cas de...

[FIX] Page de validation non ajoutée aux rapports d'activités en cas de téléchargement sous forme d'archive zip.
parent 4d2faa6c
Loading
Loading
Loading
Loading
+4 −0
Changes for CHANGELOG.md: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
Journal des modifications
=========================

4.2.2
-----
- [FIX] Page de validation non ajoutée aux rapports d'activités en cas de téléchargement sous forme d'archive zip.

4.2.1
-----
- Affichage d'une alerte à propos des délais durant la fermeture estivale (lib unicaen/alerte)
+19 −0
Changes for doc/release-notes/v4.2.2.md: 19 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Version 4.2.2

## 1. Sur le serveur d'application

- Placez-vous dans le répertoire de l'application puis lancez la commande suivante
  pour installer la nouvelle version :

```bash
git fetch --tags && git checkout --force 4.2.2 && bash ./install.sh
```

- Selon le moteur PHP que vous avez installé, rechargez le service, exemple :
    - php7.4-fpm         : `service php7.4-fpm reload`
    - apache2-mod-php7.4 : `service apache2 reload`


## 2. Dans la base de données

RAS.
 No newline at end of file
+9 −8
Changes for module/Application/src/Application/Controller/Rapport/RapportRechercheController.php: 9 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -6,17 +6,18 @@ use Application\Controller\AbstractController;
use Application\Entity\Db\Interfaces\TypeRapportAwareTrait;
use Application\Entity\Db\Interfaces\TypeValidationAwareTrait;
use Application\Entity\Db\Rapport;
use Application\Entity\FichierArchivable;
use Application\Search\Controller\SearchControllerInterface;
use Application\Search\Controller\SearchControllerTrait;
use Application\Search\SearchServiceAwareTrait;
use Application\Service\Fichier\Exception\FichierServiceException;
use Application\Service\Fichier\FichierServiceAwareTrait;
use Application\Service\Fichier\FichierServiceException;
use Application\Service\Rapport\RapportSearchService;
use Structure\Service\Structure\StructureServiceAwareTrait;
use UnicaenApp\Exception\RuntimeException;
use Laminas\Http\Response;
use Laminas\Paginator\Paginator as LaminasPaginator;
use Laminas\View\Model\ViewModel;
use Structure\Service\Structure\StructureServiceAwareTrait;
use UnicaenApp\Exception\RuntimeException;

/**
 * @property RapportSearchService $searchService
@@ -175,17 +176,17 @@ abstract class RapportRechercheController extends AbstractController implements
        /** @var LaminasPaginator $paginator */
        $paginator = $result;

        $fichiers = [];
        $fichiersArchivables = [];
        /** @var Rapport $rapport */
        foreach ($paginator as $rapport) {
            $fichier = $rapport->getFichier();
            $fichier->setPath($rapport->generateInternalPathForZipArchive());
            $fichiers[] = $rapport->getFichier();
            $fichierArchivable = new FichierArchivable($rapport->getFichier());
            $fichierArchivable->setFilePathInArchive($rapport->generateInternalPathForZipArchive());
            $fichiersArchivables[] = $fichierArchivable;
        }

        $filename = sprintf("sygal_%s.zip", strtolower($this->typeRapport->getCode()));
        try {
            $fichierZip = $this->fichierService->compresserFichiers($fichiers, $filename);
            $fichierZip = $this->fichierService->compresserFichiers($fichiersArchivables, $filename);
        } catch (FichierServiceException $e) {
            throw new RuntimeException("Une erreur est survenue empêchant la création de l'archive zip", null, $e);
        }
+6 −6
Changes for module/Application/src/Application/Entity/Db/Fichier.php: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -68,9 +68,9 @@ class Fichier implements HistoriqueAwareInterface, ResourceInterface, UploadedFi
     *
     * NB: Aucune colonne n'est mappée à cette propriété.
     *
     * @var string
     * @var string|null
     */
    private $path;
    private ?string $path = null;

    /**
     * Contenu binaire de ce fichier.
@@ -140,18 +140,18 @@ class Fichier implements HistoriqueAwareInterface, ResourceInterface, UploadedFi
    }

    /**
     * @return string
     * @return string|null
     */
    public function getPath()
    public function getPath(): ?string
    {
        return $this->path;
    }

    /**
     * @param string $path
     * @param string|null $path
     * @return Fichier
     */
    public function setPath($path)
    public function setPath(?string $path): self
    {
        $this->path = $path;

+78 −0
Changes for module/Application/src/Application/Entity/FichierArchivable.php: 78 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Entity;

use Application\Entity\Db\Fichier;

/**
 * Adaptateur de {@see \Application\Entity\Db\Fichier} ajoutant des caractéristiques utiles
 * pour une création d'archive.
 */
class FichierArchivable
{
    /**
     * Fichier original.
     */
    private Fichier $fichier;

    /**
     * Chemin de ce fichier archivable sur le filesystem, remplaçant celui du fichier original.
     */
    private ?string $filePath = null;

    /**
     * Chemin interne du fichier dans l'archive.
     */
    private string $filePathInArchive;


    public function __construct(Fichier $fichier)
    {
        $this->fichier = $fichier;
    }

    /**
     * @return \Application\Entity\Db\Fichier
     */
    public function getFichier(): Fichier
    {
        return $this->fichier;
    }

    /**
     * @return string|null
     */
    public function getFilePath(): ?string
    {
        return $this->filePath ?: $this->fichier->getPath();
    }

    /**
     * @param string|null $filePath
     * @return self
     */
    public function setFilePath(?string $filePath): self
    {
        $this->filePath = $filePath;
        return $this;
    }

    /**
     * @return string
     */
    public function getFilePathInArchive(): string
    {
        return $this->filePathInArchive;
    }

    /**
     * @param string $filePathInArchive
     * @return self
     */
    public function setFilePathInArchive(string $filePathInArchive): self
    {
        $this->filePathInArchive = $filePathInArchive;
        return $this;
    }

}
 No newline at end of file
Loading