fix minor bug

This commit is contained in:
Manuel Raynaud
2014-05-09 10:55:50 +02:00
parent d9d350ea24
commit 85d80d1d77
31 changed files with 243 additions and 309 deletions

View File

@@ -59,8 +59,6 @@ class Currency extends BaseAction implements EventSubscriberInterface
*/ */
public function update(CurrencyUpdateEvent $event) public function update(CurrencyUpdateEvent $event)
{ {
$search = CurrencyQuery::create();
if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) { if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) {
$currency $currency

View File

@@ -302,7 +302,7 @@ class Order extends BaseAction implements EventSubscriberInterface
*/ */
public function createManual(OrderManualEvent $event) public function createManual(OrderManualEvent $event)
{ {
$placedOrder = $this->createOrder( $this->createOrder(
$event->getDispatcher(), $event->getDispatcher(),
$event->getOrder(), $event->getOrder(),
$event->getCurrency(), $event->getCurrency(),

0
core/lib/Thelia/Command/ModuleDeactivateCommand.php Executable file → Normal file
View File

View File

@@ -308,4 +308,4 @@ abstract class ConditionAbstract implements ConditionInterface
] ]
); );
} }
} }

View File

@@ -271,4 +271,4 @@ class MatchForTotalAmount extends ConditionAbstract
] ]
); );
} }
} }

View File

@@ -225,4 +225,4 @@ class MatchForXArticles extends ConditionAbstract
] ]
); );
} }
} }

View File

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

View File

@@ -1,4 +1,4 @@
<?php <?php
return array( return array(
); );

View File

@@ -1,4 +1,4 @@
<?php <?php
return array( return array(
); );

View File

@@ -33,9 +33,7 @@ use Thelia\Form\Exception\FormValidationException;
use Thelia\Log\Tlog; use Thelia\Log\Tlog;
use Thelia\Model\Coupon; use Thelia\Model\Coupon;
use Thelia\Model\CouponQuery; use Thelia\Model\CouponQuery;
use Thelia\Model\Lang;
use Thelia\Model\LangQuery; use Thelia\Model\LangQuery;
use Thelia\Tools\I18n;
use Thelia\Tools\Rest\ResponseRest; use Thelia\Tools\Rest\ResponseRest;
/** /**
@@ -263,8 +261,7 @@ class CouponController extends BaseAdminController
$html = $condition->drawBackOfficeInputs(); $html = $condition->drawBackOfficeInputs();
$serviceId = $condition->getServiceId(); $serviceId = $condition->getServiceId();
} } else {
else {
$html = ''; $html = '';
$serviceId = ''; $serviceId = '';
} }

View File

@@ -38,6 +38,7 @@ use Thelia\Core\Event\ProductSaleElement\ProductSaleElementCreateEvent;
use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Core\Security\AccessManager; use Thelia\Core\Security\AccessManager;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\AccessoryQuery; use Thelia\Model\AccessoryQuery;
use Thelia\Model\CategoryQuery; use Thelia\Model\CategoryQuery;
use Thelia\Model\FeatureQuery; use Thelia\Model\FeatureQuery;

View File

@@ -16,6 +16,7 @@ use Thelia\Core\Security\AccessManager;
use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Core\Event\Profile\ProfileEvent; use Thelia\Core\Event\Profile\ProfileEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Form\ProfileCreationForm; use Thelia\Form\ProfileCreationForm;
use Thelia\Form\ProfileModificationForm; use Thelia\Form\ProfileModificationForm;
use Thelia\Form\ProfileUpdateModuleAccessForm; use Thelia\Form\ProfileUpdateModuleAccessForm;

View File

@@ -113,7 +113,7 @@ class SessionController extends BaseAdminController
/** /**
* we have tou find a way to send cookie * we have tou find a way to send cookie
*/ */
if (intval($adminLoginForm->getForm()->get('remember_me')->getData()) > 0) { if (intval($form->get('remember_me')->getData()) > 0) {
// If a remember me field if present and set in the form, create // If a remember me field if present and set in the form, create
// the cookie thant store "remember me" information // the cookie thant store "remember me" information
$this->createAdminRememberMeCookie($user); $this->createAdminRememberMeCookie($user);

View File

@@ -16,6 +16,7 @@ use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Core\Event\Tax\TaxRuleEvent; use Thelia\Core\Event\Tax\TaxRuleEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Security\AccessManager; use Thelia\Core\Security\AccessManager;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Form\TaxRuleCreationForm; use Thelia\Form\TaxRuleCreationForm;
use Thelia\Form\TaxRuleModificationForm; use Thelia\Form\TaxRuleModificationForm;
use Thelia\Form\TaxRuleTaxListUpdateForm; use Thelia\Form\TaxRuleTaxListUpdateForm;

View File

@@ -182,6 +182,4 @@ class LangCreateEvent extends LangEvent
return $this->thousands_separator; return $this->thousands_separator;
} }
} }

View File

@@ -19,7 +19,7 @@ class ProductSaleElementEvent extends ActionEvent
{ {
public $product_sale_element = null; public $product_sale_element = null;
public function __construct(ProductSaleElement $product_sale_element = null) public function __construct(ProductSaleElements $product_sale_element = null)
{ {
$this->product_sale_element = $product_sale_element; $this->product_sale_element = $product_sale_element;
} }

View File

@@ -1,71 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Core\Factory;
use Symfony\Component\HttpFoundation\Request;
/**
* *
* try to instanciate the good action class
*
* Class ActionEventFactory
* @package Thelia\Core\Factory
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ActionEventFactory
{
/**
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/**
* @var string
*/
protected $action;
/**
* array(
* "action.addCart" => "Thelia\Core\Event\CartAction"
* )
*
* @var array key are action name and value the Event class to dispatch
*/
protected $className;
protected $defaultClassName = "Thelia\Core\Event\DefaultActionEvent";
public function __construct(Request $request, $action, $className)
{
$this->request = $request;
$this->action = $action;
$this->className = $className;
}
public function createActionEvent()
{
if (array_key_exists($this->action, $this->className)) {
$class = new \ReflectionClass($this->className[$this->action]);
// return $class->newInstance($this->request, $this->action);
} else {
$class = new \ReflectionClass($this->defaultClassName);
}
if ($class->isSubclassOf("Thelia\Core\Event\ActionEvent") === false) {
throw new \RuntimeException("%s must be a subclass of Thelia\Core\Event\ActionEvent", $class->getName());
}
return $class->newInstance($this->request, $this->action);
}
}

View File

@@ -53,10 +53,10 @@ class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface
new TypeCollection( new TypeCollection(
new EnumListType(array( new EnumListType(array(
'id', 'id-reverse', 'id', 'id-reverse',
'code', 'code-reverse', 'code', 'code-reverse',
'title', 'title-reverse', 'title', 'title-reverse',
'enabled', 'enabled-reverse', 'enabled', 'enabled-reverse',
'expiration-date', 'expiration-date-reverse', 'expiration-date', 'expiration-date-reverse',
'days-left', 'days-left-reverse', 'days-left', 'days-left-reverse',
'usages-left', 'usages-left-reverse' 'usages-left', 'usages-left-reverse'
) )

View File

@@ -62,7 +62,7 @@ class OrderCoupon extends BaseLoop implements PropelSearchLoopInterface
public function parseResults(LoopResult $loopResult) public function parseResults(LoopResult $loopResult)
{ {
$conditionFactory = $this->container->get('thelia.condition.factory'); $this->container->get('thelia.condition.factory');
/** @var OrderCoupon $orderCoupon */ /** @var OrderCoupon $orderCoupon */
foreach ($loopResult->getResultDataCollection() as $orderCoupon) { foreach ($loopResult->getResultDataCollection() as $orderCoupon) {

View File

@@ -857,7 +857,7 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
$visible = $this->getVisible(); $visible = $this->getVisible();
if ($visible !== BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0); if ($visible !== Type\BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
$exclude = $this->getExclude(); $exclude = $this->getExclude();

View File

@@ -96,8 +96,6 @@ class TheliaLoop extends AbstractSmartyPlugin
$loop = $this->createLoopInstance($params); $loop = $this->createLoopInstance($params);
$dummy = null;
return $loop->count(); return $loop->count();
} }

View File

@@ -354,7 +354,8 @@ abstract class CouponAbstract implements CouponInterface
* *
* @return string HTML string * @return string HTML string
*/ */
public function drawBackOfficeInputs() { public function drawBackOfficeInputs()
{
return $this->facade->getParser()->render('coupon/type-fragments/remove-x.html', [ return $this->facade->getParser()->render('coupon/type-fragments/remove-x.html', [
'label' => $this->getInputName(), 'label' => $this->getInputName(),
'fieldName' => self::INPUT_AMOUNT_NAME, 'fieldName' => self::INPUT_AMOUNT_NAME,

View File

@@ -145,7 +145,7 @@ class CouponCreationForm extends BaseForm
/** /**
* Validate a date entered with the default Language date format. * Validate a date entered with the default Language date format.
* *
* @param string $value * @param string $value
* @param ExecutionContextInterface $context * @param ExecutionContextInterface $context
*/ */
public function checkLocalizedDate($value, ExecutionContextInterface $context) public function checkLocalizedDate($value, ExecutionContextInterface $context)

View File

@@ -17,7 +17,6 @@ use Thelia\Model\Base\AreaDeliveryModuleQuery as BaseAreaDeliveryModuleQuery;
class AreaDeliveryModuleQuery extends BaseAreaDeliveryModuleQuery class AreaDeliveryModuleQuery extends BaseAreaDeliveryModuleQuery
{ {
public function findByCountryAndModule(Country $country, Module $module) public function findByCountryAndModule(Country $country, Module $module)
{ {
$response = null; $response = null;

View File

@@ -56,9 +56,21 @@ class Content extends BaseContent
public function setDefaultFolder($folderId) public function setDefaultFolder($folderId)
{ {
/* ContentFolderQuery::create() // Unset previous category
->filterByContentId($this->getId) ContentFolderQuery::create()
->update(array("DefaultFolder" => 0));*/ ->filterByContentId($this->getId())
->filterByDefaultFolder(true)
->find()
->setByDefault(false)
->save();
// Set new default category
ContentFolderQuery::create()
->filterByContentId($this->getId())
->filterByFolderId($folderId)
->find()
->setByDefault(true)
->save();
return $this; return $this;
} }

View File

@@ -1,203 +1,201 @@
<?php <?php
/**********************************************************************************/ /**********************************************************************************/
/* */ /* */
/* Thelia */ /* Thelia */
/* */ /* */
/* Copyright (c) OpenStudio */ /* Copyright (c) OpenStudio */
/* email : info@thelia.net */ /* email : info@thelia.net */
/* web : http://www.thelia.net */ /* web : http://www.thelia.net */
/* */ /* */
/* This program is free software; you can redistribute it and/or modify */ /* 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 */ /* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */ /* the Free Software Foundation; either version 3 of the License */
/* */ /* */
/* This program is distributed in the hope that it will be useful, */ /* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */ /* GNU General Public License for more details. */
/* */ /* */
/* You should have received a copy of the GNU General Public License */ /* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */ /* */
/**********************************************************************************/ /**********************************************************************************/
namespace Thelia\Model; namespace Thelia\Model;
use Propel\Runtime\Propel; use Thelia\Model\Base\Coupon as BaseCoupon;
use Thelia\Model\Base\Coupon as BaseCoupon; use Thelia\Model\Exception\InvalidArgumentException;
use Thelia\Model\Exception\InvalidArgumentException;
use Thelia\Model\Map\CouponTableMap; /**
* Used to provide an effect (mostly a discount)
/** * at the end of the Customer checkout tunnel
* Used to provide an effect (mostly a discount) * It will be usable for a Customer only if it matches the Coupon criteria (Rules)
* at the end of the Customer checkout tunnel *
* It will be usable for a Customer only if it matches the Coupon criteria (Rules) * @package Coupon
* * @author Guillaume MOREL <gmorel@openstudio.fr>
* @package Coupon *
* @author Guillaume MOREL <gmorel@openstudio.fr> */
* class Coupon extends BaseCoupon
*/ {
class Coupon extends BaseCoupon
{ use \Thelia\Model\Tools\ModelEventDispatcherTrait;
use \Thelia\Model\Tools\ModelEventDispatcherTrait; /**
* Create or Update this Coupon
/** *
* Create or Update this Coupon * @param string $code Coupon Code
* * @param string $title Coupon title
* @param string $code Coupon Code * @param array $effects Ready to be serialized in JSON effect params
* @param string $title Coupon title * @param string $type Coupon type
* @param array $effects Ready to be serialized in JSON effect params * @param bool $isRemovingPostage Is removing Postage
* @param string $type Coupon type * @param string $shortDescription Coupon short description
* @param bool $isRemovingPostage Is removing Postage * @param string $description Coupon description
* @param string $shortDescription Coupon short description * @param boolean $isEnabled Enable/Disable
* @param string $description Coupon description * @param \DateTime $expirationDate Coupon expiration date
* @param boolean $isEnabled Enable/Disable * @param boolean $isAvailableOnSpecialOffers Is available on special offers
* @param \DateTime $expirationDate Coupon expiration date * @param boolean $isCumulative Is cumulative
* @param boolean $isAvailableOnSpecialOffers Is available on special offers * @param int $maxUsage Coupon quantity
* @param boolean $isCumulative Is cumulative * @param string $defaultSerializedRule Serialized default rule added if none found
* @param int $maxUsage Coupon quantity * @param string $locale Coupon Language code ISO (ex: fr_FR)
* @param string $defaultSerializedRule Serialized default rule added if none found *
* @param string $locale Coupon Language code ISO (ex: fr_FR) * @throws \Exception
* */
* @throws \Exception public function createOrUpdate($code, $title, array $effects, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $defaultSerializedRule, $locale = null)
*/ {
public function createOrUpdate($code, $title, array $effects, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $defaultSerializedRule, $locale = null) $this
{ ->setCode($code)
$this ->setType($type)
->setCode($code) ->setEffects($effects)
->setType($type) ->setIsRemovingPostage($isRemovingPostage)
->setEffects($effects) ->setIsEnabled($isEnabled)
->setIsRemovingPostage($isRemovingPostage) ->setExpirationDate($expirationDate)
->setIsEnabled($isEnabled) ->setIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers)
->setExpirationDate($expirationDate) ->setIsCumulative($isCumulative)
->setIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers) ->setMaxUsage($maxUsage)
->setIsCumulative($isCumulative) ->setLocale($locale)
->setMaxUsage($maxUsage) ->setTitle($title)
->setLocale($locale) ->setShortDescription($shortDescription)
->setTitle($title) ->setDescription($description);
->setShortDescription($shortDescription)
->setDescription($description); // If no rule given, set default rule
if (null === $this->getSerializedConditions()) {
// If no rule given, set default rule $this->setSerializedConditions($defaultSerializedRule);
if (null === $this->getSerializedConditions()) { }
$this->setSerializedConditions($defaultSerializedRule);
} $this->save();
}
$this->save();
} /**
* Create or Update this coupon condition
/** *
* Create or Update this coupon condition * @param string $serializableConditions Serialized conditions ready to be saved
* * @param string $locale Coupon Language code ISO (ex: fr_FR)
* @param string $serializableConditions Serialized conditions ready to be saved *
* @param string $locale Coupon Language code ISO (ex: fr_FR) * @throws \Exception
* */
* @throws \Exception public function createOrUpdateConditions($serializableConditions, $locale)
*/ {
public function createOrUpdateConditions($serializableConditions, $locale) $this->setSerializedConditions($serializableConditions);
{
$this->setSerializedConditions($serializableConditions); // Set object language (i18n)
if (!is_null($locale)) {
// Set object language (i18n) $this->setLocale($locale);
if (!is_null($locale)) { }
$this->setLocale($locale);
} $this->save();
}
$this->save();
} /**
* Set Coupon amount
/** *
* Set Coupon amount * @param float $amount Amount deduced from the Cart
* *
* @param float $amount Amount deduced from the Cart * @return $this
* */
* @return $this public function setAmount($amount)
*/ {
public function setAmount($amount) $effects = $this->unserializeEffects($this->getSerializedEffects());
{ $effects['amount'] = floatval($amount);
$effects = $this->unserializeEffects($this->getSerializedEffects()); $this->setEffects($effects);
$effects['amount'] = floatval($amount);
$this->setEffects($effects); return $this;
}
return $this;
} /**
* Get the amount removed from the coupon to the cart
/** *
* Get the amount removed from the coupon to the cart * @return float
* */
* @return float public function getAmount()
*/ {
public function getAmount() $amount = $this->getEffects()['amount'];
{
$amount = $this->getEffects()['amount']; return floatval($amount);
}
return floatval($amount);
} /**
* Get the Coupon effects
/** *
* Get the Coupon effects * @return array
* * @throws Exception\InvalidArgumentException
* @return array */
* @throws Exception\InvalidArgumentException public function getEffects()
*/ {
public function getEffects() $effects = $this->unserializeEffects($this->getSerializedEffects());
{
$effects = $this->unserializeEffects($this->getSerializedEffects()); if (null === $effects['amount']) {
throw new InvalidArgumentException('Missing key \'amount\' in Coupon effect coming from database');
if (null === $effects['amount']) { }
throw new InvalidArgumentException('Missing key \'amount\' in Coupon effect coming from database');
} return $effects;
}
return $effects;
} /**
* Get the Coupon effects
/** *
* Get the Coupon effects * @param array $effects Effect ready to be serialized
* * Needs at least the key 'amount'
* @param array $effects Effect ready to be serialized * with the amount removed from the cart
* Needs at least the key 'amount' *
* with the amount removed from the cart * @throws Exception\InvalidArgumentException
* * @return $this
* @throws Exception\InvalidArgumentException */
* @return $this public function setEffects(array $effects)
*/ {
public function setEffects(array $effects) if (null === $effects['amount']) {
{ throw new InvalidArgumentException('Missing key \'amount\' in Coupon effect ready to be serialized array');
if (null === $effects['amount']) { }
throw new InvalidArgumentException('Missing key \'amount\' in Coupon effect ready to be serialized array');
} $this->setSerializedEffects($this->serializeEffects($effects));
$this->setSerializedEffects($this->serializeEffects($effects)); return $this;
}
return $this;
} /**
* Return unserialized effects
/** *
* Return unserialized effects * @param string $serializedEffects Serialized effect string to unserialize
* *
* @param string $serializedEffects Serialized effect string to unserialize * @return array
* */
* @return array public function unserializeEffects($serializedEffects)
*/ {
public function unserializeEffects($serializedEffects) $effects = json_decode($serializedEffects, true);
{
$effects = json_decode($serializedEffects, true); return $effects;
}
return $effects;
} /**
* Return serialized effects
/** *
* Return serialized effects * @param array $unserializedEffects Unserialized array string to serialize
* *
* @param array $unserializedEffects Unserialized array string to serialize * @return string
* */
* @return string public function serializeEffects(array $unserializedEffects)
*/ {
public function serializeEffects(array $unserializedEffects) $effects = json_encode($unserializedEffects);
{
$effects = json_encode($unserializedEffects); return $effects;
}
return $effects; }
}
}

View File

@@ -172,7 +172,7 @@ class Product extends BaseProduct
$this->setTaxRuleId($taxRuleId); $this->setTaxRuleId($taxRuleId);
// Create the default product sale element of this product // Create the default product sale element of this product
$sale_elements = $this->createProductSaleElement($con, $baseWeight, $basePrice, $basePrice, $priceCurrencyId, true); $this->createProductSaleElement($con, $baseWeight, $basePrice, $basePrice, $priceCurrencyId, true);
// Store all the stuff ! // Store all the stuff !
$con->commit(); $con->commit();

View File

@@ -2,6 +2,7 @@
namespace Thelia\Model; namespace Thelia\Model;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\Base\ProductSaleElements as BaseProductSaleElements; use Thelia\Model\Base\ProductSaleElements as BaseProductSaleElements;
use Thelia\Model\Tools\ProductPriceTools; use Thelia\Model\Tools\ProductPriceTools;
use Thelia\TaxEngine\Calculator; use Thelia\TaxEngine\Calculator;

View File

@@ -2,6 +2,7 @@
namespace Thelia\Model; namespace Thelia\Model;
use Propel\Runtime\Exception\PropelException;
use Thelia\Exception\TaxEngineException; use Thelia\Exception\TaxEngineException;
use Thelia\Model\Base\Tax as BaseTax; use Thelia\Model\Base\Tax as BaseTax;
use Thelia\Model\Tools\ModelEventDispatcherTrait; use Thelia\Model\Tools\ModelEventDispatcherTrait;

View File

@@ -119,7 +119,7 @@ trait PositionManagementTrait
$result->setDispatcher($this->getDispatcher())->setPosition($my_position)->save($cnx); $result->setDispatcher($this->getDispatcher())->setPosition($my_position)->save($cnx);
$cnx->commit(); $cnx->commit();
} catch (Exception $e) { } catch (\Exception $e) {
$cnx->rollback(); $cnx->rollback();
} }
} }
@@ -185,7 +185,7 @@ trait PositionManagementTrait
; ;
$cnx->commit(); $cnx->commit();
} catch (Exception $e) { } catch (\Exception $e) {
$cnx->rollback(); $cnx->rollback();
} }
} }

View File

@@ -44,7 +44,6 @@ class ContentTest extends BaseLoopTestor
$content = ContentQuery::create()->findOne(); $content = ContentQuery::create()->findOne();
if (null === $content) { if (null === $content) {
$content = new \Thelia\Model\Content(); $content = new \Thelia\Model\Content();
$content->setDefaultFolder(0);
$content->setVisible(1); $content->setVisible(1);
$content->setTitle('foo'); $content->setTitle('foo');
$content->save(); $content->save();