Skip to content
Snippets Groups Projects
Commit 9d0bb4ce authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Action pour régénérer une MV

parent e480f4c5
Branches
Tags v4.3.0
No related merge requests found
Pipeline #17310 passed
......@@ -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' => [
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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() */ ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment