TaxManager is now a service in the container.

This commit is contained in:
Franck Allimant
2014-01-22 01:18:28 +01:00
parent c9c489a76b
commit 5d92ea0bab
23 changed files with 414 additions and 152 deletions

View File

@@ -78,7 +78,7 @@ class Cart extends BaseLoop implements ArraySearchLoopInterface
public function parseResults(LoopResult $loopResult)
{
$taxCountry = TaxEngine::getInstance($this->request->getSession())->getDeliveryCountry();
$taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
foreach ($loopResult->getResultDataCollection() as $cartItem) {
$product = $cartItem->getProduct();

View File

@@ -60,7 +60,7 @@ class Delivery extends BaseSpecificModule
throw new \InvalidArgumentException('Cannot found country id: `' . $countryId . '` in delivery loop');
}
} else {
$country = TaxEngine::getInstance($this->request->getSession())->getDeliveryCountry();
$country = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
}
foreach ($loopResult->getResultDataCollection() as $deliveryModule) {

View File

@@ -464,7 +464,7 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
return $this->parseComplex($loopResult);
}
$taxCountry = TaxEngine::getInstance($this->request->getSession())->getDeliveryCountry();
$taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
foreach ($loopResult->getResultDataCollection() as $product) {
@@ -982,7 +982,7 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
{
$loopResult = new LoopResult($results);
$taxCountry = TaxEngine::getInstance($this->request->getSession())->getDeliveryCountry();
$taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
foreach ($loopResult->getResultDataCollection() as $product) {

View File

@@ -145,7 +145,7 @@ class ProductSaleElements extends BaseLoop implements PropelSearchLoopInterface
public function parseResults(LoopResult $loopResult)
{
$taxCountry = TaxEngine::getInstance($this->request->getSession())->getDeliveryCountry();
$taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
foreach ($loopResult->getResultDataCollection() as $PSEValue) {
$loopResultRow = new LoopResultRow($PSEValue);

View File

@@ -150,6 +150,7 @@ class Tax extends BaseI18nLoop implements PropelSearchLoopInterface
$loopResultRow
->set("ID" , $tax->getId())
->set("TYPE" , $tax->getType())
->set("ESCAPED_TYPE" , \Thelia\Model\Tax::escapeTypeName($tax->getType()))
->set("REQUIREMENTS" , $tax->getRequirements())
->set("IS_TRANSLATED" , $tax->getVirtualColumn('IS_TRANSLATED'))
->set("LOCALE" , $this->locale)

View File

@@ -58,15 +58,17 @@ class DataAccessFunctions extends AbstractSmartyPlugin
protected $parserContext;
protected $request;
protected $dispatcher;
protected $taxEngine;
private static $dataAccessCache = array();
public function __construct(Request $request, SecurityContext $securityContext, ParserContext $parserContext, ContainerAwareEventDispatcher $dispatcher)
public function __construct(Request $request, SecurityContext $securityContext, TaxEngine $taxEngine, ParserContext $parserContext, ContainerAwareEventDispatcher $dispatcher)
{
$this->securityContext = $securityContext;
$this->parserContext = $parserContext;
$this->request = $request;
$this->dispatcher = $dispatcher;
$this->taxEngine = $taxEngine;
}
/**
@@ -184,7 +186,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
if (array_key_exists('currentCountry', self::$dataAccessCache)) {
$taxCountry = self::$dataAccessCache['currentCountry'];
} else {
$taxCountry = TaxEngine::getInstance($this->request->getSession())->getDeliveryCountry();
$taxCountry = $this->taxEngine->getDeliveryCountry();
self::$dataAccessCache['currentCountry'] = $taxCountry;
}
@@ -378,12 +380,17 @@ class DataAccessFunctions extends AbstractSmartyPlugin
self::$dataAccessCache['data_' . $objectLabel] = $data;
}
$noGetterData = array();
foreach ($columns as $column) {
$noGetterData[$column] = $data->getVirtualColumn('i18n_' . $column);
if ($data !== null) {
$noGetterData = array();
foreach ($columns as $column) {
$noGetterData[$column] = $data->getVirtualColumn('i18n_' . $column);
}
return $this->dataAccess($objectLabel, $params, $data, $noGetterData);
}
return $this->dataAccess($objectLabel, $params, $data, $noGetterData);
return '';
}
/**