diff --git a/composer.json b/composer.json index befeac6592c83283fa9d2f25783f00fcadc46a9f..b47c3819ff830d0175f1d98c31d56cec60d11f82 100755 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "unicaen/app": "^4|^5", "unicaen/utilisateur": "^4|^5", "unicaen/privilege": "^4|^5", - "unicaen/mail": "^4|^5" + "unicaen/mail": "^5" }, "autoload": { "psr-0": [], diff --git a/src/UnicaenIndicateur/Controller/IndicateurController.php b/src/UnicaenIndicateur/Controller/IndicateurController.php index 2f8de0fe011e8f7ec06873c00c59b2b77c72ecab..773d2983b3d2752f0569f6b9213b9ee08346692b 100644 --- a/src/UnicaenIndicateur/Controller/IndicateurController.php +++ b/src/UnicaenIndicateur/Controller/IndicateurController.php @@ -66,17 +66,21 @@ class IndicateurController extends AbstractActionController { public function creerAction() : ViewModel { $indicateur = new Indicateur(); + + $namespace = $this->params()->fromQuery('namespace'); + if ($namespace) $indicateur->setNamespace($namespace); + $form = $this->getIndicateurForm(); - $form->setAttribute('action', $this->url()->fromRoute('indicateur/creer', [], [], true)); + $form->setAttribute('action', $this->url()->fromRoute('indicateur/creer', [], ['query' => ['namespace' => $namespace]], true)); $form->bind($indicateur); - /** @var Request $request */ $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); $form->setData($data); if ($form->isValid()) { $indicateur->setDernierRafraichissement(new DateTime()); + $this->getIndicateurService()->create($indicateur); $this->getIndicateurService()->createView($indicateur); } diff --git a/src/UnicaenIndicateur/Controller/TableauDeBordController.php b/src/UnicaenIndicateur/Controller/TableauDeBordController.php index bf341df30785f22fb29a86f7e92f28e6af99bc00..806bf17e24167c269b4120cf656c1faa009d1cb6 100644 --- a/src/UnicaenIndicateur/Controller/TableauDeBordController.php +++ b/src/UnicaenIndicateur/Controller/TableauDeBordController.php @@ -39,6 +39,9 @@ class TableauDeBordController extends AbstractActionController { $tableau = new TableauDeBord(); + $namespace = $this->params()->fromQuery('namespace'); + if ($namespace) $tableau->setNamespace($namespace); + $form = $this->getTableauDeBordForm(); $form->setAttribute('action', $this->url()->fromRoute('tableau-de-bord/ajouter', [], [], true)); $form->bind($tableau); diff --git a/src/UnicaenIndicateur/Entity/Db/Indicateur.php b/src/UnicaenIndicateur/Entity/Db/Indicateur.php index 2cd987bf7c8a529cdae8c57d734d0403fdd106ae..fbe3235505dab6510931f247775c8b1070897f26 100644 --- a/src/UnicaenIndicateur/Entity/Db/Indicateur.php +++ b/src/UnicaenIndicateur/Entity/Db/Indicateur.php @@ -20,6 +20,7 @@ class Indicateur { private ?DateTime $dernierRafraichissement = null; private ?string $viewId = null; private ?string $entity = null; + private ?string $namespace = null; private Collection $abonnements; private Collection $tableaux; @@ -94,6 +95,16 @@ class Indicateur { $this->entity = $entity; } + public function getNamespace(): ?string + { + return $this->namespace; + } + + public function setNamespace(?string $namespace): void + { + $this->namespace = $namespace; + } + /** Abonnements **************************************************************** */ /** diff --git a/src/UnicaenIndicateur/Entity/Db/Mapping/UnicaenIndicateur.Entity.Db.Indicateur.dcm.xml b/src/UnicaenIndicateur/Entity/Db/Mapping/UnicaenIndicateur.Entity.Db.Indicateur.dcm.xml index 6fe35ca3089969270082a45e032d55bd18de9f57..c1f38ddc2473ce0b639e01021f3dad233f996bf5 100644 --- a/src/UnicaenIndicateur/Entity/Db/Mapping/UnicaenIndicateur.Entity.Db.Indicateur.dcm.xml +++ b/src/UnicaenIndicateur/Entity/Db/Mapping/UnicaenIndicateur.Entity.Db.Indicateur.dcm.xml @@ -12,6 +12,7 @@ <field name="dernierRafraichissement" type="datetime" column="dernier_rafraichissement" nullable="true"/> <field name="viewId" type="string" length="255" column="view_id" nullable="true"/> <field name="entity" type="string" length="255" column="entity" nullable="true"/> + <field name="namespace" type="string" length="1024" column="namespace" nullable="true"/> <one-to-many target-entity="UnicaenIndicateur\Entity\Db\Abonnement" field="abonnements" mapped-by="indicateur" /> diff --git a/src/UnicaenIndicateur/Entity/Db/Mapping/UnicaenIndicateur.Entity.Db.TableauDeBord.dcm.xml b/src/UnicaenIndicateur/Entity/Db/Mapping/UnicaenIndicateur.Entity.Db.TableauDeBord.dcm.xml index 8e9b59618a6897a1a70b5a8fad678f26935f28d7..bf5a7fa7948e87e77134ed455847b8b4546e59ec 100644 --- a/src/UnicaenIndicateur/Entity/Db/Mapping/UnicaenIndicateur.Entity.Db.TableauDeBord.dcm.xml +++ b/src/UnicaenIndicateur/Entity/Db/Mapping/UnicaenIndicateur.Entity.Db.TableauDeBord.dcm.xml @@ -9,6 +9,7 @@ <field name="titre" type="string" length="255" column="titre" nullable="false"/> <field name="description" type="string" length="2047" column="description" nullable="false"/> <field name="nbColumn" type="integer" column="nb_column" nullable="false"/> + <field name="namespace" type="string" length="1024" column="namespace" nullable="true"/> <many-to-many field="indicateurs" target-entity="UnicaenIndicateur\Entity\Db\Indicateur" inversed-by="indicateur" fetch="LAZY"> <join-table name="unicaen_indicateur_tableau_indicateur"> diff --git a/src/UnicaenIndicateur/Entity/Db/TableauDeBord.php b/src/UnicaenIndicateur/Entity/Db/TableauDeBord.php index 93cf80a4f3a18b2685a7567aafb092b5387be194..8aea59883a9f48d2bbee8e774463906e37571544 100644 --- a/src/UnicaenIndicateur/Entity/Db/TableauDeBord.php +++ b/src/UnicaenIndicateur/Entity/Db/TableauDeBord.php @@ -12,6 +12,7 @@ class TableauDeBord { private ?string $titre = null; private ?string $description = null; private ?int $nbColumn = 1; + private ?string $namespace = null; private Collection $indicateurs; public function __construct() @@ -54,6 +55,16 @@ class TableauDeBord { $this->nbColumn = $nbColumn; } + public function getNamespace(): ?string + { + return $this->namespace; + } + + public function setNamespace(?string $namespace): void + { + $this->namespace = $namespace; + } + /** * @return Indicateur[] */ diff --git a/src/UnicaenIndicateur/Form/Indicateur/IndicateurForm.php b/src/UnicaenIndicateur/Form/Indicateur/IndicateurForm.php index 48040d6e9ffa3e7adb010f3ab63cc72d15a31836..180e9671d5418000b955a4f17189ab4b876bade0 100644 --- a/src/UnicaenIndicateur/Form/Indicateur/IndicateurForm.php +++ b/src/UnicaenIndicateur/Form/Indicateur/IndicateurForm.php @@ -38,6 +38,17 @@ class IndicateurForm extends Form { 'class' => 'type2 form-control', ] ]); + // namespace + $this->add([ + 'type' => Text::class, + 'name' => 'namespace', + 'options' => [ + 'label' => "Namespace :", + ], + 'attributes' => [ + 'id' => 'namespace', + ], + ]); // view_id $this->add([ 'type' => Text::class, @@ -104,6 +115,7 @@ class IndicateurForm extends Form { $this->setInputFilter((new Factory())->createInputFilter([ 'libelle' => [ 'required' => true, ], 'description' => [ 'required' => false, ], + 'namespace' => [ 'required' => false, ], 'view_id' => [ 'required' => true, ], 'entity' => [ 'required' => true, ], 'requete' => [ 'required' => true, ], diff --git a/src/UnicaenIndicateur/Form/Indicateur/IndicateurHydrator.php b/src/UnicaenIndicateur/Form/Indicateur/IndicateurHydrator.php index cbc9694f850e8d4397ea387352a2121fb3adaf45..b4fb2738e4a88c4dcd558c338b7528958a80aa59 100644 --- a/src/UnicaenIndicateur/Form/Indicateur/IndicateurHydrator.php +++ b/src/UnicaenIndicateur/Form/Indicateur/IndicateurHydrator.php @@ -16,6 +16,7 @@ class IndicateurHydrator implements HydratorInterface { $data = [ 'libelle' => $object->getTitre(), 'description' => $object->getDescription(), + 'namespace' => $object->getNamespace(), 'view_id' => $object->getViewId(), 'entity' => $object->getEntity(), 'requete' => $object->getRequete(), @@ -30,8 +31,11 @@ class IndicateurHydrator implements HydratorInterface { */ public function hydrate(array $data, $object) : object { + $namespace = (isset($data['namespace']) AND trim($data['namespace']) !== '')?trim($data['namespace']):null; + $object->setTitre($data['libelle']); $object->setDescription($data['description']); + $object->setNamespace($namespace); $object->setViewId($data['view_id']); $object->setEntity($data['entity']); $object->setRequete($data['requete']); diff --git a/src/UnicaenIndicateur/Form/TableauDeBord/TableauDeBordForm.php b/src/UnicaenIndicateur/Form/TableauDeBord/TableauDeBordForm.php index a0ce1d973a8f8352497d8500dbb10092f67319b1..fe487f30d96c4e8b9dcd8d054ee2c343d2a3dcf1 100644 --- a/src/UnicaenIndicateur/Form/TableauDeBord/TableauDeBordForm.php +++ b/src/UnicaenIndicateur/Form/TableauDeBord/TableauDeBordForm.php @@ -37,6 +37,17 @@ class TableauDeBordForm extends Form { 'class' => 'type2 form-control', ] ]); + // libelle + $this->add([ + 'type' => Text::class, + 'name' => 'namespace', + 'options' => [ + 'label' => "Namespace :", + ], + 'attributes' => [ + 'id' => 'namespace', + ], + ]); // nbCOlum $this->add([ 'name' => 'nb_colonne', @@ -74,7 +85,8 @@ class TableauDeBordForm extends Form { $this->setInputFilter((new Factory())->createInputFilter([ 'libelle' => [ 'required' => true, ], 'description' => [ 'required' => false, ], - 'nb_colonne' => [ 'required' => true, ], + 'namespace' => [ 'required' => false, ], + 'nb_colonne' => [ 'required' => true, ], ])); } } \ No newline at end of file diff --git a/src/UnicaenIndicateur/Form/TableauDeBord/TableauDeBordHydrator.php b/src/UnicaenIndicateur/Form/TableauDeBord/TableauDeBordHydrator.php index 4f8754b700592e739e94e48ae229d86149eb9a45..9be2276e5e0f3d5c79f001143117dc89017db181 100644 --- a/src/UnicaenIndicateur/Form/TableauDeBord/TableauDeBordHydrator.php +++ b/src/UnicaenIndicateur/Form/TableauDeBord/TableauDeBordHydrator.php @@ -16,6 +16,7 @@ class TableauDeBordHydrator implements HydratorInterface { $data = [ 'libelle' => $object->getTitre(), 'description' => $object->getDescription(), + 'namespance' => $object->getNamespace(), 'nb_colonne' => $object->getNbColumn(), ]; return $data; @@ -31,10 +32,12 @@ class TableauDeBordHydrator implements HydratorInterface { $libelle = (isset($data['libelle']) AND trim($data['libelle']) !== '')?trim($data['libelle']):null; $description = (isset($data['description']) AND trim($data['description']) !== '')?trim($data['description']):null; $nbColonne = (isset($data['nb_colonne']))?$data['nb_colonne']:null; + $namespace = (isset($data['namespace']) AND trim($data['namespace']) !== '')?trim($data['namespace']):null; $object->setTitre($libelle); $object->setDescription($description); $object->setNbColumn($nbColonne); + $object->setNamespace($namespace); return $object; } diff --git a/src/UnicaenIndicateur/Service/Indicateur/IndicateurService.php b/src/UnicaenIndicateur/Service/Indicateur/IndicateurService.php index d6db1bf48960e43a183acbbfa4669cb9442733e5..935306cef65c3e5634b6dc17a64e26105ee8897f 100644 --- a/src/UnicaenIndicateur/Service/Indicateur/IndicateurService.php +++ b/src/UnicaenIndicateur/Service/Indicateur/IndicateurService.php @@ -219,6 +219,19 @@ class IndicateurService { return $this->getIndicateur($id); } + /** + * @return Indicateur[] + */ + public function getIndicateursByNamespace(?string $namespace) : array + { + $qb = $this->getObjectManager()->getRepository(Indicateur::class)->createQueryBuilder('indicateur') + ->andWhere('indicateur.namespace = :namespace') + ->setParameter('namespace', $namespace); + return $qb->getQuery()->getResult(); + } + + /** FACADE **************************************************************/ + /** RECUPERATION DONNEES ***************************************************************************************** * @param Indicateur $indicateur * @return array|null diff --git a/src/UnicaenIndicateur/Service/TableauDeBord/TableauDeBordService.php b/src/UnicaenIndicateur/Service/TableauDeBord/TableauDeBordService.php index 89bb5d1e59fc5e0bfed971c0ff98d7fedd37ac17..7b87f385bb2e10141bf4699ea473ebb9ec4d8d1d 100644 --- a/src/UnicaenIndicateur/Service/TableauDeBord/TableauDeBordService.php +++ b/src/UnicaenIndicateur/Service/TableauDeBord/TableauDeBordService.php @@ -92,5 +92,16 @@ class TableauDeBordService { return $result; } + /** + * @return TableauDeBord[] + */ + public function getTableauxDeBordByNamespace(?string $namespace) : array + { + $qb = $this->createQueryBuilder() + ->andWhere('tableau.namespace = :namespace') + ->setParameter('namespace', $namespace); + return $qb->getQuery()->getResult(); + } + /** FACADE ******************************************************/ } \ No newline at end of file