This commit is contained in:
franck
2013-09-16 12:52:59 +02:00
34 changed files with 784 additions and 350 deletions

View File

@@ -337,6 +337,7 @@ final class TheliaEvents
const BEFORE_DELETECURRENCY = "action.before_deleteCurrency";
const AFTER_DELETECURRENCY = "action.after_deleteCurrency";
const CHANGE_DEFAULT_CURRENCY = 'action.changeDefaultCurrency';
// -- Product templates management -----------------------------------------
const TEMPLATE_CREATE = "action.createTemplate";

View File

@@ -94,7 +94,7 @@ class ViewListener implements EventSubscriberInterface
{
$request = $this->container->get('request');
if (!$view = $request->attributes->get('_view')) {
if (null === $view = $request->attributes->get('_view')) {
$request->attributes->set('_view', $this->findView($request));
}

View File

@@ -164,10 +164,12 @@ class Session extends BaseSession
$cart = null;
if ($cart_id) {
$cart = CartQuery::create()->findPk($cart_id);
try {
$this->verifyValidCart($cart);
} catch (InvalidCartException $e) {
$cart = null;
if($cart) {
try {
$this->verifyValidCart($cart);
} catch (InvalidCartException $e) {
$cart = null;
}
}
}

View File

@@ -73,7 +73,7 @@ abstract class BaseI18nLoop extends BaseLoop
$columns,
$foreignTable,
$foreignKey,
$forceReturn
$this->getForce_return()
);
}
}

View File

@@ -89,6 +89,7 @@ abstract class BaseLoop
Argument::createIntTypeArgument('page'),
Argument::createIntTypeArgument('limit', PHP_INT_MAX),
Argument::createBooleanTypeArgument('backend_context', false),
Argument::createBooleanTypeArgument('force_return', false),
);
}

View File

@@ -37,6 +37,7 @@ use Thelia\Model\Product;
use Thelia\Model\ProductQuery;
use Thelia\Model\Tools\ModelCriteriaTools;
use Thelia\Tools\DateTimeFormat;
use Thelia\Cart\CartTrait;
/**
* Implementation of data access to main Thelia objects (users, cart, etc.)
@@ -46,6 +47,8 @@ use Thelia\Tools\DateTimeFormat;
*/
class DataAccessFunctions extends AbstractSmartyPlugin
{
use CartTrait;
private $securityContext;
protected $parserContext;
protected $request;
@@ -151,6 +154,20 @@ class DataAccessFunctions extends AbstractSmartyPlugin
}
}
public function cartDataAccess($params, $smarty)
{
$cart = $this->getCart($this->request);
$result = "";
switch($params["attr"]) {
case "count_item":
$result = $cart->getCartItems()->count();
break;
}
return $result;
}
/**
* Lang global data
*
@@ -263,6 +280,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
new SmartyPluginDescriptor('function', 'folder', $this, 'folderDataAccess'),
new SmartyPluginDescriptor('function', 'currency', $this, 'currencyDataAccess'),
new SmartyPluginDescriptor('function', 'lang', $this, 'langDataAccess'),
new SmartyPluginDescriptor('function', 'cart', $this, 'cartDataAccess'),
);
}
}

View File

@@ -32,6 +32,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Session;
use Thelia\Core\Event\CurrencyEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model;
/**
@@ -146,6 +148,9 @@ class TheliaHttpKernel extends HttpKernel
$currency = null;
if ($request->query->has("currency")) {
$currency = Model\CurrencyQuery::create()->findOneByCode($request->query->get("currency"));
if($currency) {
$this->container->get("event_dispatcher")->dispatch(TheliaEvents::CHANGE_DEFAULT_CURRENCY, new CurrencyEvent($currency));
}
} else {
$currency = $request->getSession()->getCurrency(false);
}