Commit 10fbc514 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

[FIX] Module Information : utilisation d'une langue par défaut (FR) pour...

[FIX] Module Information : utilisation d'une langue par défaut (FR) pour permettre la création d'une page d'information.
parent f1a119ea
Loading
Loading
Loading
Loading
+1 −0
Changes for CHANGELOG.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ Journal des modifications
-----
- Module Soutenance : modif de la qualité par défaut des membres lors de la création automatique de la proposition (lors du 1er accès à la page Proposition).
- [FIX] Requête de recherche de thèses par acteur : les acteurs historisés n'étaient pas écartés.
- [FIX] Module Information : utilisation d'une langue par défaut (FR) pour permettre la création d'une page d'information.

8.4.0
-----
+2 −4
Changes for module/Information/src/Information/Controller/InformationController.php: 2 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -43,12 +43,10 @@ class InformationController extends AbstractActionController {
        ]);
    }

    public function ajouterAction()
    public function ajouterAction(): ViewModel
    {
        /** @var Information $information */
        $information = new Information();
        $information = $this->informationService->new();

        /** @var InformationForm $form */
        $form = $this->informationForm;
        $form->bind($information);

+3 −10
Changes for module/Information/src/Information/Entity/Db/InformationLangue.php: 3 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,9 @@

namespace Information\Entity\Db;

class  InformationLangue {
class InformationLangue
{
    const ID_LANGUE_PAR_DEFAUT = 'FR';

    /** @var string */
    private $id;
@@ -13,25 +15,16 @@ class InformationLangue {
    /** @var string */
    private $drapeau;

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

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

    /**
     * @return string
     */
    public function getDrapeau(): string
    {
        return $this->drapeau;
+3 −3
Changes for module/Information/src/Information/Form/InformationHydrator.php: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -3,12 +3,12 @@
namespace Information\Form;

use Information\Entity\Db\Information;
use Information\Service\InformationLangue\InformationLangueerviceAwareTrait;
use Information\Service\InformationLangue\InformationLangueServiceAwareTrait;
use Laminas\Hydrator\HydratorInterface;

class InformationHydrator implements HydratorInterface
{
    use InformationLangueerviceAwareTrait;
    use InformationLangueServiceAwareTrait;

    /**
     * @param Information $object
@@ -32,7 +32,7 @@ class InformationHydrator implements HydratorInterface
     */
    public function hydrate(array $data, $object)
    {
        $langue = $this->getInformationLangueService()->getLangue($data['langue']);
        $langue = $this->informationLangueService->getLangue($data['langue']);

        $object->setTitre($data['titre']);
        $object->setContenu($data['contenu']);
+20 −7
Changes for module/Information/src/Information/Service/InformationLangue/InformationLangueService.php: 20 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -2,22 +2,35 @@

namespace Information\Service\InformationLangue;

use Application\Service\BaseService;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\QueryBuilder;
use Information\Entity\Db\InformationLangue;
use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait;
use Webmozart\Assert\Assert;

class InformationLangueService {
class InformationLangueService extends BaseService
{
    use EntityManagerAwareTrait;

    /**
     * @return QueryBuilder
     */
    public function createQueryBuilder()
    public function getRepository(): EntityRepository
    {
        return $this->getEntityManager()->getRepository(InformationLangue::class);
    }

    public function createQueryBuilder(): QueryBuilder
    {
        $qb = $this->getEntityManager()->getRepository(InformationLangue::class)->createQueryBuilder('langue');
        return $qb;
        return $this->getRepository()->createQueryBuilder('langue');
    }

    public function getLangueParDefaut(): InformationLangue
    {
        $lanque = $this->getRepository()->find(InformationLangue::ID_LANGUE_PAR_DEFAUT);
        Assert::notNull($lanque, "Anomalie : aucune langue par défaut n'a été trouvée !");

        return $lanque;
    }

    /**
Loading