début d'écriture de la classe principale Thelia

Elle hérite de Symfony\Component\HttpKernel\Kernel (/!\ aux interfaces)
mise en place d'un conteneur d'injection de dépendance à
modifier/compléter (voir comment gérer le chargement)
This commit is contained in:
Manuel Raynaud
2012-10-05 17:44:35 +02:00
parent 56446d0aa3
commit 47ccf66db5
5 changed files with 94 additions and 12 deletions

View File

@@ -17,5 +17,7 @@ use Symfony\Component\DependencyInjection\Reference;
$loader = require __DIR__ . '/autoload.php';
define('THELIA_ROOT', __DIR__ .'/../');
?>

View File

@@ -2,11 +2,69 @@
namespace Thelia\Core;
/**
* Root class of Thelia
*
*
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class Thelia extends Kernel {
const version = '0.0.1';
class Thelia extends Kernel{
protected function initializeContainer(){
if(false === $container = require THELIA_ROOT . '/local/config/container.php'){
/**
* @todo redirect to installation process
*
*/
}
$this->container = $container;
$this->container->set('kernel', $this);
}
/**
*
* @return \Symfony\Component\DependencyInjection\ContainerBuilder
*/
public function getContainer(){
return $this->container;
}
/**
* return available bundle
*
* Part of Symfony\Component\HttpKernel\KernelInterface
*
*/
public function registerBundles() {
}
/**
* Loads the container configuration
*
* part of Symfony\Component\HttpKernel\KernelInterface
*
* @param LoaderInterface $loader A LoaderInterface instance
*
* @api
*/
public function registerContainerConfiguration(LoaderInterface $loader){
}
}

View File

@@ -1,8 +1,4 @@
<?php
require __DIR__ . '/core/bootstrap.php';
?>

View File

@@ -3,6 +3,8 @@
use Symfony\Component\HttpFoundation\Request;
use Thelia\Core\Thelia;
use Symfony\Component\DependencyInjection;
$env = 'debug';
require __DIR__ . '/core/bootstrap.php';
@@ -18,14 +20,13 @@ if( false === in_array($request->getClientIp(), $trustIp)){
}
//$thelia = new Thelia('dev');
////
$thelia = new Thelia('dev', true);
var_dump($thelia->getContainer());
//$response = $thelia->handle($request)->prepare($request)->send();
////
//
//$thelia->terminate($request, $reponse);
Thelia::run()->send();
?>

View File

@@ -0,0 +1,25 @@
<?php
if(is_file(__DIR__ . '/config_db.php')){
require __DIR__ . '/config_db.php';
}
else{
return false;
}
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
$container = new ContainerBuilder();
$container->register('database','Thelia\\Database\\Connection');
$container->register('http_kernel','Symfony\\Component\\HttpKernel\\HttpKernel');
$container->register('session','Symfony\\Component\\HttpFoundation\\Session\\Session');
return $container;
?>