ajout d'un registre pour les applications modulaires

This commit is contained in:
Emmanuel ROY 2019-08-09 09:48:21 +02:00
parent dd7f486bf2
commit 6a2ded3c3e
3 changed files with 95 additions and 60 deletions

View file

@ -0,0 +1,28 @@
<?php
namespace MVC\Classe;
class ModularRegister{
public $registry = array();
public $index = array();
public function __construct(){
$fichier = file(MODULES_PATH.DIRECTORY_SEPARATOR."setup" . DIRECTORY_SEPARATOR ."registre.model");
foreach ($fichier as $ligne_num => $ligne) {
if (preg_match("#[ ]*([a-zA-Z-_+]*)[ ]*[:][ ]*([0-9a-zA-Z-_+ ']*[ ]*)#", $ligne, $matches)) {
$this->registry[$matches[1]] = $matches[2];
$this->index[] = $matches[1];
}
}
}
public function getRegistre(){
return $this->index;
}
public function getIndex(){
return $this->registry;
}
}

View file

@ -5,10 +5,13 @@ namespace MVC\Classe;
class Url
{
public $page;
public $registre;
public function __construct(){
$this->registre = new \MVC\Classe\ModularRegister();
$page = array();
$page['name'] = 'accueil';
$page['description'] = "";
@ -43,9 +46,11 @@ class Url
// de valeurs on sort de la fonction et on renvoie une page d'erreur.
$numParts = count($urlParts);
if ( $numParts%2 != 0 ) {
if( !in_array($page['name'], $this->registre->getIndex()) ){
$page['name'] = 'error';
$page['params'] = array();
return $page;
}
}else if ( $numParts != 0 ){
$values = array();
$keys = array();
@ -74,5 +79,6 @@ class Url
$page['name'] = 'error';
}
$this->page = $page;
}
}

View file

@ -0,0 +1 @@
sf43:Application permetttant de tester l'intégration d'un module avec symfony4.3