diff --git a/core/lib/Thelia/Core/Bundle/ModelBundle.php b/core/lib/Thelia/Core/Bundle/ModelBundle.php
new file mode 100644
index 000000000..a488a722c
--- /dev/null
+++ b/core/lib/Thelia/Core/Bundle/ModelBundle.php
@@ -0,0 +1,40 @@
+
+ */
+
+class ModelBundle extends Bundle
+{
+ /**
+ *
+ * Construct the depency injection builder
+ *
+ * Reference all Model in the Container here
+ *
+ * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
+ */
+
+ public function build(ContainerBuilder $container)
+ {
+ foreach(DIGenerator::genDiModel(realpath(THELIA_ROOT . "core/lib/Thelia/Model"), array('Base')) as $name => $class)
+ {
+ $container->register('model.'.$name, $class)
+ ->addArgument(new Reference("database"));
+ }
+ }
+}
diff --git a/core/lib/Thelia/Core/Bundle/NotORMBundle.php b/core/lib/Thelia/Core/Bundle/NotORMBundle.php
new file mode 100644
index 000000000..bf58c5351
--- /dev/null
+++ b/core/lib/Thelia/Core/Bundle/NotORMBundle.php
@@ -0,0 +1,93 @@
+
+ */
+
+class NotORMBundle extends Bundle
+{
+ /**
+ *
+ * Construct the depency injection builder
+ *
+ * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
+ */
+
+ public function build(ContainerBuilder $container)
+ {
+ $config = array();
+
+ $kernel = $container->get('kernel');
+
+ $pdo = new \PDO(THELIA_DB_DSN,THELIA_DB_USER, THELIA_DB_PASSWORD, $config);
+
+ $pdo->exec("SET NAMES UTF8");
+
+ $container->register('database','\Thelia\Database\NotORM')
+ ->addArgument($pdo);
+
+ if(defined('THELIA_DB_CACHE') && !$kernel->isDebug())
+ {
+ switch(THELIA_DB_CACHE)
+ {
+ case 'file':
+ $container->register('database_cache','\NotORM_Cache_File')
+ ->addArgument($kernel->getCacheDir().'/database.php');
+ break;
+ case 'include':
+ $container->register('database_cache','\NotORM_Cache_Include')
+ ->addArgument($kernel->getCacheDir().'/database_include.php');
+ break;
+ case 'apc':
+ if (extension_loaded('apc'))
+ {
+ $container->register('database_cache','\NotORM_Cache_APC');
+ }
+ break;
+ case 'session':
+ $container->register('database_cache','\NotORM_Cache_Session');
+ break;
+ case 'memcache':
+ if(class_exists('Memcache'))
+ {
+ $container->register('database_cache','\NotORM_Cache_Memcache')
+ ->addArgument(new \Memcache());
+ }
+ break;
+
+ }
+
+ if($container->hasDefinition('database_cache'))
+ {
+ $container->getDefinition('database')
+ ->addMethodCall('setCache', array(new Reference('database_cache')));
+ }
+ }
+
+ if($kernel->isDebug())
+ {
+ $debug = function ($query, $parameters)
+ {
+ echo $query."
";
+ };
+
+ $container->getDefinition('database')
+ ->addMethodCall('setDebug', array($debug));
+ }
+
+
+ }
+}
diff --git a/core/lib/Thelia/Core/Bundle/TheliaBundle.php b/core/lib/Thelia/Core/Bundle/TheliaBundle.php
new file mode 100644
index 000000000..2e2900fec
--- /dev/null
+++ b/core/lib/Thelia/Core/Bundle/TheliaBundle.php
@@ -0,0 +1,98 @@
+
+ */
+
+class TheliaBundle extends Bundle
+{
+ /**
+ *
+ * Construct the depency injection builder
+ *
+ * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
+ */
+
+ public function build(ContainerBuilder $container)
+ {
+ $container->addScope( new Scope('request'));
+
+ $container->register('request', 'Symfony\Component\HttpFoundation\Request')
+ ->setSynthetic(true);
+
+ $container->register('controller.default','Thelia\Controller\DefaultController');
+ $container->register('matcher.default','Thelia\Routing\Matcher\DefaultMatcher')
+ ->addArgument(new Reference('controller.default'));
+
+ $container->register('matcher','Thelia\Routing\Matcher\theliaMatcherCollection')
+ ->addMethodCall('add', array(new Reference('matcher.default'), -255))
+ //->addMethodCall('add','a matcher class (instance or class name)
+
+ ;
+
+ $container->register('resolver', 'Symfony\Component\HttpKernel\Controller\ControllerResolver');
+
+ $container->register('parser','Thelia\Core\Template\Parser')
+ ->addArgument(new Reference('service_container'))
+ ;
+
+// $container->setParameter("logger.class", "\Thelia\Log\Tlog");
+// $container->register("logger","%logger.class%");
+ /**
+ * RouterListener implements EventSubscriberInterface and listen for kernel.request event
+ */
+ $container->register('listener.router', 'Symfony\Component\HttpKernel\EventListener\RouterListener')
+ ->setArguments(array(new Reference('matcher')))
+ ;
+
+ /**
+ * @TODO add an other listener on kernel.request for checking some params Like check if User is log in, set the language and other.
+ *
+ * $container->register()
+ *
+ *
+ * $container->register('listener.request', 'Thelia\Core\EventListener\RequestListener')
+ * ->addArgument(new Reference('');
+ * ;
+ */
+
+ $container->register('thelia.listener.view','Thelia\Core\EventListener\ViewListener')
+ ->addArgument(new Reference('parser'))
+ ;
+
+
+
+ $container->register('dispatcher','Symfony\Component\EventDispatcher\EventDispatcher')
+ ->addArgument(new Reference('service_container'))
+ ->addMethodCall('addSubscriber', array(new Reference('listener.router')))
+ ->addMethodCall('addSubscriber', array(new Reference('thelia.listener.view')))
+ ;
+
+ $container->register('http_kernel','Thelia\Core\TheliaHttpKernel')
+ ->addArgument(new Reference('dispatcher'))
+ ->addArgument(new Reference('service_container'))
+ ->addArgument(new Reference('resolver'))
+ ;
+
+ // DEFINE DEFAULT PARAMETER LIKE
+
+ /**
+ * @TODO learn about container compilation
+ */
+
+ }
+}
diff --git a/core/lib/Thelia/Core/Template/Parser.php b/core/lib/Thelia/Core/Template/Parser.php
index a35d7d242..d6ef0f9fe 100644
--- a/core/lib/Thelia/Core/Template/Parser.php
+++ b/core/lib/Thelia/Core/Template/Parser.php
@@ -58,8 +58,8 @@ class Parser implements ParserInterface
$this->content = $request->get("test");
- var_dump($this->container->get("database"));
-
+ $config = $this->container->get("model.config");
+
return $this->content;
}
diff --git a/core/lib/Thelia/Database/NotORM.php b/core/lib/Thelia/Database/NotORM.php
new file mode 100644
index 000000000..db87484c0
--- /dev/null
+++ b/core/lib/Thelia/Database/NotORM.php
@@ -0,0 +1,22 @@
+cache = $cache;
+ }
+
+ public function setDebug($debug)
+ {
+ if(is_callable($debug))
+ {
+ $this->debug = $debug;
+ } else {
+ $this->debug = true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/core/lib/Thelia/Log/Tlog.php b/core/lib/Thelia/Log/Tlog.php
new file mode 100644
index 000000000..177f1484f
--- /dev/null
+++ b/core/lib/Thelia/Log/Tlog.php
@@ -0,0 +1,377 @@
+init();
+ }
+
+ return self::$instance;
+ }
+
+ protected function init() {
+ $niveau = Config::read(self::VAR_NIVEAU, self::DEFAUT_NIVEAU);
+
+ $this->set_niveau($niveau);
+
+ $this->dir_destinations = array(
+ __DIR__.'/tlog/destinations'
+ //, __DIR__.'/../client/tlog/destinations'
+ );
+
+ $this->set_prefixe(Config::read(self::VAR_PREFIXE, self::DEFAUT_PREFIXE));
+ $this->set_files(Config::read(self::VAR_FILES, self::DEFAUT_FILES));
+ $this->set_ip(Config::read(self::VAR_IP, self::DEFAUT_IP));
+ $this->set_destinations(Config::read(self::VAR_DESTINATIONS, self::DEFAUT_DESTINATIONS));
+ $this->set_show_redirect(Config::read(self::VAR_SHOW_REDIRECT, self::DEFAUT_SHOW_REDIRECT));
+
+ // Au cas ou il y aurait un exit() quelque part dans le code.
+ register_shutdown_function(array($this, 'ecrire_si_exit'));
+ }
+
+ // Configuration
+ // -------------
+
+ public function set_destinations($destinations) {
+ if (! empty($destinations)) {
+
+ $this->destinations = array();
+
+ $classes_destinations = explode(';', $destinations);
+ $this->charger_classes_destinations($this->destinations, $classes_destinations);
+ }
+ }
+
+ public function set_niveau($niveau) {
+ $this->niveau = $niveau;
+ }
+
+ public function set_prefixe($prefixe) {
+
+ $this->prefixe = $prefixe;
+ }
+
+ public function set_files($files) {
+ $this->files = explode(";", $files);
+
+ $this->all_files = in_array('*', $this->files);
+ }
+
+ public function set_ip($ips) {
+ if (! empty($ips) && ! in_array($_SERVER['REMOTE_ADDR'], explode(";", $ips))) $this->niveau = self::MUET;
+ }
+
+ public function set_show_redirect($bool) {
+ $this->show_redirect = $bool;
+ }
+
+ // Configuration d'une destination
+ public function set_config($destination, $param, $valeur) {
+
+ if (isset($this->destinations[$destination])) {
+ $this->destinations[$destination]->set_config($param, $valeur);
+ }
+ }
+
+ // Configuration d'une destination
+ public function get_config($destination, $param) {
+
+ if (isset($this->destinations[$destination])) {
+ return $this->destinations[$destination]->get_config($param);
+ }
+
+ return false;
+ }
+
+ // Methodes d'accès aux traces
+ // ---------------------------
+
+ public static function trace() {
+ if (Tlog::instance()->niveau > self::TRACE)
+ return;
+
+ $args = func_get_args();
+
+ Tlog::instance()->out("TRACE", $args);
+ }
+
+ public static function debug() {
+ if (Tlog::instance()->niveau > self::DEBUG)
+ return;
+
+ $args = func_get_args();
+
+ Tlog::instance()->out("DEBUG", $args);
+ }
+
+ public static function info() {
+ if (Tlog::instance()->niveau > self::INFO)
+ return;
+
+ $args = func_get_args();
+
+ Tlog::instance()->out("INFO", $args);
+ }
+
+ public static function warning() {
+ if (Tlog::instance()->niveau > self::WARNING)
+ return;
+
+ $args = func_get_args();
+
+ Tlog::instance()->out("WARNING", $args);
+ }
+
+ public static function error() {
+ if (Tlog::instance()->niveau > self::ERROR)
+ return;
+
+ $args = func_get_args();
+
+ Tlog::instance()->out("ERREUR", $args);
+ }
+
+ public static function fatal() {
+ if (Tlog::instance()->niveau > self::FATAL)
+ return;
+
+ $args = func_get_args();
+
+ Tlog::instance()->out("FATAL", $args);
+ }
+
+ // Mode back office
+ public static function mode_back_office($booleen) {
+
+ foreach(Tlog::instance()->destinations as $dest) {
+ $dest->mode_back_office($booleen);
+ }
+ }
+
+ // Ecriture finale
+ public static function ecrire(&$res) {
+
+ self::$ecrire_effectue = true;
+
+ // Muet ? On ne fait rien
+ if (Tlog::instance()->niveau == self::MUET) return;
+
+ foreach(Tlog::instance()->destinations as $dest) {
+ $dest->ecrire($res);
+ }
+ }
+
+ public static function ecrire_si_exit() {
+ // Si les infos de debug n'ont pas été ecrites, le faire maintenant
+ if (self::$ecrire_effectue === false) {
+
+ $res = "";
+
+ self::ecrire($res);
+
+ echo $res;
+ }
+ }
+
+ public function afficher_redirections($url) {
+
+ if ($this->niveau != self::MUET && $this->show_redirect) {
+ echo "
+
+