Commit 29e22441 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Merge branch 'refs/heads/b23'

parents 5bc08683 a6ee53cc
Loading
Loading
Loading
Loading
+2
Changes for module/Dossier/src/Form/EmployeurSaisieForm.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Dossier\Form;

use Dossier\Entity\Db\Employeur;
use Application\Form\AbstractForm;
use Dossier\Hydrator\EmployeurHydrator;
use Laminas\Form\FormInterface;
use UnicaenImport\Service\Traits\SchemaServiceAwareTrait;

@@ -15,6 +16,7 @@ class EmployeurSaisieForm extends AbstractForm
    {
        $ignore = ["identifiantAssociation", "sourceCode", "source", "critereRecherche"];
        $this->spec(Employeur::class, $ignore);
        $this->setHydrator(new EmployeurHydrator());
        $this->build();
        $this->get('raisonSociale')->setLabel('Raison sociale');
        $this->get('nomCommercial')->setLabel('Nom commercial');
+54
Changes for module/Dossier/src/Hydrator/EmployeurHydrator.php: 54 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Dossier\Hydrator;


use Dossier\Entity\Db\Employeur;
use Laminas\Hydrator\HydratorInterface;

class EmployeurHydrator implements HydratorInterface
{

    /**
     * Hydrate $object with the provided $data.
     *
     * @param array     $data
     * @param Employeur $object
     *
     * @return object
     */
    public function hydrate(array $data, $object)
    {

        $siret = preg_replace('/\D/', '', $data['siret']);
        $siren = preg_replace('/\D/', '', $data['siren']);
        $object->setSiret($siret);
        $object->setSiren($siren);
        $object->setRaisonSociale($data['raisonSociale']);
        $object->setNomCommercial($data['nomCommercial']);

        return $object;
    }



    /**
     * Extract values from an object
     *
     * @param Employeur $object
     *
     * @return array
     */
    public function extract($object): array
    {
        $data = [
            'siret'         => $object->getSiret(),
            'siren'         => $object->getSiren(),
            'raisonSociale' => $object->getRaisonSociale(),
            'nomCommercial' => $object->getNomCommercial(),

        ];

        return $data;
    }
}
 No newline at end of file