From 47ccf66db523a26cad1819d5c47b6a5c2c44cd58 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 5 Oct 2012 17:44:35 +0200 Subject: [PATCH] =?UTF-8?q?d=C3=A9but=20d'=C3=A9criture=20de=20la=20classe?= =?UTF-8?q?=20principale=20Thelia=20Elle=20h=C3=A9rite=20de=20Symfony\Comp?= =?UTF-8?q?onent\HttpKernel\Kernel=20(/!\=20aux=20interfaces)=20mise=20en?= =?UTF-8?q?=20place=20d'un=20conteneur=20d'injection=20de=20d=C3=A9pendanc?= =?UTF-8?q?e=20=C3=A0=20modifier/compl=C3=A9ter=20(voir=20comment=20g?= =?UTF-8?q?=C3=A9rer=20le=20chargement)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/bootstrap.php | 2 ++ core/lib/Thelia/Core/Thelia.php | 62 +++++++++++++++++++++++++++++++-- index.php | 4 --- index_dev.php | 13 +++---- local/config/container.php | 25 +++++++++++++ 5 files changed, 94 insertions(+), 12 deletions(-) create mode 100644 local/config/container.php diff --git a/core/bootstrap.php b/core/bootstrap.php index 20a539efe..d3a2a383f 100644 --- a/core/bootstrap.php +++ b/core/bootstrap.php @@ -17,5 +17,7 @@ use Symfony\Component\DependencyInjection\Reference; $loader = require __DIR__ . '/autoload.php'; +define('THELIA_ROOT', __DIR__ .'/../'); + ?> diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index 6f197424b..b0f7a98c6 100644 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -2,11 +2,69 @@ namespace Thelia\Core; +/** + * Root class of Thelia + * + * + * @author Manuel Raynaud + */ + + +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{ +class Thelia extends Kernel { + const version = '0.0.1'; + + + 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){ + + } } diff --git a/index.php b/index.php index f35abc7bd..f31f4cbf5 100644 --- a/index.php +++ b/index.php @@ -1,8 +1,4 @@ diff --git a/index_dev.php b/index_dev.php index 54073361f..ec67ba544 100644 --- a/index_dev.php +++ b/index_dev.php @@ -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(); - - ?> diff --git a/local/config/container.php b/local/config/container.php new file mode 100644 index 000000000..bdd3471f5 --- /dev/null +++ b/local/config/container.php @@ -0,0 +1,25 @@ +register('database','Thelia\\Database\\Connection'); + +$container->register('http_kernel','Symfony\\Component\\HttpKernel\\HttpKernel'); + +$container->register('session','Symfony\\Component\\HttpFoundation\\Session\\Session'); + + +return $container; +?>