refactor shipping object into area

This commit is contained in:
Manuel Raynaud
2013-10-10 17:18:38 +02:00
parent 9d6df61296
commit 560b80c182
7 changed files with 91 additions and 24 deletions

View File

@@ -120,8 +120,8 @@
<form name="thelia.admin.profile.modification" class="Thelia\Form\ProfileModificationForm"/> <form name="thelia.admin.profile.modification" class="Thelia\Form\ProfileModificationForm"/>
<form name="thelia.admin.shipping.create" class="Thelia\Form\Shipping\ShippingCreateForm"/> <form name="thelia.admin.area.create" class="Thelia\Form\Shipping\AreaCreateForm"/>
<form name="thelia.admin.shipping.modification" class="Thelia\Form\Shipping\ShippingModificationForm"/> <form name="thelia.admin.area.modification" class="Thelia\Form\Shipping\AreaModificationForm"/>
</forms> </forms>

View File

@@ -688,11 +688,11 @@
<!-- Shipping zones routes management --> <!-- Shipping zones routes management -->
<route id="admin.configuration.shipping-configuration.default" path="/admin/configuration/shipping_configuration"> <route id="admin.configuration.shipping-configuration.default" path="/admin/configuration/shipping_configuration">
<default key="_controller">Thelia\Controller\Admin\ShippingConfigurationController::defaultAction</default> <default key="_controller">Thelia\Controller\Admin\AreaController::defaultAction</default>
</route> </route>
<route id="admin.configuration.shipping-configuration.update.view" path="/admin/configuration/shipping_configuration/update/{shipping_configuration_id}" methods="get"> <route id="admin.configuration.shipping-configuration.update.view" path="/admin/configuration/shipping_configuration/update/{shipping_configuration_id}" methods="get">
<default key="_controller">Thelia\Controller\Admin\ShippingConfigurationController::updateAction</default> <default key="_controller">Thelia\Controller\Admin\AreaController::updateAction</default>
<requirement key="shipping_configuration_id">\d+</requirement> <requirement key="shipping_configuration_id">\d+</requirement>
</route> </route>

View File

@@ -25,11 +25,11 @@ namespace Thelia\Controller\Admin;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
/** /**
* Class ShippingConfigurationController * Class AreaController
* @package Thelia\Controller\Admin * @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class ShippingConfigurationController extends AbstractCrudController class AreaController extends AbstractCrudController
{ {
/* public function indexAction() /* public function indexAction()
{ {
@@ -51,14 +51,14 @@ class ShippingConfigurationController extends AbstractCrudController
null, null,
null, null,
'admin.shipping.default', 'admin.area.default',
'admin.shipping.create', 'admin.area.create',
'admin.shipping.update', 'admin.area.update',
'admin.shipping.delete', 'admin.area.delete',
TheliaEvents::SHIPPING_CREATE, TheliaEvents::AREA_CREATE,
TheliaEvents::SHIPPING_UPDATE, TheliaEvents::AREA_UPDATE,
TheliaEvents::SHIPPING_DELETE TheliaEvents::AREA_DELETE
); );
} }

View File

@@ -0,0 +1,66 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* 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 */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Event\Area;
use Thelia\Core\Event\ActionEvent;
/**
* Class AreaEvent
* @package Thelia\Core\Event\Shipping
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class AreaEvent extends ActionEvent
{
protected $area;
public function __construct($area = null)
{
$this->area = $area;
}
/**
* @param mixed $area
*
* @return $this
*/
public function setArea($area)
{
$this->area = $area;
return $this;
}
/**
* @return mixed
*/
public function getArea()
{
return $this->area;
}
public function hasArea()
{
return null !== $this->area;
}
}

View File

@@ -234,9 +234,9 @@ final class TheliaEvents
// -- SHIPPING CONFIGURATION MANAGEMENT // -- SHIPPING CONFIGURATION MANAGEMENT
const SHIPPING_CREATE = 'action.createShipping'; const AREA_CREATE = 'action.createArea';
const SHIPPING_UPDATE = 'action.updateShipping'; const AREA_UPDATE = 'action.updateArea';
const SHIPPING_DELETE = 'action.deleteShipping'; const AREA_DELETE = 'action.deleteArea';
// -- Categories Associated Content ---------------------------------------- // -- Categories Associated Content ----------------------------------------

View File

@@ -21,18 +21,18 @@
/* */ /* */
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Form\Shipping; namespace Thelia\Form\Area;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Form\BaseForm; use Thelia\Form\BaseForm;
/** /**
* Class ShippingCreateForm * Class AreaCreateForm
* @package Thelia\Form\Shipping * @package Thelia\Form\Shipping
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class ShippingCreateForm extends BaseForm class AreaCreateForm extends BaseForm
{ {
/** /**
@@ -74,6 +74,6 @@ class ShippingCreateForm extends BaseForm
*/ */
public function getName() public function getName()
{ {
return 'thelia_shipping_creation'; return 'thelia_area_creation';
} }
} }

View File

@@ -21,16 +21,17 @@
/* */ /* */
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Form\Shipping; namespace Thelia\Form\Area;
use Symfony\Component\Validator\Constraints\GreaterThan; use Symfony\Component\Validator\Constraints\GreaterThan;
use Thelia\Form\Area\AreaCreateForm;
/** /**
* Class ShippingModificationForm * Class AreaModificationForm
* @package Thelia\Form\Shipping * @package Thelia\Form\Shipping
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class ShippingModificationForm extends ShippingCreateForm class AreaModificationForm extends AreaCreateForm
{ {
public function buildForm() public function buildForm()
{ {
@@ -43,6 +44,6 @@ class ShippingModificationForm extends ShippingCreateForm
public function getName() public function getName()
{ {
return 'thelia_shipping_modification'; return 'thelia_area_modification';
} }
} }