137b5e76 |
<?php
|
daf6e125 |
namespace MVC\Classe;
|
137b5e76 |
|
96549497 |
use Symfony\Component\Config\FileLocator as FileLocator;
use Symfony\Component\Routing\Matcher\UrlMatcher as UrlMatcher;
use Symfony\Component\Routing\RequestContext as RequestContext;
use Symfony\Component\Routing\Loader\YamlFileLoader as YamlFileLoader;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
8d6a2feb |
require APPLICATION_PATH . DIRECTORY_SEPARATOR . "parameters.php";
|
ff461209 |
|
137b5e76 |
class Application
{
|
fa275ca6 |
public $http;
|
96549497 |
public $url;
|
fa275ca6 |
public $browser;
|
96549497 |
public function __construct(){
|
fa275ca6 |
$this->http = new HttpMethod();
$this->browser = new Browser();
$this->url = new Url($this->http->method, $this->browser->isAppRequest());
|
96549497 |
}
public function launch(){
try {
//load config file
$fileLocator = new FileLocator(array(CONFIG_PATH . DIRECTORY_SEPARATOR . 'files'));
$loader = new YamlFileLoader($fileLocator);
$routes = $loader->load('routing.yml');
//create context
$context = new RequestContext('/');
$matcher = new UrlMatcher($routes, $context);
|
ff461209 |
|
96549497 |
// Find the current route
$parameters = $matcher->match($_SERVER['REQUEST_URI']);
|
ff461209 |
|
96549497 |
echo '<pre>';
print_r($parameters);
die();
} catch (ResourceNotFoundException $e) {
echo $e->getMessage();
}
$controlleur = new Controlleur($this);
//si la page n'est un controlleur d'action alors on affiche l'écran
if(!$this->url->page['control']) {
|
3957c7ee |
print($controlleur->vue->ecran);
}
|
96549497 |
}
|
137b5e76 |
}
|