parent
e12271a57c
commit
8045f7f375
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Autoload
|
||||||
|
{
|
||||||
|
private static $_instance = null;
|
||||||
|
|
||||||
|
public static function charger()
|
||||||
|
{
|
||||||
|
if(null !== self::$_instance) {
|
||||||
|
throw new RuntimeException(sprintf('%s is already started', __CLASS__));
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$_instance = new self();
|
||||||
|
|
||||||
|
|
||||||
|
if(!spl_autoload_register(array(self::$_instance, '_autoload'), false)) {
|
||||||
|
throw new RuntimeException(sprintf('%s : Could not start the autoload', __CLASS__));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function shutDown()
|
||||||
|
{
|
||||||
|
if(null !== self::$_instance) {
|
||||||
|
|
||||||
|
if(!spl_autoload_unregister(array(self::$_instance, '_autoload'))) {
|
||||||
|
throw new RuntimeException('Could not stop the autoload');
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$_instance = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function _autoload($class)
|
||||||
|
{
|
||||||
|
global $rep;
|
||||||
|
$filename = $class.'.php';
|
||||||
|
$dir =array('Model/','./','Config/','Controller/');
|
||||||
|
foreach ($dir as $d){
|
||||||
|
$file=$rep.$d.$filename;
|
||||||
|
//echo $file;
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
include $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -1,24 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once './Config/Config.php';
|
require_once(__DIR__.'/config/config.php');
|
||||||
require_once "./Config/Connection.php";
|
require_once(__DIR__.'/config/Autoload.php');
|
||||||
require_once './Config/Validation.php';
|
Autoload::charger();
|
||||||
|
|
||||||
require_once "./Model/Joueur.php";
|
|
||||||
require_once "./Model/Enigme.php";
|
|
||||||
|
|
||||||
require_once './Controller/JoueurGateway.php';
|
|
||||||
require_once './Controller/EnigmeGateway.php';
|
|
||||||
|
|
||||||
require_once './Controller/JoueurNotFoundException.php';
|
|
||||||
require_once './Controller/InvalidMdpException.php';
|
|
||||||
|
|
||||||
require_once './Controller/Controller.php';
|
|
||||||
|
|
||||||
//unset($_SESSION['connected']);
|
|
||||||
|
|
||||||
$con = new Connection($dsn, $user, $password);
|
$con = new Connection($dsn, $user, $password);
|
||||||
$control = new Controller($con);
|
$control = new Controller($con);
|
||||||
|
|
||||||
session_unset(); //efface les variable session
|
session_unset();
|
||||||
session_destroy();//détruit la session
|
session_destroy();
|
||||||
$_SESSION = null;//histoire d'être sûre
|
$_SESSION = null;
|
Loading…
Reference in new issue