diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 94e00ab81..edb8d2a1d 100644 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -36,7 +36,7 @@ class Cart extends BaseAction */ public function addCart(Request $request) { - var_dump($this->getDispatcher()); exit; + } /** diff --git a/core/lib/Thelia/Core/Template/Parser.php b/core/lib/Thelia/Core/Template/Parser.php index ba39d2613..fc2c597b1 100644 --- a/core/lib/Thelia/Core/Template/Parser.php +++ b/core/lib/Thelia/Core/Template/Parser.php @@ -73,7 +73,7 @@ class Parser implements ParserInterface public function getContent() { $this->loadParser(); - + echo \Thelia\Model\ConfigQuery::read("alfred", "dupont"); \Thelia\Log\Tlog::getInstance()->debug("tutu"); diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index 856b1d402..a709e4937 100644 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -34,8 +34,11 @@ namespace Thelia\Core; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; + + use Thelia\Core\Bundle; use Thelia\Log\Tlog; + use Propel; use PropelConfiguration; @@ -76,9 +79,19 @@ class Thelia extends Kernel */ public function loadConfiguration() { - $request = $this->getContainer()->get('request'); + } + /** + * + * initialize session in Request object + * + * All param must be change in Config table + * + * @param \Symfony\Component\HttpFoundation\Request $request + */ + + /** * * boot parent kernel and after current kernel @@ -86,6 +99,9 @@ class Thelia extends Kernel */ public function boot() { + + + parent::boot(); $this->loadConfiguration(); diff --git a/core/lib/Thelia/Core/TheliaHttpKernel.php b/core/lib/Thelia/Core/TheliaHttpKernel.php index 9d63f420e..00b038d08 100644 --- a/core/lib/Thelia/Core/TheliaHttpKernel.php +++ b/core/lib/Thelia/Core/TheliaHttpKernel.php @@ -28,6 +28,9 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\HttpFoundation\Session; + +use Thelia\Model; /** * @@ -63,7 +66,7 @@ class TheliaHttpKernel extends HttpKernel public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) { //$request->headers->set('X-Php-Ob-Level', ob_get_level()); - + $request = $this->initSession($request); $this->container->enterScope('request'); $this->container->set('request', $request, 'request'); @@ -79,4 +82,32 @@ class TheliaHttpKernel extends HttpKernel return $response; } + + protected function initSession(Request $request) + { + + $storage = new Session\Storage\NativeSessionStorage(); + + if (Model\ConfigQuery::read("session_config.default")) { + $storage->setSaveHandler(new Session\Storage\Handler\NativeFileSessionHandler(Model\ConfigQuery::read("session_config.save_path", THELIA_ROOT . '/local/session/'))); + } else { + $handlerString = Model\ConfigQuery::read("session_config.handlers"); + + $handler = new $handlerString; + + $storage->setSaveHandler($handler); + } + + if (Model\ConfigQuery::read("session_config.config", null)) { + $storage->setOptions(json_decode(Model\ConfigQuery::read("session_config.config"))); + } + + + $session = new Session\Session($storage); + $session->start(); + + $request->setSession($session); + + return $request; + } } diff --git a/core/lib/Thelia/Model/ConfigQuery.php b/core/lib/Thelia/Model/ConfigQuery.php index 95686c624..1fac99e2b 100644 --- a/core/lib/Thelia/Model/ConfigQuery.php +++ b/core/lib/Thelia/Model/ConfigQuery.php @@ -18,7 +18,7 @@ use Thelia\Model\om\BaseConfigQuery; */ class ConfigQuery extends BaseConfigQuery { - public static function read($search, $default) + public static function read($search, $default = null) { $value = self::create()->findOneByName($search); diff --git a/local/session/.gitkeep b/local/session/.gitkeep new file mode 100644 index 000000000..e69de29bb