[*] Classes: Remove $fieldsRequired, $fieldsSize and $fieldsValidate (and lang properties) properties, use $definition instead

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11155 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-12-12 18:10:38 +00:00
parent c97bac9160
commit fddf4fb89b
92 changed files with 1495 additions and 854 deletions
+40 -35
View File
@@ -147,41 +147,8 @@ class OrderCore extends ObjectModel
*/
public $reference;
protected $fieldsRequired = array('conversion_rate', 'id_address_delivery', 'id_address_invoice', 'id_cart', 'id_currency', 'id_lang', 'id_customer', 'id_carrier', 'payment', 'total_paid', 'total_paid_real', 'total_products', 'total_products_wt');
protected $fieldsValidate = array(
'id_address_delivery' => 'isUnsignedId',
'id_address_invoice' => 'isUnsignedId',
'id_cart' => 'isUnsignedId',
'id_currency' => 'isUnsignedId',
'id_group_shop' => 'isUnsignedId',
'id_shop' => 'isUnsignedId',
'id_lang' => 'isUnsignedId',
'id_customer' => 'isUnsignedId',
'id_carrier' => 'isUnsignedId',
'secure_key' => 'isMd5',
'payment' => 'isGenericName',
'recyclable' => 'isBool',
'gift' => 'isBool',
'gift_message' => 'isMessage',
'total_discounts' => 'isPrice',
'total_discounts_tax_incl' => 'isPrice',
'total_discounts_tax_excl' => 'isPrice',
'total_paid' => 'isPrice',
'total_paid_tax_incl' => 'isPrice',
'total_paid_tax_excl' => 'isPrice',
'total_paid_real' => 'isPrice',
'total_products' => 'isPrice',
'total_products_wt' => 'isPrice',
'total_shipping' => 'isPrice',
'total_shipping_tax_incl' => 'isPrice',
'total_shipping_tax_excl' => 'isPrice',
'carrier_tax_rate' => 'isFloat',
'total_wrapping' => 'isPrice',
'total_wrapping_tax_incl' => 'isPrice',
'total_wrapping_tax_excl' => 'isPrice',
'shipping_number' => 'isUrl',
'conversion_rate' => 'isFloat'
);
protected $webserviceParameters = array(
'objectMethods' => array('add' => 'addWs'),
@@ -220,11 +187,49 @@ class OrderCore extends ObjectModel
);
/* MySQL does not allow 'order' for a table name */
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'orders',
'primary' => 'id_order',
'fields' => array(
'id_address_delivery' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_address_invoice' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_cart' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_group_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'),
'id_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'),
'id_lang' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_carrier' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'secure_key' => array('type' => 'FILL_ME', 'validate' => 'isMd5'),
'payment' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true),
'recyclable' => array('type' => 'FILL_ME', 'validate' => 'isBool'),
'gift' => array('type' => 'FILL_ME', 'validate' => 'isBool'),
'gift_message' => array('type' => 'FILL_ME', 'validate' => 'isMessage'),
'total_discounts' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_discounts_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_discounts_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_paid' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
'total_paid_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_paid_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_paid_real' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
'total_products' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
'total_products_wt' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
'total_shipping' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_shipping_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_shipping_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'carrier_tax_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat'),
'total_wrapping' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_wrapping_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_wrapping_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'shipping_number' => array('type' => 'FILL_ME', 'validate' => 'isUrl'),
'conversion_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true),
),
);
protected $_taxCalculationMethod = PS_TAX_EXC;
protected static $_historyCache = array();
+16 -10
View File
@@ -55,22 +55,28 @@ class OrderCarrierCore extends ObjectModel
/** @var string Object creation date */
public $date_add;
protected $fieldsRequired = array ('id_order', 'id_carrier');
protected $fieldsValidate = array (
'id_order_carrier' => 'isUnsignedId',
'id_order' => 'isUnsignedId',
'id_carrier' => 'isUnsignedId',
'id_order_invoice' => 'isUnsignedId',
'weight' => 'isFloat',
'shipping_cost_tax_excl' => 'isFloat',
'shipping_cost_tax_incl' => 'isFloat',
'tracking_number' => 'isAnything');
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'order_carrier',
'primary' => 'id_order_carrier',
'fields' => array(
'id_order_carrier' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'),
'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_carrier' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_order_invoice' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'),
'weight' => array('type' => 'FILL_ME', 'validate' => 'isFloat'),
'shipping_cost_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isFloat'),
'shipping_cost_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isFloat'),
'tracking_number' => array('type' => 'FILL_ME', 'validate' => 'isAnything'),
),
);
protected $webserviceParameters = array(
'fields' => array(
'id_order' => array('xlink_resource' => 'orders'),
+11 -2
View File
@@ -42,15 +42,24 @@ class OrderCartRuleCore extends ObjectModel
/** @var integer */
public $value;
protected $fieldsRequired = array ('id_order', 'name', 'value');
protected $fieldsValidate = array ('id_order' => 'isUnsignedId', 'name' => 'isGenericName', 'value' => 'isInt');
/* MySQL does not allow 'order detail' for a table name */
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'order_cart_rule',
'primary' => 'id_order_cart_rule',
'fields' => array(
'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true),
'value' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true),
),
);
protected $webserviceParameters = array(
'fields' => array(
'id_order' => array('xlink_resource' => 'orders'),
+41 -41
View File
@@ -129,54 +129,54 @@ class OrderDetailCore extends ObjectModel
/** @var int Id warehouse */
public $id_warehouse;
protected $fieldsRequired = array(
'id_order',
'id_warehouse',
'product_name',
'product_quantity',
'product_price');
protected $fieldsValidate = array(
'id_order' => 'isUnsignedId',
'id_order_invoice' => 'isUnsignedId',
'id_warehouse' => 'isUnsignedId',
'product_id' => 'isUnsignedId',
'product_attribute_id' => 'isUnsignedId',
'product_name' => 'isGenericName',
'product_quantity' => 'isInt',
'product_quantity_in_stock' => 'isInt',
'product_quantity_return' => 'isUnsignedInt',
'product_quantity_refunded' => 'isUnsignedInt',
'product_quantity_reinjected' => 'isUnsignedInt',
'product_price' => 'isPrice',
'reduction_percent' => 'isFloat',
'reduction_amount' => 'isPrice',
'group_reduction' => 'isFloat',
'product_quantity_discount' => 'isFloat',
'product_ean13' => 'isEan13',
'product_upc' => 'isUpc',
'product_reference' => 'isReference',
'product_supplier_reference' => 'isReference',
'product_weight' => 'isFloat',
'tax_name' => 'isGenericName',
'tax_rate' => 'isFloat',
'ecotax' => 'isFloat',
'ecotax_tax_rate' => 'isFloat',
'discount_quantity_applied' => 'isInt',
'download_hash' => 'isGenericName',
'download_nb' => 'isInt',
'download_deadline' => 'isDateFormat',
'unit_price_tax_incl' => 'isPrice',
'unit_price_tax_excl' => 'isPrice',
'total_price_tax_incl' => 'isPrice',
'total_price_tax_excl' => 'isPrice'
);
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'order_detail',
'primary' => 'id_order_detail',
'fields' => array(
'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_order_invoice' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'),
'id_warehouse' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'product_id' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'),
'product_attribute_id' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'),
'product_name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true),
'product_quantity' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true),
'product_quantity_in_stock' => array('type' => 'FILL_ME', 'validate' => 'isInt'),
'product_quantity_return' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'),
'product_quantity_refunded' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'),
'product_quantity_reinjected' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'),
'product_price' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
'reduction_percent' => array('type' => 'FILL_ME', 'validate' => 'isFloat'),
'reduction_amount' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'group_reduction' => array('type' => 'FILL_ME', 'validate' => 'isFloat'),
'product_quantity_discount' => array('type' => 'FILL_ME', 'validate' => 'isFloat'),
'product_ean13' => array('type' => 'FILL_ME', 'validate' => 'isEan13'),
'product_upc' => array('type' => 'FILL_ME', 'validate' => 'isUpc'),
'product_reference' => array('type' => 'FILL_ME', 'validate' => 'isReference'),
'product_supplier_reference' => array('type' => 'FILL_ME', 'validate' => 'isReference'),
'product_weight' => array('type' => 'FILL_ME', 'validate' => 'isFloat'),
'tax_name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName'),
'tax_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat'),
'ecotax' => array('type' => 'FILL_ME', 'validate' => 'isFloat'),
'ecotax_tax_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat'),
'discount_quantity_applied' => array('type' => 'FILL_ME', 'validate' => 'isInt'),
'download_hash' => array('type' => 'FILL_ME', 'validate' => 'isGenericName'),
'download_nb' => array('type' => 'FILL_ME', 'validate' => 'isInt'),
'download_deadline' => array('type' => 'FILL_ME', 'validate' => 'isDateFormat'),
'unit_price_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'unit_price_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_price_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
'total_price_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'),
),
);
protected $webserviceParameters = array(
'fields' => array (
'id_order' => array('xlink_resource' => 'orders'),
+11 -2
View File
@@ -42,14 +42,23 @@ class OrderHistoryCore extends ObjectModel
/** @var string Object last modification date */
public $date_upd;
protected $fieldsRequired = array('id_order', 'id_order_state');
protected $fieldsValidate = array('id_order' => 'isUnsignedId', 'id_order_state' => 'isUnsignedId', 'id_employee' => 'isUnsignedId');
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'order_history',
'primary' => 'id_order_history',
'fields' => array(
'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_order_state' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_employee' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'),
),
);
protected $webserviceParameters = array(
'objectsNodeName' => 'order_histories',
'fields' => array(
+10 -2
View File
@@ -66,14 +66,22 @@ class OrderInvoiceCore extends ObjectModel
/** @var intger */
public $date_add;
protected $fieldsRequired = array('id_order', 'number');
protected $fieldsValidate = array('id_order' => 'isUnsignedId', 'number' => 'isUnsignedId');
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'order_invoice',
'primary' => 'id_order_invoice',
'fields' => array(
'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'number' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
),
);
public function getFields()
{
$this->validateFields();
+14 -6
View File
@@ -36,20 +36,28 @@ class OrderMessageCore extends ObjectModel
/** @var string Object creation date */
public $date_add;
protected $fieldsRequired = array();
protected $fieldsValidate = array();
protected $fieldsSize = array();
protected $fieldsRequiredLang = array('name', 'message');
protected $fieldsSizeLang = array('name' => 128, 'message' => 1200);
protected $fieldsValidateLang = array('name' => 'isGenericName', 'message' => 'isMessage');
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'order_message',
'primary' => 'id_order_message',
'multilang' => true,
'fields' => array(
'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
'message' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isMessage', 'required' => true, 'size' => 1200),
),
);
protected $webserviceParameters = array(
'fields' => array(
'id' => array('sqlId' => 'id_discount_type', 'xlink_resource' => 'order_message_lang'),
+19 -14
View File
@@ -39,26 +39,31 @@ class OrderPaymentCore extends ObjectModel
public $card_holder;
public $date_add;
protected $fieldsRequired = array('id_order', 'id_currency', 'amount');
protected $fieldsSize = array('transaction_id' => 254, 'card_number' => 254, 'card_brand' => 254, 'card_expiration' => 254, 'card_holder' => 254);
protected $fieldsValidate = array(
'id_order' => 'isUnsignedId',
'id_currency' => 'isUnsignedId',
'amount' => 'isPrice',
'payment_method' => 'isName',
'conversion_rate' => 'isFloat',
'transaction_id' => 'isAnything',
'card_number' => 'isAnything',
'card_brand' => 'isAnything',
'card_expiration' => 'isAnything',
'card_holder' => 'isAnything'
);
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'order_payment',
'primary' => 'id_order_payment',
'fields' => array(
'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'amount' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true),
'payment_method' => array('type' => 'FILL_ME', 'validate' => 'isName'),
'conversion_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat'),
'transaction_id' => array('type' => 'FILL_ME', 'validate' => 'isAnything', 'size' => 254),
'card_number' => array('type' => 'FILL_ME', 'validate' => 'isAnything', 'size' => 254),
'card_brand' => array('type' => 'FILL_ME', 'validate' => 'isAnything', 'size' => 254),
'card_expiration' => array('type' => 'FILL_ME', 'validate' => 'isAnything', 'size' => 254),
'card_holder' => array('type' => 'FILL_ME', 'validate' => 'isAnything', 'size' => 254),
),
);
public function getFields()
{
$this->validateFields();
+11 -2
View File
@@ -48,13 +48,22 @@ class OrderReturnCore extends ObjectModel
/** @var string Object last modification date */
public $date_upd;
protected $fieldsRequired = array ('id_customer', 'id_order');
protected $fieldsValidate = array('id_customer' => 'isUnsignedId', 'id_order' => 'isUnsignedId', 'question' => 'isMessage');
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'order_return',
'primary' => 'id_order_return',
'fields' => array(
'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'question' => array('type' => 'FILL_ME', 'validate' => 'isMessage'),
),
);
public function getFields()
{
+12 -4
View File
@@ -33,17 +33,25 @@ class OrderReturnStateCore extends ObjectModel
/** @var string Display state in the specified color */
public $color;
protected $fieldsValidate = array('color' => 'isColor');
protected $fieldsRequiredLang = array('name');
protected $fieldsSizeLang = array('name' => 64);
protected $fieldsValidateLang = array('name' => 'isGenericName');
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'order_return_state',
'primary' => 'id_order_return_state',
'multilang' => true,
'fields' => array(
'color' => array('type' => 'FILL_ME', 'validate' => 'isColor'),
'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64),
),
);
public function getFields()
{
$this->validateFields();
+11 -2
View File
@@ -57,14 +57,23 @@ class OrderSlipCore extends ObjectModel
/** @var string Object last modification date */
public $date_upd;
protected $fieldsRequired = array ('id_customer', 'id_order', 'conversion_rate');
protected $fieldsValidate = array('id_customer' => 'isUnsignedId', 'id_order' => 'isUnsignedId', 'conversion_rate' => 'isFloat');
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'order_slip',
'primary' => 'id_order_slip',
'fields' => array(
'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true),
'conversion_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true),
),
);
public function getFields()
{
$this->validateFields();
+17 -10
View File
@@ -56,24 +56,31 @@ class OrderStateCore extends ObjectModel
/** @var boolean Shipped */
public $shipped;
protected $fieldsValidate = array(
'send_email' => 'isBool',
'invoice' => 'isBool',
'color' => 'isColor',
'logable' => 'isBool',
'shipped' => 'isBool'
);
protected $fieldsRequiredLang = array('name');
protected $fieldsSizeLang = array('name' => 64, 'template' => 64);
protected $fieldsValidateLang = array('name' => 'isGenericName', 'template' => 'isTplName');
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'order_state',
'primary' => 'id_order_state',
'multilang' => true,
'fields' => array(
'send_email' => array('type' => 'FILL_ME', 'validate' => 'isBool'),
'invoice' => array('type' => 'FILL_ME', 'validate' => 'isBool'),
'color' => array('type' => 'FILL_ME', 'validate' => 'isColor'),
'logable' => array('type' => 'FILL_ME', 'validate' => 'isBool'),
'shipped' => array('type' => 'FILL_ME', 'validate' => 'isBool'),
'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64),
'template' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isTplName', 'size' => 64),
),
);
protected $webserviceParameters = array(
'fields' => array(
'unremovable' => array(),