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

Action pour régénérer une MV

parent e480f4c5
Loading
Loading
Loading
Loading
Loading
+12 −0
Changes for config/merged/indicateur.config.php: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ return [
                        'modifier',
                        'detruire',
                        'exporter',
                        'regenerer',
                    ],
                    'privileges' => [
                        IndicateurPrivileges::AFFICHER,
@@ -87,6 +88,17 @@ return [
                        ],
                        'may_terminate' => true,
                    ],
                    'regenerer' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/regenerer/:indicateur',
                            'defaults' => [
                                'controller' => IndicateurController::class,
                                'action'     => 'regenerer',
                            ],
                        ],
                        'may_terminate' => true,
                    ],
                    'creer' => [
                        'type'  => Literal::class,
                        'options' => [
+12 −0
Changes for src/UnicaenIndicateur/Controller/IndicateurController.php: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -123,6 +123,18 @@ class IndicateurController extends AbstractActionController {
        return $this->redirect()->toRoute('indicateurs', [], [], true);
    }

    public function regenererAction() : Response
    {
        $indicateur = $this->getIndicateurService()->getRequestedIndicateur($this);
        $indicateur->setDernierRafraichissement(new DateTime());
        $this->getIndicateurService()->createView($indicateur);
        $this->getIndicateurService()->update($indicateur);

        $retour = $this->params()->fromQuery('retour');
        if ($retour) return $this->redirect()->toUrl($retour);
        return $this->redirect()->toRoute('indicateur/afficher', ['indicateur' => $indicateur->getId()], [], true);
    }

    public function exporterAction(): CsvModel
    {
        $indicateur = $this->getIndicateurService()->getRequestedIndicateur($this);
+4 −4
Changes for src/UnicaenIndicateur/Entity/Db/Indicateur.php: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ class Indicateur {
        return $this->id;
    }

    public function getTitre() : string
    public function getTitre() : ?string
    {
        return $this->titre;
    }
@@ -42,7 +42,7 @@ class Indicateur {
        $this->titre = $titre;
    }

    public function getDescription() : string
    public function getDescription() : ?string
    {
        return $this->description;
    }
@@ -52,7 +52,7 @@ class Indicateur {
        $this->description = $description;
    }

    public function getRequete() : string
    public function getRequete() : ?string
    {
        return $this->requete;
    }
@@ -72,7 +72,7 @@ class Indicateur {
        $this->dernierRafraichissement = $dernierRafraichissement;
    }

    public function getViewId() : string
    public function getViewId() : ?string
    {
        return $this->viewId;
    }
+11 −0
Changes for view/unicaen-indicateur/indicateur/afficher.phtml: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -19,8 +19,19 @@ use UnicaenIndicateur\Entity\Db\Indicateur;

<?php if ($exists !== true) : ?>
    <div class="alert alert-danger">
        <div class="row">
            <div class="col-md-9">
                La vue matérialisée associée à l'indicateur ne semble pas exister.
            </div>
            <div class="col-md-3">
                <?php /** @see \UnicaenIndicateur\Controller\IndicateurController::regenererAction() */?>
                <a href="<?php echo $this->url('indicateur/regenerer', ['indicateur' => $indicateur->getId()], [], true); ?>" class="btn btn-primary">
                    <span class="icon icon-synchroniser"></span>
                    Regénérer la vue associée
                </a>
            </div>
        </div>
    </div>
<?php else : ?>
    <div class="row">
        <?php /** @see IndicateurController::exportAction() */ ?>