Commit bb638c52 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

CRUD administration employeur et adaptation update-employeur avec ajout d'une...

CRUD administration employeur et adaptation update-employeur avec ajout d'une nouvelle source INSEE.

(cherry picked from commit b3970787)
parent e58977db
Loading
Loading
Loading
Loading
+43 −0
Changes for module/Application/src/Form/Employeur/EmployeurSaisieForm.php: 43 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Form\Employeur;

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

class EmployeurSaisieForm extends AbstractForm
{
    use SchemaServiceAwareTrait;

    public function init()
    {
        $ignore = ["identifiantAssociation", "sourceCode", "source", "critereRecherche"];
        $this->spec(Employeur::class, $ignore);
        $this->build();
        $this->get('raisonSociale')->setLabel('Raison sociale');
        $this->get('nomCommercial')->setLabel('Nom commercial');
        $this->addSecurity();
        $this->addSubmit();

        return $this;
    }


    public function bind($object, $flags = FormInterface::VALUES_NORMALIZED)
    {
        /* @var $object Employeur */
        parent::bind($object, $flags);

        if ($object->getSource() && $object->getSource()->getImportable()) {
            foreach ($this->getElements() as $element) {
                if ($this->getServiceSchema()->isImportedProperty($object, $element->getName())) {
                    $element->setAttribute('readonly', true);
                }
            }
        }

        return $this;
    }
}
+26 −0
Changes for module/Application/src/Form/Employeur/EmployeurSaisieFormFactory.php: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Form\Employeur;

use Psr\Container\ContainerInterface;
use UnicaenImport\Service\SchemaService;


class EmployeurSaisieFormFactory
{

    /**
     * @param ContainerInterface $container
     * @param string $requestedName
     * @param array|null $options
     *
     * @return EmployeurSaisieForm
     */
    public function __invoke(ContainerInterface $container, $requestedName, $options = null)
    {
        $form = new EmployeurSaisieForm();
        $form->setServiceSchema($container->get(SchemaService::class));

        return $form;
    }
}
 No newline at end of file
+33 −0
Changes for module/Application/src/Form/Employeur/Traits/EmployeurSaisieFormAwareTrait.php: 33 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Form\Employeur\Traits;

use Application\Form\Employeur\EmployeurSaisieForm;

trait EmployeurSaisieFormAwareTrait
{
    protected ?EmployeurSaisieForm $formEmployeurSaisie = null;


    /**
     * @param EmployeurSaisieForm $formEmployeurSaisie
     *
     * @return self
     */
    public function setFormEmployeurSaisie(?EmployeurSaisieForm $formEmployeurSaisie)
    {
        $this->formEmployeurSaisie = $formEmployeurSaisie;

        return $this;
    }


    public function getFormEmployeurSaisie(): ?EmployeurSaisieForm
    {
        if (!empty($this->formEmployeurSaisie)) {
            return $this->formEmployeurSaisie;
        }

        return \Application::$container->get('FormElementManager')->get(EmployeurSaisieForm::class);
    }
}
 No newline at end of file
+7 −0
Changes for module/Application/view/application/employeur/saisie.phtml: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php
/**
 * @var $this  \Application\View\Renderer\PhpRenderer
 */

echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
echo $this->form($form);