This commit is contained in:
Manuel Raynaud
2014-01-10 11:41:55 +01:00
parent ab0fbb6e27
commit 9d0121f321
54 changed files with 220 additions and 290 deletions

View File

@@ -186,11 +186,11 @@ class Cart extends BaseAction implements EventSubscriberInterface
/** /**
* try to attach a new item to an existing cart * try to attach a new item to an existing cart
* *
* @param \Thelia\Model\Cart $cart * @param \Thelia\Model\Cart $cart
* @param int $productId * @param int $productId
* @param \Thelia\Model\ProductSaleElements $productSaleElements * @param \Thelia\Model\ProductSaleElements $productSaleElements
* @param float $quantity * @param float $quantity
* @param ProductPrice $productPrice * @param ProductPrice $productPrice
* *
* @return CartItem * @return CartItem
*/ */

View File

@@ -211,7 +211,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
/** @var CouponManager $couponManager */ /** @var CouponManager $couponManager */
$couponManager = $this->container->get('thelia.coupon.manager'); $couponManager = $this->container->get('thelia.coupon.manager');
if($couponManager->isCouponRemovingPostage()) { if ($couponManager->isCouponRemovingPostage()) {
$order = $event->getOrder(); $order = $event->getOrder();
$order->setPostage(0); $order->setPostage(0);
@@ -235,7 +235,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
$consumedCoupons = $request->getSession()->getConsumedCoupons(); $consumedCoupons = $request->getSession()->getConsumedCoupons();
if (is_array($consumedCoupons)) { if (is_array($consumedCoupons)) {
foreach($consumedCoupons as $couponCode) { foreach ($consumedCoupons as $couponCode) {
$couponQuery = CouponQuery::create(); $couponQuery = CouponQuery::create();
$couponModel = $couponQuery->findOneByCode($couponCode); $couponModel = $couponQuery->findOneByCode($couponCode);
$couponModel->setLocale($request->getSession()->getLang()->getLocale()); $couponModel->setLocale($request->getSession()->getLang()->getLocale());

View File

@@ -30,7 +30,6 @@ use Thelia\Core\Event\Cart\CartEvent;
use Thelia\Core\Event\Order\OrderAddressEvent; use Thelia\Core\Event\Order\OrderAddressEvent;
use Thelia\Core\Event\Order\OrderEvent; use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Coupon\CouponManager;
use Thelia\Exception\TheliaProcessException; use Thelia\Exception\TheliaProcessException;
use Thelia\Model\AddressQuery; use Thelia\Model\AddressQuery;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;

View File

@@ -27,8 +27,6 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Thelia\Install\Exception\UpToDateException; use Thelia\Install\Exception\UpToDateException;
use Thelia\Install\Update; use Thelia\Install\Update;
use Thelia\Model\ConfigQuery;
/** /**
* Class UpdateCommand * Class UpdateCommand
@@ -65,7 +63,7 @@ class UpdateCommand extends ContainerAwareCommand
'<info>Your database is updated successfully !</info>', '<info>Your database is updated successfully !</info>',
'' ''
)); ));
} catch(PropelException $e) { } catch (PropelException $e) {
$errorMsg = $e->getMessage(); $errorMsg = $e->getMessage();
$output->writeln(array( $output->writeln(array(
@@ -81,4 +79,4 @@ class UpdateCommand extends ContainerAwareCommand
)); ));
} }
} }
} }

View File

@@ -26,7 +26,6 @@ namespace Thelia\Condition;
use ArrayAccess; use ArrayAccess;
use Countable; use Countable;
use Iterator; use Iterator;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Condition\Implementation\ConditionInterface; use Thelia\Condition\Implementation\ConditionInterface;
/** /**
@@ -201,4 +200,4 @@ class ConditionCollection implements Iterator, Countable, ArrayAccess
return json_encode($arrayToSerialize); return json_encode($arrayToSerialize);
} }
} }

View File

@@ -23,12 +23,10 @@
namespace Thelia\Condition; namespace Thelia\Condition;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Condition\Implementation\ConditionInterface; use Thelia\Condition\Implementation\ConditionInterface;
use Thelia\Condition\Operators; use Thelia\Condition\Operators;
use Thelia\Condition\ConditionCollection; use Thelia\Condition\ConditionCollection;
/** /**
* Validate Conditions * Validate Conditions
* *
@@ -138,4 +136,4 @@ class ConditionEvaluator
return false; return false;
} }
} }

View File

@@ -28,7 +28,6 @@ use Thelia\Condition\Implementation\ConditionInterface;
use Thelia\Coupon\FacadeInterface; use Thelia\Coupon\FacadeInterface;
use Thelia\Condition\ConditionCollection; use Thelia\Condition\ConditionCollection;
/** /**
* Manage how Condition could interact with the current application state (Thelia) * Manage how Condition could interact with the current application state (Thelia)
* *
@@ -114,7 +113,6 @@ class ConditionFactory
return $collection; return $collection;
} }
/** /**
* Build a Condition from form * Build a Condition from form
* *
@@ -123,7 +121,7 @@ class ConditionFactory
* @param array $values Values setting this Condition * @param array $values Values setting this Condition
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return ConditionInterface Ready to use Condition or false * @return ConditionInterface Ready to use Condition or false
*/ */
public function build($conditionServiceId, array $operators, array $values) public function build($conditionServiceId, array $operators, array $values)
{ {
@@ -166,7 +164,6 @@ class ConditionFactory
*/ */
public function getInputsFromConditionInterface(ConditionInterface $condition) public function getInputsFromConditionInterface(ConditionInterface $condition)
{ {
return $condition->getValidators(); return $condition->getValidators();
} }
} }

View File

@@ -44,4 +44,4 @@ class ConditionOrganizer implements ConditionOrganizerInterface
// @todo: Implement organize() method. // @todo: Implement organize() method.
} }
} }

View File

@@ -40,4 +40,4 @@ interface ConditionOrganizerInterface
* @return array Array of ConditionInterface sorted * @return array Array of ConditionInterface sorted
*/ */
public function organize(array $conditions); public function organize(array $conditions);
} }

View File

@@ -171,7 +171,6 @@ abstract class ConditionAbstract implements ConditionInterface
return $serializableCondition; return $serializableCondition;
} }
/** /**
* Check if currency if valid or not * Check if currency if valid or not
* *
@@ -232,7 +231,7 @@ abstract class ConditionAbstract implements ConditionInterface
$selectHtml = ''; $selectHtml = '';
$optionHtml = ''; $optionHtml = '';
$inputs = $this->getValidators(); $inputs = $this->getValidators();
if(isset($inputs['inputs'][$inputKey])) { if (isset($inputs['inputs'][$inputKey])) {
$operators = $inputs['inputs'][$inputKey]['availableOperators']; $operators = $inputs['inputs'][$inputKey]['availableOperators'];
foreach ($operators as $key => $operator) { foreach ($operators as $key => $operator) {
$selected = ''; $selected = '';
@@ -282,6 +281,7 @@ abstract class ConditionAbstract implements ConditionInterface
</div> </div>
</div> </div>
'; ';
return $html; return $html;
} }
@@ -316,4 +316,4 @@ abstract class ConditionAbstract implements ConditionInterface
return $selectHtml; return $selectHtml;
} }
} }

View File

@@ -24,7 +24,6 @@
namespace Thelia\Condition\Implementation; namespace Thelia\Condition\Implementation;
use Thelia\Condition\SerializableCondition; use Thelia\Condition\SerializableCondition;
use Thelia\Core\Translation\Translator;
use Thelia\Coupon\FacadeInterface; use Thelia\Coupon\FacadeInterface;
/** /**
@@ -41,7 +40,7 @@ interface ConditionInterface
* *
* @param FacadeInterface $adapter Service adapter * @param FacadeInterface $adapter Service adapter
*/ */
function __construct(FacadeInterface $adapter); public function __construct(FacadeInterface $adapter);
/** /**
* Get Condition Service id * Get Condition Service id
@@ -75,7 +74,6 @@ interface ConditionInterface
*/ */
public function getAvailableOperators(); public function getAvailableOperators();
/** /**
* Get I18n name * Get I18n name
* *

View File

@@ -148,8 +148,7 @@ class MatchForEveryone extends ConditionAbstract
public function drawBackOfficeInputs() public function drawBackOfficeInputs()
{ {
// No input // No input
return ''; return '';
} }
} }

View File

@@ -23,7 +23,6 @@
namespace Thelia\Condition\Implementation; namespace Thelia\Condition\Implementation;
use Symfony\Component\Intl\Exception\NotImplementedException;
use Thelia\Condition\Implementation\ConditionAbstract; use Thelia\Condition\Implementation\ConditionAbstract;
use Thelia\Condition\Operators; use Thelia\Condition\Operators;
use Thelia\Exception\InvalidConditionOperatorException; use Thelia\Exception\InvalidConditionOperatorException;
@@ -119,10 +118,8 @@ class MatchForTotalAmount extends ConditionAbstract
$this->isPriceValid($priceValue); $this->isPriceValid($priceValue);
$this->isCurrencyValid($currencyValue); $this->isCurrencyValid($currencyValue);
$this->operators = array( $this->operators = array(
self::INPUT1 => $priceOperator, self::INPUT1 => $priceOperator,
self::INPUT2 => $currencyOperator, self::INPUT2 => $currencyOperator,
@@ -335,4 +332,4 @@ class MatchForTotalAmount extends ConditionAbstract
return $selectHtml; return $selectHtml;
} }
} }

View File

@@ -247,6 +247,7 @@ class MatchForXArticles extends ConditionAbstract
</div> </div>
</div> </div>
'; ';
return $html; return $html;
} }

View File

@@ -124,4 +124,4 @@ abstract class Operators
return $ret; return $ret;
} }
} }

View File

@@ -314,7 +314,6 @@ class CouponController extends BaseAdminController
/** @var ConditionInterface $condition */ /** @var ConditionInterface $condition */
$condition = $this->container->get($conditionId); $condition = $this->container->get($conditionId);
if ($inputs === null) { if ($inputs === null) {
return $this->pageNotFound(); return $this->pageNotFound();
} }
@@ -723,6 +722,7 @@ class CouponController extends BaseAdminController
$args = array(); $args = array();
$args['conditions'] = $this->cleanConditionForTemplate($couponManager->getConditions()); $args['conditions'] = $this->cleanConditionForTemplate($couponManager->getConditions());
return $this->render('coupon/conditions', $args); return $this->render('coupon/conditions', $args);
} }

View File

@@ -87,10 +87,10 @@ class CouponCreateOrUpdateEvent extends ActionEvent
/** /**
* Constructor * Constructor
* *
* @param string $code Coupon Code * @param string $code Coupon Code
* @param string $serviceId Coupon Service id * @param string $serviceId Coupon Service id
* @param string $title Coupon title * @param string $title Coupon title
* @param array $effects Coupon effects ready to be serialized * @param array $effects Coupon effects ready to be serialized
* 'amount' key is mandatory and reflects * 'amount' key is mandatory and reflects
* the amount deduced from the cart * the amount deduced from the cart
* @param string $shortDescription Coupon short description * @param string $shortDescription Coupon short description

View File

@@ -23,7 +23,8 @@
namespace Thelia\Core\Template\Assets; namespace Thelia\Core\Template\Assets;
interface AssetManagerInterface { interface AssetManagerInterface
{
/** /**
* Prepare an asset directory by checking that no changes occured in * Prepare an asset directory by checking that no changes occured in
* the source directory. If any change is detected, the whole asset directory * the source directory. If any change is detected, the whole asset directory
@@ -45,23 +46,23 @@ interface AssetManagerInterface {
/** /**
* Generates assets from $asset_path in $output_path, using $filters. * Generates assets from $asset_path in $output_path, using $filters.
* *
* @param $assetSource * @param $assetSource
* @param $assetDirectoryBase * @param $assetDirectoryBase
* @param string $webAssetsDirectoryBase the full path to the asset file (or file collection, e.g. *.less) * @param string $webAssetsDirectoryBase the full path to the asset file (or file collection, e.g. *.less)
* *
* @param string $webAssetsTemplate the full disk path to the base assets output directory in the web space * @param string $webAssetsTemplate the full disk path to the base assets output directory in the web space
* @param $webAssetsKey * @param $webAssetsKey
* @param string $outputUrl the URL to the base assets output directory in the web space * @param string $outputUrl the URL to the base assets output directory in the web space
* *
* @param string $assetType the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension. * @param string $assetType the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension.
* @param array $filters a list of filters, as defined below (see switch($filter_name) ...) * @param array $filters a list of filters, as defined below (see switch($filter_name) ...)
* *
* @param boolean $debug true / false * @param boolean $debug true / false
* *
* @internal param string $web_assets_directory_base the full disk path to the base assets output directory in the web space * @internal param string $web_assets_directory_base the full disk path to the base assets output directory in the web space
* @internal param string $output_url the URL to the base assets output directory in the web space * @internal param string $output_url the URL to the base assets output directory in the web space
* *
* @return string The URL to the generated asset file. * @return string The URL to the generated asset file.
*/ */
public function processAsset($assetSource, $assetDirectoryBase, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey, $outputUrl, $assetType, $filters, $debug); public function processAsset($assetSource, $assetDirectoryBase, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey, $outputUrl, $assetType, $filters, $debug);
} }

View File

@@ -51,7 +51,7 @@ class AsseticAssetManager implements AssetManagerInterface
/** /**
* Create a stamp form the modification time of the content of the given directory and all of its subdirectories * Create a stamp form the modification time of the content of the given directory and all of its subdirectories
* *
* @param string $directory ther directory name * @param string $directory ther directory name
* @return string the stamp of this directory * @return string the stamp of this directory
*/ */
protected function getStamp($directory) protected function getStamp($directory)
@@ -76,7 +76,8 @@ class AsseticAssetManager implements AssetManagerInterface
* *
* @return bool * @return bool
*/ */
protected function isSourceFile(\SplFileInfo $fileInfo) { protected function isSourceFile(\SplFileInfo $fileInfo)
{
return in_array($fileInfo->getExtension(), $this->source_file_extensions); return in_array($fileInfo->getExtension(), $this->source_file_extensions);
} }
@@ -84,9 +85,9 @@ class AsseticAssetManager implements AssetManagerInterface
* Recursively copy assets from the source directory to the destination * Recursively copy assets from the source directory to the destination
* directory in the web space, omitting source files. * directory in the web space, omitting source files.
* *
* @param Filesystem $fs * @param Filesystem $fs
* @param string $from_directory the source * @param string $from_directory the source
* @param string $to_directory the destination * @param string $to_directory the destination
* @throws \RuntimeException if a problem occurs. * @throws \RuntimeException if a problem occurs.
*/ */
protected function copyAssets(Filesystem $fs, $from_directory, $to_directory) protected function copyAssets(Filesystem $fs, $from_directory, $to_directory)
@@ -205,8 +206,7 @@ class AsseticAssetManager implements AssetManagerInterface
throw new \RuntimeException( throw new \RuntimeException(
"Failed to create asset stamp file $stamp_file_path. Please check that your web server has the proper access rights to do that."); "Failed to create asset stamp file $stamp_file_path. Please check that your web server has the proper access rights to do that.");
} }
/* } /* } else {
else {
@fclose($fp); @fclose($fp);
} }
*/ */
@@ -216,13 +216,13 @@ class AsseticAssetManager implements AssetManagerInterface
/** /**
* Decode the filters names, and initialize the Assetic FilterManager * Decode the filters names, and initialize the Assetic FilterManager
* *
* @param FilterManager $filterManager the Assetic filter manager * @param FilterManager $filterManager the Assetic filter manager
* @param string $filters a comma separated list of filter names * @param string $filters a comma separated list of filter names
* @throws \InvalidArgumentException if a wrong filter is passed * @throws \InvalidArgumentException if a wrong filter is passed
* @return an array of filter names * @return an array of filter names
*/ */
protected function decodeAsseticFilters(FilterManager $filterManager, $filters) { protected function decodeAsseticFilters(FilterManager $filterManager, $filters)
{
if (!empty($filters)) { if (!empty($filters)) {
$filter_list = explode(',', $filters); $filter_list = explode(',', $filters);
@@ -261,8 +261,7 @@ class AsseticAssetManager implements AssetManagerInterface
break; break;
} }
} }
} } else {
else {
$filter_list = array(); $filter_list = array();
} }
@@ -272,20 +271,20 @@ class AsseticAssetManager implements AssetManagerInterface
/** /**
* Generates assets from $asset_path in $output_path, using $filters. * Generates assets from $asset_path in $output_path, using $filters.
* *
* @param $assetSource * @param $assetSource
* @param $assetDirectoryBase * @param $assetDirectoryBase
* @param string $webAssetsDirectoryBase the full path to the asset file (or file collection, e.g. *.less) * @param string $webAssetsDirectoryBase the full path to the asset file (or file collection, e.g. *.less)
* *
* @param string $webAssetsTemplate the full disk path to the base assets output directory in the web space * @param string $webAssetsTemplate the full disk path to the base assets output directory in the web space
* @param $webAssetsKey * @param $webAssetsKey
* @param string $outputUrl the URL to the base assets output directory in the web space * @param string $outputUrl the URL to the base assets output directory in the web space
* *
* @param string $assetType the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension. * @param string $assetType the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension.
* @param array $filters a list of filters, as defined below (see switch($filter_name) ...) * @param array $filters a list of filters, as defined below (see switch($filter_name) ...)
* *
* @param boolean $debug true / false * @param boolean $debug true / false
* *
* @return string The URL to the generated asset file. * @return string The URL to the generated asset file.
*/ */
public function processAsset($assetSource, $assetDirectoryBase, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey, $outputUrl, $assetType, $filters, $debug) public function processAsset($assetSource, $assetDirectoryBase, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey, $outputUrl, $assetType, $filters, $debug)
{ {

View File

@@ -15,7 +15,6 @@ use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\CountryQuery;
use Thelia\TaxEngine\TaxEngine; use Thelia\TaxEngine\TaxEngine;
use Thelia\Type; use Thelia\Type;

View File

@@ -25,8 +25,6 @@ namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Condition\ConditionFactory; use Thelia\Condition\ConditionFactory;
use Thelia\Condition\Implementation\ConditionInterface;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
@@ -35,7 +33,6 @@ use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\OrderCouponQuery; use Thelia\Model\OrderCouponQuery;
use Thelia\Model\OrderQuery; use Thelia\Model\OrderQuery;
use Thelia\Type;
/** /**
* *

View File

@@ -36,7 +36,6 @@ use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Exception\TaxEngineException; use Thelia\Exception\TaxEngineException;
use Thelia\Model\CategoryQuery; use Thelia\Model\CategoryQuery;
use Thelia\Model\CountryQuery;
use Thelia\Model\CurrencyQuery; use Thelia\Model\CurrencyQuery;
use Thelia\Model\Map\ProductPriceTableMap; use Thelia\Model\Map\ProductPriceTableMap;
use Thelia\Model\Map\ProductSaleElementsTableMap; use Thelia\Model\Map\ProductSaleElementsTableMap;

View File

@@ -34,7 +34,6 @@ use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Exception\TaxEngineException; use Thelia\Exception\TaxEngineException;
use Thelia\Model\Base\ProductSaleElementsQuery; use Thelia\Model\Base\ProductSaleElementsQuery;
use Thelia\Model\CountryQuery;
use Thelia\Model\CurrencyQuery; use Thelia\Model\CurrencyQuery;
use Thelia\Model\Map\ProductSaleElementsTableMap; use Thelia\Model\Map\ProductSaleElementsTableMap;
use Thelia\TaxEngine\TaxEngine; use Thelia\TaxEngine\TaxEngine;

View File

@@ -23,19 +23,12 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Security\AccessManager;
use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\ModuleQuery;
use Thelia\Module\BaseModule;
use Thelia\Type; use Thelia\Type;
use Thelia\Core\Template\TemplateHelper; use Thelia\Core\Template\TemplateHelper;
use Thelia\Core\Template\TemplateDefinition; use Thelia\Core\Template\TemplateDefinition;
@@ -72,7 +65,8 @@ class Template extends BaseLoop implements ArraySearchLoopInterface
); );
} }
public function buildArray() { public function buildArray()
{
$type = $this->getArg('template-type')->getValue(); $type = $this->getArg('template-type')->getValue();
if ($type == 'front-office') if ($type == 'front-office')

View File

@@ -43,20 +43,19 @@ interface ParserInterface
* *
* @param unknown $templateType the template type ( * @param unknown $templateType the template type (
* *
* @param string $templateName the template name * @param string $templateName the template name
* @param string $templateDirectory path to the template dirtectory * @param string $templateDirectory path to the template dirtectory
* @param unknown $key ??? * @param unknown $key ???
* @param string $unshift ??? Etienne ? * @param string $unshift ??? Etienne ?
*/ */
public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $unshift = false); public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $unshift = false);
/** /**
* Return the registeted template directories for a givent template type * Return the registeted template directories for a givent template type
* *
* @param unknown $templateType * @param unknown $templateType
* @throws InvalidArgumentException if the tempmateType is not defined * @throws InvalidArgumentException if the tempmateType is not defined
* @return array: an array of defined templates directories for the given template type * @return array: an array of defined templates directories for the given template type
*/ */
public function getTemplateDirectories($templateType); public function getTemplateDirectories($templateType);
} }

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Template\Smarty\Assets; namespace Thelia\Core\Template\Smarty\Assets;
use Thelia\Core\Template\Assets\AsseticHelper;
use Thelia\Core\Template\TemplateDefinition; use Thelia\Core\Template\TemplateDefinition;
use Thelia\Tools\URL; use Thelia\Tools\URL;
use Thelia\Core\Template\Assets\AssetManagerInterface; use Thelia\Core\Template\Assets\AssetManagerInterface;
@@ -37,14 +36,14 @@ class SmartyAssetsManager
private $web_root; private $web_root;
private $path_relative_to_web_root; private $path_relative_to_web_root;
static private $assetsDirectory = null; private static $assetsDirectory = null;
/** /**
* Creates a new SmartyAssetsManager instance * Creates a new SmartyAssetsManager instance
* *
* @param AssetManagerInterface $assetsManager an asset manager instance * @param AssetManagerInterface $assetsManager an asset manager instance
* @param string $web_root the disk path to the web root (with final /) * @param string $web_root the disk path to the web root (with final /)
* @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated * @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated
*/ */
public function __construct(AssetManagerInterface $assetsManager, $web_root, $path_relative_to_web_root) public function __construct(AssetManagerInterface $assetsManager, $web_root, $path_relative_to_web_root)
{ {
@@ -67,7 +66,7 @@ class SmartyAssetsManager
if (isset($templateDirectories[$templateDefinition->getName()])) { if (isset($templateDirectories[$templateDefinition->getName()])) {
/* create assets foreach registered directory : main @ modules */ /* create assets foreach registered directory : main @ modules */
foreach($templateDirectories[$templateDefinition->getName()] as $key => $directory) { foreach ($templateDirectories[$templateDefinition->getName()] as $key => $directory) {
$tpl_path = $directory . DS . self::$assetsDirectory; $tpl_path = $directory . DS . self::$assetsDirectory;
@@ -95,7 +94,7 @@ class SmartyAssetsManager
/* we trick here relative thinking for file attribute */ /* we trick here relative thinking for file attribute */
$file = ltrim($file, '/'); $file = ltrim($file, '/');
while(substr($file, 0, 3) == '../') { while (substr($file, 0, 3) == '../') {
$file = substr($file, 3); $file = substr($file, 3);
} }

View File

@@ -14,8 +14,6 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Template\Exception\ResourceNotFoundException; use Thelia\Core\Template\Exception\ResourceNotFoundException;
use Thelia\Core\Template\ParserContext; use Thelia\Core\Template\ParserContext;
use Thelia\Core\Template\TemplateDefinition; use Thelia\Core\Template\TemplateDefinition;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Template\TemplateHelper;
use Imagine\Exception\InvalidArgumentException; use Imagine\Exception\InvalidArgumentException;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
@@ -72,7 +70,6 @@ class SmartyParser extends Smarty implements ParserInterface
$this->setCompileDir($compile_dir); $this->setCompileDir($compile_dir);
$this->setCacheDir($cache_dir); $this->setCacheDir($cache_dir);
$this->debugging = $debug; $this->debugging = $debug;
// Prevent smarty ErrorException: Notice: Undefined index bla bla bla... // Prevent smarty ErrorException: Notice: Undefined index bla bla bla...
@@ -80,7 +77,7 @@ class SmartyParser extends Smarty implements ParserInterface
// Si on n'est pas en mode debug, activer le cache, avec une lifetime de 15mn, et en vérifiant que les templates sources n'ont pas été modifiés. // Si on n'est pas en mode debug, activer le cache, avec une lifetime de 15mn, et en vérifiant que les templates sources n'ont pas été modifiés.
if($debug) { if ($debug) {
$this->setCaching(Smarty::CACHING_OFF); $this->setCaching(Smarty::CACHING_OFF);
$this->setForceCompile(true); $this->setForceCompile(true);
} else { } else {
@@ -89,7 +86,6 @@ class SmartyParser extends Smarty implements ParserInterface
//$this->enableSecurity(); //$this->enableSecurity();
// The default HTTP status // The default HTTP status
$this->status = 200; $this->status = 200;
@@ -100,15 +96,15 @@ class SmartyParser extends Smarty implements ParserInterface
/** /**
* Add a template directory to the current template list * Add a template directory to the current template list
* *
* @param unknown $templateType the template type (a TemplateDefinition type constant) * @param unknown $templateType the template type (a TemplateDefinition type constant)
* @param string $templateName the template name * @param string $templateName the template name
* @param string $templateDirectory path to the template dirtectory * @param string $templateDirectory path to the template dirtectory
* @param unknown $key ??? * @param unknown $key ???
* @param string $unshift ??? Etienne ? * @param string $unshift ??? Etienne ?
*/ */
public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $unshift = false) { public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $unshift = false)
{
if(true === $unshift && isset($this->templateDirectories[$templateType][$templateName])) { if (true === $unshift && isset($this->templateDirectories[$templateType][$templateName])) {
$this->templateDirectories[$templateType][$templateName] = array_merge( $this->templateDirectories[$templateType][$templateName] = array_merge(
array( array(
@@ -124,7 +120,7 @@ class SmartyParser extends Smarty implements ParserInterface
/** /**
* Return the registeted template directories for a givent template type * Return the registeted template directories for a givent template type
* *
* @param unknown $templateType * @param unknown $templateType
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return multitype: * @return multitype:
*/ */
@@ -176,7 +172,7 @@ class SmartyParser extends Smarty implements ParserInterface
/* do not pass array directly to addTemplateDir since we cant control on keys */ /* do not pass array directly to addTemplateDir since we cant control on keys */
if (isset($this->templateDirectories[$templateDefinition->getType()][$templateDefinition->getName()])) { if (isset($this->templateDirectories[$templateDefinition->getType()][$templateDefinition->getName()])) {
foreach($this->templateDirectories[$templateDefinition->getType()][$templateDefinition->getName()] as $key => $directory) { foreach ($this->templateDirectories[$templateDefinition->getType()][$templateDefinition->getName()] as $key => $directory) {
$this->addTemplateDir($directory, $key); $this->addTemplateDir($directory, $key);
} }
} }
@@ -194,9 +190,9 @@ class SmartyParser extends Smarty implements ParserInterface
/** /**
* Return a rendered template, either from file or ftom a string * Return a rendered template, either from file or ftom a string
* *
* @param string $resourceType either 'string' (rendering from a string) or 'file' (rendering a file) * @param string $resourceType either 'string' (rendering from a string) or 'file' (rendering a file)
* @param string $resourceContent the resource content (a text, or a template file name) * @param string $resourceContent the resource content (a text, or a template file name)
* @param array $parameters an associative array of names / value pairs * @param array $parameters an associative array of names / value pairs
* *
* @return string the rendered template text * @return string the rendered template text
*/ */
@@ -215,8 +211,8 @@ class SmartyParser extends Smarty implements ParserInterface
/** /**
* Return a rendered template file * Return a rendered template file
* *
* @param string $realTemplateName the template name (from the template directory) * @param string $realTemplateName the template name (from the template directory)
* @param array $parameters an associative array of names / value pairs * @param array $parameters an associative array of names / value pairs
* @return string the rendered template text * @return string the rendered template text
*/ */
public function render($realTemplateName, array $parameters = array()) public function render($realTemplateName, array $parameters = array())
@@ -231,8 +227,8 @@ class SmartyParser extends Smarty implements ParserInterface
/** /**
* Return a rendered template text * Return a rendered template text
* *
* @param string $templateText the template text * @param string $templateText the template text
* @param array $parameters an associative array of names / value pairs * @param array $parameters an associative array of names / value pairs
* @return string the rendered template text * @return string the rendered template text
*/ */
public function renderString($templateText, array $parameters = array()) public function renderString($templateText, array $parameters = array())
@@ -298,4 +294,4 @@ class SmartyParser extends Smarty implements ParserInterface
} }
} }
} }

View File

@@ -57,13 +57,12 @@ class TemplateDefinition
*/ */
protected $type; protected $type;
public function __construct($name, $type) public function __construct($name, $type)
{ {
$this->name = $name; $this->name = $name;
$this->type = $type; $this->type = $type;
switch($type) { switch ($type) {
case TemplateDefinition::FRONT_OFFICE: case TemplateDefinition::FRONT_OFFICE:
$this->path = self::FRONT_OFFICE_SUBDIR . $name; $this->path = self::FRONT_OFFICE_SUBDIR . $name;
break; break;
@@ -90,14 +89,17 @@ class TemplateDefinition
public function setName($name) public function setName($name)
{ {
$this->name = $name; $this->name = $name;
return $this; return $this;
} }
public function getI18nPath() { public function getI18nPath()
{
return $this->getPath() . DS . 'I18n'; return $this->getPath() . DS . 'I18n';
} }
public function getAbsoluteI18nPath() { public function getAbsoluteI18nPath()
{
return THELIA_TEMPLATE_DIR . $this->getI18nPath(); return THELIA_TEMPLATE_DIR . $this->getI18nPath();
} }
@@ -106,7 +108,8 @@ class TemplateDefinition
return $this->path; return $this->path;
} }
public function getAbsolutePath() { public function getAbsolutePath()
{
return THELIA_TEMPLATE_DIR . $this->getPath(); return THELIA_TEMPLATE_DIR . $this->getPath();
} }
@@ -115,13 +118,15 @@ class TemplateDefinition
return $this->getPath() . DS . 'configs'; return $this->getPath() . DS . 'configs';
} }
public function getAbsoluteConfigPath() { public function getAbsoluteConfigPath()
{
return THELIA_TEMPLATE_DIR . $this->getConfigPath(); return THELIA_TEMPLATE_DIR . $this->getConfigPath();
} }
public function setPath($path) public function setPath($path)
{ {
$this->path = $path; $this->path = $path;
return $this; return $this;
} }
@@ -133,13 +138,15 @@ class TemplateDefinition
public function setType($type) public function setType($type)
{ {
$this->type = $type; $this->type = $type;
return $this; return $this;
} }
/** /**
* Returns an iterator on the standard templates subdir names * Returns an iterator on the standard templates subdir names
*/ */
public static function getStandardTemplatesSubdirsIterator() { public static function getStandardTemplatesSubdirsIterator()
{
return new \ArrayIterator(self::$standardTemplatesSubdirs); return new \ArrayIterator(self::$standardTemplatesSubdirs);
} }
} }

View File

@@ -93,7 +93,8 @@ class TemplateHelper
/** /**
* Returns an array which contains all standard template definitions * Returns an array which contains all standard template definitions
*/ */
public function getStandardTemplateDefinitions() { public function getStandardTemplateDefinitions()
{
return array( return array(
$this->getActiveFrontTemplate(), $this->getActiveFrontTemplate(),
$this->getActiveAdminTemplate(), $this->getActiveAdminTemplate(),
@@ -105,16 +106,16 @@ class TemplateHelper
/** /**
* Return a list of existing templates for a given template type * Return a list of existing templates for a given template type
* *
* @param int $templateType the template type * @param int $templateType the template type
* @return An array of \Thelia\Core\Template\TemplateDefinition * @return An array of \Thelia\Core\Template\TemplateDefinition
*/ */
public function getList($templateType) { public function getList($templateType)
{
$list = $exclude = array(); $list = $exclude = array();
$tplIterator = TemplateDefinition::getStandardTemplatesSubdirsIterator(); $tplIterator = TemplateDefinition::getStandardTemplatesSubdirsIterator();
foreach($tplIterator as $type => $subdir) { foreach ($tplIterator as $type => $subdir) {
if ($templateType == $type) { if ($templateType == $type) {

View File

@@ -49,7 +49,6 @@ use Thelia\Config\DefinePropel;
use Thelia\Core\Template\TemplateDefinition; use Thelia\Core\Template\TemplateDefinition;
use Thelia\Core\TheliaContainerBuilder; use Thelia\Core\TheliaContainerBuilder;
use Thelia\Core\DependencyInjection\Loader\XmlFileLoader; use Thelia\Core\DependencyInjection\Loader\XmlFileLoader;
use Thelia\Model\ConfigQuery;
use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\FileLocator;
use Propel\Runtime\Propel; use Propel\Runtime\Propel;
@@ -110,12 +109,13 @@ class Thelia extends Kernel
* Add all module's standard templates to the parser environment * Add all module's standard templates to the parser environment
* *
* @param TheliaParser $parser the parser * @param TheliaParser $parser the parser
* @param Module $module the Module. * @param Module $module the Module.
*/ */
protected function addStandardModuleTemplatesToParserEnvironment($parser, $module) { protected function addStandardModuleTemplatesToParserEnvironment($parser, $module)
{
$stdTpls = TemplateDefinition::getStandardTemplatesSubdirsIterator(); $stdTpls = TemplateDefinition::getStandardTemplatesSubdirsIterator();
foreach($stdTpls as $templateType => $templateSubdirName) { foreach ($stdTpls as $templateType => $templateSubdirName) {
$this->addModuleTemplateToParserEnvironment($parser, $module, $templateType, $templateSubdirName); $this->addModuleTemplateToParserEnvironment($parser, $module, $templateType, $templateSubdirName);
} }
} }
@@ -123,13 +123,13 @@ class Thelia extends Kernel
/** /**
* Add a module template directory to the parser environment * Add a module template directory to the parser environment
* *
* @param TheliaParser $parser the parser * @param TheliaParser $parser the parser
* @param Module $module the Module. * @param Module $module the Module.
* @param string $templateType the template type (one of the TemplateDefinition type constants) * @param string $templateType the template type (one of the TemplateDefinition type constants)
* @param string $templateSubdirName the template subdirectory name (one of the TemplateDefinition::XXX_SUBDIR constants) * @param string $templateSubdirName the template subdirectory name (one of the TemplateDefinition::XXX_SUBDIR constants)
*/ */
protected function addModuleTemplateToParserEnvironment($parser, $module, $templateType, $templateSubdirName) { protected function addModuleTemplateToParserEnvironment($parser, $module, $templateType, $templateSubdirName)
{
// Get template path // Get template path
$templateDirectory = $module->getAbsoluteTemplateDirectoryPath($templateSubdirName); $templateDirectory = $module->getAbsoluteTemplateDirectoryPath($templateSubdirName);
@@ -155,8 +155,7 @@ class Thelia extends Kernel
); );
} }
} }
} } catch (\UnexpectedValueException $ex) {
catch (\UnexpectedValueException $ex) {
// The directory does not exists, ignore it. // The directory does not exists, ignore it.
} }
} }
@@ -176,7 +175,7 @@ class Thelia extends Kernel
->depth(0) ->depth(0)
->in(THELIA_ROOT . "/core/lib/Thelia/Config/Resources"); ->in(THELIA_ROOT . "/core/lib/Thelia/Config/Resources");
foreach($finder as $file) { foreach ($finder as $file) {
$loader->load($file->getBaseName()); $loader->load($file->getBaseName());
} }
@@ -219,7 +218,7 @@ class Thelia extends Kernel
// Standard templates (front, back, pdf, mail) // Standard templates (front, back, pdf, mail)
$th = TemplateHelper::getInstance(); $th = TemplateHelper::getInstance();
foreach($th->getStandardTemplateDefinitions() as $templateDefinition) { foreach ($th->getStandardTemplateDefinitions() as $templateDefinition) {
if (is_dir($dir = $templateDefinition->getAbsoluteI18nPath())) { if (is_dir($dir = $templateDefinition->getAbsoluteI18nPath())) {
$translationDirs[] = $dir; $translationDirs[] = $dir;
} }
@@ -370,4 +369,4 @@ class Thelia extends Kernel
//Nothing is load here but it's possible to load container configuration here. //Nothing is load here but it's possible to load container configuration here.
//exemple in sf2 : $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); //exemple in sf2 : $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
} }
} }

View File

@@ -57,9 +57,9 @@ class BaseFacade implements FacadeInterface
/** /**
* Constructor * Constructor
* *
* @param ContainerInterface $container Service container * @param ContainerInterface $container Service container
*/ */
function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
$this->container = $container; $this->container = $container;
} }
@@ -135,7 +135,6 @@ class BaseFacade implements FacadeInterface
return $this->getRequest()->getSession()->getCurrency()->getCode(); return $this->getRequest()->getSession()->getCurrency()->getCode();
} }
/** /**
* Return the number of Products in the Cart * Return the number of Products in the Cart
* *
@@ -202,7 +201,6 @@ class BaseFacade implements FacadeInterface
return $this->container->get('thelia.translator'); return $this->container->get('thelia.translator');
} }
/** /**
* Return the main currency * Return the main currency
* THe one used to set prices in BackOffice * THe one used to set prices in BackOffice
@@ -234,7 +232,6 @@ class BaseFacade implements FacadeInterface
return $this->container->get('thelia.condition.validator'); return $this->container->get('thelia.condition.validator');
} }
/** /**
* Return all available currencies * Return all available currencies
* *

View File

@@ -63,7 +63,7 @@ class CouponFactory
* *
* @throws \Thelia\Exception\CouponExpiredException * @throws \Thelia\Exception\CouponExpiredException
* @throws \Thelia\Exception\InvalidConditionException * @throws \Thelia\Exception\InvalidConditionException
* @return CouponInterface ready to be processed * @return CouponInterface ready to be processed
*/ */
public function buildCouponFromCode($couponCode) public function buildCouponFromCode($couponCode)
{ {
@@ -132,6 +132,4 @@ class CouponFactory
return clone $couponManager; return clone $couponManager;
} }
} }

View File

@@ -60,7 +60,6 @@ class CouponManager
$this->facade = $container->get('thelia.facade'); $this->facade = $container->get('thelia.facade');
} }
/** /**
* Get Discount for the given Coupons * Get Discount for the given Coupons
* *
@@ -241,10 +240,10 @@ class CouponManager
$ret = $usageLeft; $ret = $usageLeft;
} }
} catch(\Exception $e) { } catch (\Exception $e) {
$ret = false; $ret = false;
} }
return $ret; return $ret;
} }
} }

View File

@@ -43,9 +43,9 @@ interface FacadeInterface
/** /**
* Constructor * Constructor
* *
* @param ContainerInterface $container Service container * @param ContainerInterface $container Service container
*/ */
function __construct(ContainerInterface $container); public function __construct(ContainerInterface $container);
/** /**
* Return a Cart a CouponManager can process * Return a Cart a CouponManager can process
@@ -170,4 +170,4 @@ interface FacadeInterface
*/ */
public function getDispatcher(); public function getDispatcher();
} }

View File

@@ -23,7 +23,6 @@
namespace Thelia\Coupon\Type; namespace Thelia\Coupon\Type;
use Symfony\Component\Intl\Exception\NotImplementedException;
use Thelia\Condition\ConditionEvaluator; use Thelia\Condition\ConditionEvaluator;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
use Thelia\Coupon\FacadeInterface; use Thelia\Coupon\FacadeInterface;
@@ -62,7 +61,6 @@ abstract class CouponAbstract implements CouponInterface
/** @var ConditionEvaluator Condition validator */ /** @var ConditionEvaluator Condition validator */
protected $conditionEvaluator = null; protected $conditionEvaluator = null;
/** @var string Service Id */ /** @var string Service Id */
protected $serviceId = null; protected $serviceId = null;
@@ -75,8 +73,6 @@ abstract class CouponAbstract implements CouponInterface
/** @var string Coupon code (ex: XMAS) */ /** @var string Coupon code (ex: XMAS) */
protected $code = null; protected $code = null;
/** @var string Coupon title (ex: Coupon for XMAS) */ /** @var string Coupon title (ex: Coupon for XMAS) */
protected $title = null; protected $title = null;
@@ -86,8 +82,6 @@ abstract class CouponAbstract implements CouponInterface
/** @var string Coupon description */ /** @var string Coupon description */
protected $description = null; protected $description = null;
/** @var bool if Coupon is enabled */ /** @var bool if Coupon is enabled */
protected $isEnabled = false; protected $isEnabled = false;
@@ -106,7 +100,6 @@ abstract class CouponAbstract implements CouponInterface
/** @var bool if Coupon is available for Products already on special offers */ /** @var bool if Coupon is available for Products already on special offers */
protected $isAvailableOnSpecialOffers = false; protected $isAvailableOnSpecialOffers = false;
/** /**
* Constructor * Constructor
* *
@@ -146,9 +139,9 @@ abstract class CouponAbstract implements CouponInterface
* @param bool $isRemovingPostage If Coupon is removing postage * @param bool $isRemovingPostage If Coupon is removing postage
* @param bool $isAvailableOnSpecialOffers If available on Product already * @param bool $isAvailableOnSpecialOffers If available on Product already
* on special offer price * on special offer price
* @param bool $isEnabled False if Coupon is disabled by admin * @param bool $isEnabled False if Coupon is disabled by admin
* @param int $maxUsage How many usage left * @param int $maxUsage How many usage left
* @param \Datetime $expirationDate When the Code is expiring * @param \Datetime $expirationDate When the Code is expiring
* *
* @return $this * @return $this
*/ */
@@ -355,7 +348,6 @@ abstract class CouponAbstract implements CouponInterface
return $this->serviceId; return $this->serviceId;
} }
/** /**
* Check if the current state of the application is matching this Coupon conditions * Check if the current state of the application is matching this Coupon conditions
* Thelia variables are given by the FacadeInterface * Thelia variables are given by the FacadeInterface
@@ -398,5 +390,4 @@ abstract class CouponAbstract implements CouponInterface
return $this->extendedInputs; return $this->extendedInputs;
} }
} }

View File

@@ -76,9 +76,9 @@ interface CouponInterface
* @param bool $isRemovingPostage If Coupon is removing postage * @param bool $isRemovingPostage If Coupon is removing postage
* @param bool $isAvailableOnSpecialOffers If available on Product already * @param bool $isAvailableOnSpecialOffers If available on Product already
* on special offer price * on special offer price
* @param bool $isEnabled False if Coupon is disabled by admin * @param bool $isEnabled False if Coupon is disabled by admin
* @param int $maxUsage How many usage left * @param int $maxUsage How many usage left
* @param \Datetime $expirationDate When the Code is expiring * @param \Datetime $expirationDate When the Code is expiring
*/ */
public function set( public function set(
FacadeInterface $facade, FacadeInterface $facade,
@@ -138,8 +138,6 @@ interface CouponInterface
*/ */
public function isRemovingPostage(); public function isRemovingPostage();
/** /**
* Return condition to validate the Coupon or not * Return condition to validate the Coupon or not
* *
@@ -173,7 +171,6 @@ interface CouponInterface
*/ */
public function isAvailableOnSpecialOffers(); public function isAvailableOnSpecialOffers();
/** /**
* Check if Coupon has been disabled by admin * Check if Coupon has been disabled by admin
* *
@@ -196,7 +193,6 @@ interface CouponInterface
*/ */
public function isExpired(); public function isExpired();
/** /**
* Return effects generated by the coupon * Return effects generated by the coupon
* A positive value * A positive value

View File

@@ -60,9 +60,9 @@ class RemoveXPercent extends CouponAbstract
* @param bool $isRemovingPostage If Coupon is removing postage * @param bool $isRemovingPostage If Coupon is removing postage
* @param bool $isAvailableOnSpecialOffers If available on Product already * @param bool $isAvailableOnSpecialOffers If available on Product already
* on special offer price * on special offer price
* @param bool $isEnabled False if Coupon is disabled by admin * @param bool $isEnabled False if Coupon is disabled by admin
* @param int $maxUsage How many usage left * @param int $maxUsage How many usage left
* @param \Datetime $expirationDate When the Code is expiring * @param \Datetime $expirationDate When the Code is expiring
* *
* @return $this * @return $this
*/ */
@@ -110,7 +110,6 @@ class RemoveXPercent extends CouponAbstract
return $basePrice * (( $this->percentage ) / 100); return $basePrice * (( $this->percentage ) / 100);
} }
/** /**
* Get I18n name * Get I18n name
* *
@@ -174,4 +173,4 @@ class RemoveXPercent extends CouponAbstract
return $html; return $html;
} }
} }

View File

@@ -22,7 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Form; namespace Thelia\Form;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\ExecutionContextInterface; use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
use Thelia\Model\ProfileQuery; use Thelia\Model\ProfileQuery;

View File

@@ -53,9 +53,8 @@ abstract class BaseInstall
throw new AlreadyInstallException("Thelia is already installed"); throw new AlreadyInstallException("Thelia is already installed");
} }
$this->exec(); $this->exec();
} }
abstract public function exec(); abstract public function exec();
} }

View File

@@ -24,12 +24,8 @@
namespace Thelia\Install; namespace Thelia\Install;
use PDO; use PDO;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
use Thelia\Install\Exception\InstallException;
/** /**
* Class CheckDatabaseConnection * Class CheckDatabaseConnection

View File

@@ -28,7 +28,6 @@ use RecursiveIteratorIterator;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
/** /**
* Class CheckPermission * Class CheckPermission
* *
@@ -164,9 +163,6 @@ class CheckPermission extends BaseInstall
} }
} }
return $this->isValid; return $this->isValid;
} }
@@ -200,7 +196,6 @@ class CheckPermission extends BaseInstall
return (is_writable(THELIA_ROOT . $directory) === true); return (is_writable(THELIA_ROOT . $directory) === true);
} }
/** /**
* Get Translated text about the directory state * Get Translated text about the directory state
* *
@@ -269,7 +264,6 @@ class CheckPermission extends BaseInstall
return $translatedText; return $translatedText;
} }
/** /**
* Get Translated text about the directory state * Get Translated text about the directory state
* Not usable with CLI * Not usable with CLI
@@ -382,7 +376,7 @@ class CheckPermission extends BaseInstall
{ {
$serverValueInBytes = $this->returnBytes(ini_get($key)); $serverValueInBytes = $this->returnBytes(ini_get($key));
if($serverValueInBytes == -1) { if ($serverValueInBytes == -1) {
return true; return true;
} }
@@ -400,7 +394,7 @@ class CheckPermission extends BaseInstall
{ {
$val = trim($val); $val = trim($val);
$last = strtolower($val[strlen($val)-1]); $last = strtolower($val[strlen($val)-1]);
switch($last) { switch ($last) {
// The 'G' modifier is available since PHP 5.1.0 // The 'G' modifier is available since PHP 5.1.0
case 'g': case 'g':
$val *= 1024; $val *= 1024;

View File

@@ -23,7 +23,6 @@
namespace Thelia\Install; namespace Thelia\Install;
/** /**
* Class Database * Class Database
* @package Thelia\Install * @package Thelia\Install
@@ -112,4 +111,4 @@ class Database
) )
); );
} }
} }

View File

@@ -23,7 +23,6 @@
namespace Thelia\Install\Exception; namespace Thelia\Install\Exception;
/** /**
* Class AlreadyInstallException * Class AlreadyInstallException
* @package Thelia\Install\Exception * @package Thelia\Install\Exception
@@ -32,4 +31,4 @@ namespace Thelia\Install\Exception;
class AlreadyInstallException extends InstallException class AlreadyInstallException extends InstallException
{ {
} }

View File

@@ -29,4 +29,4 @@ namespace Thelia\Install\Exception;
class InstallException extends \RuntimeException class InstallException extends \RuntimeException
{ {
} }

View File

@@ -23,7 +23,6 @@
namespace Thelia\Install\Exception; namespace Thelia\Install\Exception;
/** /**
* Class UpToDateException * Class UpToDateException
* @package Thelia\Install\Exception * @package Thelia\Install\Exception
@@ -32,4 +31,4 @@ namespace Thelia\Install\Exception;
class UpToDateException extends InstallException class UpToDateException extends InstallException
{ {
} }

View File

@@ -29,13 +29,12 @@ use Thelia\Log\Tlog;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
use Thelia\Model\Map\ProductTableMap; use Thelia\Model\Map\ProductTableMap;
/** /**
* Class Update * Class Update
* @package Thelia\Install * @package Thelia\Install
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class Update class Update
{ {
protected static $version = array( protected static $version = array(
'0' => '2.0.0-beta1', '0' => '2.0.0-beta1',
@@ -61,7 +60,7 @@ class Update
$currentVersion = ConfigQuery::read('thelia_version'); $currentVersion = ConfigQuery::read('thelia_version');
$logger->debug("start update process"); $logger->debug("start update process");
if(true === $this->isLatestVersion($currentVersion)) { if (true === $this->isLatestVersion($currentVersion)) {
$logger->debug("You already have the latest version. No update available"); $logger->debug("You already have the latest version. No update available");
throw new UpToDateException('You already have the latest version. No update available'); throw new UpToDateException('You already have the latest version. No update available');
} }
@@ -78,7 +77,7 @@ class Update
} }
$con->commit(); $con->commit();
$logger->debug('update successfully'); $logger->debug('update successfully');
} catch(PropelException $e) { } catch (PropelException $e) {
$con->rollBack(); $con->rollBack();
$logger->error(sprintf('error during update process with message : %s', $e->getMessage())); $logger->error(sprintf('error during update process with message : %s', $e->getMessage()));
throw $e; throw $e;
@@ -99,4 +98,4 @@ class Update
ConfigQuery::write('thelia_version', $version); ConfigQuery::write('thelia_version', $version);
} }
} }

View File

@@ -27,13 +27,13 @@ use Thelia\Core\Event\MailTransporterEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
/** /**
* Class MailerFactory * Class MailerFactory
* @package Thelia\Mailer * @package Thelia\Mailer
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class MailerFactory { class MailerFactory
{
/** /**
* @var \Swift_Mailer * @var \Swift_Mailer
*/ */
@@ -49,7 +49,7 @@ class MailerFactory {
$transporterEvent = new MailTransporterEvent(); $transporterEvent = new MailTransporterEvent();
$this->dispatcher->dispatch(TheliaEvents::MAILTRANSPORTER_CONFIG, $transporterEvent); $this->dispatcher->dispatch(TheliaEvents::MAILTRANSPORTER_CONFIG, $transporterEvent);
if($transporterEvent->hasTransporter()) { if ($transporterEvent->hasTransporter()) {
$transporter = $transporterEvent->getTransporter(); $transporter = $transporterEvent->getTransporter();
} else { } else {
if (ConfigQuery::isSmtpEnable()) { if (ConfigQuery::isSmtpEnable()) {
@@ -74,6 +74,7 @@ class MailerFactory {
->setTimeout(ConfigQuery::getSmtpTimeout()) ->setTimeout(ConfigQuery::getSmtpTimeout())
->setSourceIp(ConfigQuery::getSmtpSourceIp()) ->setSourceIp(ConfigQuery::getSmtpSourceIp())
; ;
return $smtpTransporter; return $smtpTransporter;
} }
@@ -87,5 +88,4 @@ class MailerFactory {
return $this->swiftMailer; return $this->swiftMailer;
} }
}
}

View File

@@ -22,12 +22,8 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Rewriting; namespace Thelia\Rewriting;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Thelia\Exception\RewritingUrlException;
use Thelia\Exception\UrlRewritingException; use Thelia\Exception\UrlRewritingException;
use Thelia\Model\RewritingUrlQuery; use Thelia\Model\RewritingUrlQuery;
use Thelia\Model\Map\RewritingUrlTableMap;
/** /**
* Class RewritingResolver * Class RewritingResolver
@@ -51,7 +47,7 @@ class RewritingResolver
{ {
$this->rewritingUrlQuery = new RewritingUrlQuery(); $this->rewritingUrlQuery = new RewritingUrlQuery();
if($url !== null) { if ($url !== null) {
$this->load($url); $this->load($url);
} }
} }
@@ -62,7 +58,7 @@ class RewritingResolver
$rewrittenUrl = urldecode($rewrittenUrl); $rewrittenUrl = urldecode($rewrittenUrl);
$this->search = $this->rewritingUrlQuery->getResolverSearch($rewrittenUrl); $this->search = $this->rewritingUrlQuery->getResolverSearch($rewrittenUrl);
if($this->search->count() == 0) { if ($this->search->count() == 0) {
throw new UrlRewritingException('URL NOT FOUND', UrlRewritingException::URL_NOT_FOUND); throw new UrlRewritingException('URL NOT FOUND', UrlRewritingException::URL_NOT_FOUND);
} }
@@ -76,16 +72,16 @@ class RewritingResolver
protected function getOtherParameters() protected function getOtherParameters()
{ {
if($this->search === null) { if ($this->search === null) {
throw new UrlRewritingException('RESOLVER NULL SEARCH', UrlRewritingException::RESOLVER_NULL_SEARCH); throw new UrlRewritingException('RESOLVER NULL SEARCH', UrlRewritingException::RESOLVER_NULL_SEARCH);
} }
$otherParameters = array(); $otherParameters = array();
foreach($this->search as $result) { foreach ($this->search as $result) {
$parameter = $result->getParameter(); $parameter = $result->getParameter();
$value = $result->getValue(); $value = $result->getValue();
if(null !== $parameter) { if (null !== $parameter) {
$otherParameters[$parameter] = $value; $otherParameters[$parameter] = $value;
} }
} }
@@ -93,5 +89,4 @@ class RewritingResolver
return $otherParameters; return $otherParameters;
} }
} }

View File

@@ -22,9 +22,7 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Rewriting; namespace Thelia\Rewriting;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Model\RewritingUrlQuery; use Thelia\Model\RewritingUrlQuery;
use Thelia\Model\Map\RewritingUrlTableMap;
use Thelia\Tools\URL; use Thelia\Tools\URL;
/** /**
@@ -46,7 +44,7 @@ class RewritingRetriever
{ {
$this->rewritingUrlQuery = new RewritingUrlQuery(); $this->rewritingUrlQuery = new RewritingUrlQuery();
if($view !== null && $viewLocale !== null) { if ($view !== null && $viewLocale !== null) {
$this->load($view, $viewLocale, $viewId); $this->load($view, $viewLocale, $viewId);
} }
} }
@@ -61,16 +59,16 @@ class RewritingRetriever
$this->search = $this->rewritingUrlQuery->getViewUrlQuery($view, $viewLocale, $viewId); $this->search = $this->rewritingUrlQuery->getViewUrlQuery($view, $viewLocale, $viewId);
$allParametersWithoutView = array(); $allParametersWithoutView = array();
if(null !== $viewId) { if (null !== $viewId) {
$allParametersWithoutView['locale'] = $viewLocale; $allParametersWithoutView['locale'] = $viewLocale;
} }
if(null !== $viewId) { if (null !== $viewId) {
$allParametersWithoutView[$view . '_id'] = $viewId; $allParametersWithoutView[$view . '_id'] = $viewId;
} }
$this->rewrittenUrl = null; $this->rewrittenUrl = null;
$this->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView); $this->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
if($this->search !== null) { if ($this->search !== null) {
$this->rewrittenUrl = URL::getInstance()->absoluteUrl( $this->rewrittenUrl = URL::getInstance()->absoluteUrl(
$this->search->getUrl() $this->search->getUrl()
); );
@@ -85,8 +83,9 @@ class RewritingRetriever
*/ */
public function loadSpecificUrl($view, $viewLocale, $viewId = null, $viewOtherParameters = array()) public function loadSpecificUrl($view, $viewLocale, $viewId = null, $viewOtherParameters = array())
{ {
if(empty($viewOtherParameters)) { if (empty($viewOtherParameters)) {
$this->loadViewUrl($view, $viewLocale, $viewId); $this->loadViewUrl($view, $viewLocale, $viewId);
return; return;
} }
@@ -94,13 +93,13 @@ class RewritingRetriever
$allParametersWithoutView = $viewOtherParameters; $allParametersWithoutView = $viewOtherParameters;
$allParametersWithoutView['locale'] = $viewLocale; $allParametersWithoutView['locale'] = $viewLocale;
if(null !== $viewId) { if (null !== $viewId) {
$allParametersWithoutView[$view . '_id'] = $viewId; $allParametersWithoutView[$view . '_id'] = $viewId;
} }
$this->rewrittenUrl = null; $this->rewrittenUrl = null;
$this->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView); $this->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
if($this->search !== null) { if ($this->search !== null) {
$this->rewrittenUrl = $this->search->getUrl(); $this->rewrittenUrl = $this->search->getUrl();
} }
} }

View File

@@ -61,10 +61,10 @@ class Calculator
$this->country = null; $this->country = null;
$this->taxRulesCollection = null; $this->taxRulesCollection = null;
if($product->getId() === null) { if ($product->getId() === null) {
throw new TaxEngineException('Product id is empty in Calculator::load', TaxEngineException::UNDEFINED_PRODUCT); throw new TaxEngineException('Product id is empty in Calculator::load', TaxEngineException::UNDEFINED_PRODUCT);
} }
if($country->getId() === null) { if ($country->getId() === null) {
throw new TaxEngineException('Country id is empty in Calculator::load', TaxEngineException::UNDEFINED_COUNTRY); throw new TaxEngineException('Country id is empty in Calculator::load', TaxEngineException::UNDEFINED_COUNTRY);
} }
@@ -82,13 +82,13 @@ class Calculator
$this->country = null; $this->country = null;
$this->taxRulesCollection = null; $this->taxRulesCollection = null;
if($taxRule->getId() === null) { if ($taxRule->getId() === null) {
throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE); throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE);
} }
if($country->getId() === null) { if ($country->getId() === null) {
throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY); throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY);
} }
if($product->getId() === null) { if ($product->getId() === null) {
throw new TaxEngineException('Product id is empty in Calculator::load', TaxEngineException::UNDEFINED_PRODUCT); throw new TaxEngineException('Product id is empty in Calculator::load', TaxEngineException::UNDEFINED_PRODUCT);
} }
@@ -120,15 +120,15 @@ class Calculator
*/ */
public function getTaxedPrice($untaxedPrice, &$taxCollection = null, $askedLocale = null) public function getTaxedPrice($untaxedPrice, &$taxCollection = null, $askedLocale = null)
{ {
if(null === $this->taxRulesCollection) { if (null === $this->taxRulesCollection) {
throw new TaxEngineException('Tax rules collection is empty in Calculator::getTaxedPrice', TaxEngineException::UNDEFINED_TAX_RULES_COLLECTION); throw new TaxEngineException('Tax rules collection is empty in Calculator::getTaxedPrice', TaxEngineException::UNDEFINED_TAX_RULES_COLLECTION);
} }
if(null === $this->product) { if (null === $this->product) {
throw new TaxEngineException('Product is empty in Calculator::getTaxedPrice', TaxEngineException::UNDEFINED_PRODUCT); throw new TaxEngineException('Product is empty in Calculator::getTaxedPrice', TaxEngineException::UNDEFINED_PRODUCT);
} }
if(false === filter_var($untaxedPrice, FILTER_VALIDATE_FLOAT)) { if (false === filter_var($untaxedPrice, FILTER_VALIDATE_FLOAT)) {
throw new TaxEngineException('BAD AMOUNT FORMAT', TaxEngineException::BAD_AMOUNT_FORMAT); throw new TaxEngineException('BAD AMOUNT FORMAT', TaxEngineException::BAD_AMOUNT_FORMAT);
} }
@@ -136,16 +136,16 @@ class Calculator
$currentPosition = 1; $currentPosition = 1;
$currentTax = 0; $currentTax = 0;
if(null !== $taxCollection) { if (null !== $taxCollection) {
$taxCollection = new OrderProductTaxCollection(); $taxCollection = new OrderProductTaxCollection();
} }
foreach($this->taxRulesCollection as $taxRule) { foreach ($this->taxRulesCollection as $taxRule) {
$position = (int)$taxRule->getTaxRuleCountryPosition(); $position = (int) $taxRule->getTaxRuleCountryPosition();
$taxType = $taxRule->getTypeInstance(); $taxType = $taxRule->getTypeInstance();
$taxType->loadRequirements( $taxRule->getRequirements() ); $taxType->loadRequirements( $taxRule->getRequirements() );
if($currentPosition !== $position) { if ($currentPosition !== $position) {
$taxedPrice += $currentTax; $taxedPrice += $currentTax;
$currentTax = 0; $currentTax = 0;
$currentPosition = $position; $currentPosition = $position;
@@ -154,7 +154,7 @@ class Calculator
$taxAmount = round($taxType->calculate($this->product, $taxedPrice), 2); $taxAmount = round($taxType->calculate($this->product, $taxedPrice), 2);
$currentTax += $taxAmount; $currentTax += $taxAmount;
if(null !== $taxCollection) { if (null !== $taxCollection) {
$taxI18n = I18n::forceI18nRetrieving($askedLocale, 'Tax', $taxRule->getId()); $taxI18n = I18n::forceI18nRetrieving($askedLocale, 'Tax', $taxRule->getId());
$orderProductTax = new OrderProductTax(); $orderProductTax = new OrderProductTax();
$orderProductTax->setTitle($taxI18n->getTitle()); $orderProductTax->setTitle($taxI18n->getTitle());
@@ -171,36 +171,36 @@ class Calculator
public function getUntaxedPrice($taxedPrice) public function getUntaxedPrice($taxedPrice)
{ {
if(null === $this->taxRulesCollection) { if (null === $this->taxRulesCollection) {
throw new TaxEngineException('Tax rules collection is empty in Calculator::getTaxAmount', TaxEngineException::UNDEFINED_TAX_RULES_COLLECTION); throw new TaxEngineException('Tax rules collection is empty in Calculator::getTaxAmount', TaxEngineException::UNDEFINED_TAX_RULES_COLLECTION);
} }
if(null === $this->product) { if (null === $this->product) {
throw new TaxEngineException('Product is empty in Calculator::getTaxedPrice', TaxEngineException::UNDEFINED_PRODUCT); throw new TaxEngineException('Product is empty in Calculator::getTaxedPrice', TaxEngineException::UNDEFINED_PRODUCT);
} }
if(false === filter_var($taxedPrice, FILTER_VALIDATE_FLOAT)) { if (false === filter_var($taxedPrice, FILTER_VALIDATE_FLOAT)) {
throw new TaxEngineException('BAD AMOUNT FORMAT', TaxEngineException::BAD_AMOUNT_FORMAT); throw new TaxEngineException('BAD AMOUNT FORMAT', TaxEngineException::BAD_AMOUNT_FORMAT);
} }
$taxRule = $this->taxRulesCollection->getLast(); $taxRule = $this->taxRulesCollection->getLast();
if(null === $taxRule) { if (null === $taxRule) {
throw new TaxEngineException('Tax rules collection got no tax ', TaxEngineException::NO_TAX_IN_TAX_RULES_COLLECTION); throw new TaxEngineException('Tax rules collection got no tax ', TaxEngineException::NO_TAX_IN_TAX_RULES_COLLECTION);
} }
$untaxedPrice = $taxedPrice; $untaxedPrice = $taxedPrice;
$currentPosition = (int)$taxRule->getTaxRuleCountryPosition(); $currentPosition = (int) $taxRule->getTaxRuleCountryPosition();
$currentFixTax = 0; $currentFixTax = 0;
$currentTaxFactor = 0; $currentTaxFactor = 0;
do { do {
$position = (int)$taxRule->getTaxRuleCountryPosition(); $position = (int) $taxRule->getTaxRuleCountryPosition();
$taxType = $taxRule->getTypeInstance(); $taxType = $taxRule->getTypeInstance();
$taxType->loadRequirements( $taxRule->getRequirements() ); $taxType->loadRequirements( $taxRule->getRequirements() );
if($currentPosition !== $position) { if ($currentPosition !== $position) {
$untaxedPrice -= $currentFixTax; $untaxedPrice -= $currentFixTax;
$untaxedPrice = $untaxedPrice / (1+$currentTaxFactor); $untaxedPrice = $untaxedPrice / (1+$currentTaxFactor);
$currentFixTax = 0; $currentFixTax = 0;
@@ -211,8 +211,7 @@ class Calculator
$currentFixTax += $taxType->fixAmountRetriever($this->product); $currentFixTax += $taxType->fixAmountRetriever($this->product);
$currentTaxFactor += $taxType->pricePercentRetriever(); $currentTaxFactor += $taxType->pricePercentRetriever();
} while ($taxRule = $this->taxRulesCollection->getPrevious());
} while($taxRule = $this->taxRulesCollection->getPrevious());
$untaxedPrice -= $currentFixTax; $untaxedPrice -= $currentFixTax;
$untaxedPrice = $untaxedPrice / (1+$currentTaxFactor); $untaxedPrice = $untaxedPrice / (1+$currentTaxFactor);
@@ -224,7 +223,7 @@ class Calculator
$untaxedPrice -= $taxType->fixAmountRetriever(); $untaxedPrice -= $taxType->fixAmountRetriever();
} while($taxRule = $this->taxRulesCollection->getPrevious()); } while ($taxRule = $this->taxRulesCollection->getPrevious());
$taxRule = $this->taxRulesCollection->getLast(); $taxRule = $this->taxRulesCollection->getLast();
@@ -238,7 +237,7 @@ class Calculator
$toto = true; $toto = true;
} while($taxRule = $this->taxRulesCollection->getPrevious()); } while ($taxRule = $this->taxRulesCollection->getPrevious());
$untaxedPrice = $untaxedPrice / (1+$currentTaxFactor);*/ $untaxedPrice = $untaxedPrice / (1+$currentTaxFactor);*/

View File

@@ -42,13 +42,13 @@ class TaxEngine
*/ */
protected $session = null; protected $session = null;
static public function getInstance(Session $session = null) public static function getInstance(Session $session = null)
{ {
if(null === self::$instance) { if (null === self::$instance) {
self::$instance = new TaxEngine(); self::$instance = new TaxEngine();
} }
if(null !== self::$instance) { if (null !== self::$instance) {
self::$instance->setSession($session); self::$instance->setSession($session);
} }
@@ -85,7 +85,7 @@ class TaxEngine
$fileName = $directoryContent->getFilename(); $fileName = $directoryContent->getFilename();
$className = substr($fileName, 0, (1+strlen($directoryContent->getExtension())) * -1); $className = substr($fileName, 0, (1+strlen($directoryContent->getExtension())) * -1);
if($className == "BaseTaxType") { if ($className == "BaseTaxType") {
continue; continue;
} }
@@ -101,14 +101,14 @@ class TaxEngine
* Then look at the current customer default address country * Then look at the current customer default address country
* Else look at the default website country * Else look at the default website country
* *
* @param bool $force result is static cached ; even if a below parameter change between 2 calls, we need to keep coherent results. but you can force it. * @param bool $force result is static cached ; even if a below parameter change between 2 calls, we need to keep coherent results. but you can force it.
* @return null|TaxEngine * @return null|TaxEngine
*/ */
public function getDeliveryCountry($force = false) public function getDeliveryCountry($force = false)
{ {
if(false === $force || null === self::$taxCountry) { if (false === $force || null === self::$taxCountry) {
/* is there a logged in customer ? */ /* is there a logged in customer ? */
if(null !== $customer = $this->session->getCustomerUser()) { if (null !== $customer = $this->session->getCustomerUser()) {
if (null !== $this->session->getOrder() if (null !== $this->session->getOrder()
&& null !== $this->session->getOrder()->chosenDeliveryAddress && null !== $this->session->getOrder()->chosenDeliveryAddress
&& null !== $currentDeliveryAddress = AddressQuery::create()->findPk($this->session->getOrder()->chosenDeliveryAddress)) { && null !== $currentDeliveryAddress = AddressQuery::create()->findPk($this->session->getOrder()->chosenDeliveryAddress)) {

View File

@@ -35,13 +35,13 @@ abstract class BaseTaxType
{ {
protected $requirements = null; protected $requirements = null;
public abstract function pricePercentRetriever(); abstract public function pricePercentRetriever();
public abstract function fixAmountRetriever(Product $product); abstract public function fixAmountRetriever(Product $product);
public abstract function getRequirementsList(); abstract public function getRequirementsList();
public abstract function getTitle(); abstract public function getTitle();
public function calculate(Product $product, $untaxedPrice) public function calculate(Product $product, $untaxedPrice)
{ {
@@ -52,20 +52,20 @@ abstract class BaseTaxType
{ {
$this->requirements = $this->getRequirementsList(); $this->requirements = $this->getRequirementsList();
if(!is_array($this->requirements)) { if (!is_array($this->requirements)) {
throw new TaxEngineException('getRequirementsList must return an array', TaxEngineException::TAX_TYPE_BAD_ABSTRACT_METHOD); throw new TaxEngineException('getRequirementsList must return an array', TaxEngineException::TAX_TYPE_BAD_ABSTRACT_METHOD);
} }
foreach($this->requirements as $requirement => $requirementType) { foreach ($this->requirements as $requirement => $requirementType) {
if(!$requirementType instanceof TypeInterface) { if (!$requirementType instanceof TypeInterface) {
throw new TaxEngineException('getRequirementsList must return an array of TypeInterface', TaxEngineException::TAX_TYPE_BAD_ABSTRACT_METHOD); throw new TaxEngineException('getRequirementsList must return an array of TypeInterface', TaxEngineException::TAX_TYPE_BAD_ABSTRACT_METHOD);
} }
if(!array_key_exists($requirement, $requirementsValues)) { if (!array_key_exists($requirement, $requirementsValues)) {
throw new TaxEngineException('Cannot load requirements : requirement value for `' . $requirement . '` not found', TaxEngineException::TAX_TYPE_REQUIREMENT_NOT_FOUND); throw new TaxEngineException('Cannot load requirements : requirement value for `' . $requirement . '` not found', TaxEngineException::TAX_TYPE_REQUIREMENT_NOT_FOUND);
} }
if(!$requirementType->isValid($requirementsValues[$requirement])) { if (!$requirementType->isValid($requirementsValues[$requirement])) {
throw new TaxEngineException('Requirement value for `' . $requirement . '` does not match required type', TaxEngineException::TAX_TYPE_BAD_REQUIREMENT_VALUE); throw new TaxEngineException('Requirement value for `' . $requirement . '` does not match required type', TaxEngineException::TAX_TYPE_BAD_REQUIREMENT_VALUE);
} }
@@ -75,11 +75,11 @@ abstract class BaseTaxType
public function getRequirement($key) public function getRequirement($key)
{ {
if($this->requirements === null) { if ($this->requirements === null) {
throw new TaxEngineException('Requirements are empty in BaseTaxType::getRequirement', TaxEngineException::UNDEFINED_REQUIREMENTS); throw new TaxEngineException('Requirements are empty in BaseTaxType::getRequirement', TaxEngineException::UNDEFINED_REQUIREMENTS);
} }
if(!array_key_exists($key, $this->requirements)) { if (!array_key_exists($key, $this->requirements)) {
throw new TaxEngineException('Requirement value for `' . $key . '` does not exists in BaseTaxType::$requirements', TaxEngineException::UNDEFINED_REQUIREMENT_VALUE); throw new TaxEngineException('Requirement value for `' . $key . '` does not exists in BaseTaxType::$requirements', TaxEngineException::UNDEFINED_REQUIREMENT_VALUE);
} }

View File

@@ -52,7 +52,7 @@ class FeatureFixAmountTaxType extends BaseTaxType
$taxAmount = $query->getFreeTextValue(); $taxAmount = $query->getFreeTextValue();
$testInt = new FloatType(); $testInt = new FloatType();
if(!$testInt->isValid($taxAmount)) { if (!$testInt->isValid($taxAmount)) {
throw new TaxEngineException('Feature value does not match FLOAT format', TaxEngineException::FEATURE_BAD_EXPECTED_VALUE); throw new TaxEngineException('Feature value does not match FLOAT format', TaxEngineException::FEATURE_BAD_EXPECTED_VALUE);
} }

View File

@@ -406,7 +406,6 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
$couponManager = new RemoveXAmount($stubFacade); $couponManager = new RemoveXAmount($stubFacade);
$condition1 = new MatchForTotalAmount($stubFacade); $condition1 = new MatchForTotalAmount($stubFacade);
$operators = array( $operators = array(
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
@@ -439,7 +438,6 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
->method('unserializeConditionCollection') ->method('unserializeConditionCollection')
->will($this->returnValue($conditions)); ->will($this->returnValue($conditions));
$stubContainer->expects($this->any()) $stubContainer->expects($this->any())
->method('get') ->method('get')
->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory)); ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory));