Commit 2ef667c2 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

- Up : Ajout d'un contrôle sur le dossier de stoquage des documents à signer avec check-config

- Constructeur pour SignatureRecipient pour simplifier le code (un peu)
parent 2c893bbd
Loading
Loading
Loading
Loading
+21 −3
Changes for src/Command/SignatureConfigCheckCommand.php: 21 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -21,9 +21,23 @@ class SignatureConfigCheckCommand extends SignatureCommandAbstract
    {
        $io = $this->getIO($input, $output);
        $io->title("Vérification de la configuration UnicaenSignature");

        $this->getSignatureService()->getLoggerService()->setVerbosity($output->getVerbosity());

        $io->section("BASE");
        $path = $this->getSignatureService()->getSignatureConfigurationService()->getDocumentsLocation(false);
        $msg = "Dossier des documents ($path): ";
        try {
            $documentLocation = $this->getSignatureService()->getSignatureConfigurationService()->getDocumentsLocation(
                true
            );
            $msg .= "✅";
        } catch (\Exception $e) {
            $io->error("Accès à '$path' : " . $e->getMessage());
            return self::FAILURE;
        }

        $io->text("$msg");

        $default = false;
        $error = false;

@@ -73,7 +87,9 @@ class SignatureConfigCheckCommand extends SignatureCommandAbstract
            $headers = ["clef", "valeur", "type"];
            $rows = [];
            foreach ($config['config'] as $key => $value) {
                if( $key == 'levels' ) continue;
                if ($key == 'levels') {
                    continue;
                }
                $val = is_callable($value) ? 'Dynamic' : "$value";
                $row = [$key, $val, gettype($value)];
                $rows[] = $row;
@@ -90,7 +106,9 @@ class SignatureConfigCheckCommand extends SignatureCommandAbstract
                $output = $letterFile->checkAccess();
                $io->success("$output");
            } catch (\Exception $e) {
                $io->error("Problème détécté sur le parafeur <bold>" . $config['name'] . "</bold> : " . $e->getMessage());
                $io->error(
                    "Problème détécté sur le parafeur <bold>" . $config['name'] . "</bold> : " . $e->getMessage()
                );
                $error = true;
            }
        }
+21 −0
Changes for src/Entity/Db/SignatureRecipient.php: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -88,6 +88,25 @@ class SignatureRecipient
     */
    private Signature $signature;

    /**
     * @param Signature $signature Objet Signature
     * @param string $email Courriel du destinataire
     * @param string|null $firstname Prénom
     * @param string|null $lastname Nom
     * @param int|string|null $status Etat
     */
    public function __construct(
        ?string $email = null,
        ?string $firstname = null,
        ?string $lastname = null,
        ?int $status = Signature::STATUS_SIGNATURE_DRAFT
    ) {
        if($email) $this->setEmail($email);
        if($firstname) $this->setFirstname($firstname);
        if($lastname) $this->setLastname($lastname);
        $this->setStatus($status);
    }

    /**
     * @return int
     */
@@ -104,6 +123,8 @@ class SignatureRecipient
        return $this->status;
    }
    
    

    /**
     * @param int $status
     * @return SignatureRecipient
+1 −1
Changes for src/Form/SignatureForm.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ class SignatureForm extends Form
    private array $marksOptions;

    /**
     * @param array $marksOptions
     * @param array $marksOptions Liste des niveaux de signature
     */
    public function __construct(array $marksOptions)
    {

src/Hydrator/FileFormHydrator.php

deleted100644 → 0
+0 −57
Changes for src/Hydrator/FileFormHydrator.php: 0 added lines, 57 removed lines.
Original line number Diff line number Diff line
<?php

namespace UnicaenSignature\Hydrator;

use Laminas\Hydrator\HydratorInterface;

class FileFormHydrator implements HydratorInterface
{
    private string $prefixe;
    private string $dir;

    /**
     * @param string $prefixe
     * @param string $dir
     */
    public function __construct(string $dir, string $prefixe)
    {
        $this->dir = $dir;
        $this->prefixe = $prefixe;
    }


    /**
     * @param array $data
     */
    public function hydrate(array $data, $object)
    {
//        // Path
//        $path = '';
//        if( array_key_exists('path', $data) ){
//            $err = intval($data['path']['error']);
//            if( $err == 0 ){
//                // TODO Passer en paramètre l'emplacement des fichiers temporaire
//                $tmpName = $this->dir . DIRECTORY_SEPARATOR . $this->prefixe;
//                if( move_uploaded_file($data['path']['tmp_name'], $tmpName) ){
//                    $path = $tmpName;
//                } else {
//                    throw new \Exception('Impossible de déplacer le fichier temporaire');
//                }
//            } else {
//                throw new \Exception("Erreur d'upload  '$err'");
//            }
//        }

        return $object;
    }

    /**
     * @return array
     */
    public function extract(object $object): array
    {
        return [

        ];
    }
}
 No newline at end of file
+2 −0
Changes for src/Service/SignatureConfigurationService.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -34,9 +34,11 @@ class SignatureConfigurationService
    public function getDocumentsLocation( bool $checkWritable = true ):string
    {
        $path = $this->configuration->getConfiguration('unicaen-signature.documents_path');
        if( $checkWritable ){
            if( !is_writable($path) ) {
                throw new SignatureException("Le dossier pour stoquer les documents est inaccessible en écriture");
            }
        }
        return $path;
    }