Commit c61a6a6a authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Amélioration des services : query builder et creation d'instance via un code

parent 1478ee31
Loading
Loading
Loading
Loading

Empty file added.

+18
Changes for module/Autoform/src/Autoform/Entity/Db/Formulaire.php: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ class Formulaire {
    private $libelle;
    /** @var string */
    private $description;
    /** @var string */
    private $code;

    /** @var ArrayCollection */
    private $categories;
@@ -67,6 +69,22 @@ class Formulaire {
        return $this;
    }

    /**
     * @return string
     */
    public function getCode()
    {
        return $this->code;
    }

    /**
     * @param string $code
     */
    public function setCode($code)
    {
        $this->code = $code;
    }

    /**
     * @return Categorie[]
     */
+1
Changes for module/Autoform/src/Autoform/Entity/Db/Mapping/Autoform.Entity.Db.Formulaire.dcm.xml: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@

        <field name="libelle"           column="libelle"            type="string"    length="128"    nullable="false" />
        <field name="description"       column="description"        type="string"    length="2048"   nullable="false" />
        <field name="code"              column="code"               type="string"    length="256"    nullable="false" />

        <one-to-many target-entity="Autoform\Entity\Db\Categorie" mapped-by="formulaire" field="categories"/>

+15
Changes for module/Autoform/src/Autoform/Service/Formulaire/FormulaireInstanceService.php: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ class FormulaireInstanceService {
    use DateTimeAwareTrait;
    use EntityManagerAwareTrait;
    use UserServiceAwareTrait;
    use FormulaireServiceAwareTrait;
    use FormulaireReponseServiceAwareTrait;

    /** GESTION DES ENTITES *******************************************************************************************/
@@ -121,6 +122,20 @@ class FormulaireInstanceService {
        return $instance;
    }

    /**
     * @param string $code
     * @return FormulaireInstance
     */
    public function createInstance($code)
    {
        $instance = new FormulaireInstance();
        $formulaire = $this->getFormulaireService()->getFormulaireByCode($code);
        $instance->setFormulaire($formulaire);
        $this->create($instance);
        return $instance;
    }


    /** REQUETAGES ****************************************************************************************************/

    /**
+6 −2
Changes for module/Autoform/src/Autoform/Service/Formulaire/FormulaireInstanceServiceFactory.php: 6 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -12,17 +12,21 @@ class FormulaireInstanceServiceFactory {
    {
        /**
         * @var EntityManager $entityManager
         * @var FormulaireService $formulaireService
         * @var FormulaireReponseService $formulaireReponseService
         * @var UserService $userService
         */
        $entityManager = $container->get('doctrine.entitymanager.orm_default');
        $userService = $container->get(UserService::class);
        $formulaireService = $container->get(FormulaireService::class);
        $formulaireReponseService = $container->get(FormulaireReponseService::class);
        $userService = $container->get(UserService::class);

        /** @var FormulaireInstanceService $service */
        $service = new FormulaireInstanceService();
        $service->setEntityManager($entityManager);
        $service->setUserService($userService);
        $service->setFormulaireService($formulaireService);
        $service->setFormulaireReponseService($formulaireReponseService);
        $service->setUserService($userService);
        return $service;
    }
}
 No newline at end of file
Loading