From 49129f85dc06bda1b26353adedefbb06abc2c9dc Mon Sep 17 00:00:00 2001 From: rMalie Date: Wed, 14 Dec 2011 17:21:18 +0000 Subject: [PATCH] // Format definitions git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11230 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/Address.php | 9 ------ classes/CMSCategory.php | 9 ------ classes/Cart.php | 63 ++++++++++++++-------------------------- classes/Category.php | 9 ------ classes/Customer.php | 13 --------- classes/Group.php | 13 --------- classes/Hook.php | 4 +-- classes/Manufacturer.php | 13 --------- classes/ObjectModel.php | 2 +- classes/Product.php | 3 -- 10 files changed, 25 insertions(+), 113 deletions(-) diff --git a/classes/Address.php b/classes/Address.php index e4502e611..b3f87622f 100644 --- a/classes/Address.php +++ b/classes/Address.php @@ -200,15 +200,6 @@ class AddressCore extends ObjectModel return $out; } - public function getFields() - { - $fields = parent::getFields(); - if (isset($this->id)) - $fields['id_address'] = (int)$this->id; - - return $fields; - } - public function validateController($htmlentities = true) { $errors = parent::validateController($htmlentities); diff --git a/classes/CMSCategory.php b/classes/CMSCategory.php index 4051f5847..a0a82a98c 100644 --- a/classes/CMSCategory.php +++ b/classes/CMSCategory.php @@ -100,15 +100,6 @@ class CMSCategoryCore extends ObjectModel parent::__construct($id_cms_category, $id_lang); } - public function getFields() - { - $fields = parent::getFields(); - if (isset($this->id)) - $fields['id_cms_category'] = (int)($this->id); - - return $fields; - } - /** * Check then return multilingual fields for database interaction * diff --git a/classes/Cart.php b/classes/Cart.php index d582de72c..977c320a3 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -84,21 +84,6 @@ class CartCore extends ObjectModel protected static $_nbProducts = array(); protected static $_isVirtualCart = array(); - protected $fieldsRequired = array('id_currency', 'id_lang'); - protected $fieldsValidate = array( - 'id_address_delivery' => 'isUnsignedId', - 'id_carrier' => 'isUnsignedId', - 'id_address_invoice' => 'isUnsignedId', - 'id_currency' => 'isUnsignedId', - 'id_customer' => 'isUnsignedId', - 'id_guest' => 'isUnsignedId', - 'id_lang' => 'isUnsignedId', - 'recyclable' => 'isBool', - 'gift' => 'isBool', - 'gift_message' => 'isMessage', - 'allow_seperated_package' => 'isBool' - ); - protected $_products = null; protected static $_totalWeight = array(); protected $_taxCalculationMethod = PS_TAX_EXC; @@ -106,9 +91,31 @@ class CartCore extends ObjectModel protected static $_taxes_rate = null; protected static $_attributesLists = array(); + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'cart', 'primary' => 'id_cart', + 'fields' => array( + 'id_group_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_address_delivery' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_address_invoice' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'recyclable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'gift' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'gift_message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage'), + 'delivery_option' => array('type' => self::TYPE_STRING), + 'secure_key' => array('type' => self::TYPE_STRING, 'size' => 32), + 'allow_seperated_package' =>array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'), + ), ); protected $webserviceParameters = array( @@ -138,32 +145,6 @@ class CartCore extends ObjectModel const ONLY_WRAPPING = 6; const ONLY_PRODUCTS_WITHOUT_SHIPPING = 7; - public function getFields() - { - $this->validateFields(); - - $fields['id_group_shop'] = (int)$this->id_group_shop; - $fields['id_shop'] = (int)$this->id_shop; - - $fields['id_address_delivery'] = (int)$this->id_address_delivery; - $fields['id_address_invoice'] = (int)$this->id_address_invoice; - $fields['id_currency'] = (int)$this->id_currency; - $fields['id_customer'] = (int)$this->id_customer; - $fields['id_carrier'] = (int)$this->id_carrier; - $fields['id_guest'] = (int)$this->id_guest; - $fields['id_lang'] = (int)$this->id_lang; - $fields['recyclable'] = (int)$this->recyclable; - $fields['gift'] = (int)$this->gift; - $fields['secure_key'] = pSQL($this->secure_key); - $fields['gift_message'] = pSQL($this->gift_message); - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - $fields['allow_seperated_package'] = (int)$this->allow_seperated_package; - $fields['delivery_option'] = $this->delivery_option; - - return $fields; - } - public function __construct($id = null, $id_lang = null) { parent::__construct($id, $id_lang); diff --git a/classes/Category.php b/classes/Category.php index 9d9d5df25..8ef697abe 100644 --- a/classes/Category.php +++ b/classes/Category.php @@ -130,15 +130,6 @@ class CategoryCore extends ObjectModel $this->image_dir = _PS_CAT_IMG_DIR_; } - public function getFields() - { - $fields = parent::getFields(); - if (isset($this->id)) - $fields['id_category'] = (int)$this->id; - - return $fields; - } - /** * Allows to display the category description without HTML tags and slashes * diff --git a/classes/Customer.php b/classes/Customer.php index 9afafd1e7..08f0762d6 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -156,19 +156,6 @@ class CustomerCore extends ObjectModel protected static $_customerHasAddress = array(); protected static $_customer_groups = array(); - /** - * @see ObjectModel::getFields() - * @return array - */ - public function getFields() - { - $fields = parent::getFields(); - if (isset($this->id)) - $fields['id_customer'] = (int)$this->id; - - return $fields; - } - public function add($autodate = true, $null_values = true) { $this->id_shop = ($this->id_shop) ? $this->id_shop : Context::getContext()->shop->getID(); diff --git a/classes/Group.php b/classes/Group.php index 733a632fc..ccd21cf35 100644 --- a/classes/Group.php +++ b/classes/Group.php @@ -67,19 +67,6 @@ class GroupCore extends ObjectModel protected $webserviceParameters = array(); - /** - * @see ObjectModel::getFields() - * @return array - */ - public function getFields() - { - $fields = parent::getFields(); - if (isset($this->id)) - $fields['id_group'] = (int)$this->id; - - return $fields; - } - public function getTranslationsFieldsChild() { if (!$this->validateFieldsLang()) diff --git a/classes/Hook.php b/classes/Hook.php index 9c3a8f6c9..14aad0bec 100644 --- a/classes/Hook.php +++ b/classes/Hook.php @@ -38,8 +38,8 @@ class HookCore extends ObjectModel 'table' => 'hook', 'primary' => 'id_hook', 'fields' => array( - 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isHookName', 'required' => true, 'size' => 32), - 'title' => array('type' => self::TYPE_STRING), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isHookName', 'required' => true, 'size' => 32), + 'title' => array('type' => self::TYPE_STRING), ), ); diff --git a/classes/Manufacturer.php b/classes/Manufacturer.php index 92ad984b4..7ac526dd9 100644 --- a/classes/Manufacturer.php +++ b/classes/Manufacturer.php @@ -109,19 +109,6 @@ class ManufacturerCore extends ObjectModel $this->image_dir = _PS_MANU_IMG_DIR_; } - /** - * @see ObjectModel::getFields() - * @return array - */ - public function getFields() - { - $fields = parent::getFields(); - if (isset($this->id)) - $fields['id_manufacturer'] = (int)$this->id; - - return $fields; - } - public function getTranslationsFieldsChild() { $this->validateFieldsLang(); diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index e5a0650ab..e496a9133 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -235,7 +235,7 @@ abstract class ObjectModelCore case self::TYPE_BOOL : $fields[$field] = (int)$this->$field; - break; + break; case self::TYPE_FLOAT : $fields[$field] = (float)$this->$field; diff --git a/classes/Product.php b/classes/Product.php index 3da7ad7d2..415ab3600 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -402,9 +402,6 @@ class ProductCore extends ObjectModel public function getFields() { $fields = parent::getFields(); - - if (isset($this->id)) - $fields['id_product'] = (int)$this->id; $fields['unit_price_ratio'] = (float)$this->unit_price > 0 ? $this->price / $this->unit_price : 0; return $fields;