Working : Coupon : fix update effect (becomes type), update max usage
This commit is contained in:
@@ -160,26 +160,31 @@
|
||||
|
||||
<!-- Route to the Coupon controller (process Coupon browsing) -->
|
||||
|
||||
<route id="admin.coupon.list" path="/admin/coupon/">
|
||||
<route id="admin.coupon.list" path="/admin/coupon">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::browseAction</default>
|
||||
</route>
|
||||
<route id="admin.coupon.create" path="/admin/coupon/create/">
|
||||
<route id="admin.coupon.create" path="/admin/coupon/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::createAction</default>
|
||||
</route>
|
||||
<route id="admin.coupon.update" path="/admin/coupon/update/{couponId}/">
|
||||
<route id="admin.coupon.update" path="/admin/coupon/update/{couponId}">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::updateAction</default>
|
||||
<requirement key="couponId">\d+</requirement>
|
||||
</route>
|
||||
<route id="admin.coupon.read" path="/admin/coupon/read/{couponId}/">
|
||||
<route id="admin.coupon.read" path="/admin/coupon/read/{couponId}">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::readAction</default>
|
||||
<requirement key="couponId">\d+</requirement>
|
||||
</route>
|
||||
<route id="admin.coupon.rule.input" path="/admin/coupon/rule/{ruleId}/">
|
||||
<route id="admin.coupon.rule.input" path="/admin/coupon/rule/{ruleId}">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::getRuleInputAction</default>
|
||||
<requirement key="ruleId">.*</requirement>
|
||||
</route>
|
||||
<route id="admin.coupon.rule.update" path="/admin/coupon/{couponId}/rule/update/">
|
||||
<route id="admin.coupon.rule.update" path="/admin/coupon/{couponId}/rule/update">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::updateRulesAction</default>
|
||||
<requirement key="couponId">\d+</requirement>
|
||||
</route>
|
||||
<route id="admin.coupon.consume" path="/admin/coupon/consume/{couponCode}/">
|
||||
<route id="admin.coupon.consume" path="/admin/coupon/consume/{couponCode}">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::consumeAction</default>
|
||||
<requirement key="couponCode">.*</requirement>
|
||||
</route>
|
||||
|
||||
<!-- Routes to the Config (system variables) controller -->
|
||||
|
||||
@@ -201,7 +201,7 @@ class CouponController extends BaseAdminController
|
||||
$lang = $this->getSession()->getLang();
|
||||
$eventToDispatch = TheliaEvents::COUPON_UPDATE;
|
||||
|
||||
// Create
|
||||
// Update
|
||||
if ($this->getRequest()->isMethod('POST')) {
|
||||
$this->validateCreateOrUpdateForm(
|
||||
$i18n,
|
||||
@@ -210,7 +210,7 @@ class CouponController extends BaseAdminController
|
||||
'updated',
|
||||
'update'
|
||||
);
|
||||
} else { // Update
|
||||
} else { // Display
|
||||
|
||||
// Prepare the data that will hydrate the form
|
||||
/** @var ConstraintFactory $constraintFactory */
|
||||
@@ -495,11 +495,12 @@ class CouponController extends BaseAdminController
|
||||
|
||||
// Get the form field values
|
||||
$data = $form->getData();
|
||||
|
||||
$couponEvent = new CouponCreateOrUpdateEvent(
|
||||
$data['code'],
|
||||
$data['title'],
|
||||
$data['amount'],
|
||||
$data['effect'],
|
||||
$data['type'],
|
||||
$data['shortDescription'],
|
||||
$data['description'],
|
||||
$data['isEnabled'],
|
||||
|
||||
@@ -90,7 +90,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
* @param string $code Coupon Code
|
||||
* @param string $title Coupon title
|
||||
* @param float $amount Amount removed from the Total Checkout
|
||||
* @param string $effect Coupon effect
|
||||
* @param string $type Coupon type
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
* @param boolean $isEnabled Enable/Disable
|
||||
@@ -106,7 +106,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
$code,
|
||||
$title,
|
||||
$amount,
|
||||
$effect,
|
||||
$type,
|
||||
$shortDescription,
|
||||
$description,
|
||||
$isEnabled,
|
||||
@@ -130,7 +130,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
$this->rules = $rules;
|
||||
$this->shortDescription = $shortDescription;
|
||||
$this->title = $title;
|
||||
$this->effect = $effect;
|
||||
$this->type = $type;
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
@@ -264,13 +264,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Coupon effect
|
||||
* Get Coupon type (effect)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEffect()
|
||||
public function getType()
|
||||
{
|
||||
return $this->effect;
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,7 +87,7 @@ class CouponCreationForm extends BaseForm
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'effect',
|
||||
'type',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(
|
||||
|
||||
@@ -54,7 +54,7 @@ class Coupon extends BaseCoupon
|
||||
* @param string $code Coupon Code
|
||||
* @param string $title Coupon title
|
||||
* @param float $amount Amount removed from the Total Checkout
|
||||
* @param string $effect Coupon effect
|
||||
* @param string $type Coupon type
|
||||
* @param bool $isRemovingPostage Is removing Postage
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
@@ -67,13 +67,13 @@ class Coupon extends BaseCoupon
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
function createOrUpdate($code, $title, $amount, $effect, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $locale = null)
|
||||
function createOrUpdate($code, $title, $amount, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $locale = null)
|
||||
{
|
||||
$this->setCode($code)
|
||||
->setTitle($title)
|
||||
->setShortDescription($shortDescription)
|
||||
->setDescription($description)
|
||||
->setType($effect)
|
||||
->setType($type)
|
||||
->setAmount($amount)
|
||||
->setIsRemovingPostage($isRemovingPostage)
|
||||
->setIsEnabled($isEnabled)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Coupon;
|
||||
|
||||
use Thelia\Coupon\RuleOrganizer;
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 8/19/13
|
||||
@@ -47,7 +48,7 @@ class RuleOrganizerTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->object = new RuleOrganizer;
|
||||
$this->object = new RuleOrganizer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user