Merge branch 'master' into modules

This commit is contained in:
Etienne Roudeix
2013-11-25 10:05:01 +01:00
29 changed files with 242 additions and 53 deletions

View File

@@ -52,7 +52,7 @@ class CacheClear extends ContainerAwareCommand
"without-assets",
null,
InputOption::VALUE_NONE,
"remove cache assets"
"do not clear the assets cache in the web space"
)
;
}
@@ -82,17 +82,17 @@ class CacheClear extends ContainerAwareCommand
} catch (\UnexpectedValueException $e) {
// throws same exception code for does not exist and permission denied ...
if (!file_exists($dir)) {
$output->writeln(sprintf("<info>%s cache dir already clear</info>", $dir));
$output->writeln(sprintf("<info>%s cache dir already cleared</info>", $dir));
return;
}
throw $e;
} catch (IOException $e) {
$output->writeln(sprintf("Error during clearing cache : %s", $e->getMessage()));
$output->writeln(sprintf("Error during clearing of cache : %s", $e->getMessage()));
}
$output->writeln(sprintf("<info>%s cache dir cleared successfully</info>", $dir));
$output->writeln(sprintf("<info>%s cache directory cleared successfully</info>", $dir));
}
}

View File

@@ -63,8 +63,6 @@ class ModuleActivateCommand extends BaseModuleGenerate
}
try {
new \TheliaDebugBar\TheliaDebugBar();
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
$moduleInstance = $moduleReflection->newInstance();

View File

@@ -4,12 +4,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
<parameters>
<parameter key="thelia.actionEvent" type="collection">
</parameter>
</parameters>
<services>
<service id="thelia.action.cart" class="Thelia\Action\Cart">

View File

@@ -4,11 +4,15 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
<parameters>
<parameter key="esi.class">Symfony\Component\HttpKernel\HttpCache\Esi</parameter>
<parameter key="esi_listener.class">Symfony\Component\HttpKernel\EventListener\EsiListener</parameter>
<parameter key="fragment.renderer.esi.class">Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer</parameter>
<parameter key="fragment.renderer.inline.class">Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer</parameter>
</parameters>
<services>
<!-- URL maganement -->
<service id="thelia.url.manager" class="Thelia\Tools\URL">
<argument type="service" id="service_container" />
</service>
@@ -17,6 +21,20 @@
<argument type="service" id="service_container" />
</service>
<service id="esi" class="%esi.class%" />
<service id="esi_listener" class="%esi_listener.class%">
<tag name="kernel.event_subscriber" />
<argument type="service" id="esi" on-invalid="ignore" />
</service>
<service id="fragment.renderer.inline" class="%fragment.renderer.inline.class%">
<argument type="service" id="http_kernel" />
</service>
<service id="fragment.renderer.esi" class="%fragment.renderer.esi.class%">
<argument type="service" id="esi" />
<argument type="service" id="fragment.renderer.inline" />
</service>
<!--
A ControllerResolver that supports "a:b:c", "service:method" and class::method" notations,
thus allowing the definition of controllers as service (see http://symfony.com/fr/doc/current/cookbook/controller/service.html)
@@ -70,8 +88,6 @@
<service id="mailer" class="Thelia\Mailer\MailerFactory">
<argument type="service" id="event_dispatcher"/>
</service>
</services>
</config>

View File

@@ -91,7 +91,11 @@
<argument type="service" id="request" />
</service>
<service id="smarty.plugin.esi" class="Thelia\Core\Template\Smarty\Plugins\Esi" scope="request">
<tag name="thelia.parser.register_plugin"/>
<argument type="service" id="fragment.renderer.esi" />
<argument type="service" id="request" />
</service>
</services>

View File

@@ -22,6 +22,7 @@
/*************************************************************************************/
namespace Thelia\Core\Bundle;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Scope;
@@ -61,7 +62,7 @@ class TheliaBundle extends Bundle
$container
->addCompilerPass(new TranslatorPass())
->addCompilerPass(new RegisterListenersPass())
->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_AFTER_REMOVING)
->addCompilerPass(new RegisterParserPluginPass())
->addCompilerPass(new RegisterRouterPass())
->addCompilerPass(new RegisterCouponPass())

View File

@@ -85,19 +85,11 @@ class ViewListener implements EventSubscriberInterface
$content = $parser->render($request->attributes->get('_view').".html");
if ($content instanceof Response) {
$response = $content;$event->setResponse($content);
$response = $content;
} else {
$response = new Response($content, $parser->getStatus() ?: 200);
}
/* $response->setCache(array(
'last_modified' => new \DateTime(),
'max_age' => 600,
's_maxage' => 600,
'private' => false,
'public' => true,
));*/
$event->setResponse($response);
} catch (ResourceNotFoundException $e) {
throw new NotFoundHttpException();

View File

@@ -0,0 +1,71 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\HttpKernel\HttpCache;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpCache\Esi;
use Symfony\Component\HttpKernel\HttpCache\HttpCache as BaseHttpCache;
use Symfony\Component\HttpKernel\HttpCache\Store;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Thelia\Core\HttpFoundation\Request as TheliaRequest;
/**
* Class HttpCache
* @package Thelia\Core\HttpKernel\HttpCache
* @author manuel raynaud <mraynaud@openstudio.fr>
*/
class HttpCache extends BaseHttpCache implements HttpKernelInterface
{
public function __construct(HttpKernelInterface $kernel, $options = array())
{
parent::__construct(
$kernel,
new Store($kernel->getCacheDir().'/http_cache'),
new Esi(),
array_merge(
array('debug' => $kernel->isDebug()),
$options
)
);
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
if (!($request instanceof \Thelia\Core\HttpFoundation\Request)) {
$request = TheliaRequest::create(
$request->getUri(),
$request->getMethod(),
$request->getMethod() == 'GET' ? $request->query->all() : $request->request->all(),
$request->cookies->all(),
$request->files->all(),
$request->server->all(),
$request->getContent()
);
}
return parent::handle($request, $type, $catch);
}
}

View File

@@ -0,0 +1,82 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Template\Smarty\Plugins;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer;
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Template\Smarty\an;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
/**
* Class Esi
* @package Thelia\Core\Template\Smarty\Plugins
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Esi extends AbstractSmartyPlugin
{
protected $esiFragmentRender;
protected $request;
public function __construct(EsiFragmentRenderer $esiFragmentRenderer, Request $request)
{
$this->esiFragmentRender = $esiFragmentRenderer;
$this->request = $request;
}
public function renderEsi($params, $template = null)
{
$path = $this->getParam($params, 'path');
$alt = $this->getParam($params, 'alt');
$ignore_errors = $this->getParam($params, 'ignore_errors');
$comment = $this->getParam($params, 'comment');
if(null === $path) {
return;
}
$response = $this->esiFragmentRender->render($path, $this->request, array(
'alt' => $alt,
'ignore_errors' => $ignore_errors,
'comment' => $comment
));
if (!$response->isSuccessful()) {
return null;
}
return $response->getContent();
}
/**
* @return an array of SmartyPluginDescriptor
*/
public function getPluginDescriptors()
{
return array(
new SmartyPluginDescriptor('function', 'render_esi', $this, 'renderEsi')
);
}
}

View File

@@ -43,6 +43,7 @@ use Thelia\Model;
class TheliaHttpKernel extends HttpKernel
{
protected static $session;
protected $container;
@@ -79,8 +80,11 @@ 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->initParam($request);
if ($type == HttpKernelInterface::MASTER_REQUEST) {
$request = $this->initSession($request);
$this->initParam($request);
}
$this->container->enterScope('request');
$this->container->set('request', $request, 'request');
@@ -211,26 +215,29 @@ class TheliaHttpKernel extends HttpKernel
protected function initSession(Request $request)
{
if(null === self::$session) {
$storage = new Session\Storage\NativeSessionStorage();
$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", 'Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler');
if (Model\ConfigQuery::read("session_config.default")) {
$storage->setSaveHandler(new Session\Storage\Handler\NativeFileSessionHandler(Model\ConfigQuery::read("session_config.save_path", THELIA_LOCAL_DIR . 'session/')));
$handler = new $handlerString;
$storage->setSaveHandler($handler);
}
if (Model\ConfigQuery::read("session_config.config", null)) {
$storage->setOptions(json_decode(Model\ConfigQuery::read("session_config.config")));
}
self::$session = $session = new \Thelia\Core\HttpFoundation\Session\Session($storage);
} else {
$handlerString = Model\ConfigQuery::read("session_config.handlers", 'Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler');
$handler = new $handlerString;
$storage->setSaveHandler($handler);
$session = self::$session;
}
if (Model\ConfigQuery::read("session_config.config", null)) {
$storage->setOptions(json_decode(Model\ConfigQuery::read("session_config.config")));
}
$session = new \Thelia\Core\HttpFoundation\Session\Session($storage);
$session->start();
$request->setSession($session);
return $request;

View File

@@ -84,7 +84,7 @@ class CustomerCreateForm extends AddressCreateForm
array($this, "verifyPasswordField")
)))
),
"label" => "Password confirmation",
"label" => Translator::getInstance()->trans("Password confirmation"),
"label_attr" => array(
"for" => "password_confirmation"
)
@@ -102,6 +102,7 @@ class CustomerCreateForm extends AddressCreateForm
"constraints" => array(
new Constraints\True(array("message" => "Please accept the Terms and conditions in order to register."))
),
"label"=>"Test",
"label_attr" => array(
"for" => "agreed"
)