commit
f2cea0d18d
@ -1,6 +1,11 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /php/public/
|
||||
#RewriteEngine On
|
||||
#
|
||||
#RewriteCond %{REQUEST_FILENAME} !-f
|
||||
#RewriteCond %{REQUEST_FILENAME} !-d
|
||||
#RewriteRule ^(.*)$ index.php/$1 [L]
|
||||
|
||||
|
||||
RewriteEngine on
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^(.*)$ index.php [QSA,L]
|
||||
</IfModule>
|
||||
RewriteRule . index.php [L]
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/** PC IUT - PHP 8.1 */
|
||||
|
||||
/** Chargement config */
|
||||
|
||||
require_once __DIR__ . '/src/config/config.php';
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
|
||||
/** Configuration twig */
|
||||
$loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/templates');
|
||||
$twig = new \Twig\Environment($loader, [
|
||||
'cache' => false,
|
||||
'debug' => true
|
||||
]);
|
||||
$twig->addExtension(new \Twig\Extension\DebugExtension());
|
||||
$twig->addGlobal('dir', '/SAE_2A_FA-Reseau_ALICA/php');
|
||||
|
||||
|
||||
|
||||
|
||||
$cont = new \App\controleur\FrontControleur();
|
After Width: | Height: | Size: 842 KiB |
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
/** PC IUT - PHP 8.1 */
|
||||
|
||||
/** Chargement config */
|
||||
require_once __DIR__ . '/../src/config/config.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__ . '/../src/TwigExtensions.php'; // utile pour les images à supprimer sinon
|
||||
|
||||
/** Configuration twig */
|
||||
$loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/../templates');
|
||||
$twig = new \Twig\Environment($loader, [
|
||||
'cache' => false,
|
||||
'debug' => true
|
||||
]);
|
||||
$twig->addExtension(new \Twig\Extension\DebugExtension());
|
||||
$cont = new \App\controleur\FrontControleur();
|
||||
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
|
||||
class TwigExtensions extends AbstractExtension
|
||||
{
|
||||
public function getFilters()
|
||||
{
|
||||
return [
|
||||
new TwigFilter('base64', [$this, 'twig_base64_filter']),
|
||||
];
|
||||
}
|
||||
|
||||
public function twig_base64_filter($source)
|
||||
{
|
||||
if ($source !== null) {
|
||||
return base64_encode($source);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
@ -1,55 +1,105 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\controleur;
|
||||
|
||||
use App\router\AltoRouter;
|
||||
use App\metier\Alumni;
|
||||
|
||||
use App\controleur\UtilisateurControleur;
|
||||
use App\controleur\MembreControleur;
|
||||
use App\controleur\AdminControleur;
|
||||
|
||||
class FrontControleur
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
|
||||
global $twig;
|
||||
session_start();
|
||||
$dVueErreur = [];
|
||||
$actions = array(
|
||||
"Admin" => [
|
||||
"supprimerCompte", "consulterSignalement","supprimerOffre"
|
||||
],
|
||||
"Moderateur" => [
|
||||
//TODO
|
||||
],
|
||||
"Membre" => [
|
||||
"deconnexion","proposerOffre","consulterProfil","modifierProfil","signaler",
|
||||
],
|
||||
"Utilisateur" => [
|
||||
|
||||
"connexion", "getProfilByPage","inscription", "accueil", "consulterProfilLimite", "publierOffre", "listerEvenement", "creerEvenement", "supprimerEvenement", "avoirDetailEvenement", "rechercherEvenement"
|
||||
]
|
||||
);
|
||||
|
||||
$action = \App\config\Validation::nettoyerString($_GET["action"] ?? "");
|
||||
if(in_array($action,$actions['Admin'])) {
|
||||
if (!isset($_SESSION["role"]) || $_SESSION["role"]!="admin") {
|
||||
$dVueErreur[] = 'Veuillez vous connecter';
|
||||
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
||||
} else{
|
||||
new AdminControleur();
|
||||
|
||||
$router = new AltoRouter();
|
||||
|
||||
$router->setBasePath('/SAE_2A_FA-Reseau_ALICA/php');
|
||||
|
||||
$router->map('GET', '/', 'UtilisateurControleur');
|
||||
|
||||
$router->map('GET','/[a:action]?','UtilisateurControleur');
|
||||
|
||||
$router->map('POST','/[a:action]?','UtilisateurControleur');
|
||||
|
||||
$router->map('GET','/[a:action]/[i:id]?','UtilisateurControleur');
|
||||
|
||||
$router->map('GET|POST', '/user/[i:id]/[a:action]?', 'MembreControleur');
|
||||
|
||||
$router->map('GET|POST', '/admin/[i:id]/[a:action]?', 'AdminControleur');
|
||||
|
||||
$id = 0;
|
||||
|
||||
$match = $router->match();
|
||||
|
||||
$action = array();
|
||||
|
||||
$id = array();
|
||||
|
||||
$twig->render("accueil.html",[]);
|
||||
|
||||
if (!$match) {
|
||||
|
||||
$dVueErreur[] = "Error 404 Page not found";
|
||||
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
|
||||
}
|
||||
|
||||
if ($match) {
|
||||
|
||||
$controller = $match['target'] ?? NULL;
|
||||
$action = $match['params']['action'] ?? NULL;
|
||||
$id = $match['params']['id'] ?? NULL;
|
||||
|
||||
//var_dump($match);
|
||||
|
||||
try {
|
||||
if ($controller == "MembreControleur") {
|
||||
if ($_SESSION["utilisateur"]->getRole() != "Admin" || $_SESSION["utilisateur"]->getRole() != "Membre") {
|
||||
|
||||
echo $twig->render("connection.html",['msg' => 'Vous devez vous connecter pour effectuer cette action']);
|
||||
}
|
||||
}
|
||||
else if(in_array($action,$actions['Moderateur'])) {
|
||||
if (!isset($_SESSION["role"]) || ($_SESSION["role"]!="moderateur" && $_SESSION["role"]!="admin")) {
|
||||
$dVueErreur[] = 'Veuillez vous connecter';
|
||||
|
||||
if ($controller == "AdminControleur") {
|
||||
$Alumni = $_SESSION["utilisateur"];
|
||||
if ($Alumni->getRole() != "Admin") {
|
||||
$dVueErreur = ["Erreur : Vous n'avez pas les privileges pour cette action"];
|
||||
|
||||
global $twig;
|
||||
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
new ModerateurControleur();
|
||||
$namespace = 'App\\Controleur\\';
|
||||
$controller = $namespace . $controller;
|
||||
$controller = new $controller();
|
||||
}
|
||||
|
||||
if (is_callable(array($controller, $action))) {
|
||||
|
||||
call_user_func(array($controller, $action), $match['params']);
|
||||
} else {
|
||||
|
||||
$dVueErreur = ['Erreur : Action inconnue'];
|
||||
|
||||
echo $twig->render('accueil.html', ['dVueErreur' => $dVueErreur]);
|
||||
}
|
||||
else if(in_array($action,$actions['Membre'])) {
|
||||
if (!isset($_SESSION["utilisateur"])) {
|
||||
$dVueErreur[] = 'Veuillez vous connecter';
|
||||
|
||||
} catch (Error $error) {
|
||||
$dVueErreur = ['Erreur : Action inconnue'];
|
||||
|
||||
|
||||
|
||||
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
||||
} else{
|
||||
new MembreControleur();
|
||||
}
|
||||
}else{
|
||||
new UtilisateurControleur();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,145 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\modele;
|
||||
|
||||
use App\gateway\AlumniGateway;
|
||||
use App\gateway\Connection;
|
||||
use App\gateway\ImageGateway;
|
||||
use App\gateway\OffreGateway;
|
||||
use App\gateway\ProfilGateway;
|
||||
use App\metier\Alumni;
|
||||
use App\metier\Offre;
|
||||
use App\metier\Image;
|
||||
use mysql_xdevapi\Exception;
|
||||
|
||||
class OffreModele
|
||||
{
|
||||
private OffreGateway $offreGw;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->offreGw = new OffreGateway(new Connection(DB_HOST,DB_USER,DB_PASS));
|
||||
}
|
||||
|
||||
public function publishOffer(string $img, string $logo)
|
||||
{
|
||||
$desc = $_POST["description"];
|
||||
$descposte = $_POST["descriptPoste"];
|
||||
$nom = $_POST["name"];
|
||||
$ville = $_POST["ville"];
|
||||
$entreprise = $_POST["entreprise"];
|
||||
$profilRecherche = $_POST["profilRecherche"];
|
||||
$mail = $_POST["mail"];
|
||||
$num = $_POST["num"];
|
||||
$site = $_POST["site"];
|
||||
$exp = $_POST["choixExp"];
|
||||
$typeContrat = $_POST["typeContrat"];
|
||||
$niveauEtudes = $_POST["education"];
|
||||
$date = new \DateTime();
|
||||
|
||||
if(isset($_POST["fullRemote"]))
|
||||
{
|
||||
$remote = true;
|
||||
}
|
||||
else $remote = false;
|
||||
|
||||
// à la place de NULL passer id utilisateur créateur offre
|
||||
$offre = new Offre($this->offreGw->getNewId(),
|
||||
new Alumni("test.mail@icloud.fr","password","admin","prenom","nom"),
|
||||
$nom,
|
||||
$desc,
|
||||
$img,
|
||||
$logo,
|
||||
$typeContrat,
|
||||
$ville,
|
||||
$entreprise,
|
||||
$descposte,
|
||||
$profilRecherche,
|
||||
$exp,
|
||||
$niveauEtudes,
|
||||
$mail,
|
||||
$num,
|
||||
$site,
|
||||
$remote,
|
||||
$date);
|
||||
|
||||
$this->offreGw->addOffers($offre);
|
||||
|
||||
return $offre;
|
||||
|
||||
}
|
||||
public function getOffers() : array
|
||||
{
|
||||
$res = $this->offreGw->getOffers();
|
||||
$offers = $this->CreateOffersFromGw($res);
|
||||
return $offers;
|
||||
}
|
||||
|
||||
|
||||
public function getOfferFromId(int $id) : ?Offre
|
||||
{
|
||||
$res = $this->offreGw->getOfferFromId($id);
|
||||
if($res != null)
|
||||
return $this->CreateOffersFromGw($res)[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
public function CreateOffersFromGw($res) : array
|
||||
{
|
||||
$alGw = new AlumniGateway(new Connection(DB_HOST,DB_USER,DB_PASS));
|
||||
|
||||
$offers=[];
|
||||
foreach ($res as $row)
|
||||
{
|
||||
$resal = $alGw->ObtenirById($row['offreur']);
|
||||
$profilGw = new ProfilGateway(new Connection(DB_HOST,DB_USER,DB_PASS));
|
||||
$resProfl = $profilGw->getProfilById($row['offreur']);
|
||||
|
||||
$alumni = new Alumni($resal[0]['mail'],$resal[0]['mdp'],$resal[0]['role'],$resProfl[0]['nom'],$resProfl[0]["prenom"]);
|
||||
|
||||
$date = \DateTime::createFromFormat('Y-m-d', $row['date']);
|
||||
|
||||
$offers[]=new Offre(
|
||||
$row['id'],
|
||||
$alumni,
|
||||
$row['titre'],
|
||||
$row['description'],
|
||||
$row["image"],
|
||||
$row["logo"],
|
||||
$row['typeContrat'],
|
||||
$row['ville'],
|
||||
$row["entreprise"],
|
||||
$row['descriptifPoste'],
|
||||
$row['profil'],
|
||||
$row['experience'],
|
||||
$row['niveauEtudes'],
|
||||
$row['mailContact'],
|
||||
$row['numero'],
|
||||
$row['websiteURL'],
|
||||
$row['remote'],
|
||||
$date);
|
||||
}
|
||||
|
||||
|
||||
return $offers;
|
||||
}
|
||||
|
||||
public function getOfferLimit($start, $nbOffers): array
|
||||
{
|
||||
$res = $this->offreGw->getOfferLimit($start, $nbOffers);
|
||||
return $this->CreateOffersFromGw($res);
|
||||
}
|
||||
|
||||
public function getNbOffers() : int
|
||||
{
|
||||
return $this->offreGw->getNbOffers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getOffersWithFilters($params) : array
|
||||
{
|
||||
return $this->offreGw->getOffersWithFilters($params);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,304 @@
|
||||
<?php
|
||||
|
||||
namespace App\router;
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012 Danny van Kooten <hi@dannyvankooten.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
class AltoRouter
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array Array of all routes (incl. named routes).
|
||||
*/
|
||||
protected $routes = [];
|
||||
|
||||
/**
|
||||
* @var array Array of all named routes.
|
||||
*/
|
||||
protected $namedRoutes = [];
|
||||
|
||||
/**
|
||||
* @var string Can be used to ignore leading part of the Request URL (if main file lives in subdirectory of host)
|
||||
*/
|
||||
protected $basePath = '';
|
||||
|
||||
/**
|
||||
* @var array Array of default match types (regex helpers)
|
||||
*/
|
||||
protected $matchTypes = [
|
||||
'i' => '[0-9]++',
|
||||
'a' => '[0-9A-Za-z]++',
|
||||
'h' => '[0-9A-Fa-f]++',
|
||||
'*' => '.+?',
|
||||
'**' => '.++',
|
||||
'' => '[^/\.]++'
|
||||
];
|
||||
|
||||
/**
|
||||
* Create router in one call from config.
|
||||
*
|
||||
* @param array $routes
|
||||
* @param string $basePath
|
||||
* @param array $matchTypes
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(array $routes = [], $basePath = '', array $matchTypes = [])
|
||||
{
|
||||
$this->addRoutes($routes);
|
||||
$this->setBasePath($basePath);
|
||||
$this->addMatchTypes($matchTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all routes.
|
||||
* Useful if you want to process or display routes.
|
||||
* @return array All routes.
|
||||
*/
|
||||
public function getRoutes()
|
||||
{
|
||||
return $this->routes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add multiple routes at once from array in the following format:
|
||||
*
|
||||
* $routes = [
|
||||
* [$method, $route, $target, $name]
|
||||
* ];
|
||||
*
|
||||
* @param array $routes
|
||||
* @return void
|
||||
* @author Koen Punt
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addRoutes($routes)
|
||||
{
|
||||
if (!is_array($routes) && !$routes instanceof Traversable) {
|
||||
throw new RuntimeException('Routes should be an array or an instance of Traversable');
|
||||
}
|
||||
foreach ($routes as $route) {
|
||||
call_user_func_array([$this, 'map'], $route);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the base path.
|
||||
* Useful if you are running your application from a subdirectory.
|
||||
* @param string $basePath
|
||||
*/
|
||||
public function setBasePath($basePath)
|
||||
{
|
||||
$this->basePath = $basePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add named match types. It uses array_merge so keys can be overwritten.
|
||||
*
|
||||
* @param array $matchTypes The key is the name and the value is the regex.
|
||||
*/
|
||||
public function addMatchTypes(array $matchTypes)
|
||||
{
|
||||
$this->matchTypes = array_merge($this->matchTypes, $matchTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a route to a target
|
||||
*
|
||||
* @param string $method One of 5 HTTP Methods, or a pipe-separated list of multiple HTTP Methods (GET|POST|PATCH|PUT|DELETE)
|
||||
* @param string $route The route regex, custom regex must start with an @. You can use multiple pre-set regex filters, like [i:id]
|
||||
* @param mixed $target The target where this route should point to. Can be anything.
|
||||
* @param string $name Optional name of this route. Supply if you want to reverse route this url in your application.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function map($method, $route, $target, $name = null)
|
||||
{
|
||||
|
||||
$this->routes[] = [$method, $route, $target, $name];
|
||||
|
||||
if ($name) {
|
||||
if (isset($this->namedRoutes[$name])) {
|
||||
throw new RuntimeException("Can not redeclare route '{$name}'");
|
||||
}
|
||||
$this->namedRoutes[$name] = $route;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reversed routing
|
||||
*
|
||||
* Generate the URL for a named route. Replace regexes with supplied parameters
|
||||
*
|
||||
* @param string $routeName The name of the route.
|
||||
* @param array @params Associative array of parameters to replace placeholders with.
|
||||
* @return string The URL of the route with named parameters in place.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function generate($routeName, array $params = [])
|
||||
{
|
||||
|
||||
// Check if named route exists
|
||||
if (!isset($this->namedRoutes[$routeName])) {
|
||||
throw new RuntimeException("Route '{$routeName}' does not exist.");
|
||||
}
|
||||
|
||||
// Replace named parameters
|
||||
$route = $this->namedRoutes[$routeName];
|
||||
|
||||
// prepend base path to route url again
|
||||
$url = $this->basePath . $route;
|
||||
|
||||
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
|
||||
foreach ($matches as $index => $match) {
|
||||
list($block, $pre, $type, $param, $optional) = $match;
|
||||
|
||||
if ($pre) {
|
||||
$block = substr($block, 1);
|
||||
}
|
||||
|
||||
if (isset($params[$param])) {
|
||||
// Part is found, replace for param value
|
||||
$url = str_replace($block, $params[$param], $url);
|
||||
} elseif ($optional && $index !== 0) {
|
||||
// Only strip preceding slash if it's not at the base
|
||||
$url = str_replace($pre . $block, '', $url);
|
||||
} else {
|
||||
// Strip match block
|
||||
$url = str_replace($block, '', $url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Match a given Request Url against stored routes
|
||||
* @param string $requestUrl
|
||||
* @param string $requestMethod
|
||||
* @return array|boolean Array with route information on success, false on failure (no match).
|
||||
*/
|
||||
public function match($requestUrl = null, $requestMethod = null)
|
||||
{
|
||||
|
||||
$params = [];
|
||||
|
||||
// set Request Url if it isn't passed as parameter
|
||||
if ($requestUrl === null) {
|
||||
$requestUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
|
||||
}
|
||||
|
||||
// strip base path from request url
|
||||
$requestUrl = substr($requestUrl, strlen($this->basePath));
|
||||
|
||||
// Strip query string (?a=b) from Request Url
|
||||
if (($strpos = strpos($requestUrl, '?')) !== false) {
|
||||
$requestUrl = substr($requestUrl, 0, $strpos);
|
||||
}
|
||||
|
||||
$lastRequestUrlChar = $requestUrl ? $requestUrl[strlen($requestUrl)-1] : '';
|
||||
|
||||
// set Request Method if it isn't passed as a parameter
|
||||
if ($requestMethod === null) {
|
||||
$requestMethod = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
|
||||
}
|
||||
|
||||
foreach ($this->routes as $handler) {
|
||||
list($methods, $route, $target, $name) = $handler;
|
||||
|
||||
$method_match = (stripos($methods, $requestMethod) !== false);
|
||||
|
||||
// Method did not match, continue to next route.
|
||||
if (!$method_match) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($route === '*') {
|
||||
// * wildcard (matches all)
|
||||
$match = true;
|
||||
} elseif (isset($route[0]) && $route[0] === '@') {
|
||||
// @ regex delimiter
|
||||
$pattern = '`' . substr($route, 1) . '`u';
|
||||
$match = preg_match($pattern, $requestUrl, $params) === 1;
|
||||
} elseif (($position = strpos($route, '[')) === false) {
|
||||
// No params in url, do string comparison
|
||||
$match = strcmp($requestUrl, $route) === 0;
|
||||
} else {
|
||||
// Compare longest non-param string with url before moving on to regex
|
||||
// Check if last character before param is a slash, because it could be optional if param is optional too (see https://github.com/dannyvankooten/AltoRouter/issues/241)
|
||||
if (strncmp($requestUrl, $route, $position) !== 0 && ($lastRequestUrlChar === '/' || $route[$position-1] !== '/')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$regex = $this->compileRoute($route);
|
||||
$match = preg_match($regex, $requestUrl, $params) === 1;
|
||||
}
|
||||
|
||||
if ($match) {
|
||||
if ($params) {
|
||||
foreach ($params as $key => $value) {
|
||||
if (is_numeric($key)) {
|
||||
unset($params[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'target' => $target,
|
||||
'params' => $params,
|
||||
'name' => $name
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile the regex for a given route (EXPENSIVE)
|
||||
* @param $route
|
||||
* @return string
|
||||
*/
|
||||
protected function compileRoute($route)
|
||||
{
|
||||
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
|
||||
$matchTypes = $this->matchTypes;
|
||||
foreach ($matches as $match) {
|
||||
list($block, $pre, $type, $param, $optional) = $match;
|
||||
|
||||
if (isset($matchTypes[$type])) {
|
||||
$type = $matchTypes[$type];
|
||||
}
|
||||
if ($pre === '.') {
|
||||
$pre = '\.';
|
||||
}
|
||||
|
||||
$optional = $optional !== '' ? '?' : null;
|
||||
|
||||
//Older versions of PCRE require the 'P' in (?P<named>)
|
||||
$pattern = '(?:'
|
||||
. ($pre !== '' ? $pre : null)
|
||||
. '('
|
||||
. ($param !== '' ? "?P<$param>" : null)
|
||||
. $type
|
||||
. ')'
|
||||
. $optional
|
||||
. ')'
|
||||
. $optional;
|
||||
|
||||
$route = str_replace($block, $pattern, $route);
|
||||
}
|
||||
}
|
||||
return "`^$route$`u";
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Offre {{ offre.getNom() }}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in new issue