From c9485075d455b0f232e546fbea20322f33c57447 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 13 Aug 2013 11:40:24 +0200 Subject: [PATCH 001/268] new faker entries new category view --- core/lib/Thelia/Model/Base/Accessory.php | 13 +- .../Thelia/Model/Map/AccessoryTableMap.php | 6 +- install/faker.php | 185 +++++++++--------- install/insert.sql | 18 +- install/thelia.sql | 34 ++-- local/config/schema.xml | 34 ++-- templates/default/category.html | 165 ++++++++++------ 7 files changed, 256 insertions(+), 199 deletions(-) diff --git a/core/lib/Thelia/Model/Base/Accessory.php b/core/lib/Thelia/Model/Base/Accessory.php index f5acd9977..f4110b19e 100644 --- a/core/lib/Thelia/Model/Base/Accessory.php +++ b/core/lib/Thelia/Model/Base/Accessory.php @@ -891,6 +891,10 @@ abstract class Accessory implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; + $this->modifiedColumns[] = AccessoryTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AccessoryTableMap::ID . ')'); + } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AccessoryTableMap::ID)) { @@ -948,6 +952,13 @@ abstract class Accessory implements ActiveRecordInterface throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + $this->setNew(false); } @@ -1224,7 +1235,6 @@ abstract class Accessory implements ActiveRecordInterface */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { - $copyObj->setId($this->getId()); $copyObj->setProductId($this->getProductId()); $copyObj->setAccessory($this->getAccessory()); $copyObj->setPosition($this->getPosition()); @@ -1232,6 +1242,7 @@ abstract class Accessory implements ActiveRecordInterface $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value } } diff --git a/core/lib/Thelia/Model/Map/AccessoryTableMap.php b/core/lib/Thelia/Model/Map/AccessoryTableMap.php index 80c0548ef..bcd663892 100644 --- a/core/lib/Thelia/Model/Map/AccessoryTableMap.php +++ b/core/lib/Thelia/Model/Map/AccessoryTableMap.php @@ -148,7 +148,7 @@ class AccessoryTableMap extends TableMap $this->setPhpName('Accessory'); $this->setClassName('\\Thelia\\Model\\Accessory'); $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); + $this->setUseIdGenerator(true); $this->setIsCrossRef(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); @@ -429,6 +429,10 @@ class AccessoryTableMap extends TableMap $criteria = $criteria->buildCriteria(); // build Criteria from Accessory object } + if ($criteria->containsKey(AccessoryTableMap::ID) && $criteria->keyContainsValue(AccessoryTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AccessoryTableMap::ID.')'); + } + // Set the correct dbName $query = AccessoryQuery::create()->mergeWith($criteria); diff --git a/install/faker.php b/install/faker.php index 23bbed2bb..39c3270e8 100755 --- a/install/faker.php +++ b/install/faker.php @@ -50,86 +50,108 @@ try { ->find(); $content->delete(); - //first category - $sweet = new Thelia\Model\Category(); - $sweet->setParent(0); - $sweet->setVisible(1); - $sweet->setPosition(1); - $sweet->setDescription($faker->text(255)); - $sweet->setTitle($faker->text(20)); + $accessory = Thelia\Model\AccessoryQuery::create() + ->find(); + $accessory->delete(); - $sweet->save(); + //features and features_av + $featureList = array(); + for($i=0; $i<4; $i++) { + $feature = new Thelia\Model\Feature(); + $feature->setVisible(rand(1, 10)>7 ? 0 : 1); + $feature->setPosition($i); + $feature->setTitle($faker->text(20)); + $feature->setDescription($faker->text(50)); - //second category - $jeans = new Thelia\Model\Category(); - $jeans->setParent(0); - $jeans->setVisible(1); - $jeans->setPosition(2); - $jeans->setDescription($faker->text(255)); - $jeans->setTitle($faker->text(20)); + $feature->save(); + $featureId = $feature->getId(); + $featureList[$featureId] = array(); - $jeans->save(); - - //third category - $other = new Thelia\Model\Category(); - $other->setParent($jeans->getId()); - $other->setVisible(1); - $other->setPosition(3); - $other->setDescription($faker->text(255)); - $other->setTitle($faker->text(20)); - - $other->save(); - - for ($i=1; $i <= 5; $i++) { - $product = new \Thelia\Model\Product(); - $product->addCategory($sweet); - $product->setTitle($faker->text(20)); - $product->setDescription($faker->text(250)); -/* $product->setQuantity($faker->randomNumber(1,50)); - $product->setPrice($faker->randomFloat(2, 20, 2500));*/ - $product->setVisible(1); - $product->setPosition($i); - $product->setRef($faker->text(255)); - $product->save(); - - $stock = new \Thelia\Model\ProductSaleElements(); - $stock->setProduct($product); - $stock->setQuantity($faker->randomNumber(1,50)); - $stock->setPromo($faker->randomNumber(0,1)); - $stock->save(); - - $productPrice = new \Thelia\Model\ProductPrice(); - $productPrice->setProductSaleElements($stock); - $productPrice->setCurrency($currency); - $productPrice->setPrice($faker->randomFloat(2, 20, 2500)); - $productPrice->save(); + for($j=0; $jsetFeature($feature); + $featureAv->setPosition($j); + $featureAv->setTitle($faker->text(20)); + $featureAv->setDescription($faker->text(255)); + $featureAv->save(); + $featureList[$featureId][] = $featureAv->getId(); + } } - for ($i=1; $i <= 5; $i++) { - $product = new \Thelia\Model\Product(); - $product->addCategory($jeans); - $product->setTitle($faker->text(20)); - $product->setDescription($faker->text(250)); -/* $product->setQuantity($faker->randomNumber(1,50)); - $product->setPrice($faker->randomFloat(2, 20, 2500));*/ - $product->setVisible(1); - $product->setPosition($i); - $product->setRef($faker->text(255)); - $product->save(); + //categories and products + $productIdList = array(); + $categoryIdList = array(); + for($i=0; $i<4; $i++) { + $category = new Thelia\Model\Category(); + $category->setParent(0); + $category->setVisible(rand(1, 10)>7 ? 0 : 1); + $category->setPosition($i); + $category->setTitle($faker->text(20)); + $category->setDescription($faker->text(255)); - $stock = new \Thelia\Model\ProductSaleElements(); - $stock->setProduct($product); - $stock->setQuantity($faker->randomNumber(1,50)); - $stock->setPromo($faker->randomNumber(0,1)); - $stock->save(); + $category->save(); + $categoryIdList[] = $category->getId(); - $productPrice = new \Thelia\Model\ProductPrice(); - $productPrice->setProductSaleElements($stock); - $productPrice->setCurrency($currency); - $productPrice->setPrice($faker->randomFloat(2, 20, 2500)); - $productPrice->save(); + for($j=0; $jsetParent($category->getId()); + $subcategory->setVisible(rand(1, 10)>7 ? 0 : 1); + $subcategory->setPosition($j); + $subcategory->setTitle($faker->text(20)); + $subcategory->setDescription($faker->text(255)); + $subcategory->save(); + $categoryIdList[] = $subcategory->getId(); + + for($k=0; $ksetRef($subcategory->getId() . '_' . $k . '_' . $faker->randomNumber(8)); + $product->addCategory($subcategory); + $product->setVisible(rand(1, 10)>7 ? 0 : 1); + $product->setPosition($k); + $product->setTitle($faker->text(20)); + $product->setDescription($faker->text(255)); + + $product->save(); + $productId = $product->getId(); + $productIdList[] = $productId; + + //add random accessories - or not + for($l=0; $lsetAccessory($productIdList[array_rand($productIdList, 1)]); + $accessory->setProductId($productId); + $accessory->setPosition($l); + + $accessory->save(); + } + } + } + + for($k=0; $ksetRef($category->getId() . '_' . $k . '_' . $faker->randomNumber(8)); + $product->addCategory($category); + $product->setVisible(rand(1, 10)>7 ? 0 : 1); + $product->setPosition($k); + $product->setTitle($faker->text(20)); + $product->setDescription($faker->text(255)); + + $product->save(); + $productId = $product->getId(); + $productIdList[] = $productId; + + //add random accessories + for($l=0; $lsetAccessory($productIdList[array_rand($productIdList, 1)]); + $accessory->setProductId($productId); + $accessory->setPosition($l); + + $accessory->save(); + } + } } //folders and contents @@ -166,27 +188,6 @@ try { } } - //features and features_av - for($i=0; $i<4; $i++) { - $feature = new Thelia\Model\Feature(); - $feature->setVisible(rand(1, 10)>7 ? 0 : 1); - $feature->setPosition($i); - $feature->setTitle($faker->text(20)); - $feature->setDescription($faker->text(50)); - - $feature->save(); - - for($j=0; $jsetFeature($feature); - $featureAv->setPosition($j); - $featureAv->setTitle($faker->text(20)); - $featureAv->setDescription($faker->text(255)); - - $featureAv->save(); - } - } - $con->commit(); } catch (Exception $e) { echo "error : ".$e->getMessage()."\n"; diff --git a/install/insert.sql b/install/insert.sql index ab349e09a..6518462c4 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -1,8 +1,8 @@ -INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`by_default`,`position`,`created_at`,`updated_at`)VALUES -(1, 'Français', 'fr', 'fr_FR', '','1', '1', NOW(), NOW()), -(2, 'English', 'en', 'en_EN', '', '0', '2', NOW(), NOW()), -(3, 'Espanol', 'es', 'es_ES', '', '0', '3', NOW(), NOW()), -(4, 'Italiano', 'it', 'it_IT', '','0', '4', NOW(), NOW()); +INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`by_default`,`created_at`,`updated_at`)VALUES +(1, 'Français', 'fr', 'fr_FR', '','1', NOW(), NOW()), +(2, 'English', 'en', 'en_EN', '', '0', NOW(), NOW()), +(3, 'Espanol', 'es', 'es_ES', '', '0', NOW(), NOW()), +(4, 'Italiano', 'it', 'it_IT', '','0', NOW(), NOW()); INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES ('session_config.default', '1', 1, 1, NOW(), NOW()), @@ -23,11 +23,11 @@ INSERT INTO `customer_title_i18n` (`id`, `locale`, `short`, `long`) VALUES (3, 'en_US', 'Miss', 'Miss'), (3, 'fr_FR', 'Mlle', 'Madamemoiselle'); -INSERT INTO `currency` (`id` ,`code` ,`symbol` ,`rate` ,`by_default`, `position` ,`created_at` ,`updated_at`) +INSERT INTO `currency` (`id` ,`code` ,`symbol` ,`rate` ,`by_default` ,`created_at` ,`updated_at`) VALUES -(1, 'EUR', '€', '1', '1', '1', NOW() , NOW()), -(2, 'USD', '$', '1.26', '0', '2', NOW(), NOW()), -(3, 'GBP', '£', '0.89', '0', '3',NOW(), NOW()); +(1, 'EUR', '€', '1', '1', NOW() , NOW()), +(2, 'USD', '$', '1.26', '0', NOW(), NOW()), +(3, 'GBP', '£', '0.89', '0', NOW(), NOW()); INSERT INTO `currency_i18n` (`id` ,`locale` ,`name`) VALUES diff --git a/install/thelia.sql b/install/thelia.sql index 547f22786..bf36a1708 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -617,8 +617,8 @@ CREATE TABLE `produt_image` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_product_id` (`product_id`), - CONSTRAINT `fk_product_id` + INDEX `idx_product_image_product_id` (`product_id`), + CONSTRAINT `fk_product_image_product_id` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`) ON UPDATE RESTRICT @@ -640,8 +640,8 @@ CREATE TABLE `product_document` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_product_id` (`product_id`), - CONSTRAINT `fk_product_id` + INDEX `idx_product_document_product_id` (`product_id`), + CONSTRAINT `fk_product_document_product_id` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`) ON UPDATE RESTRICT @@ -844,7 +844,7 @@ DROP TABLE IF EXISTS `accessory`; CREATE TABLE `accessory` ( - `id` INTEGER NOT NULL, + `id` INTEGER NOT NULL AUTO_INCREMENT, `product_id` INTEGER NOT NULL, `accessory` INTEGER NOT NULL, `position` INTEGER NOT NULL, @@ -1332,8 +1332,8 @@ CREATE TABLE `category_image` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_category_id` (`category_id`), - CONSTRAINT `fk_category_id` + INDEX `idx_category_image_category_id` (`category_id`), + CONSTRAINT `fk_category_image_category_id` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON UPDATE RESTRICT @@ -1355,8 +1355,8 @@ CREATE TABLE `folder_image` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_folder_id` (`folder_id`), - CONSTRAINT `fk_folder_id` + INDEX `idx_folder_image_folder_id` (`folder_id`), + CONSTRAINT `fk_folder_image_folder_id` FOREIGN KEY (`folder_id`) REFERENCES `folder` (`id`) ON UPDATE RESTRICT @@ -1378,8 +1378,8 @@ CREATE TABLE `content_image` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_content_id` (`content_id`), - CONSTRAINT `fk_content_id` + INDEX `idx_content_image_content_id` (`content_id`), + CONSTRAINT `fk_content_image_content_id` FOREIGN KEY (`content_id`) REFERENCES `content` (`id`) ON UPDATE RESTRICT @@ -1401,8 +1401,8 @@ CREATE TABLE `category_document` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_category_id` (`category_id`), - CONSTRAINT `fk_category_id` + INDEX `idx_category_document_category_id` (`category_id`), + CONSTRAINT `fk_catgory_document_category_id` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON UPDATE RESTRICT @@ -1424,8 +1424,8 @@ CREATE TABLE `content_document` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_content_id` (`content_id`), - CONSTRAINT `fk_content_id` + INDEX `idx_content_document_content_id` (`content_id`), + CONSTRAINT `fk_content_document_content_id` FOREIGN KEY (`content_id`) REFERENCES `content` (`id`) ON UPDATE RESTRICT @@ -1447,8 +1447,8 @@ CREATE TABLE `folder_document` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_folder_id` (`folder_id`), - CONSTRAINT `fk_folder_id` + INDEX `idx_folder_document_folder_id` (`folder_id`), + CONSTRAINT `fk_folder_document_folder_id` FOREIGN KEY (`folder_id`) REFERENCES `folder` (`id`) ON UPDATE RESTRICT diff --git a/local/config/schema.xml b/local/config/schema.xml index b52550e9c..48b46b3da 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -459,10 +459,10 @@ - + - + @@ -479,10 +479,10 @@ - + - + @@ -629,7 +629,7 @@ - + @@ -973,10 +973,10 @@ - + - + @@ -993,10 +993,10 @@ - + - + @@ -1013,10 +1013,10 @@ - + - + @@ -1033,10 +1033,10 @@ - + - + @@ -1053,10 +1053,10 @@ - + - + @@ -1073,10 +1073,10 @@ - + - + diff --git a/templates/default/category.html b/templates/default/category.html index acb98e919..6aabd6edf 100755 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -1,70 +1,80 @@ -{*loop name="category0" type="category" parent="0"} -

CATEGORY : #TITLE

- {loop name="category1" type="category" parent="#ID"} -
+
+ +

CATALOG

+ +{loop name="category0" type="category" parent="0" order="manual"} +
+

CATEGORY : #TITLE (#LOOP_COUNT / #LOOP_TOTAL)

+ {loop name="product" type="product" category="#ID"} +
+

PRODUCT : #REF (#LOOP_COUNT / #LOOP_TOTAL)

+

#TITLE

+

#DESCRIPTION

+ {ifloop rel="acc"} +
Accessories
+
    + {loop name="acc" type="accessory" product="#ID" order="accessory"} +
  • #REF
  • + {/loop} +
+ {/ifloop} + {elseloop rel="acc"} +
No accessory
+ {/elseloop} + {ifloop rel="ft"} +
Features
+
    + {loop name="ft" type="feature" order="manual" product="#ID"} +
  • #TITLE
  • + {/loop} +
+ {/ifloop} + {elseloop rel="ft"} +
No feature
+ {/elseloop} +
+ {/loop} + {loop name="catgory1" type="category" parent="#ID"} +

SUBCATEGORY : #TITLE (#LOOP_COUNT / #LOOP_TOTAL)

{loop name="product" type="product" category="#ID"} -

PRODUCT : #REF / #TITLE

- #PRICE € +
+

PRODUCT : #REF (#LOOP_COUNT / #LOOP_TOTAL)

+

#TITLE

+

#DESCRIPTION

+ {ifloop rel="acc"} +
Accessories
+
    + {loop name="acc" type="accessory" product="#ID" order="accessory"} +
  • #REF
  • + {/loop} +
+ {/ifloop} + {elseloop rel="acc"} +
No accessory
+ {/elseloop} + {ifloop rel="ft"} +
Features
+
    + {loop name="ft" type="feature" order="manual" product="#ID"} +
  • #TITLE
  • + {/loop} +
+ {/ifloop} + {elseloop rel="ft"} +
No feature
+ {/elseloop} +
{/loop} -
-
+
{/loop} - - {loop name="product" type="product" category="#ID"} -

PRODUCT : #REF / #TITLE

- #PRICE € - {/loop} -
-
-{/loop*} -

PRODUCTS

-{*loop name="product" type="product" order="promo,min_price" exclude_category="3"} -

PRODUCT : #REF / #TITLE

- price : #PRICE €
- promo price : #PROMO_PRICE €
- is promo : #PROMO
- is new : #NEW
- weight : #WEIGHT
-{/loop*} - -{*loop name="product" type="product" order="ref" feature_available="1: (1 | 2) , 2: 4, 3: 433"} -

PRODUCT : #REF / #TITLE

- price : #PRICE €
- promo price : #PROMO_PRICE €
- is promo : #PROMO
- is new : #NEW
- weight : #WEIGHT
-{/loop*} - -{*loop name="product" type="product" order="ref" feature_values="1: foo"} -

PRODUCT : #REF / #TITLE

- price : #PRICE €
- promo price : #PROMO_PRICE €
- is promo : #PROMO
- is new : #NEW
- weight : #WEIGHT
-{/loop*} - -{loop name="product" type="product" order="ref"} -

PRODUCT #ID : #REF / #TITLE

- -

Accessories

-
    - {loop name="acc" type="accessory" product="#ID" order="accessory"} -
  • #REF
  • - {/loop} -
- -

Features

-
    - {loop name="ft" type="feature" order="manual" product="#ID"} -
  • #TITLE
  • - {/loop} -
- +
{/loop} +
+ +
+

ALL FEATURES AND THEIR AVAILABILITY

    @@ -78,4 +88,35 @@
{/loop} - \ No newline at end of file + + +
+ +
+ {*loop name="product" type="product" order="promo,min_price" exclude_category="3"} +

PRODUCT : #REF / #TITLE

+ price : #PRICE €
+ promo price : #PROMO_PRICE €
+ is promo : #PROMO
+ is new : #NEW
+ weight : #WEIGHT
+ {/loop*} + + {*loop name="product" type="product" order="ref" feature_available="1: (1 | 2) , 2: 4, 3: 433"} +

PRODUCT : #REF / #TITLE

+ price : #PRICE €
+ promo price : #PROMO_PRICE €
+ is promo : #PROMO
+ is new : #NEW
+ weight : #WEIGHT
+ {/loop*} + + {*loop name="product" type="product" order="ref" feature_values="1: foo"} +

PRODUCT : #REF / #TITLE

+ price : #PRICE €
+ promo price : #PROMO_PRICE €
+ is promo : #PROMO
+ is new : #NEW
+ weight : #WEIGHT
+ {/loop*} +
\ No newline at end of file From 70f483ad97ab92d68865fb73e0b067552c524d8f Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 14 Aug 2013 14:02:14 +0200 Subject: [PATCH 002/268] availability instead of available --- core/lib/Thelia/Config/Resources/config.xml | 5 +- .../Thelia/Core/Template/Loop/Attribute.php | 169 +++++++ .../Template/Loop/AttributeAvailability.php | 144 ++++++ .../Thelia/Core/Template/Loop/Category.php | 6 +- ...eAvailable.php => FeatureAvailability.php} | 7 +- core/lib/Thelia/Core/Template/Loop/Folder.php | 4 +- .../lib/Thelia/Core/Template/Loop/Product.php | 35 +- .../Core/Template/Loop/ProductSaleElement.php | 420 ++++++++++++++++++ install/faker.php | 175 +++++--- templates/default/category.html | 29 +- 10 files changed, 896 insertions(+), 98 deletions(-) create mode 100755 core/lib/Thelia/Core/Template/Loop/Attribute.php create mode 100755 core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php rename core/lib/Thelia/Core/Template/Loop/{FeatureAvailable.php => FeatureAvailability.php} (97%) create mode 100755 core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 98017f979..07d12d9f0 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -7,19 +7,22 @@ + + - + + diff --git a/core/lib/Thelia/Core/Template/Loop/Attribute.php b/core/lib/Thelia/Core/Template/Loop/Attribute.php new file mode 100755 index 000000000..1c7b23acf --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Attribute.php @@ -0,0 +1,169 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Join; +use Thelia\Core\Template\Element\BaseLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Log\Tlog; + +use Thelia\Model\Base\CategoryQuery; +use Thelia\Model\Base\ProductCategoryQuery; +use Thelia\Model\Base\AttributeQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Model\Map\ProductCategoryTableMap; +use Thelia\Type\TypeCollection; +use Thelia\Type; +use Thelia\Type\BooleanOrBothType; + +/** + * + * Attribute loop + * + * + * Class Attribute + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Attribute extends BaseLoop +{ + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + Argument::createIntListTypeArgument('product'), + Argument::createIntListTypeArgument('category'), + Argument::createBooleanOrBothTypeArgument('visible', 1), + Argument::createIntListTypeArgument('exclude'), + new Argument( + 'order', + new TypeCollection( + new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse')) + ), + 'manual' + ) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = AttributeQuery::create(); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $exclude = $this->getExclude(); + + if (null !== $exclude) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $visible = $this->getVisible(); + + if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible); + + $product = $this->getProduct(); + $category = $this->getCategory(); + + if(null !== $product) { + $productCategories = ProductCategoryQuery::create()->select(array(ProductCategoryTableMap::CATEGORY_ID))->filterByProductId($product, Criteria::IN)->find()->getData(); + + if(null === $category) { + $category = $productCategories; + } else { + $category = array_merge($category, $productCategories); + } + } + + if(null !== $category) { + $search->filterByCategory( + CategoryQuery::create()->filterById($category)->find(), + Criteria::IN + ); + } + + $orders = $this->getOrder(); + + foreach($orders as $order) { + switch ($order) { + case "alpha": + $search->addAscendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE); + break; + case "alpha_reverse": + $search->addDescendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE); + break; + case "manual": + $search->orderByPosition(Criteria::ASC); + break; + case "manual_reverse": + $search->orderByPosition(Criteria::DESC); + break; + } + } + + /** + * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. + * + * @todo : verify here if we want results for row without translations. + */ + + $search->joinWithI18n( + $this->request->getSession()->getLocale(), + (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN + ); + + $attributes = $this->search($search, $pagination); + + $loopResult = new LoopResult(); + + foreach ($attributes as $attribute) { + $loopResultRow = new LoopResultRow(); + $loopResultRow->set("ID", $attribute->getId()); + $loopResultRow->set("TITLE",$attribute->getTitle()); + $loopResultRow->set("CHAPO", $attribute->getChapo()); + $loopResultRow->set("DESCRIPTION", $attribute->getDescription()); + $loopResultRow->set("POSTSCRIPTUM", $attribute->getPostscriptum()); + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php new file mode 100755 index 000000000..1033bf450 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php @@ -0,0 +1,144 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Join; +use Thelia\Core\Template\Element\BaseLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Log\Tlog; + +use Thelia\Model\Base\AttributeAvQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; + +/** + * AttributeAvailability loop + * + * + * Class AttributeAvailability + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class AttributeAvailability extends BaseLoop +{ + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + Argument::createIntListTypeArgument('attribute'), + Argument::createIntListTypeArgument('exclude'), + new Argument( + 'order', + new TypeCollection( + new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse')) + ), + 'manual' + ) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = AttributeAvQuery::create(); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $exclude = $this->getExclude(); + + if (null !== $exclude) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $attribute = $this->getAttribute(); + + if(null !== $attribute) { + $search->filterByAttributeId($attribute, Criteria::IN); + } + + $orders = $this->getOrder(); + + foreach($orders as $order) { + switch ($order) { + case "alpha": + $search->addAscendingOrderByColumn(\Thelia\Model\Map\AttributeAvI18nTableMap::TITLE); + break; + case "alpha_reverse": + $search->addDescendingOrderByColumn(\Thelia\Model\Map\AttributeAvI18nTableMap::TITLE); + break; + case "manual": + $search->orderByPosition(Criteria::ASC); + break; + case "manual_reverse": + $search->orderByPosition(Criteria::DESC); + break; + } + } + + /** + * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. + * + * @todo : verify here if we want results for row without translations. + */ + + $search->joinWithI18n( + $this->request->getSession()->getLocale(), + (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN + ); + + $attributesAv = $this->search($search, $pagination); + + $loopResult = new LoopResult(); + + foreach ($attributesAv as $attributeAv) { + $loopResultRow = new LoopResultRow(); + $loopResultRow->set("ID", $attributeAv->getId()); + $loopResultRow->set("TITLE",$attributeAv->getTitle()); + $loopResultRow->set("CHAPO", $attributeAv->getChapo()); + $loopResultRow->set("DESCRIPTION", $attributeAv->getDescription()); + $loopResultRow->set("POSTSCRIPTUM", $attributeAv->getPostscriptum()); + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index a3769150d..d856b6d73 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -47,7 +47,7 @@ use Thelia\Type\BooleanOrBothType; * - current : current id is used if you are on a category page * - not_empty : if value is 1, category and subcategories must have at least 1 product * - visible : default 1, if you want category not visible put 0 - * - order : all value available : 'alpha', 'alpha_reverse', 'manual' (default), 'manual-reverse', 'random' + * - order : all value available : 'alpha', 'alpha_reverse', 'manual' (default), 'manual_reverse', 'random' * - exclude : all category id you want to exclude (as for id, an integer or a "string list" can be used) * * example : @@ -78,7 +78,7 @@ class Category extends BaseLoop new Argument( 'order', new TypeCollection( - new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual-reverse', 'random')) + new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'random')) ), 'manual' ), @@ -136,7 +136,7 @@ class Category extends BaseLoop case "alpha_reverse": $search->addDescendingOrderByColumn(\Thelia\Model\Map\CategoryI18nTableMap::TITLE); break; - case "manual-reverse": + case "manual_reverse": $search->orderByPosition(Criteria::DESC); break; case "manual": diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureAvailable.php b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php similarity index 97% rename from core/lib/Thelia/Core/Template/Loop/FeatureAvailable.php rename to core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php index 595794bf4..888d30a92 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureAvailable.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php @@ -39,15 +39,14 @@ use Thelia\Type\TypeCollection; use Thelia\Type; /** - *todo : to be finished - * FeatureAvailable loop + * FeatureAvailability loop * * - * Class FeatureAvailable + * Class FeatureAvailability * @package Thelia\Core\Template\Loop * @author Etienne Roudeix */ -class FeatureAvailable extends BaseLoop +class FeatureAvailability extends BaseLoop { /** * @return ArgumentCollection diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php index 13d0409a6..e41361d0a 100755 --- a/core/lib/Thelia/Core/Template/Loop/Folder.php +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -60,7 +60,7 @@ class Folder extends BaseLoop new Argument( 'order', new TypeCollection( - new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual-reverse', 'random')) + new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'random')) ), 'manual' ), @@ -119,7 +119,7 @@ class Folder extends BaseLoop case "alpha_reverse": $search->addDescendingOrderByColumn(\Thelia\Model\Map\FolderI18nTableMap::TITLE); break; - case "manual-reverse": + case "manual_reverse": $search->orderByPosition(Criteria::DESC); break; case "manual": diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 8d892a446..2efddad94 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -33,10 +33,7 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; -use Thelia\Model\Base\FeatureProductQuery; use Thelia\Model\CategoryQuery; -use Thelia\Model\FeatureAvQuery; -use Thelia\Model\FeatureQuery; use Thelia\Model\Map\FeatureProductTableMap; use Thelia\Model\Map\ProductTableMap; use Thelia\Model\ProductCategoryQuery; @@ -71,13 +68,13 @@ class Product extends BaseLoop ) ), Argument::createIntListTypeArgument('category'), - //Argument::createBooleanTypeArgument('new'), - //Argument::createBooleanTypeArgument('promo'), - //Argument::createFloatTypeArgument('min_price'), - //Argument::createFloatTypeArgument('max_price'), - //Argument::createIntTypeArgument('min_stock'), - //Argument::createFloatTypeArgument('min_weight'), - //Argument::createFloatTypeArgument('max_weight'), + Argument::createBooleanTypeArgument('new'), + Argument::createBooleanTypeArgument('promo'), + Argument::createFloatTypeArgument('min_price'), + Argument::createFloatTypeArgument('max_price'), + Argument::createIntTypeArgument('min_stock'), + Argument::createFloatTypeArgument('min_weight'), + Argument::createFloatTypeArgument('max_weight'), Argument::createBooleanTypeArgument('current'), Argument::createBooleanTypeArgument('current_category'), Argument::createIntTypeArgument('depth', 1), @@ -85,7 +82,7 @@ class Product extends BaseLoop new Argument( 'order', new TypeCollection( - new Type\EnumListType(array('alpha', 'alpha_reverse', /*'min_price', 'max_price',*/ 'manual', 'manual_reverse', 'ref', /*'promo', 'new',*/ 'random', 'given_id')) + new Type\EnumListType(array('alpha', 'alpha_reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new', 'random', 'given_id')) ), 'alpha' ), @@ -149,20 +146,24 @@ class Product extends BaseLoop ); } - /*$new = $this->getNew(); + $new = $this->getNew(); if ($new === true) { - $search->filterByNewness(1, Criteria::EQUAL); + $search->joinProductSaleElements('is_new', Criteria::INNER_JOIN) + ->addJoinCondition('is_new', "`is_new`.NEWNESS = 1"); } else if($new === false) { - $search->filterByNewness(0, Criteria::EQUAL); + $search->joinProductSaleElements('is_new', Criteria::INNER_JOIN) + ->addJoinCondition('is_new', "`is_new`.NEWNESS = 0"); } $promo = $this->getPromo(); if ($promo === true) { - $search->filterByPromo(1, Criteria::EQUAL); + $search->joinProductSaleElements('is_promo', Criteria::INNER_JOIN) + ->addJoinCondition('is_promo', "`is_promo`.PROMO = 1"); } else if($promo === false) { - $search->filterByNewness(0, Criteria::EQUAL); + $search->joinProductSaleElements('is_promo', Criteria::INNER_JOIN) + ->addJoinCondition('is_promo', "`is_promo`.PROMO = 0"); } $min_stock = $this->getMin_stock(); @@ -171,7 +172,7 @@ class Product extends BaseLoop $search->filterByQuantity($min_stock, Criteria::GREATER_EQUAL); } - $min_price = $this->getMin_price();*/ + //$min_price = $this->getMin_price(); //if(null !== $min_price) { /** diff --git a/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php b/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php new file mode 100755 index 000000000..8d892a446 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php @@ -0,0 +1,420 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Join; +use Thelia\Core\Template\Element\BaseLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Log\Tlog; + +use Thelia\Model\Base\FeatureProductQuery; +use Thelia\Model\CategoryQuery; +use Thelia\Model\FeatureAvQuery; +use Thelia\Model\FeatureQuery; +use Thelia\Model\Map\FeatureProductTableMap; +use Thelia\Model\Map\ProductTableMap; +use Thelia\Model\ProductCategoryQuery; +use Thelia\Model\ProductQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; +use Thelia\Type\BooleanOrBothType; + +/** + * + * Product loop + * + * + * Class Product + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Product extends BaseLoop +{ + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + new Argument( + 'ref', + new TypeCollection( + new Type\AlphaNumStringListType() + ) + ), + Argument::createIntListTypeArgument('category'), + //Argument::createBooleanTypeArgument('new'), + //Argument::createBooleanTypeArgument('promo'), + //Argument::createFloatTypeArgument('min_price'), + //Argument::createFloatTypeArgument('max_price'), + //Argument::createIntTypeArgument('min_stock'), + //Argument::createFloatTypeArgument('min_weight'), + //Argument::createFloatTypeArgument('max_weight'), + Argument::createBooleanTypeArgument('current'), + Argument::createBooleanTypeArgument('current_category'), + Argument::createIntTypeArgument('depth', 1), + Argument::createBooleanOrBothTypeArgument('visible', 1), + new Argument( + 'order', + new TypeCollection( + new Type\EnumListType(array('alpha', 'alpha_reverse', /*'min_price', 'max_price',*/ 'manual', 'manual_reverse', 'ref', /*'promo', 'new',*/ 'random', 'given_id')) + ), + 'alpha' + ), + Argument::createIntListTypeArgument('exclude'), + Argument::createIntListTypeArgument('exclude_category'), + new Argument( + 'feature_available', + new TypeCollection( + new Type\IntToCombinedIntsListType() + ) + ), + new Argument( + 'feature_values', + new TypeCollection( + new Type\IntToCombinedStringsListType() + ) + ) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + * @throws \InvalidArgumentException + */ + public function exec(&$pagination) + { + $search = ProductQuery::create(); + + //$search->withColumn('CASE WHEN ' . ProductTableMap::PROMO . '=1 THEN ' . ProductTableMap::PRICE2 . ' ELSE ' . ProductTableMap::PRICE . ' END', 'real_price'); + + $id = $this->getId(); + + if (!is_null($id)) { + $search->filterById($id, Criteria::IN); + } + + $ref = $this->getRef(); + + if (!is_null($ref)) { + $search->filterByRef($ref, Criteria::IN); + } + + $category = $this->getCategory(); + + if (!is_null($category)) { + $categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find(); + + $depth = $this->getDepth(); + + if(null !== $depth) { + foreach(CategoryQuery::findAllChild($category, $depth) as $subCategory) { + $categories->prepend($subCategory); + } + } + + $search->filterByCategory( + $categories, + Criteria::IN + ); + } + + /*$new = $this->getNew(); + + if ($new === true) { + $search->filterByNewness(1, Criteria::EQUAL); + } else if($new === false) { + $search->filterByNewness(0, Criteria::EQUAL); + } + + $promo = $this->getPromo(); + + if ($promo === true) { + $search->filterByPromo(1, Criteria::EQUAL); + } else if($promo === false) { + $search->filterByNewness(0, Criteria::EQUAL); + } + + $min_stock = $this->getMin_stock(); + + if (null != $min_stock) { + $search->filterByQuantity($min_stock, Criteria::GREATER_EQUAL); + } + + $min_price = $this->getMin_price();*/ + + //if(null !== $min_price) { + /** + * Following should work but does not : + * + * $search->filterBy('real_price', $max_price, Criteria::GREATER_EQUAL); + */ + /*$search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1') + ->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1') + ->condition('min_price2', ProductTableMap::PRICE2 . Criteria::GREATER_EQUAL . '?', $min_price) + ->condition('min_price', ProductTableMap::PRICE . Criteria::GREATER_EQUAL . '?', $min_price) + ->combine(array('in_promo', 'min_price2'), Criteria::LOGICAL_AND, 'in_promo_min_price') + ->combine(array('not_in_promo', 'min_price'), Criteria::LOGICAL_AND, 'not_in_promo_min_price') + ->where(array('not_in_promo_min_price', 'in_promo_min_price'), Criteria::LOGICAL_OR); + } + + $max_price = $this->getMax_price();*/ + + //if(null !== $max_price) { + /** + * Following should work but does not : + * + * $search->filterBy('real_price', $max_price, Criteria::LESS_EQUAL); + */ + /*$search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1') + ->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1') + ->condition('max_price2', ProductTableMap::PRICE2 . Criteria::LESS_EQUAL . '?', $max_price) + ->condition('max_price', ProductTableMap::PRICE . Criteria::LESS_EQUAL . '?', $max_price) + ->combine(array('in_promo', 'max_price2'), Criteria::LOGICAL_AND, 'in_promo_max_price') + ->combine(array('not_in_promo', 'max_price'), Criteria::LOGICAL_AND, 'not_in_promo_max_price') + ->where(array('not_in_promo_max_price', 'in_promo_max_price'), Criteria::LOGICAL_OR); + }*/ + + /*$min_weight = $this->getMin_weight(); + + if(null !== $min_weight) { + $search->filterByWeight($min_weight, Criteria::GREATER_EQUAL); + } + + $max_weight = $this->getMax_weight(); + + if(null !== $max_weight) { + $search->filterByWeight($max_weight, Criteria::LESS_EQUAL); + }*/ + + $current = $this->getCurrent(); + + if ($current === true) { + $search->filterById($this->request->get("product_id")); + } elseif($current === false) { + $search->filterById($this->request->get("product_id"), Criteria::NOT_IN); + } + + $current_category = $this->getCurrent_category(); + + if ($current_category === true) { + $search->filterByCategory( + CategoryQuery::create()->filterByProduct( + ProductCategoryQuery::create()->filterByProductId( + $this->request->get("product_id"), + Criteria::EQUAL + )->find(), + Criteria::IN + )->find(), + Criteria::IN + ); + } elseif($current_category === false) { + $search->filterByCategory( + CategoryQuery::create()->filterByProduct( + ProductCategoryQuery::create()->filterByProductId( + $this->request->get("product_id"), + Criteria::EQUAL + )->find(), + Criteria::IN + )->find(), + Criteria::NOT_IN + ); + } + + $visible = $this->getVisible(); + + if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0); + + $orders = $this->getOrder(); + + foreach($orders as $order) { + switch ($order) { + case "alpha": + $search->addAscendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE); + break; + case "alpha_reverse": + $search->addDescendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE); + break; + /*case "min_price": + $search->orderBy('real_price', Criteria::ASC); + break; + case "max_price": + $search->orderBy('real_price', Criteria::DESC); + break;*/ + case "manual": + if(null === $category || count($category) != 1) + throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); + $search->orderByPosition(Criteria::ASC); + break; + case "manual_reverse": + if(null === $category || count($category) != 1) + throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); + $search->orderByPosition(Criteria::DESC); + break; + case "ref": + $search->orderByRef(Criteria::ASC); + break; + /*case "promo": + $search->orderByPromo(Criteria::DESC); + break; + case "new": + $search->orderByNewness(Criteria::DESC); + break;*/ + case "given_id": + if(null === $id) + throw new \InvalidArgumentException('Given_id order cannot be set without `id` argument'); + foreach($id as $singleId) { + $givenIdMatched = 'given_id_matched_' . $singleId; + $search->withColumn(ProductTableMap::ID . "='$singleId'", $givenIdMatched); + $search->orderBy($givenIdMatched, Criteria::DESC); + } + break; + case "random": + $search->clearOrderByColumns(); + $search->addAscendingOrderByColumn('RAND()'); + break(2); + } + } + + $exclude = $this->getExclude(); + + if (!is_null($exclude)) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $exclude_category = $this->getExclude_category(); + + if (!is_null($exclude_category)) { + $search->filterByCategory( + CategoryQuery::create()->filterById($exclude_category, Criteria::IN)->find(), + Criteria::NOT_IN + ); + } + + $feature_available = $this->getFeature_available(); + + if(null !== $feature_available) { + foreach($feature_available as $feature => $feature_choice) { + foreach($feature_choice['values'] as $feature_av) { + $featureAlias = 'fa_' . $feature; + if($feature_av != '*') + $featureAlias .= '_' . $feature_av; + $search->joinFeatureProduct($featureAlias, Criteria::LEFT_JOIN) + ->addJoinCondition($featureAlias, "`$featureAlias`.FEATURE_ID = ?", $feature, null, \PDO::PARAM_INT); + if($feature_av != '*') + $search->addJoinCondition($featureAlias, "`$featureAlias`.FEATURE_AV_ID = ?", $feature_av, null, \PDO::PARAM_INT); + } + + /* format for mysql */ + $sqlWhereString = $feature_choice['expression']; + if($sqlWhereString == '*') { + $sqlWhereString = 'NOT ISNULL(`fa_' . $feature . '`.ID)'; + } else { + $sqlWhereString = preg_replace('#([0-9]+)#', 'NOT ISNULL(`fa_' . $feature . '_' . '\1`.ID)', $sqlWhereString); + $sqlWhereString = str_replace('&', ' AND ', $sqlWhereString); + $sqlWhereString = str_replace('|', ' OR ', $sqlWhereString); + } + + $search->where("(" . $sqlWhereString . ")"); + } + } + + $feature_values = $this->getFeature_values(); + + if(null !== $feature_values) { + foreach($feature_values as $feature => $feature_choice) { + foreach($feature_choice['values'] as $feature_value) { + $featureAlias = 'fv_' . $feature; + if($feature_value != '*') + $featureAlias .= '_' . $feature_value; + $search->joinFeatureProduct($featureAlias, Criteria::LEFT_JOIN) + ->addJoinCondition($featureAlias, "`$featureAlias`.FEATURE_ID = ?", $feature, null, \PDO::PARAM_INT); + if($feature_value != '*') + $search->addJoinCondition($featureAlias, "`$featureAlias`.BY_DEFAULT = ?", $feature_value, null, \PDO::PARAM_STR); + } + + /* format for mysql */ + $sqlWhereString = $feature_choice['expression']; + if($sqlWhereString == '*') { + $sqlWhereString = 'NOT ISNULL(`fv_' . $feature . '`.ID)'; + } else { + $sqlWhereString = preg_replace('#([a-zA-Z0-9_\-]+)#', 'NOT ISNULL(`fv_' . $feature . '_' . '\1`.ID)', $sqlWhereString); + $sqlWhereString = str_replace('&', ' AND ', $sqlWhereString); + $sqlWhereString = str_replace('|', ' OR ', $sqlWhereString); + } + + $search->where("(" . $sqlWhereString . ")"); + } + } + + /** + * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. + * + * @todo : verify here if we want results for row without translations. + */ + + $search->joinWithI18n( + $this->request->getSession()->getLocale(), + (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN + ); + + $search->groupBy(ProductTableMap::ID); + + $products = $this->search($search, $pagination); + + $loopResult = new LoopResult(); + + foreach ($products as $product) { + $loopResultRow = new LoopResultRow(); + + $loopResultRow->set("ID", $product->getId()) + ->set("REF",$product->getRef()) + ->set("TITLE",$product->getTitle()) + ->set("CHAPO", $product->getChapo()) + ->set("DESCRIPTION", $product->getDescription()) + ->set("POSTSCRIPTUM", $product->getPostscriptum()) + //->set("PRICE", $product->getPrice()) + //->set("PROMO_PRICE", $product->getPrice2()) + //->set("WEIGHT", $product->getWeight()) + //->set("PROMO", $product->getPromo()) + //->set("NEW", $product->getNewness()) + ->set("POSITION", $product->getPosition()) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } + +} diff --git a/install/faker.php b/install/faker.php index 39c3270e8..d3d073994 100755 --- a/install/faker.php +++ b/install/faker.php @@ -12,6 +12,22 @@ $currency = \Thelia\Model\CurrencyQuery::create()->filterByCode('EUR')->findOne( try { + $feature = Thelia\Model\FeatureQuery::create() + ->find(); + $feature->delete(); + + $featureAv = Thelia\Model\FeatureAvQuery::create() + ->find(); + $featureAv->delete(); + + $attribute = Thelia\Model\AttributeQuery::create() + ->find(); + $attribute->delete(); + + $attributeAv = Thelia\Model\AttributeAvQuery::create() + ->find(); + $attributeAv->delete(); + $category = Thelia\Model\CategoryQuery::create() ->find(); $category->delete(); @@ -54,6 +70,14 @@ try { ->find(); $accessory->delete(); + $stock = \Thelia\Model\ProductSaleElementsQuery::create() + ->find(); + $stock->delete(); + + $productPrice = \Thelia\Model\ProductPriceQuery::create() + ->find(); + $productPrice->delete(); + //features and features_av $featureList = array(); for($i=0; $i<4; $i++) { @@ -79,78 +103,46 @@ try { } } + //attributes and attributes_av + $attributeList = array(); + for($i=0; $i<4; $i++) { + $attribute = new Thelia\Model\Attribute(); + $attribute->setPosition($i); + $attribute->setTitle($faker->text(20)); + $attribute->setDescription($faker->text(50)); + + $attribute->save(); + $attributeId = $attribute->getId(); + $attributeList[$attributeId] = array(); + + for($j=0; $jsetAttribute($attribute); + $attributeAv->setPosition($j); + $attributeAv->setTitle($faker->text(20)); + $attributeAv->setDescription($faker->text(255)); + + $attributeAv->save(); + $attributeList[$attributeId][] = $attributeAv->getId(); + } + } + //categories and products $productIdList = array(); $categoryIdList = array(); for($i=0; $i<4; $i++) { - $category = new Thelia\Model\Category(); - $category->setParent(0); - $category->setVisible(rand(1, 10)>7 ? 0 : 1); - $category->setPosition($i); - $category->setTitle($faker->text(20)); - $category->setDescription($faker->text(255)); + $category = createCategory($faker, 0, $i, $categoryIdList); - $category->save(); - $categoryIdList[] = $category->getId(); + for($j=1; $jgetId(), $j, $categoryIdList); - for($j=0; $jsetParent($category->getId()); - $subcategory->setVisible(rand(1, 10)>7 ? 0 : 1); - $subcategory->setPosition($j); - $subcategory->setTitle($faker->text(20)); - $subcategory->setDescription($faker->text(255)); - - $subcategory->save(); - $categoryIdList[] = $subcategory->getId(); - - for($k=0; $ksetRef($subcategory->getId() . '_' . $k . '_' . $faker->randomNumber(8)); - $product->addCategory($subcategory); - $product->setVisible(rand(1, 10)>7 ? 0 : 1); - $product->setPosition($k); - $product->setTitle($faker->text(20)); - $product->setDescription($faker->text(255)); - - $product->save(); - $productId = $product->getId(); - $productIdList[] = $productId; - - //add random accessories - or not - for($l=0; $lsetAccessory($productIdList[array_rand($productIdList, 1)]); - $accessory->setProductId($productId); - $accessory->setPosition($l); - - $accessory->save(); - } + for($k=0; $ksetRef($category->getId() . '_' . $k . '_' . $faker->randomNumber(8)); - $product->addCategory($category); - $product->setVisible(rand(1, 10)>7 ? 0 : 1); - $product->setPosition($k); - $product->setTitle($faker->text(20)); - $product->setDescription($faker->text(255)); - - $product->save(); - $productId = $product->getId(); - $productIdList[] = $productId; - - //add random accessories - for($l=0; $lsetAccessory($productIdList[array_rand($productIdList, 1)]); - $accessory->setProductId($productId); - $accessory->setPosition($l); - - $accessory->save(); - } + createProduct($faker, $category, $k, $currency, $productIdList); } } @@ -165,7 +157,7 @@ try { $folder->save(); - for($j=0; $jsetParent($folder->getId()); $subfolder->setVisible(rand(1, 10)>7 ? 0 : 1); @@ -175,7 +167,7 @@ try { $subfolder->save(); - for($k=0; $kaddFolder($subfolder); $content->setVisible(rand(1, 10)>7 ? 0 : 1); @@ -194,5 +186,60 @@ try { $con->rollBack(); } +function createProduct($faker, $category, $position, $currency, &$productIdList) +{ + $product = new Thelia\Model\Product(); + $product->setRef($category->getId() . '_' . $position . '_' . $faker->randomNumber(8)); + $product->addCategory($category); + $product->setVisible(rand(1, 10)>7 ? 0 : 1); + $product->setPosition($position); + $product->setTitle($faker->text(20)); + $product->setDescription($faker->text(255)); + $product->save(); + $productId = $product->getId(); + $productIdList[] = $productId; + + $stock = new \Thelia\Model\ProductSaleElements(); + $stock->setProduct($product); + $stock->setQuantity($faker->randomNumber(1,50)); + $stock->setPromo($faker->randomNumber(0,1)); + $stock->setNewness($faker->randomNumber(0,1)); + $stock->setWeight($faker->randomFloat(2, 100,10000)); + $stock->save(); + + $productPrice = new \Thelia\Model\ProductPrice(); + $productPrice->setProductSaleElements($stock); + $productPrice->setCurrency($currency); + $productPrice->setPrice($faker->randomFloat(2, 20, 250)); + $productPrice->setPromoPrice($faker->randomFloat(2, 20, 250)); + $productPrice->save(); + + //add random accessories - or not + for($i=1; $isetAccessory($productIdList[array_rand($productIdList, 1)]); + $accessory->setProductId($productId); + $accessory->setPosition($i); + + $accessory->save(); + } + + return $product; +} + +function createCategory($faker, $parent, $position, &$categoryIdList) +{ + $category = new Thelia\Model\Category(); + $category->setParent($parent); + $category->setVisible(rand(1, 10)>7 ? 0 : 1); + $category->setPosition($position); + $category->setTitle($faker->text(20)); + $category->setDescription($faker->text(255)); + + $category->save(); + $categoryIdList[] = $category->getId(); + + return $category; +} diff --git a/templates/default/category.html b/templates/default/category.html index 6aabd6edf..9a79f24c2 100755 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -1,3 +1,5 @@ +

Category page

+

CATALOG

@@ -90,17 +92,30 @@ {/loop} +
+ +

ALL ATTRIBUTES AND THEIR AVAILABILITY

+ +
    + {loop name="attr" type="attribute" order="manual"} +
  • + #TITLE +
      + {loop name="attrav" type="attribute_available" order="manual" attribute="#ID"} +
    • #TITLE
    • + {/loop} +
    +
  • + {/loop} +
+
- {*loop name="product" type="product" order="promo,min_price" exclude_category="3"} + + {loop name="product" type="product" order="promo,min_price" exclude_category="3" new="on" promo="off"}

PRODUCT : #REF / #TITLE

- price : #PRICE €
- promo price : #PROMO_PRICE €
- is promo : #PROMO
- is new : #NEW
- weight : #WEIGHT
- {/loop*} + {/loop} {*loop name="product" type="product" order="ref" feature_available="1: (1 | 2) , 2: 4, 3: 433"}

PRODUCT : #REF / #TITLE

From 805c9cf685c193ab82409cd68fd746a8daa53c7d Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 14 Aug 2013 14:05:10 +0200 Subject: [PATCH 003/268] fix template category --- templates/default/category.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/default/category.html b/templates/default/category.html index 9a79f24c2..976ec7416 100755 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -84,7 +84,7 @@
  • #TITLE
      - {loop name="ftav" type="feature_available" order="manual" feature="#ID"} + {loop name="ftav" type="feature_availability" order="manual" feature="#ID"}
    • #TITLE
    • {/loop}
    @@ -101,7 +101,7 @@
  • #TITLE
      - {loop name="attrav" type="attribute_available" order="manual" attribute="#ID"} + {loop name="attrav" type="attribute_availability" order="manual" attribute="#ID"}
    • #TITLE
    • {/loop}
    @@ -117,7 +117,7 @@

    PRODUCT : #REF / #TITLE

    {/loop} - {*loop name="product" type="product" order="ref" feature_available="1: (1 | 2) , 2: 4, 3: 433"} + {*loop name="product" type="product" order="ref" feature_availability="1: (1 | 2) , 2: 4, 3: 433"}

    PRODUCT : #REF / #TITLE

    price : #PRICE €
    promo price : #PROMO_PRICE €
    From d50b0e6e1049f27ef0885cf981243c4a6d6263ce Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Mon, 19 Aug 2013 17:18:20 +0200 Subject: [PATCH 004/268] big progress on product loop --- .../lib/Thelia/Core/Template/Loop/Product.php | 291 ++++++++++-------- .../Template/Smarty/Plugins/TheliaLoop.php | 119 ++++++- templates/default/bug.html | 0 templates/default/category.html | 18 +- templates/default/debug.html | 7 + 5 files changed, 301 insertions(+), 134 deletions(-) delete mode 100644 templates/default/bug.html create mode 100644 templates/default/debug.html diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 2efddad94..aca4139aa 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -99,6 +99,22 @@ class Product extends BaseLoop new TypeCollection( new Type\IntToCombinedStringsListType() ) + ), + /* + * promo, new, quantity and weight may differ depending on the different attributes + * by default, product loop will look for at least 1 attribute which matches all the loop criteria : attribute_non_strict_match="none" + * you can also provide a list of non-strict attributes. + * ie : attribute_non_strict_match="promo,new" + * loop will return the product if he has at least an attribute in promo and at least an attribute as new ; even if it's not the same attribute. + * you can set all the attributes as non strict : attribute_non_strict_match="*" + */ + new Argument( + 'attribute_non_strict_match', + new TypeCollection( + new Type\EnumListType(array('min_stock', 'promo', 'new', 'min_weight', 'max_weight', 'min_price', 'max_price')), + new Type\EnumType(array('*', 'none')) + ), + 'none' ) ); } @@ -115,6 +131,20 @@ class Product extends BaseLoop //$search->withColumn('CASE WHEN ' . ProductTableMap::PROMO . '=1 THEN ' . ProductTableMap::PRICE2 . ' ELSE ' . ProductTableMap::PRICE . ' END', 'real_price'); + /** + * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. + * + * @todo : verify here if we want results for row without translations. + */ + + $search->joinWithI18n( + $this->request->getSession()->getLocale(), + (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN + ); + + $attributeNonStrictMatch = $this->getAttribute_non_strict_match(); + $usedAttributeNonStrictMatchList = array(); + $id = $this->getId(); if (!is_null($id)) { @@ -127,7 +157,7 @@ class Product extends BaseLoop $search->filterByRef($ref, Criteria::IN); } - $category = $this->getCategory(); + $category = $this->getCategory(); if (!is_null($category)) { $categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find(); @@ -149,74 +179,107 @@ class Product extends BaseLoop $new = $this->getNew(); if ($new === true) { - $search->joinProductSaleElements('is_new', Criteria::INNER_JOIN) - ->addJoinCondition('is_new', "`is_new`.NEWNESS = 1"); + $usedAttributeNonStrictMatchList[] = 'new'; + $search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN) + ->addJoinCondition('is_new', '`is_new`.NEWNESS = 1') + ->where('NOT ISNULL(`is_new`.ID)'); } else if($new === false) { - $search->joinProductSaleElements('is_new', Criteria::INNER_JOIN) - ->addJoinCondition('is_new', "`is_new`.NEWNESS = 0"); + $usedAttributeNonStrictMatchList[] = 'new'; + $search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN) + ->addJoinCondition('is_new', '`is_new`.NEWNESS = 0') + ->where('NOT ISNULL(`is_new`.ID)'); } $promo = $this->getPromo(); if ($promo === true) { - $search->joinProductSaleElements('is_promo', Criteria::INNER_JOIN) - ->addJoinCondition('is_promo', "`is_promo`.PROMO = 1"); + $usedAttributeNonStrictMatchList[] = 'promo'; + $search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN) + ->addJoinCondition('is_promo', "`is_promo`.PROMO = 1") + ->where('NOT ISNULL(`is_promo`.ID)'); } else if($promo === false) { - $search->joinProductSaleElements('is_promo', Criteria::INNER_JOIN) - ->addJoinCondition('is_promo', "`is_promo`.PROMO = 0"); + $usedAttributeNonStrictMatchList[] = 'promo'; + $search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN) + ->addJoinCondition('is_promo', "`is_promo`.PROMO = 0") + ->where('NOT ISNULL(`is_promo`.ID)'); } $min_stock = $this->getMin_stock(); if (null != $min_stock) { - $search->filterByQuantity($min_stock, Criteria::GREATER_EQUAL); + $usedAttributeNonStrictMatchList[] = 'min_stock'; + $search->joinProductSaleElements('is_min_stock', Criteria::LEFT_JOIN) + ->addJoinCondition('is_min_stock', "`is_min_stock`.QUANTITY > ?", $min_stock, null, \PDO::PARAM_INT) + ->where('NOT ISNULL(`is_min_stock`.ID)'); + } + + $min_weight = $this->getMin_weight(); + + if (null != $min_weight) { + $usedAttributeNonStrictMatchList[] = 'min_weight'; + $search->joinProductSaleElements('is_min_weight', Criteria::LEFT_JOIN) + ->addJoinCondition('is_min_weight', "`is_min_weight`.WEIGHT > ?", $min_weight, null, \PDO::PARAM_INT) + ->where('NOT ISNULL(`is_min_weight`.ID)'); + } + + $max_weight = $this->getMax_weight(); + + if (null != $max_weight) { + $usedAttributeNonStrictMatchList[] = 'max_weight'; + $search->joinProductSaleElements('is_max_weight', Criteria::LEFT_JOIN) + ->addJoinCondition('is_max_weight', "`is_max_weight`.WEIGHT < ?", $max_weight, null, \PDO::PARAM_INT) + ->where('NOT ISNULL(`is_max_weight`.ID)'); + } + + if( $attributeNonStrictMatch != '*' ) { + if($attributeNonStrictMatch == 'none') { + $actuallyUsedAttributeNonStrictMatchList = $usedAttributeNonStrictMatchList; + } else { + $actuallyUsedAttributeNonStrictMatchList = array_values(array_intersect($usedAttributeNonStrictMatchList, $attributeNonStrictMatch)); + } + + foreach($actuallyUsedAttributeNonStrictMatchList as $key => $actuallyUsedAttributeNonStrictMatch) { + if($key == 0) + continue; + $search->where('`is_' . $actuallyUsedAttributeNonStrictMatch . '`.ID=' . '`is_' . $actuallyUsedAttributeNonStrictMatchList[$key-1] . '`.ID'); + } } //$min_price = $this->getMin_price(); //if(null !== $min_price) { - /** - * Following should work but does not : - * - * $search->filterBy('real_price', $max_price, Criteria::GREATER_EQUAL); - */ - /*$search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1') - ->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1') - ->condition('min_price2', ProductTableMap::PRICE2 . Criteria::GREATER_EQUAL . '?', $min_price) - ->condition('min_price', ProductTableMap::PRICE . Criteria::GREATER_EQUAL . '?', $min_price) - ->combine(array('in_promo', 'min_price2'), Criteria::LOGICAL_AND, 'in_promo_min_price') - ->combine(array('not_in_promo', 'min_price'), Criteria::LOGICAL_AND, 'not_in_promo_min_price') - ->where(array('not_in_promo_min_price', 'in_promo_min_price'), Criteria::LOGICAL_OR); + /** + * Following should work but does not : + * + * $search->filterBy('real_price', $max_price, Criteria::GREATER_EQUAL); + */ + /*$search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1') + ->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1') + ->condition('min_price2', ProductTableMap::PRICE2 . Criteria::GREATER_EQUAL . '?', $min_price) + ->condition('min_price', ProductTableMap::PRICE . Criteria::GREATER_EQUAL . '?', $min_price) + ->combine(array('in_promo', 'min_price2'), Criteria::LOGICAL_AND, 'in_promo_min_price') + ->combine(array('not_in_promo', 'min_price'), Criteria::LOGICAL_AND, 'not_in_promo_min_price') + ->where(array('not_in_promo_min_price', 'in_promo_min_price'), Criteria::LOGICAL_OR); } $max_price = $this->getMax_price();*/ //if(null !== $max_price) { - /** - * Following should work but does not : - * - * $search->filterBy('real_price', $max_price, Criteria::LESS_EQUAL); - */ - /*$search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1') - ->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1') - ->condition('max_price2', ProductTableMap::PRICE2 . Criteria::LESS_EQUAL . '?', $max_price) - ->condition('max_price', ProductTableMap::PRICE . Criteria::LESS_EQUAL . '?', $max_price) - ->combine(array('in_promo', 'max_price2'), Criteria::LOGICAL_AND, 'in_promo_max_price') - ->combine(array('not_in_promo', 'max_price'), Criteria::LOGICAL_AND, 'not_in_promo_max_price') - ->where(array('not_in_promo_max_price', 'in_promo_max_price'), Criteria::LOGICAL_OR); + /** + * Following should work but does not : + * + * $search->filterBy('real_price', $max_price, Criteria::LESS_EQUAL); + */ + /*$search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1') + ->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1') + ->condition('max_price2', ProductTableMap::PRICE2 . Criteria::LESS_EQUAL . '?', $max_price) + ->condition('max_price', ProductTableMap::PRICE . Criteria::LESS_EQUAL . '?', $max_price) + ->combine(array('in_promo', 'max_price2'), Criteria::LOGICAL_AND, 'in_promo_max_price') + ->combine(array('not_in_promo', 'max_price'), Criteria::LOGICAL_AND, 'not_in_promo_max_price') + ->where(array('not_in_promo_max_price', 'in_promo_max_price'), Criteria::LOGICAL_OR); }*/ - /*$min_weight = $this->getMin_weight(); - - if(null !== $min_weight) { - $search->filterByWeight($min_weight, Criteria::GREATER_EQUAL); - } - - $max_weight = $this->getMax_weight(); - - if(null !== $max_weight) { - $search->filterByWeight($max_weight, Criteria::LESS_EQUAL); - }*/ + /**/ $current = $this->getCurrent(); @@ -256,57 +319,6 @@ class Product extends BaseLoop if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0); - $orders = $this->getOrder(); - - foreach($orders as $order) { - switch ($order) { - case "alpha": - $search->addAscendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE); - break; - case "alpha_reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE); - break; - /*case "min_price": - $search->orderBy('real_price', Criteria::ASC); - break; - case "max_price": - $search->orderBy('real_price', Criteria::DESC); - break;*/ - case "manual": - if(null === $category || count($category) != 1) - throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); - $search->orderByPosition(Criteria::ASC); - break; - case "manual_reverse": - if(null === $category || count($category) != 1) - throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); - $search->orderByPosition(Criteria::DESC); - break; - case "ref": - $search->orderByRef(Criteria::ASC); - break; - /*case "promo": - $search->orderByPromo(Criteria::DESC); - break; - case "new": - $search->orderByNewness(Criteria::DESC); - break;*/ - case "given_id": - if(null === $id) - throw new \InvalidArgumentException('Given_id order cannot be set without `id` argument'); - foreach($id as $singleId) { - $givenIdMatched = 'given_id_matched_' . $singleId; - $search->withColumn(ProductTableMap::ID . "='$singleId'", $givenIdMatched); - $search->orderBy($givenIdMatched, Criteria::DESC); - } - break; - case "random": - $search->clearOrderByColumns(); - $search->addAscendingOrderByColumn('RAND()'); - break(2); - } - } - $exclude = $this->getExclude(); if (!is_null($exclude)) { @@ -378,19 +390,59 @@ class Product extends BaseLoop } } - /** - * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - $search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - ); - $search->groupBy(ProductTableMap::ID); + $orders = $this->getOrder(); + + foreach($orders as $order) { + switch ($order) { + case "alpha": + $search->addAscendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE); + break; + case "alpha_reverse": + $search->addDescendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE); + break; + /*case "min_price": + $search->orderBy('real_price', Criteria::ASC); + break; + case "max_price": + $search->orderBy('real_price', Criteria::DESC); + break;*/ + case "manual": + if(null === $category || count($category) != 1) + throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); + $search->orderByPosition(Criteria::ASC); + break; + case "manual_reverse": + if(null === $category || count($category) != 1) + throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); + $search->orderByPosition(Criteria::DESC); + break; + case "ref": + $search->orderByRef(Criteria::ASC); + break; + /*case "promo": + $search->orderByPromo(Criteria::DESC); + break; + case "new": + $search->orderByNewness(Criteria::DESC); + break;*/ + case "given_id": + if(null === $id) + throw new \InvalidArgumentException('Given_id order cannot be set without `id` argument'); + foreach($id as $singleId) { + $givenIdMatched = 'given_id_matched_' . $singleId; + $search->withColumn(ProductTableMap::ID . "='$singleId'", $givenIdMatched); + $search->orderBy($givenIdMatched, Criteria::DESC); + } + break; + case "random": + $search->clearOrderByColumns(); + $search->addAscendingOrderByColumn('RAND()'); + break(2); + } + } + $products = $this->search($search, $pagination); $loopResult = new LoopResult(); @@ -399,23 +451,22 @@ class Product extends BaseLoop $loopResultRow = new LoopResultRow(); $loopResultRow->set("ID", $product->getId()) - ->set("REF",$product->getRef()) - ->set("TITLE",$product->getTitle()) - ->set("CHAPO", $product->getChapo()) - ->set("DESCRIPTION", $product->getDescription()) - ->set("POSTSCRIPTUM", $product->getPostscriptum()) - //->set("PRICE", $product->getPrice()) - //->set("PROMO_PRICE", $product->getPrice2()) - //->set("WEIGHT", $product->getWeight()) - //->set("PROMO", $product->getPromo()) - //->set("NEW", $product->getNewness()) - ->set("POSITION", $product->getPosition()) - ; + ->set("REF",$product->getRef()) + ->set("TITLE",$product->getTitle()) + ->set("CHAPO", $product->getChapo()) + ->set("DESCRIPTION", $product->getDescription()) + ->set("POSTSCRIPTUM", $product->getPostscriptum()) + //->set("PRICE", $product->getPrice()) + //->set("PROMO_PRICE", $product->getPrice2()) + //->set("WEIGHT", $product->getWeight()) + //->set("PROMO", $product->getPromo()) + //->set("NEW", $product->getNewness()) + ->set("POSITION", $product->getPosition()) + ; $loopResult->addRow($loopResultRow); } return $loopResult; } - } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php index e1eefedb0..946b73f82 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php @@ -75,8 +75,9 @@ class TheliaLoop extends AbstractSmartyPlugin { $type = $this->getParam($params, 'type'); - if (null == $type) + if (null == $type) { throw new \InvalidArgumentException("Missing 'type' parameter in count arguments"); + } $loop = $this->createLoopInstance($params); @@ -101,13 +102,15 @@ class TheliaLoop extends AbstractSmartyPlugin { $name = $this->getParam($params, 'name'); - if (null == $name) + if (null == $name) { throw new \InvalidArgumentException("Missing 'name' parameter in loop arguments"); + } $type = $this->getParam($params, 'type'); - if (null == $type) + if (null == $type) { throw new \InvalidArgumentException("Missing 'type' parameter in loop arguments"); + } if ($content === null) { // Check if a loop with the same name exists in the current scope, and abort if it's the case. @@ -272,6 +275,105 @@ class TheliaLoop extends AbstractSmartyPlugin } } + /** + * Process {unionloop name="loop name" type="loop type" ... } ... {/unionloop} block + * + * @param $params + * @param $content + * @param $template + * @param $repeat + * + * @return string + * @throws \InvalidArgumentException + */ + public function theliaUnion($params, $content, $template, &$repeat) + { + return; + + $name = $this->getParam($params, 'name'); + + if (null == $name) + throw new \InvalidArgumentException("Missing 'name' parameter in unionloop arguments"); + + $type = $this->getParam($params, 'type'); + + if (null == $type) + throw new \InvalidArgumentException("Missing 'type' parameter in unionloop arguments"); + + if ($content === null) { + // Check if a loop with the same name exists in the current scope, and abort if it's the case. + if (array_key_exists($name, $this->varstack)) { + throw new \InvalidArgumentException("A loop named '$name' already exists in the current scope."); + } + + $loop = $this->createLoopInstance($params); + + self::$pagination[$name] = null; + + $loopResults = $loop->exec(self::$pagination[$name]); + + $this->loopstack[$name] = $loopResults; + + // Pas de résultat ? la boucle est terminée, ne pas évaluer le contenu. + if ($loopResults->isEmpty()) $repeat = false; + + } else { + $loopResults = $this->loopstack[$name]; + + $loopResults->next(); + } + + if ($loopResults->valid()) { + $loopResultRow = $loopResults->current(); + + // On first iteration, save variables that may be overwritten by this loop + if (! isset($this->varstack[$name])) { + + $saved_vars = array(); + + $varlist = $loopResultRow->getVars(); + $varlist[] = 'LOOP_COUNT'; + $varlist[] = 'LOOP_TOTAL'; + + foreach($varlist as $var) { + $saved_vars[$var] = $template->getTemplateVars($var); + } + + $this->varstack[$name] = $saved_vars; + } + + foreach($loopResultRow->getVarVal() as $var => $val) { + $template->assign($var, $val); + } + + $repeat = true; + } + + // Assign meta information + $template->assign('LOOP_COUNT', 1 + $loopResults->key()); + $template->assign('LOOP_TOTAL', $loopResults->getCount()); + + // Loop is terminated. Cleanup. + if (! $repeat) { + // Restore previous variables values before terminating + if (isset($this->varstack[$name])) { + foreach($this->varstack[$name] as $var => $value) { + $template->assign($var, $value); + } + + unset($this->varstack[$name]); + } + } + + if ($content !== null) { + if ($loopResults->isEmpty()) { + $content = ""; + } + + return $content; + } + } + /** * Check if a loop has returned results. The loop shoud have been executed before, or an * InvalidArgumentException is thrown @@ -367,11 +469,12 @@ class TheliaLoop extends AbstractSmartyPlugin { return array( - new SmartyPluginDescriptor('function', 'count' , $this, 'theliaCount'), - new SmartyPluginDescriptor('block' , 'loop' , $this, 'theliaLoop'), - new SmartyPluginDescriptor('block' , 'elseloop' , $this, 'theliaElseloop'), - new SmartyPluginDescriptor('block' , 'ifloop' , $this, 'theliaIfLoop'), - new SmartyPluginDescriptor('block' , 'pageloop' , $this, 'theliaPageLoop'), + new SmartyPluginDescriptor('function', 'count', $this, 'theliaCount'), + new SmartyPluginDescriptor('block' , 'loop', $this, 'theliaLoop'), + new SmartyPluginDescriptor('block' , 'elseloop', $this, 'theliaElseloop'), + new SmartyPluginDescriptor('block' , 'ifloop', $this, 'theliaIfLoop'), + new SmartyPluginDescriptor('block' , 'pageloop', $this, 'theliaPageLoop'), + new SmartyPluginDescriptor('block' , 'union', $this, 'theliaUnion'), ); } } diff --git a/templates/default/bug.html b/templates/default/bug.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/templates/default/category.html b/templates/default/category.html index 976ec7416..6a671f78a 100755 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -12,7 +12,7 @@

    PRODUCT : #REF (#LOOP_COUNT / #LOOP_TOTAL)

    #TITLE

    #DESCRIPTION

    - {ifloop rel="acc"} + {*ifloop rel="acc"}
    Accessories
      {loop name="acc" type="accessory" product="#ID" order="accessory"} @@ -22,7 +22,7 @@ {/ifloop} {elseloop rel="acc"}
      No accessory
      - {/elseloop} + {/elseloop*} {ifloop rel="ft"}
      Features
        @@ -44,7 +44,7 @@

        PRODUCT : #REF (#LOOP_COUNT / #LOOP_TOTAL)

        #TITLE

        #DESCRIPTION

        - {ifloop rel="acc"} + {*ifloop rel="acc"}
        Accessories
          {loop name="acc" type="accessory" product="#ID" order="accessory"} @@ -54,7 +54,7 @@ {/ifloop} {elseloop rel="acc"}
          No accessory
          - {/elseloop} + {/elseloop*} {ifloop rel="ft"}
          Features
            @@ -113,9 +113,15 @@
            - {loop name="product" type="product" order="promo,min_price" exclude_category="3" new="on" promo="off"} + {*loop name="product" type="product" order="promo,min_price" exclude_category="3" new="on" promo="off"}

            PRODUCT : #REF / #TITLE

            - {/loop} + {/loop*} + +{loop name="product" type="product" new="on" promo="off"} +

            PRODUCT : #REF / #TITLE

            +{/loop} + + {*loop name="product" type="product" order="ref" feature_availability="1: (1 | 2) , 2: 4, 3: 433"}

            PRODUCT : #REF / #TITLE

            diff --git a/templates/default/debug.html b/templates/default/debug.html new file mode 100644 index 000000000..19dea8c59 --- /dev/null +++ b/templates/default/debug.html @@ -0,0 +1,7 @@ +{*loop name="product" type="product" new="on" promo="on" min_stock="20" attribute_non_strict_match="min_stock,promo"} +

            PRODUCT : #REF / #TITLE (#ID)

            +{/loop*} + +{*loop name="product" type="product" min_weight="1000" max_weight="6000" attribute_non_strict_match="*"} +

            PRODUCT : #REF / #TITLE (#ID)

            +{/loop*} \ No newline at end of file From 4e405553132713e234141e0449abf7f7e0bdb6cf Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 19 Aug 2013 18:50:45 +0200 Subject: [PATCH 005/268] Init Coupon module design --- core/lib/Thelia/Coupon/CouponAbstract.php | 115 ++++++++++++++++++ .../Thelia/Coupon/CouponAdapterInterface.php | 60 +++++++++ core/lib/Thelia/Coupon/CouponBaseAdapter.php | 67 ++++++++++ core/lib/Thelia/Coupon/CouponFactory.php | 49 ++++++++ core/lib/Thelia/Coupon/CouponInterface.php | 89 ++++++++++++++ core/lib/Thelia/Coupon/CouponManager.php | 54 ++++++++ .../Thelia/Coupon/Rule/AvailableForDate.php | 38 ++++++ .../Coupon/Rule/AvailableForLocationX.php | 38 ++++++ .../Coupon/Rule/AvailableForNbArticles.php | 38 ++++++ .../Thelia/Coupon/Rule/AvailableForPeriod.php | 38 ++++++ .../Coupon/Rule/AvailableForRepeatedDate.php | 38 ++++++ .../Rule/AvailableForRepeatedPeriod.php | 38 ++++++ .../Coupon/Rule/AvailableForTotalAmount.php | 38 ++++++ .../AvailableForTotalAmountForCategoryY.php | 38 ++++++ .../Thelia/Coupon/Rule/CouponRuleAbstract.php | 69 +++++++++++ .../Thelia/Coupon/Rule/CuponRuleInterface.php | 60 +++++++++ core/lib/Thelia/Coupon/RuleOrganizer.php | 51 ++++++++ .../Thelia/Coupon/RuleOrganizerInterface.php | 47 +++++++ core/lib/Thelia/Coupon/Type/RemoveXAmount.php | 40 ++++++ .../Coupon/Type/RemoveXAmountForCategoryY.php | 38 ++++++ .../lib/Thelia/Coupon/Type/RemoveXPercent.php | 38 ++++++ .../Type/RemoveXPercentForAttributeY.php | 38 ++++++ .../Type/RemoveXPercentForCategoryY.php | 38 ++++++ ...RemoveXPercentForProductSaleElementIdY.php | 38 ++++++ .../Coupon/Type/RemoveXPercentForProductY.php | 38 ++++++ .../Tests/Coupon/CouponBaseAdapterTest.php | 66 ++++++++++ .../Thelia/Tests/Coupon/CouponFactoryTest.php | 42 +++++++ .../Thelia/Tests/Coupon/CouponManagerTest.php | 42 +++++++ .../Rule/AvailableForNbArticlesTest.php | 26 ++++ .../Thelia/Tests/Coupon/RuleOrganizerTest.php | 42 +++++++ .../Type/RemoveXAmountForCategoryYTest.php | 26 ++++ .../Tests/Coupon/Type/RemoveXAmountTest.php | 26 ++++ .../Type/RemoveXPercentForCategoryYTest.php | 26 ++++ .../Tests/Coupon/Type/RemoveXPercentTest.php | 26 ++++ 34 files changed, 1555 insertions(+) create mode 100644 core/lib/Thelia/Coupon/CouponAbstract.php create mode 100644 core/lib/Thelia/Coupon/CouponAdapterInterface.php create mode 100644 core/lib/Thelia/Coupon/CouponBaseAdapter.php create mode 100644 core/lib/Thelia/Coupon/CouponFactory.php create mode 100644 core/lib/Thelia/Coupon/CouponInterface.php create mode 100644 core/lib/Thelia/Coupon/CouponManager.php create mode 100644 core/lib/Thelia/Coupon/Rule/AvailableForDate.php create mode 100644 core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php create mode 100644 core/lib/Thelia/Coupon/Rule/AvailableForNbArticles.php create mode 100644 core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php create mode 100644 core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php create mode 100644 core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php create mode 100644 core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php create mode 100644 core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php create mode 100644 core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php create mode 100644 core/lib/Thelia/Coupon/Rule/CuponRuleInterface.php create mode 100644 core/lib/Thelia/Coupon/RuleOrganizer.php create mode 100644 core/lib/Thelia/Coupon/RuleOrganizerInterface.php create mode 100644 core/lib/Thelia/Coupon/Type/RemoveXAmount.php create mode 100644 core/lib/Thelia/Coupon/Type/RemoveXAmountForCategoryY.php create mode 100644 core/lib/Thelia/Coupon/Type/RemoveXPercent.php create mode 100644 core/lib/Thelia/Coupon/Type/RemoveXPercentForAttributeY.php create mode 100644 core/lib/Thelia/Coupon/Type/RemoveXPercentForCategoryY.php create mode 100644 core/lib/Thelia/Coupon/Type/RemoveXPercentForProductSaleElementIdY.php create mode 100644 core/lib/Thelia/Coupon/Type/RemoveXPercentForProductY.php create mode 100644 core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/CouponManagerTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/Rule/AvailableForNbArticlesTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php diff --git a/core/lib/Thelia/Coupon/CouponAbstract.php b/core/lib/Thelia/Coupon/CouponAbstract.php new file mode 100644 index 000000000..8c78dd924 --- /dev/null +++ b/core/lib/Thelia/Coupon/CouponAbstract.php @@ -0,0 +1,115 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Assist in writing a CouponInterface + * + * @package Coupon + * @author Guillaume MOREL + * + */ +abstract class CouponAbstract implements CouponInterface +{ + /** @var RuleOrganizerInterface */ + protected $organizer = null; + + + /** + * Return Coupon code (ex: XMAS) + * + * @return string + */ + public function getCode() + { + // TODO: Implement getCode() method. + } + + /** + * Return Coupon title (ex: Coupon for XMAS) + * + * @return string + */ + public function getTitle() + { + // TODO: Implement getTitle() method. + } + + /** + * Return Coupon short description + * + * @return string + */ + public function getShortDescription() + { + // TODO: Implement getShortDescription() method. + } + + /** + * Return Coupon description + * + * @return string + */ + public function getDescription() + { + // TODO: Implement getDescription() method. + } + + /** + * If Coupon is cumulative or prevent any accumulation + * If is cumulative you can sum Coupon effects + * If not cancel all other Coupon and take the last given + * + * @return string + */ + public function isCumulative() + { + // TODO: Implement isCumulative() method. + } + + /** + * If Coupon is removing Checkout Postage + * + * @return bool + */ + public function isRemovingPostage() + { + // TODO: Implement isRemovingPostage() method. + } + + /** + * Return effects generated by the coupon + * + * @return \Closure + */ + public function getEffect() + { + // TODO: Implement getEffect() method. + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponAdapterInterface.php b/core/lib/Thelia/Coupon/CouponAdapterInterface.php new file mode 100644 index 000000000..ece82fe28 --- /dev/null +++ b/core/lib/Thelia/Coupon/CouponAdapterInterface.php @@ -0,0 +1,60 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Allow a CouponManager class to be fed with relevant Thelia data + * + * @package Coupon + * @author Guillaume MOREL + * + */ +interface CouponAdapterInterface +{ + + /** + * Return a Cart a CouponManager can process + * + * @return \Thelia\Model\Cart + */ + public function getCart(); + + /** + * Return an Address a CouponManager can process + * + * @return \Thelia\Model\Address + */ + public function getDeliveryAddress(); + + /** + * Return an Customer a CouponManager can process + * + * @return \Thelia\Model\Customer + */ + public function getCustomer(); +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponBaseAdapter.php b/core/lib/Thelia/Coupon/CouponBaseAdapter.php new file mode 100644 index 000000000..35b15af41 --- /dev/null +++ b/core/lib/Thelia/Coupon/CouponBaseAdapter.php @@ -0,0 +1,67 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class CouponBaseAdapter implements CouponAdapterInterface +{ + /** + * Return a Cart a CouponManager can process + * + * @return \Thelia\Model\Cart + */ + public function getCart() + { + // TODO: Implement getCart() method. + } + + /** + * Return an Address a CouponManager can process + * + * @return \Thelia\Model\Address + */ + public function getDeliveryAddress() + { + // TODO: Implement getDeliveryAddress() method. + } + + /** + * Return an Customer a CouponManager can process + * + * @return \Thelia\Model\Customer + */ + public function getCustomer() + { + // TODO: Implement getCustomer() method. + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php new file mode 100644 index 000000000..f999eabff --- /dev/null +++ b/core/lib/Thelia/Coupon/CouponFactory.php @@ -0,0 +1,49 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Generate a CouponInterface + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class CouponFactory +{ + /** + * Build a CouponInterface from its database data + * + * @param int $couponId CouponInterface id + * + * @return CouponInterface ready to be processed + */ + public function buildCouponFromId($couponId) + { + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponInterface.php b/core/lib/Thelia/Coupon/CouponInterface.php new file mode 100644 index 000000000..ad332ad0a --- /dev/null +++ b/core/lib/Thelia/Coupon/CouponInterface.php @@ -0,0 +1,89 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Represents a Coupon ready to be processed in a Checkout process + * + * @package Coupon + * @author Guillaume MOREL + * + */ +interface CouponInterface +{ + /** + * Return Coupon code (ex: XMAS) + * + * @return string + */ + public function getCode(); + + /** + * Return Coupon title (ex: Coupon for XMAS) + * + * @return string + */ + public function getTitle(); + + /** + * Return Coupon short description + * + * @return string + */ + public function getShortDescription(); + + /** + * Return Coupon description + * + * @return string + */ + public function getDescription(); + + /** + * If Coupon is cumulative or prevent any accumulation + * If is cumulative you can sum Coupon effects + * If not cancel all other Coupon and take the last given + * + * @return string + */ + public function isCumulative(); + + /** + * If Coupon is removing Checkout Postage + * + * @return bool + */ + public function isRemovingPostage(); + + /** + * Return effects generated by the coupon + * + * @return \Closure + */ + public function getEffect(); +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php new file mode 100644 index 000000000..958f65db5 --- /dev/null +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -0,0 +1,54 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Manage how Coupons could interact with a Checkout + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class CouponManager +{ + /** @var CouponAdapterInterface Provide necessary value from Thelia*/ + protected $adapter; + + /** @var array CouponInterface to process*/ + protected $coupons = array(); + + /** + * Get Discount for the given Coupons + * + * @return float checkout discount + */ + public function getDiscount() + { + return 10.00; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForDate.php b/core/lib/Thelia/Coupon/Rule/AvailableForDate.php new file mode 100644 index 000000000..f55c48973 --- /dev/null +++ b/core/lib/Thelia/Coupon/Rule/AvailableForDate.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Rule; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class AvailableForDate extends AvailableForPeriod +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php b/core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php new file mode 100644 index 000000000..c57702b2f --- /dev/null +++ b/core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Rule; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class AvailableForLocationX extends CouponRuleAbstract +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForNbArticles.php b/core/lib/Thelia/Coupon/Rule/AvailableForNbArticles.php new file mode 100644 index 000000000..78bbb0e00 --- /dev/null +++ b/core/lib/Thelia/Coupon/Rule/AvailableForNbArticles.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Rule; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class AvailableForNbArticles extends CouponRuleAbstract +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php b/core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php new file mode 100644 index 000000000..1a2753dc4 --- /dev/null +++ b/core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Rule; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class AvailableForPeriod extends CouponRuleAbstract +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php new file mode 100644 index 000000000..7d03a1c5b --- /dev/null +++ b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Rule; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class AvailableForRepeatedDate extends AvailableForDate +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php new file mode 100644 index 000000000..8552947c2 --- /dev/null +++ b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Rule; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class AvailableForRepeatedPeriod extends AvailableForPeriod +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php new file mode 100644 index 000000000..b90ef1da5 --- /dev/null +++ b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Rule; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class AvailableForTotalAmount extends CouponRuleAbstract +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php new file mode 100644 index 000000000..08bdc23e5 --- /dev/null +++ b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Rule; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class AvailableForTotalAmountForCategoryY extends AvailableForTotalAmount +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php b/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php new file mode 100644 index 000000000..1c30f0321 --- /dev/null +++ b/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php @@ -0,0 +1,69 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Rule; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Assist in writing a condition of whether the Rule is applied or not + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class CouponRuleAbstract implements CuponRuleInterface +{ + /** + * Check if backoffice inputs are relevant or not + * + * @return bool + */ + public function checkBackOfficeIntput() + { + // TODO: Implement checkBackOfficeIntput() method. + } + + /** + * Check if Checkout inputs are relevant or not + * + * @return bool + */ + public function checkCheckoutInput() + { + // TODO: Implement checkCheckoutInput() method. + } + + /** + * Check if the current Checkout matchs this condition + * + * @return bool + */ + public function isMatching() + { + // TODO: Implement isMatching() method. + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/CuponRuleInterface.php b/core/lib/Thelia/Coupon/Rule/CuponRuleInterface.php new file mode 100644 index 000000000..b0cbfa767 --- /dev/null +++ b/core/lib/Thelia/Coupon/Rule/CuponRuleInterface.php @@ -0,0 +1,60 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Rule; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Represents a condition of whether the Rule is applied or not + * + * @package Coupon + * @author Guillaume MOREL + * + */ +interface CuponRuleInterface +{ + /** + * Check if backoffice inputs are relevant or not + * + * @return bool + */ + public function checkBackOfficeIntput(); + + /** + * Check if Checkout inputs are relevant or not + * + * @return bool + */ + public function checkCheckoutInput(); + + /** + * Check if the current Checkout matchs this condition + * + * @return bool + */ + public function isMatching(); + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/RuleOrganizer.php b/core/lib/Thelia/Coupon/RuleOrganizer.php new file mode 100644 index 000000000..b3699fc6c --- /dev/null +++ b/core/lib/Thelia/Coupon/RuleOrganizer.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Manage how Coupons could interact with a Checkout + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class RuleOrganizer implements RuleOrganizerInterface +{ + /** + * Organize CouponRuleInterface + * + * @param array $rules Array of CouponRuleInterface + * + * @return array Array of CouponRuleInterface sorted + */ + public function organize(array $rules) + { + // TODO: Implement organize() method. + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/RuleOrganizerInterface.php b/core/lib/Thelia/Coupon/RuleOrganizerInterface.php new file mode 100644 index 000000000..bc901d24c --- /dev/null +++ b/core/lib/Thelia/Coupon/RuleOrganizerInterface.php @@ -0,0 +1,47 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Manage how Coupons could interact with a Checkout + * + * @package Coupon + * @author Guillaume MOREL + * + */ +interface RuleOrganizerInterface +{ + /** + * Organize CouponRuleInterface + * + * @param array $rules Array of CouponRuleInterface + * + * @return array Array of CouponRuleInterface sorted + */ + public function organize(array $rules); +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Type/RemoveXAmount.php b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php new file mode 100644 index 000000000..1119d4ac2 --- /dev/null +++ b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php @@ -0,0 +1,40 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Type; + +use Thelia\Coupon\CouponAbstract; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class RemoveXAmount extends CouponAbstract +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Type/RemoveXAmountForCategoryY.php b/core/lib/Thelia/Coupon/Type/RemoveXAmountForCategoryY.php new file mode 100644 index 000000000..2cd8e5db6 --- /dev/null +++ b/core/lib/Thelia/Coupon/Type/RemoveXAmountForCategoryY.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Type; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class RemoveXAmountForCategoryY extends RemoveXAmount +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php new file mode 100644 index 000000000..638861e71 --- /dev/null +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Type; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class RemoveXPercent extends CouponAbstract +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentForAttributeY.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentForAttributeY.php new file mode 100644 index 000000000..643016c93 --- /dev/null +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercentForAttributeY.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Type; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class RemoveXPercentForAttributeY extends RemoveXPercent +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentForCategoryY.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentForCategoryY.php new file mode 100644 index 000000000..6ad0d21df --- /dev/null +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercentForCategoryY.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Type; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class RemoveXPercentForCategoryY extends RemoveXPercent +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductSaleElementIdY.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductSaleElementIdY.php new file mode 100644 index 000000000..b19913617 --- /dev/null +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductSaleElementIdY.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Type; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class RemoveXPercentForProductSaleElementIdY extends RemoveXPercent +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductY.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductY.php new file mode 100644 index 000000000..494e30fcd --- /dev/null +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductY.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Type; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class RemoveXPercentForProductY extends RemoveXPercent +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php b/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php new file mode 100644 index 000000000..57d0ce131 --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php @@ -0,0 +1,66 @@ +object = new CouponBaseAdapter; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers Thelia\Coupon\CouponBaseAdapter::getCart + * @todo Implement testGetCart(). + */ + public function testGetCart() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Thelia\Coupon\CouponBaseAdapter::getDeliveryAddress + * @todo Implement testGetDeliveryAddress(). + */ + public function testGetDeliveryAddress() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Thelia\Coupon\CouponBaseAdapter::getCustomer + * @todo Implement testGetCustomer(). + */ + public function testGetCustomer() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php new file mode 100644 index 000000000..9a637b299 --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -0,0 +1,42 @@ +object = new CouponFactory; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers Thelia\Coupon\CouponFactory::buildCouponFromId + * @todo Implement testBuildCouponFromId(). + */ + public function testBuildCouponFromId() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php new file mode 100644 index 000000000..55b48f4d9 --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -0,0 +1,42 @@ +object = new CouponManager; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers Thelia\Coupon\CouponManager::getDiscount + * @todo Implement testGetDiscount(). + */ + public function testGetDiscount() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForNbArticlesTest.php b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForNbArticlesTest.php new file mode 100644 index 000000000..ed8a57833 --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForNbArticlesTest.php @@ -0,0 +1,26 @@ +object = new RuleOrganizer; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers Thelia\Coupon\RuleOrganizer::organize + * @todo Implement testOrganize(). + */ + public function testOrganize() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php new file mode 100644 index 000000000..ed8a57833 --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php @@ -0,0 +1,26 @@ + Date: Mon, 19 Aug 2013 20:02:53 +0200 Subject: [PATCH 006/268] WIP Coupon RemoveXPercent and RemoveXAmount implementation --- core/lib/Thelia/Coupon/CouponAbstract.php | 69 +++++++- .../Thelia/Coupon/CouponAdapterInterface.php | 22 +++ core/lib/Thelia/Coupon/CouponBaseAdapter.php | 20 +++ core/lib/Thelia/Coupon/Type/RemoveXAmount.php | 40 +++++ .../lib/Thelia/Coupon/Type/RemoveXPercent.php | 55 +++++++ .../Exception/MissingAdapterException.php | 50 ++++++ .../Tests/Coupon/Type/RemoveXAmountTest.php | 147 +++++++++++++++++- .../Tests/Coupon/Type/RemoveXPercentTest.php | 139 +++++++++++++++++ 8 files changed, 533 insertions(+), 9 deletions(-) create mode 100644 core/lib/Thelia/Exception/MissingAdapterException.php diff --git a/core/lib/Thelia/Coupon/CouponAbstract.php b/core/lib/Thelia/Coupon/CouponAbstract.php index 8c78dd924..b2d4f9268 100644 --- a/core/lib/Thelia/Coupon/CouponAbstract.php +++ b/core/lib/Thelia/Coupon/CouponAbstract.php @@ -23,6 +23,8 @@ namespace Thelia\Coupon; +use Symfony\Component\Intl\Exception\NotImplementedException; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -36,9 +38,57 @@ namespace Thelia\Coupon; */ abstract class CouponAbstract implements CouponInterface { + /** @var CouponAdapterInterface Provide necessary value from Thelia*/ + protected $adapter; + /** @var RuleOrganizerInterface */ protected $organizer = null; + /** @var string Coupon code (ex: XMAS) */ + protected $code = null; + + /** @var string Coupon title (ex: Coupon for XMAS) */ + protected $title = null; + + /** @var string Coupon short description */ + protected $shortDescription = null; + + /** @var string Coupon description */ + protected $description = null; + + /** @var bool if Coupon is cumulative */ + protected $isCumulative = false; + + /** @var bool if Coupon is removing postage */ + protected $isRemovingPostage = false; + + /** + * Set Adapter containing all relevant data + * + * @param CouponAdapterInterface $adapter Adapter + * + * @return $this + */ + public function setAdapter($adapter) + { + $this->adapter = $adapter; + + return $this; + } + + /** + * Set Rule Organizer + * + * @param RuleOrganizerInterface $organizer Manage Rule groups (&& and ||) + * + * @return $this + */ + public function setOrganizer($organizer) + { + $this->organizer = $organizer; + + return $this; + } /** * Return Coupon code (ex: XMAS) @@ -47,7 +97,7 @@ abstract class CouponAbstract implements CouponInterface */ public function getCode() { - // TODO: Implement getCode() method. + return $this->code; } /** @@ -57,7 +107,7 @@ abstract class CouponAbstract implements CouponInterface */ public function getTitle() { - // TODO: Implement getTitle() method. + return $this->title; } /** @@ -67,7 +117,7 @@ abstract class CouponAbstract implements CouponInterface */ public function getShortDescription() { - // TODO: Implement getShortDescription() method. + return $this->shortDescription; } /** @@ -77,7 +127,7 @@ abstract class CouponAbstract implements CouponInterface */ public function getDescription() { - // TODO: Implement getDescription() method. + return $this->description; } /** @@ -85,11 +135,11 @@ abstract class CouponAbstract implements CouponInterface * If is cumulative you can sum Coupon effects * If not cancel all other Coupon and take the last given * - * @return string + * @return bool */ public function isCumulative() { - // TODO: Implement isCumulative() method. + return $this->isCumulative; } /** @@ -99,17 +149,20 @@ abstract class CouponAbstract implements CouponInterface */ public function isRemovingPostage() { - // TODO: Implement isRemovingPostage() method. + return $this->isRemovingPostage; } /** * Return effects generated by the coupon * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException * @return \Closure */ public function getEffect() { - // TODO: Implement getEffect() method. + throw new NotImplementedException( + 'Abstract method to implement (CouponAbstract->getEffect)' + ); } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponAdapterInterface.php b/core/lib/Thelia/Coupon/CouponAdapterInterface.php index ece82fe28..f36c13427 100644 --- a/core/lib/Thelia/Coupon/CouponAdapterInterface.php +++ b/core/lib/Thelia/Coupon/CouponAdapterInterface.php @@ -57,4 +57,26 @@ interface CouponAdapterInterface * @return \Thelia\Model\Customer */ public function getCustomer(); + + /** + * Return Checkout total price + * + * @return float + */ + public function getCheckoutTotalPrice(); + + /** + * Return Products total price + * + * @return float + */ + public function getCheckoutTotalPriceWithoutDiscountAndPostagePrice(); + + /** + * Return Checkout total postage (only) price + * + * @return float + */ + public function getCheckoutPostagePrice(); + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponBaseAdapter.php b/core/lib/Thelia/Coupon/CouponBaseAdapter.php index 35b15af41..bb24306e2 100644 --- a/core/lib/Thelia/Coupon/CouponBaseAdapter.php +++ b/core/lib/Thelia/Coupon/CouponBaseAdapter.php @@ -64,4 +64,24 @@ class CouponBaseAdapter implements CouponAdapterInterface // TODO: Implement getCustomer() method. } + /** + * Return Checkout total price + * + * @return float + */ + public function getCheckoutTotalPrice() + { + // TODO: Implement getCheckoutTotalPrice() method. + } + + /** + * Return Checkout total postage (only) price + * + * @return float + */ + public function getCheckoutPostagePrice() + { + // TODO: Implement getCheckoutPostagePrice() method. + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Type/RemoveXAmount.php b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php index 1119d4ac2..6c9a6e7ba 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXAmount.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php @@ -30,6 +30,8 @@ use Thelia\Coupon\CouponAbstract; * Date: 8/19/13 * Time: 3:24 PM * + * Allow to remove an amount from the checkout total + * * @package Coupon * @author Guillaume MOREL * @@ -37,4 +39,42 @@ use Thelia\Coupon\CouponAbstract; class RemoveXAmount extends CouponAbstract { + protected $amount = 0; + + /** + * Constructor + * + * @param string $code Coupon code (ex: XMAS) + * @param string $title Coupon title (ex: Coupon for XMAS) + * @param string $shortDescription Coupon short description + * @param string $description Coupon description + * @param float $amount Coupon amount to deduce + * @param bool $isCumulative if Coupon is cumulative + * @param bool $isRemovingPostage if Coupon is removing postage + */ + function __construct($code, $title, $shortDescription, $description, $amount, $isCumulative, $isRemovingPostage) + { + $this->code = $code; + $this->title = $title; + $this->shortDescription = $shortDescription; + $this->description = $description; + + $this->isCumulative = $isCumulative; + $this->isRemovingPostage = $isRemovingPostage; + + $this->amount = $amount; + } + + /** + * Return effects generated by the coupon + * A negative value + * + * @return float + */ + public function getEffect() + { + return -$this->amount; + } + + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php index 638861e71..3f0fd43fc 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php @@ -23,6 +23,9 @@ namespace Thelia\Coupon\Type; +use Thelia\Coupon\CouponAbstract; +use Thelia\Exception\MissingAdapterException; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -34,5 +37,57 @@ namespace Thelia\Coupon\Type; */ class RemoveXPercent extends CouponAbstract { + protected $percent = 0; + + /** + * Constructor + * + * @param string $code Coupon code (ex: XMAS) + * @param string $title Coupon title (ex: Coupon for XMAS) + * @param string $shortDescription Coupon short description + * @param string $description Coupon description + * @param float $percent Coupon % to deduce (ex:3.14 for 3.14%) + * @param bool $isCumulative if Coupon is cumulative + * @param bool $isRemovingPostage if Coupon is removing postage + */ + function __construct($code, $title, $shortDescription, $description, $percent, $isCumulative, $isRemovingPostage) + { + $this->code = $code; + $this->title = $title; + $this->shortDescription = $shortDescription; + $this->description = $description; + + $this->isCumulative = $isCumulative; + $this->isRemovingPostage = $isRemovingPostage; + + $this->percent = $percent; + } + + /** + * Return effects generated by the coupon + * A negative value + * + * @throws \Thelia\Exception\MissingAdapterException + * @throws \InvalidArgumentException + * @return float + */ + public function getEffect() + { + if ($this->adapter === null) { + throw new MissingAdapterException( + 'Cant calculate effect : CouponAdapterInterface is missing.' + ); + } + + if ($this->percent >= 100) { + throw new \InvalidArgumentException( + 'Percentage must be inferior to 100' + ); + } + + $basePrice = $this->adapter + ->getCheckoutTotalPriceWithoutDiscountAndPostagePrice(); + return $basePrice * (( 100 - $this->percent ) / 100); + } } \ No newline at end of file diff --git a/core/lib/Thelia/Exception/MissingAdapterException.php b/core/lib/Thelia/Exception/MissingAdapterException.php new file mode 100644 index 000000000..645020cab --- /dev/null +++ b/core/lib/Thelia/Exception/MissingAdapterException.php @@ -0,0 +1,50 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Exception; + +use Thelia\Log\Tlog; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when the Adapter is not set + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class MissingAdapterException extends \RuntimeException +{ + /** + * {@inheritdoc} + */ + public function __construct($message, $code = null, $previous = null) { + + Tlog::getInstance()->addError($message); + + parent::__construct($message, $code, $previous); + } +} diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php index 4b28a1d7b..27d0e9afb 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php @@ -1,20 +1,165 @@ Loremipsum'; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { + } + + protected function generateValidCumulativeRemovingPostageCoupon() + { + $coupon = new RemoveXAmount( + self::VALID_COUPON_CODE, + self::VALID_COUPON_TITLE, + self::VALID_COUPON_SHORT_DESCRIPTION, + self::VALID_COUPON_DESCRIPTION, + 30.00, + true, + true + ); + + return $coupon; + } + + protected function generateValidNonCumulativeNonRemovingPostageCoupon() + { + $coupon = new RemoveXAmount( + self::VALID_COUPON_CODE, + self::VALID_COUPON_TITLE, + self::VALID_COUPON_SHORT_DESCRIPTION, + self::VALID_COUPON_DESCRIPTION, + 30.00, + false, + false + ); + + return $coupon; + } + + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::getCode + * @covers Thelia\Coupon\type\RemoveXAmount::getTitle + * @covers Thelia\Coupon\type\RemoveXAmount::getShortDescription + * @covers Thelia\Coupon\type\RemoveXAmount::getDescription + * + */ + public function testDisplay() + { + + $coupon = $this->generateValidCumulativeRemovingPostageCoupon(); + + $expected = self::VALID_COUPON_CODE; + $actual = $coupon->getCode(); + $this->assertEquals($expected, $actual); + + $expected = self::VALID_COUPON_TITLE; + $actual = $coupon->getTitle(); + $this->assertEquals($expected, $actual); + + $expected = self::VALID_COUPON_SHORT_DESCRIPTION; + $actual = $coupon->getShortDescription(); + $this->assertEquals($expected, $actual); + + $expected = self::VALID_COUPON_DESCRIPTION; + $actual = $coupon->getDescription(); + $this->assertEquals($expected, $actual); + + } + + + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::isCumulative + * + */ + public function testIsCumulative() + { + + $coupon = $this->generateValidCumulativeRemovingPostageCoupon(); + + $actual = $coupon->isCumulative(); + $this->assertTrue($actual); + } + + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::isCumulative + * + */ + public function testIsNotCumulative() + { + + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + $actual = $coupon->isCumulative(); + $this->assertFalse($actual); + } + + + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::isRemovingPostage + * + */ + public function testIsRemovingPostage() + { + + $coupon = $this->generateValidCumulativeRemovingPostageCoupon(); + + $actual = $coupon->isRemovingPostage(); + $this->assertTrue($actual); + } + + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::isRemovingPostage + * + */ + public function testIsNotRemovingPostage() + { + + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + $actual = $coupon->isRemovingPostage(); + $this->assertFalse($actual); + } + + + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::getEffect + * + */ + public function testGetEffect() + { + + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + $expected = -30.00; + $actual = $coupon->getEffect(); + $this->assertEquals($expected, $actual); + } + + /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php index a7aa2e65f..33372cdb2 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php @@ -1,6 +1,9 @@ generateValidCumulativeRemovingPostageCoupon(); + + $expected = self::VALID_COUPON_CODE; + $actual = $coupon->getCode(); + $this->assertEquals($expected, $actual); + + $expected = self::VALID_COUPON_TITLE; + $actual = $coupon->getTitle(); + $this->assertEquals($expected, $actual); + + $expected = self::VALID_COUPON_SHORT_DESCRIPTION; + $actual = $coupon->getShortDescription(); + $this->assertEquals($expected, $actual); + + $expected = self::VALID_COUPON_DESCRIPTION; + $actual = $coupon->getDescription(); + $this->assertEquals($expected, $actual); + + } + + + /** + * + * @covers Thelia\Coupon\Type\RemoveXPercent::isCumulative + * + */ + public function testIsCumulative() + { + + $coupon = $this->generateValidCumulativeRemovingPostageCoupon(); + + $actual = $coupon->isCumulative(); + $this->assertTrue($actual); + } + + /** + * + * @covers Thelia\Coupon\Type\RemoveXPercent::isCumulative + * + */ + public function testIsNotCumulative() + { + + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + $actual = $coupon->isCumulative(); + $this->assertFalse($actual); + } + + + /** + * + * @covers Thelia\Coupon\Type\RemoveXPercent::isRemovingPostage + * + */ + public function testIsRemovingPostage() + { + + $coupon = $this->generateValidCumulativeRemovingPostageCoupon(); + + $actual = $coupon->isRemovingPostage(); + $this->assertTrue($actual); + } + + /** + * + * @covers Thelia\Coupon\Type\RemoveXPercent::isRemovingPostage + * + */ + public function testIsNotRemovingPostage() + { + + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + $actual = $coupon->isRemovingPostage(); + $this->assertFalse($actual); + } + + + /** + * + * @covers Thelia\Coupon\Type\RemoveXPercent::getEffect + * + */ + public function testGetEffect() + { + + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + $expected = -30.00; + $actual = $coupon->getEffect(); + $this->assertEquals($expected, $actual); + } + /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. From 42270991c537f13d4483873b5a20c386b56578c8 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 20 Aug 2013 11:29:35 +0200 Subject: [PATCH 007/268] product loop parameters done --- .../lib/Thelia/Core/Template/Loop/Product.php | 96 ++++++++++--------- templates/default/debug.html | 10 +- 2 files changed, 58 insertions(+), 48 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index aca4139aa..8b0bd72fe 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -35,6 +35,8 @@ use Thelia\Log\Tlog; use Thelia\Model\CategoryQuery; use Thelia\Model\Map\FeatureProductTableMap; +use Thelia\Model\Map\ProductPriceTableMap; +use Thelia\Model\Map\ProductSaleElementsTableMap; use Thelia\Model\Map\ProductTableMap; use Thelia\Model\ProductCategoryQuery; use Thelia\Model\ProductQuery; @@ -101,7 +103,7 @@ class Product extends BaseLoop ) ), /* - * promo, new, quantity and weight may differ depending on the different attributes + * promo, new, quantity, weight or price may differ depending on the different attributes * by default, product loop will look for at least 1 attribute which matches all the loop criteria : attribute_non_strict_match="none" * you can also provide a list of non-strict attributes. * ie : attribute_non_strict_match="promo,new" @@ -129,8 +131,6 @@ class Product extends BaseLoop { $search = ProductQuery::create(); - //$search->withColumn('CASE WHEN ' . ProductTableMap::PROMO . '=1 THEN ' . ProductTableMap::PRICE2 . ' ELSE ' . ProductTableMap::PRICE . ' END', 'real_price'); - /** * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. * @@ -181,12 +181,12 @@ class Product extends BaseLoop if ($new === true) { $usedAttributeNonStrictMatchList[] = 'new'; $search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN) - ->addJoinCondition('is_new', '`is_new`.NEWNESS = 1') + ->where('`is_new`.NEWNESS' . Criteria::EQUAL . '1') ->where('NOT ISNULL(`is_new`.ID)'); } else if($new === false) { $usedAttributeNonStrictMatchList[] = 'new'; $search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN) - ->addJoinCondition('is_new', '`is_new`.NEWNESS = 0') + ->where('`is_new`.NEWNESS' . Criteria::EQUAL . '0') ->where('NOT ISNULL(`is_new`.ID)'); } @@ -195,12 +195,12 @@ class Product extends BaseLoop if ($promo === true) { $usedAttributeNonStrictMatchList[] = 'promo'; $search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN) - ->addJoinCondition('is_promo', "`is_promo`.PROMO = 1") + ->where('`is_promo`.PROMO' . Criteria::EQUAL . '1') ->where('NOT ISNULL(`is_promo`.ID)'); } else if($promo === false) { $usedAttributeNonStrictMatchList[] = 'promo'; $search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN) - ->addJoinCondition('is_promo', "`is_promo`.PROMO = 0") + ->where('`is_promo`.PROMO' . Criteria::EQUAL . '0') ->where('NOT ISNULL(`is_promo`.ID)'); } @@ -209,7 +209,7 @@ class Product extends BaseLoop if (null != $min_stock) { $usedAttributeNonStrictMatchList[] = 'min_stock'; $search->joinProductSaleElements('is_min_stock', Criteria::LEFT_JOIN) - ->addJoinCondition('is_min_stock', "`is_min_stock`.QUANTITY > ?", $min_stock, null, \PDO::PARAM_INT) + ->where('`is_min_stock`.QUANTITY' . Criteria::GREATER_THAN . '?', $min_stock, \PDO::PARAM_INT) ->where('NOT ISNULL(`is_min_stock`.ID)'); } @@ -218,7 +218,7 @@ class Product extends BaseLoop if (null != $min_weight) { $usedAttributeNonStrictMatchList[] = 'min_weight'; $search->joinProductSaleElements('is_min_weight', Criteria::LEFT_JOIN) - ->addJoinCondition('is_min_weight', "`is_min_weight`.WEIGHT > ?", $min_weight, null, \PDO::PARAM_INT) + ->where('`is_min_weight`.WEIGHT' . Criteria::GREATER_THAN . '?', $min_weight, \PDO::PARAM_STR) ->where('NOT ISNULL(`is_min_weight`.ID)'); } @@ -227,17 +227,55 @@ class Product extends BaseLoop if (null != $max_weight) { $usedAttributeNonStrictMatchList[] = 'max_weight'; $search->joinProductSaleElements('is_max_weight', Criteria::LEFT_JOIN) - ->addJoinCondition('is_max_weight', "`is_max_weight`.WEIGHT < ?", $max_weight, null, \PDO::PARAM_INT) + ->where('`is_max_weight`.WEIGHT' . Criteria::LESS_THAN . '?', $max_weight, \PDO::PARAM_STR) ->where('NOT ISNULL(`is_max_weight`.ID)'); } + $min_price = $this->getMin_price(); + + if(null !== $min_price) { + + $minPriceJoin = new Join(); + $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'min_price_pse', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'is_min_price'); + $minPriceJoin->setJoinType(Criteria::LEFT_JOIN); + + $search->joinProductSaleElements('min_price_pse', Criteria::LEFT_JOIN) + ->addJoinObject($minPriceJoin) + ->condition('in_promo', '`min_price_pse`.promo'. Criteria::EQUAL .'1') + ->condition('not_in_promo', '`min_price_pse`.promo'. Criteria::NOT_EQUAL .'1') + ->condition('min_promo_price', '`is_min_price`.promo_price' . Criteria::GREATER_EQUAL . '?', $min_price, \PDO::PARAM_STR) + ->condition('min_price', '`is_min_price`.price' . Criteria::GREATER_EQUAL . '?', $min_price, \PDO::PARAM_STR) + ->combine(array('in_promo', 'min_promo_price'), Criteria::LOGICAL_AND, 'in_promo_min_price') + ->combine(array('not_in_promo', 'min_price'), Criteria::LOGICAL_AND, 'not_in_promo_min_price') + ->where(array('not_in_promo_min_price', 'in_promo_min_price'), Criteria::LOGICAL_OR); + } + + $max_price = $this->getMax_price(); + + if(null !== $max_price) { + + $minPriceJoin = new Join(); + $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'max_price_pse', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'is_max_price'); + $minPriceJoin->setJoinType(Criteria::LEFT_JOIN); + + $search->joinProductSaleElements('max_price_pse', Criteria::LEFT_JOIN) + ->addJoinObject($minPriceJoin) + ->condition('in_promo', '`max_price_pse`.promo'. Criteria::EQUAL .'1') + ->condition('not_in_promo', '`max_price_pse`.promo'. Criteria::NOT_EQUAL .'1') + ->condition('min_promo_price', '`is_max_price`.promo_price' . Criteria::LESS_EQUAL . '?', $max_price, \PDO::PARAM_STR) + ->condition('max_price', '`is_max_price`.price' . Criteria::LESS_EQUAL . '?', $max_price, \PDO::PARAM_STR) + ->combine(array('in_promo', 'min_promo_price'), Criteria::LOGICAL_AND, 'in_promo_max_price') + ->combine(array('not_in_promo', 'max_price'), Criteria::LOGICAL_AND, 'not_in_promo_max_price') + ->where(array('not_in_promo_max_price', 'in_promo_max_price'), Criteria::LOGICAL_OR); + } + if( $attributeNonStrictMatch != '*' ) { if($attributeNonStrictMatch == 'none') { $actuallyUsedAttributeNonStrictMatchList = $usedAttributeNonStrictMatchList; } else { $actuallyUsedAttributeNonStrictMatchList = array_values(array_intersect($usedAttributeNonStrictMatchList, $attributeNonStrictMatch)); } - + foreach($actuallyUsedAttributeNonStrictMatchList as $key => $actuallyUsedAttributeNonStrictMatch) { if($key == 0) continue; @@ -245,42 +283,6 @@ class Product extends BaseLoop } } - //$min_price = $this->getMin_price(); - - //if(null !== $min_price) { - /** - * Following should work but does not : - * - * $search->filterBy('real_price', $max_price, Criteria::GREATER_EQUAL); - */ - /*$search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1') - ->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1') - ->condition('min_price2', ProductTableMap::PRICE2 . Criteria::GREATER_EQUAL . '?', $min_price) - ->condition('min_price', ProductTableMap::PRICE . Criteria::GREATER_EQUAL . '?', $min_price) - ->combine(array('in_promo', 'min_price2'), Criteria::LOGICAL_AND, 'in_promo_min_price') - ->combine(array('not_in_promo', 'min_price'), Criteria::LOGICAL_AND, 'not_in_promo_min_price') - ->where(array('not_in_promo_min_price', 'in_promo_min_price'), Criteria::LOGICAL_OR); - } - - $max_price = $this->getMax_price();*/ - - //if(null !== $max_price) { - /** - * Following should work but does not : - * - * $search->filterBy('real_price', $max_price, Criteria::LESS_EQUAL); - */ - /*$search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1') - ->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1') - ->condition('max_price2', ProductTableMap::PRICE2 . Criteria::LESS_EQUAL . '?', $max_price) - ->condition('max_price', ProductTableMap::PRICE . Criteria::LESS_EQUAL . '?', $max_price) - ->combine(array('in_promo', 'max_price2'), Criteria::LOGICAL_AND, 'in_promo_max_price') - ->combine(array('not_in_promo', 'max_price'), Criteria::LOGICAL_AND, 'not_in_promo_max_price') - ->where(array('not_in_promo_max_price', 'in_promo_max_price'), Criteria::LOGICAL_OR); - }*/ - - /**/ - $current = $this->getCurrent(); if ($current === true) { diff --git a/templates/default/debug.html b/templates/default/debug.html index 19dea8c59..cc445f992 100644 --- a/templates/default/debug.html +++ b/templates/default/debug.html @@ -4,4 +4,12 @@ {*loop name="product" type="product" min_weight="1000" max_weight="6000" attribute_non_strict_match="*"}

            PRODUCT : #REF / #TITLE (#ID)

            -{/loop*} \ No newline at end of file +{/loop*} + +{*loop name="product" type="product" min_price="100" max_price="300" min_stock="4" min_weight="6000" max_weight="7000" attribute_non_strict_match="*" promo="on"} +

            PRODUCT : #REF / #TITLE (#ID)

            +{/loop*} + +{loop name="product" type="product" order="promo,min_price"} +

            PRODUCT : #REF / #TITLE (#ID)

            +{/loop} \ No newline at end of file From ef756979bddee886eabaa8aca55e07ed2191344c Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 20 Aug 2013 14:40:30 +0200 Subject: [PATCH 008/268] product loop : order by promo or newness --- .../lib/Thelia/Core/Template/Loop/Product.php | 64 +++++++++++++------ templates/default/debug.html | 4 ++ 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 8b0bd72fe..120461192 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -143,7 +143,7 @@ class Product extends BaseLoop ); $attributeNonStrictMatch = $this->getAttribute_non_strict_match(); - $usedAttributeNonStrictMatchList = array(); + $isPSELeftJoinList = array(); $id = $this->getId(); @@ -179,12 +179,12 @@ class Product extends BaseLoop $new = $this->getNew(); if ($new === true) { - $usedAttributeNonStrictMatchList[] = 'new'; + $isPSELeftJoinList[] = 'is_new'; $search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN) ->where('`is_new`.NEWNESS' . Criteria::EQUAL . '1') ->where('NOT ISNULL(`is_new`.ID)'); } else if($new === false) { - $usedAttributeNonStrictMatchList[] = 'new'; + $isPSELeftJoinList[] = 'is_new'; $search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN) ->where('`is_new`.NEWNESS' . Criteria::EQUAL . '0') ->where('NOT ISNULL(`is_new`.ID)'); @@ -193,12 +193,12 @@ class Product extends BaseLoop $promo = $this->getPromo(); if ($promo === true) { - $usedAttributeNonStrictMatchList[] = 'promo'; + $isPSELeftJoinList[] = 'is_promo'; $search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN) ->where('`is_promo`.PROMO' . Criteria::EQUAL . '1') ->where('NOT ISNULL(`is_promo`.ID)'); } else if($promo === false) { - $usedAttributeNonStrictMatchList[] = 'promo'; + $isPSELeftJoinList[] = 'is_promo'; $search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN) ->where('`is_promo`.PROMO' . Criteria::EQUAL . '0') ->where('NOT ISNULL(`is_promo`.ID)'); @@ -207,7 +207,7 @@ class Product extends BaseLoop $min_stock = $this->getMin_stock(); if (null != $min_stock) { - $usedAttributeNonStrictMatchList[] = 'min_stock'; + $isPSELeftJoinList[] = 'is_min_stock'; $search->joinProductSaleElements('is_min_stock', Criteria::LEFT_JOIN) ->where('`is_min_stock`.QUANTITY' . Criteria::GREATER_THAN . '?', $min_stock, \PDO::PARAM_INT) ->where('NOT ISNULL(`is_min_stock`.ID)'); @@ -216,7 +216,7 @@ class Product extends BaseLoop $min_weight = $this->getMin_weight(); if (null != $min_weight) { - $usedAttributeNonStrictMatchList[] = 'min_weight'; + $isPSELeftJoinList[] = 'is_min_weight'; $search->joinProductSaleElements('is_min_weight', Criteria::LEFT_JOIN) ->where('`is_min_weight`.WEIGHT' . Criteria::GREATER_THAN . '?', $min_weight, \PDO::PARAM_STR) ->where('NOT ISNULL(`is_min_weight`.ID)'); @@ -225,7 +225,7 @@ class Product extends BaseLoop $max_weight = $this->getMax_weight(); if (null != $max_weight) { - $usedAttributeNonStrictMatchList[] = 'max_weight'; + $isPSELeftJoinList[] = 'is_max_weight'; $search->joinProductSaleElements('is_max_weight', Criteria::LEFT_JOIN) ->where('`is_max_weight`.WEIGHT' . Criteria::LESS_THAN . '?', $max_weight, \PDO::PARAM_STR) ->where('NOT ISNULL(`is_max_weight`.ID)'); @@ -234,7 +234,7 @@ class Product extends BaseLoop $min_price = $this->getMin_price(); if(null !== $min_price) { - + $isPSELeftJoinList[] = 'is_min_price'; $minPriceJoin = new Join(); $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'min_price_pse', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'is_min_price'); $minPriceJoin->setJoinType(Criteria::LEFT_JOIN); @@ -253,7 +253,7 @@ class Product extends BaseLoop $max_price = $this->getMax_price(); if(null !== $max_price) { - + $isPSELeftJoinList[] = 'is_max_price'; $minPriceJoin = new Join(); $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'max_price_pse', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'is_max_price'); $minPriceJoin->setJoinType(Criteria::LEFT_JOIN); @@ -271,18 +271,40 @@ class Product extends BaseLoop if( $attributeNonStrictMatch != '*' ) { if($attributeNonStrictMatch == 'none') { - $actuallyUsedAttributeNonStrictMatchList = $usedAttributeNonStrictMatchList; + $actuallyUsedAttributeNonStrictMatchList = $isPSELeftJoinList; } else { - $actuallyUsedAttributeNonStrictMatchList = array_values(array_intersect($usedAttributeNonStrictMatchList, $attributeNonStrictMatch)); + $actuallyUsedAttributeNonStrictMatchList = array_values(array_intersect($isPSELeftJoinList, $attributeNonStrictMatch)); } foreach($actuallyUsedAttributeNonStrictMatchList as $key => $actuallyUsedAttributeNonStrictMatch) { if($key == 0) continue; - $search->where('`is_' . $actuallyUsedAttributeNonStrictMatch . '`.ID=' . '`is_' . $actuallyUsedAttributeNonStrictMatchList[$key-1] . '`.ID'); + $search->where('`' . $actuallyUsedAttributeNonStrictMatch . '`.ID=' . '`' . $actuallyUsedAttributeNonStrictMatchList[$key-1] . '`.ID'); } } + /* + * for ordering and outputs, the product will be : + * - new if at least one the criteria matching PSE is new + * - in promo if at least one the criteria matching PSE is in promo + */ + + if(count($isPSELeftJoinList) == 0) { + // + $isPSELeftJoinList[] = "global"; + $search->joinProductSaleElements('global', Criteria::LEFT_JOIN); + } + + $booleanMatchesPromoList = array(); + $booleanMatchesNewnessList = array(); + foreach($isPSELeftJoinList as $isPSELeftJoin) { + $booleanMatchesPromoList[] = '`' . $isPSELeftJoin . '`.PROMO'; + $booleanMatchesNewnessList[] = '`' . $isPSELeftJoin . '`.NEWNESS'; + } + $search->withColumn('MAX(' . implode(' OR ', $booleanMatchesPromoList) . ')', 'main_product_is_promo'); + $search->withColumn('MAX(' . implode(' OR ', $booleanMatchesNewnessList) . ')', 'main_product_is_new'); + + $current = $this->getCurrent(); if ($current === true) { @@ -404,12 +426,12 @@ class Product extends BaseLoop case "alpha_reverse": $search->addDescendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE); break; - /*case "min_price": - $search->orderBy('real_price', Criteria::ASC); + case "min_price": + $search->addAscendingOrderByColumn('real_price', Criteria::ASC); break; case "max_price": - $search->orderBy('real_price', Criteria::DESC); - break;*/ + $search->addDescendingOrderByColumn('real_price'); + break; case "manual": if(null === $category || count($category) != 1) throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); @@ -423,12 +445,12 @@ class Product extends BaseLoop case "ref": $search->orderByRef(Criteria::ASC); break; - /*case "promo": - $search->orderByPromo(Criteria::DESC); + case "promo": + $search->addDescendingOrderByColumn('main_product_is_promo'); break; case "new": - $search->orderByNewness(Criteria::DESC); - break;*/ + $search->addDescendingOrderByColumn('main_product_is_new'); + break; case "given_id": if(null === $id) throw new \InvalidArgumentException('Given_id order cannot be set without `id` argument'); diff --git a/templates/default/debug.html b/templates/default/debug.html index cc445f992..f023674ad 100644 --- a/templates/default/debug.html +++ b/templates/default/debug.html @@ -10,6 +10,10 @@

            PRODUCT : #REF / #TITLE (#ID)

            {/loop*} +{*loop name="product" type="product" promo="0" min_stock="4" order="promo,min_price"} +

            PRODUCT : #REF / #TITLE (#ID)

            +{/loop*} + {loop name="product" type="product" order="promo,min_price"}

            PRODUCT : #REF / #TITLE (#ID)

            {/loop} \ No newline at end of file From 9e3d8bcc5ec105621af1ebea7c75e7c16a9bb116 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 20 Aug 2013 15:22:34 +0200 Subject: [PATCH 009/268] product loop : order by min and max price --- .../lib/Thelia/Core/Template/Loop/Product.php | 74 +++++++++++++------ 1 file changed, 53 insertions(+), 21 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 120461192..3429ec208 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -109,6 +109,8 @@ class Product extends BaseLoop * ie : attribute_non_strict_match="promo,new" * loop will return the product if he has at least an attribute in promo and at least an attribute as new ; even if it's not the same attribute. * you can set all the attributes as non strict : attribute_non_strict_match="*" + * + * In order to allow such a process, we will have to make a LEFT JOIN foreach of the following case. */ new Argument( 'attribute_non_strict_match', @@ -144,6 +146,7 @@ class Product extends BaseLoop $attributeNonStrictMatch = $this->getAttribute_non_strict_match(); $isPSELeftJoinList = array(); + $isProductPriceLeftJoinList = array(); $id = $this->getId(); @@ -235,16 +238,17 @@ class Product extends BaseLoop if(null !== $min_price) { $isPSELeftJoinList[] = 'is_min_price'; + $isProductPriceLeftJoinList['is_min_price'] = 'min_price_data'; $minPriceJoin = new Join(); - $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'min_price_pse', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'is_min_price'); + $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_min_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'min_price_data'); $minPriceJoin->setJoinType(Criteria::LEFT_JOIN); - $search->joinProductSaleElements('min_price_pse', Criteria::LEFT_JOIN) + $search->joinProductSaleElements('is_min_price', Criteria::LEFT_JOIN) ->addJoinObject($minPriceJoin) - ->condition('in_promo', '`min_price_pse`.promo'. Criteria::EQUAL .'1') - ->condition('not_in_promo', '`min_price_pse`.promo'. Criteria::NOT_EQUAL .'1') - ->condition('min_promo_price', '`is_min_price`.promo_price' . Criteria::GREATER_EQUAL . '?', $min_price, \PDO::PARAM_STR) - ->condition('min_price', '`is_min_price`.price' . Criteria::GREATER_EQUAL . '?', $min_price, \PDO::PARAM_STR) + ->condition('in_promo', '`is_min_price`.promo'. Criteria::EQUAL .'1') + ->condition('not_in_promo', '`is_min_price`.promo'. Criteria::NOT_EQUAL .'1') + ->condition('min_promo_price', '`min_price_data`.promo_price' . Criteria::GREATER_EQUAL . '?', $min_price, \PDO::PARAM_STR) + ->condition('min_price', '`min_price_data`.price' . Criteria::GREATER_EQUAL . '?', $min_price, \PDO::PARAM_STR) ->combine(array('in_promo', 'min_promo_price'), Criteria::LOGICAL_AND, 'in_promo_min_price') ->combine(array('not_in_promo', 'min_price'), Criteria::LOGICAL_AND, 'not_in_promo_min_price') ->where(array('not_in_promo_min_price', 'in_promo_min_price'), Criteria::LOGICAL_OR); @@ -254,16 +258,17 @@ class Product extends BaseLoop if(null !== $max_price) { $isPSELeftJoinList[] = 'is_max_price'; + $isProductPriceLeftJoinList['is_max_price'] = 'max_price_data'; $minPriceJoin = new Join(); - $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'max_price_pse', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'is_max_price'); + $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_max_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'max_price_data'); $minPriceJoin->setJoinType(Criteria::LEFT_JOIN); - $search->joinProductSaleElements('max_price_pse', Criteria::LEFT_JOIN) + $search->joinProductSaleElements('is_max_price', Criteria::LEFT_JOIN) ->addJoinObject($minPriceJoin) - ->condition('in_promo', '`max_price_pse`.promo'. Criteria::EQUAL .'1') - ->condition('not_in_promo', '`max_price_pse`.promo'. Criteria::NOT_EQUAL .'1') - ->condition('min_promo_price', '`is_max_price`.promo_price' . Criteria::LESS_EQUAL . '?', $max_price, \PDO::PARAM_STR) - ->condition('max_price', '`is_max_price`.price' . Criteria::LESS_EQUAL . '?', $max_price, \PDO::PARAM_STR) + ->condition('in_promo', '`is_max_price`.promo'. Criteria::EQUAL .'1') + ->condition('not_in_promo', '`is_max_price`.promo'. Criteria::NOT_EQUAL .'1') + ->condition('min_promo_price', '`max_price_data`.promo_price' . Criteria::LESS_EQUAL . '?', $max_price, \PDO::PARAM_STR) + ->condition('max_price', '`max_price_data`.price' . Criteria::LESS_EQUAL . '?', $max_price, \PDO::PARAM_STR) ->combine(array('in_promo', 'min_promo_price'), Criteria::LOGICAL_AND, 'in_promo_max_price') ->combine(array('not_in_promo', 'max_price'), Criteria::LOGICAL_AND, 'not_in_promo_max_price') ->where(array('not_in_promo_max_price', 'in_promo_max_price'), Criteria::LOGICAL_OR); @@ -290,19 +295,46 @@ class Product extends BaseLoop */ if(count($isPSELeftJoinList) == 0) { - // $isPSELeftJoinList[] = "global"; $search->joinProductSaleElements('global', Criteria::LEFT_JOIN); + } if(count($isProductPriceLeftJoinList) == 0) { + $isProductPriceLeftJoinList['global'] = 'global_price_data'; + + $minPriceJoin = new Join(); + $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'global', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data'); + $minPriceJoin->setJoinType(Criteria::LEFT_JOIN); + + $search->addJoinObject($minPriceJoin); } - $booleanMatchesPromoList = array(); - $booleanMatchesNewnessList = array(); + /* + * we need to test all promo field from our previous conditions. Indeed ie: + * product P0, attributes color : red + * P0red is in promo and is the only attribute combinaton available. + * so the product might be consider as in promo (in outputs and ordering) + * We got the following loop to display in promo AND new product but we don't care it's the same attribute which is new and in promo : + * {loop type="product" promo="1" new="1" attribute_non_strict_match="promo,new"} {/loop} + * our request will so far returns 1 line + * + * is_promo.ID | is_promo.PROMO | is_promo.NEWNESS | is_new.ID | is_new.PROMO | is_new.NEWNESS + * NULL NULL NULL red_id 1 0 + * + * So that we can say the product is in global promo only with is_promo.PROMO, we must acknowledge it with (is_promo.PROMO OR is_new.PROMO) + */ + $booleanMatchedPromoList = array(); + $booleanMatchedNewnessList = array(); foreach($isPSELeftJoinList as $isPSELeftJoin) { - $booleanMatchesPromoList[] = '`' . $isPSELeftJoin . '`.PROMO'; - $booleanMatchesNewnessList[] = '`' . $isPSELeftJoin . '`.NEWNESS'; + $booleanMatchedPromoList[] = '`' . $isPSELeftJoin . '`.PROMO'; + $booleanMatchedNewnessList[] = '`' . $isPSELeftJoin . '`.NEWNESS'; } - $search->withColumn('MAX(' . implode(' OR ', $booleanMatchesPromoList) . ')', 'main_product_is_promo'); - $search->withColumn('MAX(' . implode(' OR ', $booleanMatchesNewnessList) . ')', 'main_product_is_new'); + $booleanMatchedPriceList = array(); + foreach($isProductPriceLeftJoinList as $pSE => $isProductPriceLeftJoin) { + $booleanMatchedPriceList[] = 'CASE WHEN `' . $pSE . '`.PROMO=1 THEN `' . $isProductPriceLeftJoin . '`.PROMO_PRICE ELSE `' . $isProductPriceLeftJoin . '`.PRICE END'; + } + $search->withColumn('MAX(' . implode(' OR ', $booleanMatchedPromoList) . ')', 'main_product_is_promo'); + $search->withColumn('MAX(' . implode(' OR ', $booleanMatchedNewnessList) . ')', 'main_product_is_new'); + $search->withColumn('MAX(' . implode(' OR ', $booleanMatchedPriceList) . ')', 'real_highest_price'); + $search->withColumn('MIN(' . implode(' OR ', $booleanMatchedPriceList) . ')', 'real_lowest_price'); $current = $this->getCurrent(); @@ -427,10 +459,10 @@ class Product extends BaseLoop $search->addDescendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE); break; case "min_price": - $search->addAscendingOrderByColumn('real_price', Criteria::ASC); + $search->addAscendingOrderByColumn('real_lowest_price', Criteria::ASC); break; case "max_price": - $search->addDescendingOrderByColumn('real_price'); + $search->addDescendingOrderByColumn('real_lowest_price'); break; case "manual": if(null === $category || count($category) != 1) From 731a406d1c419caa2bf0ca2e1841c6721dd8d22b Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 20 Aug 2013 15:32:13 +0200 Subject: [PATCH 010/268] new product loop --- core/lib/Thelia/Core/Template/Element/BaseLoop.php | 6 +++--- core/lib/Thelia/Core/Template/Loop/Product.php | 10 +++++----- templates/default/debug.html | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index bff6ea54d..ab1f119fa 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -191,8 +191,8 @@ abstract class BaseLoop } /** - * @param \ModelCriteria $search - * @param null $pagination + * @param ModelCriteria $search + * @param null $pagination * * @return array|mixed|\PropelModelPager|\PropelObjectCollection */ @@ -206,7 +206,7 @@ abstract class BaseLoop } /** - * @param \ModelCriteria $search + * @param ModelCriteria $search * * @return array|mixed|\PropelObjectCollection */ diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 3429ec208..76d628b56 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -53,6 +53,8 @@ use Thelia\Type\BooleanOrBothType; * Class Product * @package Thelia\Core\Template\Loop * @author Etienne Roudeix + * + * @todo : manage currency in price filter */ class Product extends BaseLoop { @@ -512,11 +514,9 @@ class Product extends BaseLoop ->set("CHAPO", $product->getChapo()) ->set("DESCRIPTION", $product->getDescription()) ->set("POSTSCRIPTUM", $product->getPostscriptum()) - //->set("PRICE", $product->getPrice()) - //->set("PROMO_PRICE", $product->getPrice2()) - //->set("WEIGHT", $product->getWeight()) - //->set("PROMO", $product->getPromo()) - //->set("NEW", $product->getNewness()) + ->set("BEST_PRICE", $product->getVirtualColumn('real_lowest_price')) + ->set("PROMO", $product->getVirtualColumn('main_product_is_promo')) + ->set("NEW", $product->getVirtualColumn('main_product_is_new')) ->set("POSITION", $product->getPosition()) ; diff --git a/templates/default/debug.html b/templates/default/debug.html index f023674ad..72bbc332b 100644 --- a/templates/default/debug.html +++ b/templates/default/debug.html @@ -15,5 +15,5 @@ {/loop*} {loop name="product" type="product" order="promo,min_price"} -

            PRODUCT : #REF / #TITLE (#ID)

            +

            PRODUCT : #REF / #TITLE (#ID) / NEW : #NEW / PROMO : #PROMO / best price : #BEST_PRICE

            {/loop} \ No newline at end of file From 6a14bef3de668375aa8834e97065d38b3523816a Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 20 Aug 2013 17:59:22 +0200 Subject: [PATCH 011/268] feature product loop + improve faker --- .../Core/Template/Loop/FeatureValue.php | 31 ++-- .../lib/Thelia/Core/Template/Loop/Product.php | 17 ++- install/faker.php | 140 ++++++++++++++---- templates/default/category.html | 22 ++- templates/default/debug.html | 6 +- 5 files changed, 154 insertions(+), 62 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php index 403baf37a..2d5689462 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php @@ -35,6 +35,7 @@ use Thelia\Log\Tlog; use Thelia\Model\Base\FeatureProductQuery; use Thelia\Model\ConfigQuery; +use Thelia\Model\FeatureAvQuery; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -108,31 +109,20 @@ class FeatureValue extends BaseLoop foreach($orders as $order) { switch ($order) { case "alpha": - $search->addAscendingOrderByColumn(\Thelia\Model\Map\FeatureI18nTableMap::TITLE); + //$search->addAscendingOrderByColumn(\Thelia\Model\Map\FeatureI18nTableMap::TITLE); break; case "alpha_reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\Map\FeatureI18nTableMap::TITLE); + //$search->addDescendingOrderByColumn(\Thelia\Model\Map\FeatureI18nTableMap::TITLE); break; case "manual": - $search->orderByPosition(Criteria::ASC); + //$search->orderByPosition(Criteria::ASC); break; case "manual_reverse": - $search->orderByPosition(Criteria::DESC); + //$search->orderByPosition(Criteria::DESC); break; } } - /** - * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - /*$search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - );*/ - $featureValues = $this->search($search, $pagination); $loopResult = new LoopResult(); @@ -140,10 +130,13 @@ class FeatureValue extends BaseLoop foreach ($featureValues as $featureValue) { $loopResultRow = new LoopResultRow(); $loopResultRow->set("ID", $featureValue->getId()); - /*$loopResultRow->set("TITLE",$featureValue->getTitle()); - $loopResultRow->set("CHAPO", $featureValue->getChapo()); - $loopResultRow->set("DESCRIPTION", $featureValue->getDescription()); - $loopResultRow->set("POSTSCRIPTUM", $featureValue->getPostscriptum());*/ + + $loopResultRow->set("PERSONAL_VALUE", $featureValue->getByDefault()); + + $loopResultRow->set("TITLE", $featureValue->getFeatureAv()->getTitle()); + $loopResultRow->set("CHAPO", $featureValue->getFeatureAv()->getChapo()); + $loopResultRow->set("DESCRIPTION", $featureValue->getFeatureAv()->getDescription()); + $loopResultRow->set("POSTSCRIPTUM", $featureValue->getFeatureAv()->getPostscriptum()); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 76d628b56..31a488f7e 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -296,14 +296,19 @@ class Product extends BaseLoop * - in promo if at least one the criteria matching PSE is in promo */ - if(count($isPSELeftJoinList) == 0) { - $isPSELeftJoinList[] = "global"; - $search->joinProductSaleElements('global', Criteria::LEFT_JOIN); - } if(count($isProductPriceLeftJoinList) == 0) { - $isProductPriceLeftJoinList['global'] = 'global_price_data'; + if(count($isProductPriceLeftJoinList) == 0) { + if(count($isPSELeftJoinList) == 0) { + $joiningTable = "global"; + $isPSELeftJoinList[] = $joiningTable; + $search->joinProductSaleElements('global', Criteria::LEFT_JOIN); + } else { + $joiningTable = $isPSELeftJoinList[0]; + } + + $isProductPriceLeftJoinList[$joiningTable] = 'global_price_data'; $minPriceJoin = new Join(); - $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'global', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data'); + $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', $joiningTable, ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data'); $minPriceJoin->setJoinType(Criteria::LEFT_JOIN); $search->addJoinObject($minPriceJoin); diff --git a/install/faker.php b/install/faker.php index d3d073994..9da307540 100755 --- a/install/faker.php +++ b/install/faker.php @@ -12,6 +12,22 @@ $currency = \Thelia\Model\CurrencyQuery::create()->filterByCode('EUR')->findOne( try { + $attributeCategory = Thelia\Model\AttributeCategoryQuery::create() + ->find(); + $attributeCategory->delete(); + + $featureCategory = Thelia\Model\FeatureCategoryQuery::create() + ->find(); + $featureCategory->delete(); + + $featureProduct = Thelia\Model\FeatureProductQuery::create() + ->find(); + $featureProduct->delete(); + + $attributeCombination = Thelia\Model\AttributeCombinationQuery::create() + ->find(); + $attributeCombination->delete(); + $feature = Thelia\Model\FeatureQuery::create() ->find(); $feature->delete(); @@ -91,7 +107,7 @@ try { $featureId = $feature->getId(); $featureList[$featureId] = array(); - for($j=0; $jsetFeature($feature); $featureAv->setPosition($j); @@ -137,12 +153,103 @@ try { $subcategory = createCategory($faker, $category->getId(), $j, $categoryIdList); for($k=0; $k $attributeAvId) { + $attributeCategory = new Thelia\Model\AttributeCategory(); + $attributeCategory->setCategoryId($categoryId) + ->setAttributeId($attributeId) + ->save(); + } + foreach($featureList as $featureId => $featureAvId) { + $featureCategory = new Thelia\Model\FeatureCategory(); + $featureCategory->setCategoryId($categoryId) + ->setFeatureId($featureId) + ->save(); + } + } + + foreach($productIdList as $productId) { + //add random accessories - or not + $alreadyPicked = array(); + for($i=1; $isetAccessory($productIdList[$pick]) + ->setProductId($productId) + ->setPosition($i) + ->save(); + } + + //associate PSE and stocks to products + for($i=0; $isetProductId($productId); + $stock->setQuantity($faker->randomNumber(1,50)); + $stock->setPromo($faker->randomNumber(0,1)); + $stock->setNewness($faker->randomNumber(0,1)); + $stock->setWeight($faker->randomFloat(2, 100,10000)); + $stock->save(); + + $productPrice = new \Thelia\Model\ProductPrice(); + $productPrice->setProductSaleElements($stock); + $productPrice->setCurrency($currency); + $productPrice->setPrice($faker->randomFloat(2, 20, 250)); + $productPrice->setPromoPrice($faker->randomFloat(2, 20, 250)); + $productPrice->save(); + + //associate attributes - or not - to PSE + + $alreadyPicked = array(); + for($i=0; $isetAttributeId($pick) + ->setAttributeAvId($attributeList[$pick][array_rand($attributeList[$pick], 1)]) + ->setProductSaleElements($stock) + ->save(); + } + } + + + foreach($attributeList as $attributeId => $attributeAvId) { + + } + + //associate features to products + foreach($featureList as $featureId => $featureAvId) { + $featureProduct = new Thelia\Model\FeatureProduct(); + $featureProduct->setProductId($productId) + ->setFeatureId($featureId); + + if(count($featureAvId) > 0) { //got some av + $featureProduct->setFeatureAvId( + $featureAvId[array_rand($featureAvId, 1)] + ); + } else { //no av + $featureProduct->setByDefault($faker->text(10)); + } + + $featureProduct->save(); } } @@ -186,7 +293,7 @@ try { $con->rollBack(); } -function createProduct($faker, $category, $position, $currency, &$productIdList) +function createProduct($faker, $category, $position, &$productIdList) { $product = new Thelia\Model\Product(); $product->setRef($category->getId() . '_' . $position . '_' . $faker->randomNumber(8)); @@ -200,31 +307,6 @@ function createProduct($faker, $category, $position, $currency, &$productIdList) $productId = $product->getId(); $productIdList[] = $productId; - $stock = new \Thelia\Model\ProductSaleElements(); - $stock->setProduct($product); - $stock->setQuantity($faker->randomNumber(1,50)); - $stock->setPromo($faker->randomNumber(0,1)); - $stock->setNewness($faker->randomNumber(0,1)); - $stock->setWeight($faker->randomFloat(2, 100,10000)); - $stock->save(); - - $productPrice = new \Thelia\Model\ProductPrice(); - $productPrice->setProductSaleElements($stock); - $productPrice->setCurrency($currency); - $productPrice->setPrice($faker->randomFloat(2, 20, 250)); - $productPrice->setPromoPrice($faker->randomFloat(2, 20, 250)); - $productPrice->save(); - - //add random accessories - or not - for($i=1; $isetAccessory($productIdList[array_rand($productIdList, 1)]); - $accessory->setProductId($productId); - $accessory->setPosition($i); - - $accessory->save(); - } - return $product; } diff --git a/templates/default/category.html b/templates/default/category.html index 6a671f78a..fd4651a93 100755 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -12,7 +12,7 @@

            PRODUCT : #REF (#LOOP_COUNT / #LOOP_TOTAL)

            #TITLE

            #DESCRIPTION

            - {*ifloop rel="acc"} + {ifloop rel="acc"}
            Accessories
              {loop name="acc" type="accessory" product="#ID" order="accessory"} @@ -22,12 +22,18 @@ {/ifloop} {elseloop rel="acc"}
              No accessory
              - {/elseloop*} + {/elseloop} {ifloop rel="ft"}
              Features
                + {assign var=current_product value=#ID} {loop name="ft" type="feature" order="manual" product="#ID"} -
              • #TITLE
              • +
              • + #TITLE : + {loop name="ft_v" type="feature_value" product="{$current_product}" feature="#ID"} + #TITLE / #PERSONAL_VALUE + {/loop} +
              • {/loop}
              {/ifloop} @@ -44,7 +50,7 @@

              PRODUCT : #REF (#LOOP_COUNT / #LOOP_TOTAL)

              #TITLE

              #DESCRIPTION

              - {*ifloop rel="acc"} + {ifloop rel="acc"}
              Accessories
                {loop name="acc" type="accessory" product="#ID" order="accessory"} @@ -54,7 +60,7 @@ {/ifloop} {elseloop rel="acc"}
                No accessory
                - {/elseloop*} + {/elseloop} {ifloop rel="ft"}
                Features
                  @@ -113,13 +119,15 @@
                  +

                  SANDBOX

                  + {*loop name="product" type="product" order="promo,min_price" exclude_category="3" new="on" promo="off"}

                  PRODUCT : #REF / #TITLE

                  {/loop*} -{loop name="product" type="product" new="on" promo="off"} +{*loop name="product" type="product" new="on" promo="off"}

                  PRODUCT : #REF / #TITLE

                  -{/loop} +{/loop*} diff --git a/templates/default/debug.html b/templates/default/debug.html index 72bbc332b..251a9b891 100644 --- a/templates/default/debug.html +++ b/templates/default/debug.html @@ -14,6 +14,10 @@

                  PRODUCT : #REF / #TITLE (#ID)

                  {/loop*} -{loop name="product" type="product" order="promo,min_price"} +{*loop name="product" type="product" order="promo,min_price"}

                  PRODUCT : #REF / #TITLE (#ID) / NEW : #NEW / PROMO : #PROMO / best price : #BEST_PRICE

                  +{/loop*} + +{loop name="product" type="product"} +

                  PRODUCT : #REF / #TITLE

                  {/loop} \ No newline at end of file From df08158cff14eb0900338784a7660e363a04c33e Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 20 Aug 2013 19:05:41 +0200 Subject: [PATCH 012/268] WIP Coupon Implementation Comparable Parameters --- .../Thelia/Coupon/CouponAdapterInterface.php | 7 + core/lib/Thelia/Coupon/CouponBaseAdapter.php | 21 ++ .../Comparable.php} | 28 +- .../lib/Thelia/Coupon/Parameter/DateParam.php | 95 +++++ .../Thelia/Coupon/Parameter/IntervalParam.php | 107 ++++++ .../Coupon/Parameter/RepeatedDateParam.php | 89 +++++ .../Parameter/RepeatedIntervalParam.php | 122 +++++++ .../Thelia/Coupon/Parameter/RepeatedParam.php | 236 +++++++++++++ .../Coupon/Rule/AvailableForXArticles.php | 77 +++++ .../Thelia/Coupon/Rule/CouponRuleAbstract.php | 18 + .../Tests/Coupon/Parameter/DateParamTest.php | 96 +++++ .../Coupon/Parameter/IntervalParamTest.php | 121 +++++++ .../Parameter/RepeatedDateParamTest.php | 238 +++++++++++++ .../Parameter/RepeatedIntervalParamTest.php | 327 ++++++++++++++++++ .../Rule/AvailableForNbArticlesTest.php | 26 -- .../Coupon/Rule/AvailableForXArticlesTest.php | 211 +++++++++++ 16 files changed, 1784 insertions(+), 35 deletions(-) rename core/lib/Thelia/Coupon/{Rule/AvailableForNbArticles.php => Parameter/Comparable.php} (70%) create mode 100644 core/lib/Thelia/Coupon/Parameter/DateParam.php create mode 100644 core/lib/Thelia/Coupon/Parameter/IntervalParam.php create mode 100644 core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php create mode 100644 core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php create mode 100644 core/lib/Thelia/Coupon/Parameter/RepeatedParam.php create mode 100644 core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php create mode 100644 core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php delete mode 100644 core/lib/Thelia/Tests/Coupon/Rule/AvailableForNbArticlesTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php diff --git a/core/lib/Thelia/Coupon/CouponAdapterInterface.php b/core/lib/Thelia/Coupon/CouponAdapterInterface.php index f36c13427..06e3a3ca7 100644 --- a/core/lib/Thelia/Coupon/CouponAdapterInterface.php +++ b/core/lib/Thelia/Coupon/CouponAdapterInterface.php @@ -79,4 +79,11 @@ interface CouponAdapterInterface */ public function getCheckoutPostagePrice(); + /** + * Return the number of Products in the Cart + * + * @return int + */ + public function getNbArticlesInTheCart(); + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponBaseAdapter.php b/core/lib/Thelia/Coupon/CouponBaseAdapter.php index bb24306e2..6908b3317 100644 --- a/core/lib/Thelia/Coupon/CouponBaseAdapter.php +++ b/core/lib/Thelia/Coupon/CouponBaseAdapter.php @@ -84,4 +84,25 @@ class CouponBaseAdapter implements CouponAdapterInterface // TODO: Implement getCheckoutPostagePrice() method. } + /** + * Return Products total price + * + * @return float + */ + public function getCheckoutTotalPriceWithoutDiscountAndPostagePrice() + { + // TODO: Implement getCheckoutTotalPriceWithoutDiscountAndPostagePrice() method. + } + + /** + * Return the number of Products in the Cart + * + * @return int + */ + public function getNbArticlesInTheCart() + { + // TODO: Implement getNbArticlesInTheCart() method. + } + + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForNbArticles.php b/core/lib/Thelia/Coupon/Parameter/Comparable.php similarity index 70% rename from core/lib/Thelia/Coupon/Rule/AvailableForNbArticles.php rename to core/lib/Thelia/Coupon/Parameter/Comparable.php index 78bbb0e00..37a7faeab 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForNbArticles.php +++ b/core/lib/Thelia/Coupon/Parameter/Comparable.php @@ -21,18 +21,28 @@ /* */ /*************************************************************************************/ -namespace Thelia\Coupon\Rule; +namespace Thelia\Coupon\Parameter; /** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * @package Coupon - * @author Guillaume MOREL + * Comparable interface that allows to compare two value objects to each other for similarity. * + * @author Benjamin Eberlei + * @author Guilherme Blanco */ -class AvailableForNbArticles extends CouponRuleAbstract +interface Comparable { - + /** + * Compare the current object to the passed $other. + * + * Returns 0 if they are semantically equal, 1 if the other object + * is less than the current one, or -1 if its more than the current one. + * + * This method should not check for identity using ===, only for semantical equality for example + * when two different DateTime instances point to the exact same Date + TZ. + * + * @param mixed $other Object + * + * @return int + */ + public function compareTo($other); } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/DateParam.php b/core/lib/Thelia/Coupon/Parameter/DateParam.php new file mode 100644 index 000000000..29dab530d --- /dev/null +++ b/core/lib/Thelia/Coupon/Parameter/DateParam.php @@ -0,0 +1,95 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Parameter; + +use Thelia\Coupon\Parameter\Comparable; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Represent a DateTime + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class DateParam implements Comparable +{ + /** @var \DateTime Date */ + protected $dateTime = null; + + /** + * Constructor + * + * @param \DateTime $dateTime DateTime + */ + public function __construct(\DateTime $dateTime) + { + $this->dateTime = $dateTime; + } + + /** + * Get DateTime + * + * @return \DateTime + */ + public function getDateTime() + { + return clone $this->dateTime; + } + + /** + * Compare the current object to the passed $other. + * + * Returns 0 if they are semantically equal, 1 if the other object + * is less than the current one, or -1 if its more than the current one. + * + * This method should not check for identity using ===, only for semantical equality for example + * when two different DateTime instances point to the exact same Date + TZ. + * + * @param mixed $other Object + * + * @return int + */ + public function compareTo($other) + { + if (!$other instanceof \DateTime) { + throw new \InvalidArgumentException('DateParam can compare only DateTime'); + } + + $ret = -1; + if ($this->dateTime == $other) { + $ret = 0; + } elseif ($this->dateTime > $other) { + $ret = 1; + } else { + $ret = -1; + } + + return $ret; + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/IntervalParam.php b/core/lib/Thelia/Coupon/Parameter/IntervalParam.php new file mode 100644 index 000000000..656cf69ca --- /dev/null +++ b/core/lib/Thelia/Coupon/Parameter/IntervalParam.php @@ -0,0 +1,107 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Parameter; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Represent an DateTime period + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class IntervalParam implements Comparable +{ + /** @var \DatePeriod Date period */ + protected $datePeriod = null; + + /** + * Constructor + * + * @param \DateTime $start Start interval + * @param \DateInterval $interval Period + */ + public function __construct(\DateTime $start, \DateInterval $interval) + { + $this->datePeriod = new \DatePeriod($start, $interval, 1); + } + + /** + * Get DatePeriod + * + * @return \DatePeriod + */ + public function getDatePeriod() + { + return clone $this->datePeriod; + } + + /** + * Compare the current object to the passed $other. + * + * Returns 0 if they are semantically equal, 1 if the other object + * is less than the current one, or -1 if its more than the current one. + * + * This method should not check for identity using ===, only for semantical equality for example + * when two different DateTime instances point to the exact same Date + TZ. + * + * @param mixed $other Object + * + * @return int + */ + public function compareTo($other) + { + if (!$other instanceof \DateTime) { + throw new \InvalidArgumentException('IntervalParam can compare only DateTime'); + } + + /** @var \DateTime Start Date */ + $startDate = null; + /** @var \DateTime End Date */ + $endDate = null; + + foreach ($this->datePeriod as $key => $value) { + if ($key == 0) { + $startDate = $value; + } + if ($key == 1) { + $endDate = $value; + } + } + + $ret = -1; + if ($startDate <= $other && $other <= $endDate) { + $ret = 0; + } elseif ($startDate > $other) { + $ret = 1; + } else { + $ret = -1; + } + + return $ret; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php b/core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php new file mode 100644 index 000000000..150f632b8 --- /dev/null +++ b/core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php @@ -0,0 +1,89 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Parameter; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Represent A repeated Date across the time + * Ex : + * A date repeated every 1 months 5 times + * ---------*---*---*---*---*---*---------------------------> time + * 1 2 3 4 5 6 + * 1 : $this->from Start date of the repetition + * *--- : $this->interval Duration of a whole cycle + * x6 : $this->recurrences How many cycle + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class RepeatedDateParam extends RepeatedParam +{ + /** + * Constructor + */ + public function __construct() + { + $this->defaultConstructor(); + } + + /** + * Compare the current object to the passed $other. + * + * Returns 0 if they are semantically equal, 1 if the other object + * is less than the current one, or -1 if its more than the current one. + * + * This method should not check for identity using ===, only for semantical equality for example + * when two different DateTime instances point to the exact same Date + TZ. + * + * @param mixed $other Object + * + * @throws \InvalidArgumentException + * @return int + */ + public function compareTo($other) + { + if (!$other instanceof \DateTime) { + throw new \InvalidArgumentException('RepeatedDateParam can compare only DateTime'); + } + + $ret = -1; + $dates = array(); + /** @var $value \DateTime */ + foreach ($this->datePeriod as $value) { + $dates[$value->getTimestamp()] = $value; + } + + foreach ($dates as $date) { + if ($date == $other) { + return 0; + } + } + + return $ret; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php b/core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php new file mode 100644 index 000000000..4bbbd8569 --- /dev/null +++ b/core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php @@ -0,0 +1,122 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Parameter; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Represent A repeated DateInterval across the time + * Ex : + * A duration of 1 month repeated every 2 months 5 times + * ---------****----****----****----****----****----****-----------------> time + * 1 2 3 4 5 6 + * 1 : $this->from Start date of the repetition + * ****---- : $this->interval Duration of a whole cycle + * x6 : $this->recurrences How many cycle + * **** : $this->durationInDays Duration of a period + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class RepeatedIntervalParam extends RepeatedParam +{ + + /** @var int duration of the param */ + protected $durationInDays = 1; + + /** + * Get how many day a Param is lasting + * + * @return int + */ + public function getDurationInDays() + { + return $this->durationInDays; + } + + /** + * Set how many day a Param is lasting + * + * @param int $durationInDays How many day a Param is lasting + * + * @return $this + */ + public function setDurationInDays($durationInDays = 1) + { + $this->durationInDays = $durationInDays; + + return $this; + } + + /** + * Constructor + */ + public function __construct() + { + $this->defaultConstructor(); + } + + /** + * Compare the current object to the passed $other. + * + * Returns 0 if they are semantically equal, 1 if the other object + * is less than the current one, or -1 if its more than the current one. + * + * This method should not check for identity using ===, only for semantical equality for example + * when two different DateTime instances point to the exact same Date + TZ. + * + * @param mixed $other Object + * + * @return int + */ + public function compareTo($other) + { + if (!$other instanceof \DateTime) { + throw new \InvalidArgumentException('RepeatedIntervalParam can compare only DateTime'); + } + + $ret = -1; + $dates = array(); + /** @var $value \DateTime */ + foreach ($this->datePeriod as $value) { + $dates[$value->getTimestamp()]['startDate'] = $value; + $endDate = new \DateTime(); + $dates[$value->getTimestamp()]['endDate'] = $endDate->setTimestamp( + $value->getTimestamp() + ($this->durationInDays * 60 *60 *24) + ); + } + + foreach ($dates as $date) { + if ($date['startDate'] <= $other && $other <= $date['endDate']) { + return 0; + } + } + + return $ret; + + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/RepeatedParam.php b/core/lib/Thelia/Coupon/Parameter/RepeatedParam.php new file mode 100644 index 000000000..ed5dcbf03 --- /dev/null +++ b/core/lib/Thelia/Coupon/Parameter/RepeatedParam.php @@ -0,0 +1,236 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Parameter; + +use DateInterval; +use DatePeriod; +use DateTime; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Allow to set the way a parameter can be repeated across the time + * + * @package Coupon + * @author Guillaume MOREL + * + */ +abstract class RepeatedParam implements Comparable +{ + /** @var DateTime The start date of the period. */ + protected $from = null; + + /** @var DateInterval The interval between recurrences within the period. */ + protected $interval = null; + + /** @var int The number of recurrences. */ + protected $recurrences = null; + + /** @var DatePeriod dates recurring at regular intervals, over a given period */ + protected $datePeriod = null; + + /** + * Generate default repetition + * Every 1 week 100 times from now + * + * @return $this + */ + protected function defaultConstructor() + { + $this->from = new \DateTime(); + $this->interval = new \DateInterval('P1W'); // 1 week + $this->recurrences = 100; + $this->generateDatePeriod(); + + return $this; + } + + /** + * Generate DatePeriod from class attributes + * Will repeat every DatePeriod + * + * @return $this + */ + protected function generateDatePeriod() + { + $this->datePeriod = new DatePeriod( + $this->from, + $this->interval, + $this->recurrences + ); + + return $this; + } + + /** + * Set the Object to be repeated every days + * Ex : $obj->repeatEveryDay() will be repeated every days indefinitely + * $obj->repeatEveryDay(10) will be repeated every 10 days indefinitely + * $obj->repeatEveryDay(10, 4) will be repeated every 10 days only 4 times + * + * @param int $frequency Frequency the object will be repeated + * @param int $nbRepetition Time the object will be repeated (0 = infinite) + * + * @return $this + */ + public function repeatEveryDay($frequency = 1, $nbRepetition = 0) + { + $this->_repeatEveryPeriod($period = 'D', $frequency, $nbRepetition); + + return $this; + } + + /** + * Set the Object to be repeated every week + * Ex : $obj->repeatEveryWeek() will be repeated every week indefinitely + * $obj->repeatEveryWeek(10) will be repeated every 10 weeks (70days) indefinitely + * $obj->repeatEveryWeek(10, 4) will be repeated every 10 weeks (70days) only 4 times + * + * @param int $frequency Frequency the object will be repeated + * @param int $nbRepetition Time the object will be repeated (0 = infinite) + * + * @return $this + */ + public function repeatEveryWeek($frequency = 1, $nbRepetition = null) + { + $this->_repeatEveryPeriod($period = 'W', $frequency, $nbRepetition); + + return $this; + } + + /** + * Set the Object to be repeated every month + * Ex : $obj->repeatEveryWeek() will be repeated every month indefinitely + * $obj->repeatEveryWeek(10) will be repeated every 10 month (70days) indefinitely + * $obj->repeatEveryWeek(10, 4) will be repeated every 10 month (70days) only 4 times + * + * @param int $frequency Frequency the object will be repeated + * @param int $nbRepetition Time the object will be repeated (0 = infinite) + * + * @return $this + */ + public function repeatEveryMonth($frequency = 1, $nbRepetition = null) + { + $this->_repeatEveryPeriod($period = 'M', $frequency, $nbRepetition); + + return $this; + } + + /** + * Set the Object to be repeated every year + * Ex : $obj->repeatEveryWeek() will be repeated every year indefinitely + * $obj->repeatEveryWeek(10) will be repeated every 10 year indefinitely + * $obj->repeatEveryWeek(10, 4) will be repeated every 10 year only 4 times + * + * @param int $frequency Frequency the object will be repeated + * @param int $nbRepetition Time the object will be repeated + * + * @return $this + */ + public function repeatEveryYear($frequency = 1, $nbRepetition = null) + { + $this->_repeatEveryPeriod($period = 'Y', $frequency, $nbRepetition); + + return $this; + } + + /** + * Set the Object to be repeated every Period + * Ex : $obj->repeatEveryPeriod('D') will be repeated every day once + * $obj->repeatEveryPeriod('W', 10) will be repeated every 10 week once + * $obj->repeatEveryPeriod('M', 10, 4) will be repeated every 10 month only 4 times + * + * @param string $period Period Y|M||D|W + * @param int $frequency Frequency the object will be repeated + * @param int $nbRepetition Time the object will be repeated + * + * @return $this + */ + private function _repeatEveryPeriod($period, $frequency = 1, $nbRepetition = null) + { + if (is_numeric($frequency) && $frequency > 0) { + $this->interval = new \DateInterval('P' . $frequency . $period); + } + + if (is_numeric($nbRepetition) && $nbRepetition > 0) { + $this->recurrences = $nbRepetition; + } + + $this->generateDatePeriod(); + + return $this; + } + + + + /** + * Set Start time + * + * @param \DateTime $from Start time + * + * @return $this + */ + public function setFrom($from) + { + $this->from = $from; + + return $this; + } + + /** + * Get Start time + * + * @return \DateTime + */ + public function getFrom() + { + return clone $this->from; + } + + /** + * Set DatePeriod + * + * @param DatePeriod $datePeriod DatePeriod + * + * @return $this + */ + public function setDatePeriod(DatePeriod $datePeriod) + { + $this->datePeriod = $datePeriod; + + return $this; + } + + /** + * Get date DatePeriod + * + * @return DatePeriod + */ + public function getDatePeriod() + { + return clone $this->datePeriod; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php b/core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php new file mode 100644 index 000000000..1fac12f94 --- /dev/null +++ b/core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php @@ -0,0 +1,77 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Coupon\Rule; + +use Thelia\Type\IntType; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Check a Checkout against its Product number + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class AvailableForXArticles extends CouponRuleAbstract +{ + /** + * @inheritdoc + */ + public function checkBackOfficeIntput() + { + $ret = false; + $validator = new IntType(); + $firstParam = reset($this->validators); + if ($firstParam) { + $ret = $validator->isValid($firstParam); + } + + return $ret; + } + + public function checkCheckoutInput() + { + $ret = false; + $validator = new IntType(); + $firstParam = reset($this->validated); + if ($firstParam) { + $ret = $validator->isValid($firstParam); + } + + return $ret; + } + + public function isMatching() + { + if ($this->checkBackOfficeIntput() && $this->checkCheckoutInput()) { + $firstValidatorsParam = reset($this->validators); + $firstValidatedParam = reset($this->validated); +// if($firstValidatedParam >= $firstValidatedParam) + } + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php b/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php index 1c30f0321..4a01494ae 100644 --- a/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php +++ b/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php @@ -36,6 +36,24 @@ namespace Thelia\Coupon\Rule; */ class CouponRuleAbstract implements CuponRuleInterface { + /** @var array Parameters validating $validated against */ + protected $validators = array(); + + /** @var array Parameters to be validated */ + protected $validated = array(); + + /** + * Constructor + * + * @param array $validators Parameters validating $validated against + * @param array $validated Parameters to be validated + */ + public function __construct(array $validators, array $validated) + { + $this->validators = $validators; + $this->validated = $validated; + } + /** * Check if backoffice inputs are relevant or not * diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php new file mode 100644 index 000000000..7ba6610df --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php @@ -0,0 +1,96 @@ +compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\DateParam::compareTo + * + */ + public function testEquelsDate() + { + $dateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2012-07-08"); + + $dateParam = new DateParam($dateValidator); + + $expected = 0; + $actual = $dateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\DateParam::compareTo + * + */ + public function testSuperiorDate() + { + $dateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2012-07-09"); + + $dateParam = new DateParam($dateValidator); + + $expected = -1; + $actual = $dateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\Parameter\DateParam::compareTo + * @expectedException InvalidArgumentException + */ + public function testInvalidArgumentException() + { + $dateValidator = new \DateTime("2012-07-08"); + $dateToValidate = 1377012588; + + $dateParam = new DateParam($dateValidator); + + $dateParam->compareTo($dateToValidate); + } + + + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + +} diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php new file mode 100644 index 000000000..0c1018af5 --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php @@ -0,0 +1,121 @@ +compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\IntervalParam::compareTo + * + */ + public function testEqualsDate() + { + $dateValidatorStart = new \DateTime("2012-07-08"); + $dateValidatorInterval = new \DateInterval("P1M"); //1month + $dateToValidate = new \DateTime("2012-07-08"); + + echo '1 ' . date_format($dateValidatorStart, 'g:ia \o\n l jS F Y') . "\n"; + echo '2 ' . date_format($dateToValidate, 'g:ia \o\n l jS F Y') . "\n"; + + $dateParam = new IntervalParam($dateValidatorStart, $dateValidatorInterval); + + $expected = 0; + $actual = $dateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\IntervalParam::compareTo + * + */ + public function testEqualsDate2() + { + $dateValidatorStart = new \DateTime("2012-07-08"); + $dateValidatorInterval = new \DateInterval("P1M"); //1month + $dateToValidate = new \DateTime("2012-08-08"); + + $dateParam = new IntervalParam($dateValidatorStart, $dateValidatorInterval); + + $expected = 0; + $actual = $dateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\IntervalParam::compareTo + * + */ + public function testSuperiorDate() + { + $dateValidatorStart = new \DateTime("2012-07-08"); + $dateValidatorInterval = new \DateInterval("P1M"); //1month + $dateToValidate = new \DateTime("2012-08-09"); + + $dateParam = new IntervalParam($dateValidatorStart, $dateValidatorInterval); + + $expected = -1; + $actual = $dateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\Parameter\DateParam::compareTo + * @expectedException InvalidArgumentException + */ + public function testInvalidArgumentException() + { + $dateValidatorStart = new \DateTime("2012-07-08"); + $dateValidatorInterval = new \DateInterval("P1M"); //1month + $dateToValidate = 1377012588; + + $dateParam = new IntervalParam($dateValidatorStart, $dateValidatorInterval); + + $dateParam->compareTo($dateToValidate); + } + + + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + +} diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php new file mode 100644 index 000000000..5d5f1badc --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php @@ -0,0 +1,238 @@ +setFrom($startDateValidator); + $repeatedDateParam->repeatEveryMonth(); + + $expected = -1; + $actual = $repeatedDateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo + * + */ + public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriod() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2012-07-08"); + + $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam->setFrom($startDateValidator); + $repeatedDateParam->repeatEveryMonth(); + + $expected = 0; + $actual = $repeatedDateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo + * + */ + public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriod() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2012-08-08"); + + $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam->setFrom($startDateValidator); + $repeatedDateParam->repeatEveryMonth(); + + $expected = 0; + $actual = $repeatedDateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo + * + */ + public function testEqualsDateRepeatEveryMonthTenTimesThirdPeriod() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2012-09-08"); + + $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam->setFrom($startDateValidator); + $repeatedDateParam->repeatEveryMonth(1, 10); + + $expected = 0; + $actual = $repeatedDateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo + * + */ + public function testEqualsDateRepeatEveryMonthTenTimesTensPeriod() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2013-05-08"); + + $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam->setFrom($startDateValidator); + $repeatedDateParam->repeatEveryMonth(1, 10); + + $expected = 0; + $actual = $repeatedDateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo + * + */ + public function testEqualsDateRepeatEveryFourMonthTwoTimesSecondPeriod() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2012-11-08"); + + $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam->setFrom($startDateValidator); + $repeatedDateParam->repeatEveryMonth(4, 2); + + $expected = 0; + $actual = $repeatedDateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo + * + */ + public function testEqualsDateRepeatEveryFourMonthTwoTimesLastPeriod() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2013-03-08"); + + $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam->setFrom($startDateValidator); + $repeatedDateParam->repeatEveryMonth(4, 2); + + $expected = 0; + $actual = $repeatedDateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo + * + */ + public function testNotEqualsDateRepeatEveryFourMonthTwoTimes1() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2012-08-08"); + + $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam->setFrom($startDateValidator); + $repeatedDateParam->repeatEveryMonth(4, 2); + + $expected = -1; + $actual = $repeatedDateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo + * + */ + public function testNotEqualsDateRepeatEveryFourMonthTwoTimes2() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2012-12-08"); + + $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam->setFrom($startDateValidator); + $repeatedDateParam->repeatEveryMonth(4, 2); + + $expected = -1; + $actual = $repeatedDateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo + * + */ + public function testSuperiorDateRepeatEveryFourMonthTwoTimes() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2013-03-09"); + + $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam->setFrom($startDateValidator); + $repeatedDateParam->repeatEveryMonth(4, 2); + + $expected = -1; + $actual = $repeatedDateParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\Parameter\DateParam::compareTo + * @expectedException InvalidArgumentException + */ + public function testInvalidArgumentException() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = 1377012588; + + $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam->setFrom($startDateValidator); + $repeatedDateParam->repeatEveryMonth(4, 2); + + $repeatedDateParam->compareTo($dateToValidate); + } + + + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + +} diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php new file mode 100644 index 000000000..0783bac3e --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php @@ -0,0 +1,327 @@ +setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + + $RepeatedIntervalParam->repeatEveryMonth(); + + $expected = -1; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo + * + */ + public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriodBegining() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2012-07-08"); + $duration = 10; + + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(); + + $expected = 0; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo + * + */ + public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriodMiddle() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2012-07-13"); + $duration = 10; + + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(); + + $expected = 0; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo + * + */ + public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriodEnding() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = new \DateTime("2012-07-18"); + $duration = 10; + + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(); + + $expected = 0; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo + * + */ + public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriodBegining() + { + $startDateValidator = new \DateTime("2012-08-08"); + $dateToValidate = new \DateTime("2012-08-08"); + $duration = 10; + + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(); + + $expected = 0; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo + * + */ + public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriodMiddle() + { + $startDateValidator = new \DateTime("2012-08-08"); + $dateToValidate = new \DateTime("2012-08-13"); + $duration = 10; + + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(); + + $expected = 0; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo + * + */ + public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriodEnding() + { + $startDateValidator = new \DateTime("2012-08-08"); + $dateToValidate = new \DateTime("2012-08-18"); + $duration = 10; + + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(); + + $expected = 0; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo + * + */ + public function testEqualsDateRepeatEveryMonthFourTimeLastPeriodBegining() + { + $startDateValidator = new \DateTime("2012-10-08"); + $dateToValidate = new \DateTime("2012-10-08"); + $duration = 10; + + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(1, 4); + + $expected = 0; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo + * + */ + public function testEqualsDateRepeatEveryMonthFourTimeLastPeriodMiddle() + { + $startDateValidator = new \DateTime("2012-10-08"); + $dateToValidate = new \DateTime("2012-10-13"); + $duration = 10; + + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(1, 4); + + $expected = 0; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo + * + */ + public function testEqualsDateRepeatEveryMonthFourTimeLastPeriodEnding() + { + $startDateValidator = new \DateTime("2012-10-08"); + $dateToValidate = new \DateTime("2012-10-18"); + $duration = 10; + + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(1, 4); + + $expected = 0; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo + * + */ + public function testNotEqualsDateRepeatEveryMonthFourTimeInTheBegining() + { + $startDateValidator = new \DateTime("2012-10-08"); + $dateToValidate = new \DateTime("2012-07-19"); + $duration = 10; + + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(1, 4); + + $expected = -1; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo + * + */ + public function testNotEqualsDateRepeatEveryMonthFourTimeInTheMiddle() + { + $startDateValidator = new \DateTime("2012-10-08"); + $dateToValidate = new \DateTime("2012-08-01"); + $duration = 10; + + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(1, 4); + + $expected = -1; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo + * + */ + public function testNotEqualsDateRepeatEveryMonthFourTimeInTheEnd() + { + $startDateValidator = new \DateTime("2012-10-08"); + $dateToValidate = new \DateTime("2012-08-07"); + $duration = 10; + + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(1, 4); + + $expected = -1; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + + + /** + * + * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo + * + */ + public function testSuperiorDateRepeatEveryMonthFourTime() + { + $startDateValidator = new \DateTime("2012-10-08"); + $dateToValidate = new \DateTime("2012-10-19"); + $duration = 10; + + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(1, 4); + + $expected = -1; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + +} diff --git a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForNbArticlesTest.php b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForNbArticlesTest.php deleted file mode 100644 index ed8a57833..000000000 --- a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForNbArticlesTest.php +++ /dev/null @@ -1,26 +0,0 @@ -getMock( + 'CouponBaseAdapter', + array('getNbArticlesInTheCart'), + array() + ); + $stubTheliaAdapater->expects($this->any()) + ->method('getNbArticlesInTheCart') + ->will($this->returnValue(4)); + + return $stubTheliaAdapater; + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeIntput + * + */ + public function testValidBackOfficeInput() + { + /** @var CouponAdapterInterface $stubTheliaAdapater */ + $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + + $validators = array(4); + $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $rule = new AvailableForXArticles($validators, $validated); + + $expected = true; + $actual = $rule->checkBackOfficeIntput(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeIntput + * + */ + public function testInValidBackOfficeInput() + { + /** @var CouponAdapterInterface $stubTheliaAdapater */ + $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + + $validators = array(4.5); + $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $rule = new AvailableForXArticles($validators, $validated); + + $expected = false; + $actual = $rule->checkBackOfficeIntput(); + $this->assertEquals($expected, $actual); + + $validators = array(-1); + $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $rule = new AvailableForXArticles($validators, $validated); + + $expected = false; + $actual = $rule->checkBackOfficeIntput(); + $this->assertEquals($expected, $actual); + + $validators = array('bad'); + $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $rule = new AvailableForXArticles($validators, $validated); + + $expected = false; + $actual = $rule->checkBackOfficeIntput(); + $this->assertEquals($expected, $actual); + } + + + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkCheckoutInput + * + */ + public function testValidCheckoutInput() + { + /** @var CouponAdapterInterface $stubTheliaAdapater */ + $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + + $validators = array(4); + $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $rule = new AvailableForXArticles($validators, $validated); + + $expected = true; + $actual = $rule->checkCheckoutInput(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkCheckoutInput + * + */ + public function testInValidCheckoutInput() + { + /** @var CouponAdapterInterface $stubTheliaAdapater */ + $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + + $validators = array(4.5); + $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $rule = new AvailableForXArticles($validators, $validated); + + $expected = false; + $actual = $rule->checkCheckoutInput(); + $this->assertEquals($expected, $actual); + + $validators = array(-1); + $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $rule = new AvailableForXArticles($validators, $validated); + + $expected = false; + $actual = $rule->checkCheckoutInput(); + $this->assertEquals($expected, $actual); + + $validators = array('bad'); + $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $rule = new AvailableForXArticles($validators, $validated); + + $expected = false; + $actual = $rule->checkCheckoutInput(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::isMatching + * + */ + public function testMatchingRuleEqual() + { + /** @var CouponAdapterInterface $stubTheliaAdapater */ + $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + + $validators = array(4); + $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $rule = new AvailableForXArticles($validators, $validated); + + $expected = true; + $actual = $rule->isMatching(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::isMatching + * + */ + public function testMatchingRuleSuperior() + { + /** @var CouponAdapterInterface $stubTheliaAdapater */ + $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + + $validators = array(5); + $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $rule = new AvailableForXArticles($validators, $validated); + + $expected = true; + $actual = $rule->isMatching(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::isMatching + * + */ + public function testNotMatchingRule() + { + /** @var CouponAdapterInterface $stubTheliaAdapater */ + $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + + $validators = array(3); + $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $rule = new AvailableForXArticles($validators, $validated); + + $expected = false; + $actual = $rule->isMatching(); + $this->assertEquals($expected, $actual); + } + + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + +} From 8cc09824a8df6799e32ab043568cff8b68214543 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 21 Aug 2013 09:28:50 +0200 Subject: [PATCH 013/268] feature value loop fix --- core/lib/Thelia/Core/Template/Loop/FeatureValue.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php index 2d5689462..6e5d05057 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php @@ -133,10 +133,12 @@ class FeatureValue extends BaseLoop $loopResultRow->set("PERSONAL_VALUE", $featureValue->getByDefault()); - $loopResultRow->set("TITLE", $featureValue->getFeatureAv()->getTitle()); - $loopResultRow->set("CHAPO", $featureValue->getFeatureAv()->getChapo()); - $loopResultRow->set("DESCRIPTION", $featureValue->getFeatureAv()->getDescription()); - $loopResultRow->set("POSTSCRIPTUM", $featureValue->getFeatureAv()->getPostscriptum()); + $featureAvailability = $featureValue->getFeatureAv(); + + $loopResultRow->set("TITLE", ($featureAvailability === null ? '' : $featureAvailability->getTitle())); + $loopResultRow->set("CHAPO", ($featureAvailability === null ? '' : $featureAvailability->getChapo())); + $loopResultRow->set("DESCRIPTION", ($featureAvailability === null ? '' : $featureAvailability->getDescription())); + $loopResultRow->set("POSTSCRIPTUM", ($featureAvailability === null ? '' : $featureAvailability->getPostscriptum())); $loopResult->addRow($loopResultRow); } From 3d0c7d67734d27d62f8ef009ba80641335096a5a Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 21 Aug 2013 09:33:43 +0200 Subject: [PATCH 014/268] loop tests --- .../Loop/AttributeAvailabilityTest.php | 51 +++++++++++++++++++ ...ureAvailableTest.php => AttributeTest.php} | 8 +-- .../Template/Loop/FeatureAvailabilityTest.php | 51 +++++++++++++++++++ 3 files changed, 106 insertions(+), 4 deletions(-) create mode 100755 core/lib/Thelia/Tests/Core/Template/Loop/AttributeAvailabilityTest.php rename core/lib/Thelia/Tests/Core/Template/Loop/{FeatureAvailableTest.php => AttributeTest.php} (89%) create mode 100755 core/lib/Thelia/Tests/Core/Template/Loop/FeatureAvailabilityTest.php diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/AttributeAvailabilityTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/AttributeAvailabilityTest.php new file mode 100755 index 000000000..c870f32ef --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/AttributeAvailabilityTest.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\AttributeAvailability; + +/** + * + * @author Etienne Roudeix + * + */ +class AttributeAvailabilityTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\AttributeAvailability'; + } + + public function getTestedInstance() + { + return new AttributeAvailability($this->request, $this->dispatcher, $this->securityContext); + } + + public function getMandatoryArguments() + { + return array(); + } +} diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/FeatureAvailableTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/AttributeTest.php similarity index 89% rename from core/lib/Thelia/Tests/Core/Template/Loop/FeatureAvailableTest.php rename to core/lib/Thelia/Tests/Core/Template/Loop/AttributeTest.php index e93b05a69..653de34e9 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/FeatureAvailableTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/AttributeTest.php @@ -25,23 +25,23 @@ namespace Thelia\Tests\Core\Template\Loop; use Thelia\Tests\Core\Template\Element\BaseLoopTestor; -use Thelia\Core\Template\Loop\FeatureAvailable; +use Thelia\Core\Template\Loop\Attribute; /** * * @author Etienne Roudeix * */ -class FeatureAvailableTest extends BaseLoopTestor +class AttributeTest extends BaseLoopTestor { public function getTestedClassName() { - return 'Thelia\Core\Template\Loop\FeatureAvailable'; + return 'Thelia\Core\Template\Loop\Attribute'; } public function getTestedInstance() { - return new FeatureAvailable($this->request, $this->dispatcher, $this->securityContext); + return new Attribute($this->request, $this->dispatcher, $this->securityContext); } public function getMandatoryArguments() diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/FeatureAvailabilityTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/FeatureAvailabilityTest.php new file mode 100755 index 000000000..d3a045f33 --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/FeatureAvailabilityTest.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\FeatureAvailability; + +/** + * + * @author Etienne Roudeix + * + */ +class FeatureAvailabilityTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\FeatureAvailability'; + } + + public function getTestedInstance() + { + return new FeatureAvailability($this->request, $this->dispatcher, $this->securityContext); + } + + public function getMandatoryArguments() + { + return array(); + } +} From 9dbd8a283b5150052a8788078346f89ccca93bd0 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 21 Aug 2013 12:50:49 +0200 Subject: [PATCH 015/268] pse and combi loops --- core/lib/Thelia/Config/Resources/config.xml | 3 +- .../Template/Loop/AttributeCombination.php | 125 ++++++ .../Core/Template/Loop/FeatureValue.php | 15 +- .../lib/Thelia/Core/Template/Loop/Product.php | 14 +- .../Core/Template/Loop/ProductSaleElement.php | 368 +++--------------- .../Loop/AttributeCombinationTest.php | 51 +++ .../Template/Loop/ProductSaleElementTest.php | 51 +++ templates/default/category.html | 33 +- 8 files changed, 324 insertions(+), 336 deletions(-) create mode 100755 core/lib/Thelia/Core/Template/Loop/AttributeCombination.php create mode 100755 core/lib/Thelia/Tests/Core/Template/Loop/AttributeCombinationTest.php create mode 100755 core/lib/Thelia/Tests/Core/Template/Loop/ProductSaleElementTest.php diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 24d36e0ee..eb07b7b1b 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -9,6 +9,7 @@ + @@ -22,7 +23,7 @@ - + diff --git a/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php b/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php new file mode 100755 index 000000000..f0b54c4f3 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php @@ -0,0 +1,125 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Join; +use Thelia\Core\Template\Element\BaseLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Log\Tlog; + +use Thelia\Model\Base\AttributeCombinationQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; + +/** + * + * Attribute Combination loop + * + * Class AttributeCombination + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class AttributeCombination extends BaseLoop +{ + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntTypeArgument('product_sale_element', null, true), + new Argument( + 'order', + new TypeCollection( + new Type\EnumListType(array('attribute_availability', 'attribute_availability_reverse', 'attribute', 'attribute_reverse')) + ), + 'attribute' + ) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = AttributeCombinationQuery::create(); + + $productSaleElement = $this->getProduct_sale_element(); + + $search->filterByProductSaleElementsId($productSaleElement, Criteria::EQUAL); + + $orders = $this->getOrder(); + + foreach($orders as $order) { + switch ($order) { + case "attribute_availability": + //$search->addAscendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE); + break; + case "attribute_availability_reverse": + //$search->addDescendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE); + break; + case "attribute": + //$search->orderByPosition(Criteria::ASC); + break; + case "attribute_reverse": + //$search->orderByPosition(Criteria::DESC); + break; + } + } + + $attributeCombinations = $this->search($search, $pagination); + + $loopResult = new LoopResult(); + + foreach ($attributeCombinations as $attributeCombination) { + $loopResultRow = new LoopResultRow(); + + $attribute = $attributeCombination->getAttribute(); + $attributeAvailability = $attributeCombination->getAttributeAv(); + + $loopResultRow + ->set("ATTRIBUTE_TITLE", $attribute->getTitle()) + ->set("ATTRIBUTE_CHAPO", $attribute->getChapo()) + ->set("ATTRIBUTE_DESCRIPTION", $attribute->getDescription()) + ->set("ATTRIBUTE_POSTSCRIPTUM", $attribute->getPostscriptum()) + ->set("ATTRIBUTE_AVAILABILITY_TITLE", $attributeAvailability->getTitle()) + ->set("ATTRIBUTE_AVAILABILITY_CHAPO", $attributeAvailability->getChapo()) + ->set("ATTRIBUTE_AVAILABILITY_DESCRIPTION", $attributeAvailability->getDescription()) + ->set("ATTRIBUTE_AVAILABILITY_POSTSCRIPTUM", $attributeAvailability->getPostscriptum()); + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php index 6e5d05057..80ae1e75b 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php @@ -35,7 +35,6 @@ use Thelia\Log\Tlog; use Thelia\Model\Base\FeatureProductQuery; use Thelia\Model\ConfigQuery; -use Thelia\Model\FeatureAvQuery; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -58,8 +57,8 @@ class FeatureValue extends BaseLoop return new ArgumentCollection( Argument::createIntTypeArgument('feature', null, true), Argument::createIntTypeArgument('product', null, true), - Argument::createIntListTypeArgument('feature_available'), - Argument::createBooleanTypeArgument('exclude_feature_available', 0), + Argument::createIntListTypeArgument('feature_availability'), + Argument::createBooleanTypeArgument('exclude_feature_availability', 0), Argument::createBooleanTypeArgument('exclude_default_values', 0), new Argument( 'order', @@ -88,14 +87,14 @@ class FeatureValue extends BaseLoop $search->filterByProductId($product, Criteria::EQUAL); - $featureAvailable = $this->getFeature_available(); + $featureAvailability = $this->getFeature_availability(); - if (null !== $featureAvailable) { - $search->filterByFeatureAvId($featureAvailable, Criteria::IN); + if (null !== $featureAvailability) { + $search->filterByFeatureAvId($featureAvailability, Criteria::IN); } - $excludeFeatureAvailable = $this->getExclude_feature_available(); - if($excludeFeatureAvailable == true) { + $excludeFeatureAvailability = $this->getExclude_feature_availability(); + if($excludeFeatureAvailability == true) { $search->filterByFeatureAvId(null, Criteria::NULL); } diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 31a488f7e..74eda3a00 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -93,7 +93,7 @@ class Product extends BaseLoop Argument::createIntListTypeArgument('exclude'), Argument::createIntListTypeArgument('exclude_category'), new Argument( - 'feature_available', + 'feature_availability', new TypeCollection( new Type\IntToCombinedIntsListType() ) @@ -317,7 +317,7 @@ class Product extends BaseLoop /* * we need to test all promo field from our previous conditions. Indeed ie: * product P0, attributes color : red - * P0red is in promo and is the only attribute combinaton available. + * P0red is in promo and is the only attribute combinaton availability. * so the product might be consider as in promo (in outputs and ordering) * We got the following loop to display in promo AND new product but we don't care it's the same attribute which is new and in promo : * {loop type="product" promo="1" new="1" attribute_non_strict_match="promo,new"} {/loop} @@ -397,10 +397,10 @@ class Product extends BaseLoop ); } - $feature_available = $this->getFeature_available(); + $feature_availability = $this->getFeature_availability(); - if(null !== $feature_available) { - foreach($feature_available as $feature => $feature_choice) { + if(null !== $feature_availability) { + foreach($feature_availability as $feature => $feature_choice) { foreach($feature_choice['values'] as $feature_av) { $featureAlias = 'fa_' . $feature; if($feature_av != '*') @@ -520,8 +520,8 @@ class Product extends BaseLoop ->set("DESCRIPTION", $product->getDescription()) ->set("POSTSCRIPTUM", $product->getPostscriptum()) ->set("BEST_PRICE", $product->getVirtualColumn('real_lowest_price')) - ->set("PROMO", $product->getVirtualColumn('main_product_is_promo')) - ->set("NEW", $product->getVirtualColumn('main_product_is_new')) + ->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo')) + ->set("IS_NEW", $product->getVirtualColumn('main_product_is_new')) ->set("POSITION", $product->getPosition()) ; diff --git a/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php b/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php index 8d892a446..36b234c33 100755 --- a/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php +++ b/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php @@ -33,29 +33,22 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; -use Thelia\Model\Base\FeatureProductQuery; -use Thelia\Model\CategoryQuery; -use Thelia\Model\FeatureAvQuery; -use Thelia\Model\FeatureQuery; -use Thelia\Model\Map\FeatureProductTableMap; -use Thelia\Model\Map\ProductTableMap; -use Thelia\Model\ProductCategoryQuery; -use Thelia\Model\ProductQuery; +use Thelia\Model\Base\ProductSaleElementsQuery; use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; use Thelia\Type; -use Thelia\Type\BooleanOrBothType; /** * - * Product loop + * Product Sale Elements loop * + * @todo : manage currency * - * Class Product + * Class ProductSaleElements * @package Thelia\Core\Template\Loop * @author Etienne Roudeix */ -class Product extends BaseLoop +class ProductSaleElements extends BaseLoop { /** * @return ArgumentCollection @@ -63,45 +56,20 @@ class Product extends BaseLoop protected function getArgDefinitions() { return new ArgumentCollection( - Argument::createIntListTypeArgument('id'), + Argument::createIntTypeArgument('devise'), + Argument::createIntTypeArgument('product', null, true), new Argument( - 'ref', - new TypeCollection( - new Type\AlphaNumStringListType() - ) - ), - Argument::createIntListTypeArgument('category'), - //Argument::createBooleanTypeArgument('new'), - //Argument::createBooleanTypeArgument('promo'), - //Argument::createFloatTypeArgument('min_price'), - //Argument::createFloatTypeArgument('max_price'), - //Argument::createIntTypeArgument('min_stock'), - //Argument::createFloatTypeArgument('min_weight'), - //Argument::createFloatTypeArgument('max_weight'), - Argument::createBooleanTypeArgument('current'), - Argument::createBooleanTypeArgument('current_category'), - Argument::createIntTypeArgument('depth', 1), - Argument::createBooleanOrBothTypeArgument('visible', 1), - new Argument( - 'order', - new TypeCollection( - new Type\EnumListType(array('alpha', 'alpha_reverse', /*'min_price', 'max_price',*/ 'manual', 'manual_reverse', 'ref', /*'promo', 'new',*/ 'random', 'given_id')) - ), - 'alpha' - ), - Argument::createIntListTypeArgument('exclude'), - Argument::createIntListTypeArgument('exclude_category'), - new Argument( - 'feature_available', + 'attribute_availability', new TypeCollection( new Type\IntToCombinedIntsListType() ) ), new Argument( - 'feature_values', + 'order', new TypeCollection( - new Type\IntToCombinedStringsListType() - ) + new Type\EnumListType(array('alpha', 'alpha_reverse', 'attribute', 'attribute_reverse')) + ), + 'attribute' ) ); } @@ -110,311 +78,73 @@ class Product extends BaseLoop * @param $pagination * * @return \Thelia\Core\Template\Element\LoopResult - * @throws \InvalidArgumentException */ public function exec(&$pagination) { - $search = ProductQuery::create(); + $search = ProductSaleElementsQuery::create(); - //$search->withColumn('CASE WHEN ' . ProductTableMap::PROMO . '=1 THEN ' . ProductTableMap::PRICE2 . ' ELSE ' . ProductTableMap::PRICE . ' END', 'real_price'); + $product = $this->getProduct(); - $id = $this->getId(); - - if (!is_null($id)) { - $search->filterById($id, Criteria::IN); - } - - $ref = $this->getRef(); - - if (!is_null($ref)) { - $search->filterByRef($ref, Criteria::IN); - } - - $category = $this->getCategory(); - - if (!is_null($category)) { - $categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find(); - - $depth = $this->getDepth(); - - if(null !== $depth) { - foreach(CategoryQuery::findAllChild($category, $depth) as $subCategory) { - $categories->prepend($subCategory); - } - } - - $search->filterByCategory( - $categories, - Criteria::IN - ); - } - - /*$new = $this->getNew(); - - if ($new === true) { - $search->filterByNewness(1, Criteria::EQUAL); - } else if($new === false) { - $search->filterByNewness(0, Criteria::EQUAL); - } - - $promo = $this->getPromo(); - - if ($promo === true) { - $search->filterByPromo(1, Criteria::EQUAL); - } else if($promo === false) { - $search->filterByNewness(0, Criteria::EQUAL); - } - - $min_stock = $this->getMin_stock(); - - if (null != $min_stock) { - $search->filterByQuantity($min_stock, Criteria::GREATER_EQUAL); - } - - $min_price = $this->getMin_price();*/ - - //if(null !== $min_price) { - /** - * Following should work but does not : - * - * $search->filterBy('real_price', $max_price, Criteria::GREATER_EQUAL); - */ - /*$search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1') - ->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1') - ->condition('min_price2', ProductTableMap::PRICE2 . Criteria::GREATER_EQUAL . '?', $min_price) - ->condition('min_price', ProductTableMap::PRICE . Criteria::GREATER_EQUAL . '?', $min_price) - ->combine(array('in_promo', 'min_price2'), Criteria::LOGICAL_AND, 'in_promo_min_price') - ->combine(array('not_in_promo', 'min_price'), Criteria::LOGICAL_AND, 'not_in_promo_min_price') - ->where(array('not_in_promo_min_price', 'in_promo_min_price'), Criteria::LOGICAL_OR); - } - - $max_price = $this->getMax_price();*/ - - //if(null !== $max_price) { - /** - * Following should work but does not : - * - * $search->filterBy('real_price', $max_price, Criteria::LESS_EQUAL); - */ - /*$search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1') - ->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1') - ->condition('max_price2', ProductTableMap::PRICE2 . Criteria::LESS_EQUAL . '?', $max_price) - ->condition('max_price', ProductTableMap::PRICE . Criteria::LESS_EQUAL . '?', $max_price) - ->combine(array('in_promo', 'max_price2'), Criteria::LOGICAL_AND, 'in_promo_max_price') - ->combine(array('not_in_promo', 'max_price'), Criteria::LOGICAL_AND, 'not_in_promo_max_price') - ->where(array('not_in_promo_max_price', 'in_promo_max_price'), Criteria::LOGICAL_OR); - }*/ - - /*$min_weight = $this->getMin_weight(); - - if(null !== $min_weight) { - $search->filterByWeight($min_weight, Criteria::GREATER_EQUAL); - } - - $max_weight = $this->getMax_weight(); - - if(null !== $max_weight) { - $search->filterByWeight($max_weight, Criteria::LESS_EQUAL); - }*/ - - $current = $this->getCurrent(); - - if ($current === true) { - $search->filterById($this->request->get("product_id")); - } elseif($current === false) { - $search->filterById($this->request->get("product_id"), Criteria::NOT_IN); - } - - $current_category = $this->getCurrent_category(); - - if ($current_category === true) { - $search->filterByCategory( - CategoryQuery::create()->filterByProduct( - ProductCategoryQuery::create()->filterByProductId( - $this->request->get("product_id"), - Criteria::EQUAL - )->find(), - Criteria::IN - )->find(), - Criteria::IN - ); - } elseif($current_category === false) { - $search->filterByCategory( - CategoryQuery::create()->filterByProduct( - ProductCategoryQuery::create()->filterByProductId( - $this->request->get("product_id"), - Criteria::EQUAL - )->find(), - Criteria::IN - )->find(), - Criteria::NOT_IN - ); - } - - $visible = $this->getVisible(); - - if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0); + $search->filterByProductId($product, Criteria::EQUAL); $orders = $this->getOrder(); foreach($orders as $order) { switch ($order) { case "alpha": - $search->addAscendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE); + //$search->addAscendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE); break; case "alpha_reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE); + //$search->addDescendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE); break; - /*case "min_price": - $search->orderBy('real_price', Criteria::ASC); + case "attribute": + //$search->orderByPosition(Criteria::ASC); break; - case "max_price": - $search->orderBy('real_price', Criteria::DESC); - break;*/ - case "manual": - if(null === $category || count($category) != 1) - throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); - $search->orderByPosition(Criteria::ASC); + case "attribute_reverse": + //$search->orderByPosition(Criteria::DESC); break; - case "manual_reverse": - if(null === $category || count($category) != 1) - throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); - $search->orderByPosition(Criteria::DESC); - break; - case "ref": - $search->orderByRef(Criteria::ASC); - break; - /*case "promo": - $search->orderByPromo(Criteria::DESC); - break; - case "new": - $search->orderByNewness(Criteria::DESC); - break;*/ - case "given_id": - if(null === $id) - throw new \InvalidArgumentException('Given_id order cannot be set without `id` argument'); - foreach($id as $singleId) { - $givenIdMatched = 'given_id_matched_' . $singleId; - $search->withColumn(ProductTableMap::ID . "='$singleId'", $givenIdMatched); - $search->orderBy($givenIdMatched, Criteria::DESC); - } - break; - case "random": - $search->clearOrderByColumns(); - $search->addAscendingOrderByColumn('RAND()'); - break(2); } } - $exclude = $this->getExclude(); + $devise = $this->getDevise(); - if (!is_null($exclude)) { - $search->filterById($exclude, Criteria::NOT_IN); - } + $search->joinProductPrice('price', Criteria::INNER_JOIN); + //->addJoinCondition('price', ''); - $exclude_category = $this->getExclude_category(); + $search->withColumn('`price`.CURRENCY_ID', 'price_CURRENCY_ID') + ->withColumn('`price`.PRICE', 'price_PRICE') + ->withColumn('`price`.PROMO_PRICE', 'price_PROMO_PRICE'); - if (!is_null($exclude_category)) { - $search->filterByCategory( - CategoryQuery::create()->filterById($exclude_category, Criteria::IN)->find(), - Criteria::NOT_IN - ); - } - - $feature_available = $this->getFeature_available(); - - if(null !== $feature_available) { - foreach($feature_available as $feature => $feature_choice) { - foreach($feature_choice['values'] as $feature_av) { - $featureAlias = 'fa_' . $feature; - if($feature_av != '*') - $featureAlias .= '_' . $feature_av; - $search->joinFeatureProduct($featureAlias, Criteria::LEFT_JOIN) - ->addJoinCondition($featureAlias, "`$featureAlias`.FEATURE_ID = ?", $feature, null, \PDO::PARAM_INT); - if($feature_av != '*') - $search->addJoinCondition($featureAlias, "`$featureAlias`.FEATURE_AV_ID = ?", $feature_av, null, \PDO::PARAM_INT); - } - - /* format for mysql */ - $sqlWhereString = $feature_choice['expression']; - if($sqlWhereString == '*') { - $sqlWhereString = 'NOT ISNULL(`fa_' . $feature . '`.ID)'; - } else { - $sqlWhereString = preg_replace('#([0-9]+)#', 'NOT ISNULL(`fa_' . $feature . '_' . '\1`.ID)', $sqlWhereString); - $sqlWhereString = str_replace('&', ' AND ', $sqlWhereString); - $sqlWhereString = str_replace('|', ' OR ', $sqlWhereString); - } - - $search->where("(" . $sqlWhereString . ")"); - } - } - - $feature_values = $this->getFeature_values(); - - if(null !== $feature_values) { - foreach($feature_values as $feature => $feature_choice) { - foreach($feature_choice['values'] as $feature_value) { - $featureAlias = 'fv_' . $feature; - if($feature_value != '*') - $featureAlias .= '_' . $feature_value; - $search->joinFeatureProduct($featureAlias, Criteria::LEFT_JOIN) - ->addJoinCondition($featureAlias, "`$featureAlias`.FEATURE_ID = ?", $feature, null, \PDO::PARAM_INT); - if($feature_value != '*') - $search->addJoinCondition($featureAlias, "`$featureAlias`.BY_DEFAULT = ?", $feature_value, null, \PDO::PARAM_STR); - } - - /* format for mysql */ - $sqlWhereString = $feature_choice['expression']; - if($sqlWhereString == '*') { - $sqlWhereString = 'NOT ISNULL(`fv_' . $feature . '`.ID)'; - } else { - $sqlWhereString = preg_replace('#([a-zA-Z0-9_\-]+)#', 'NOT ISNULL(`fv_' . $feature . '_' . '\1`.ID)', $sqlWhereString); - $sqlWhereString = str_replace('&', ' AND ', $sqlWhereString); - $sqlWhereString = str_replace('|', ' OR ', $sqlWhereString); - } - - $search->where("(" . $sqlWhereString . ")"); - } - } - - /** - * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - $search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - ); - - $search->groupBy(ProductTableMap::ID); - - $products = $this->search($search, $pagination); + $PSEValues = $this->search($search, $pagination); $loopResult = new LoopResult(); - foreach ($products as $product) { + foreach ($PSEValues as $PSEValue) { $loopResultRow = new LoopResultRow(); - $loopResultRow->set("ID", $product->getId()) - ->set("REF",$product->getRef()) - ->set("TITLE",$product->getTitle()) - ->set("CHAPO", $product->getChapo()) - ->set("DESCRIPTION", $product->getDescription()) - ->set("POSTSCRIPTUM", $product->getPostscriptum()) - //->set("PRICE", $product->getPrice()) - //->set("PROMO_PRICE", $product->getPrice2()) - //->set("WEIGHT", $product->getWeight()) - //->set("PROMO", $product->getPromo()) - //->set("NEW", $product->getNewness()) - ->set("POSITION", $product->getPosition()) - ; + $loopResultRow->set("ID", $PSEValue->getId()) + ->set("QUANTITY", $PSEValue->getQuantity()) + ->set("IS_PROMO", $PSEValue->getPromo() === 1 ? 1 : 0) + ->set("IS_NEW", $PSEValue->getNewness() === 1 ? 1 : 0) + ->set("WEIGHT", $PSEValue->getWeight()) + + ->set("CURRENCY", $PSEValue->getVirtualColumn('price_CURRENCY_ID')) + ->set("PRICE", $PSEValue->getVirtualColumn('price_PRICE')) + ->set("PROMO_PRICE", $PSEValue->getVirtualColumn('price_PROMO_PRICE')); + + //$price = $PSEValue->getAttributeAv(); + + /* + $attributeAvailability = $PSEValue->getAttributeAv(); + + $loopResultRow->set("TITLE", ($attributeAvailability === null ? '' : $attributeAvailability->getTitle())); + $loopResultRow->set("CHAPO", ($attributeAvailability === null ? '' : $attributeAvailability->getChapo())); + $loopResultRow->set("DESCRIPTION", ($attributeAvailability === null ? '' : $attributeAvailability->getDescription())); + $loopResultRow->set("POSTSCRIPTUM", ($attributeAvailability === null ? '' : $attributeAvailability->getPostscriptum()));*/ $loopResult->addRow($loopResultRow); } return $loopResult; } - -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/AttributeCombinationTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/AttributeCombinationTest.php new file mode 100755 index 000000000..208899bab --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/AttributeCombinationTest.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\AttributeCombination; + +/** + * + * @author Etienne Roudeix + * + */ +class AttributeCombinationTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\AttributeCombination'; + } + + public function getTestedInstance() + { + return new AttributeCombination($this->request, $this->dispatcher, $this->securityContext); + } + + public function getMandatoryArguments() + { + return array('product_sale_element' => 1); + } +} diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/ProductSaleElementTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/ProductSaleElementTest.php new file mode 100755 index 000000000..612519e04 --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ProductSaleElementTest.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\ProductSaleElements; + +/** + * + * @author Etienne Roudeix + * + */ +class ProductSaleElementsTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\ProductSaleElements'; + } + + public function getTestedInstance() + { + return new ProductSaleElements($this->request, $this->dispatcher, $this->securityContext); + } + + public function getMandatoryArguments() + { + return array('product' => 1); + } +} diff --git a/templates/default/category.html b/templates/default/category.html index fd4651a93..2f14976f9 100755 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -40,6 +40,32 @@ {elseloop rel="ft"}
                  No feature
                  {/elseloop} + {ifloop rel="pse"} +
                  Product sale elements
                  + + {assign var=current_product value=#ID} + {loop name="pse" type="product_sale_elements" product="#ID"} +
                  + {loop name="combi" type="attribute_combination" product_sale_element="#ID"} + #ATTRIBUTE_TITLE = #ATTRIBUTE_AVAILABILITY_TITLE
                  + {/loop} +
                  #WEIGHT g +
                  {if #IS_PROMO == 1} #PROMO_PRICE € (instead of #PRICE) {else} #PRICE € {/if} +

                  + Add + + to my cart +
                +
            + {/loop} + {/ifloop} + {elseloop rel="ft"} +
            No feature
            + {/elseloop}
  • {/loop} {loop name="catgory1" type="category" parent="#ID"} @@ -65,7 +91,12 @@
    Features
      {loop name="ft" type="feature" order="manual" product="#ID"} -
    • #TITLE
    • +
    • + #TITLE : + {loop name="ft_v" type="feature_value" product="{$current_product}" feature="#ID"} + #TITLE / #PERSONAL_VALUE + {/loop} +
    • {/loop}
    {/ifloop} From 2e6cbe637a808105f3c0a028064508863663bf88 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 21 Aug 2013 16:32:48 +0200 Subject: [PATCH 016/268] working on loop translation --- .../Thelia/Core/Template/Loop/Category.php | 39 ++++-- .../Core/Template/Loop/FeatureValue.php | 8 +- install/faker.php | 112 ++++++++++++------ 3 files changed, 113 insertions(+), 46 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index d856b6d73..b0f9e2862 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -156,10 +156,32 @@ class Category extends BaseLoop * @todo : verify here if we want results for row without translations. */ - $search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - ); + if(ConfigQuery::read("default_lang_without_translation", 1) == 0) { + /* + * don't use the following to be able to use the same getter than below + * $search->joinWithI18n( $this->request->getSession()->getLocale(), Criteria::INNER_JOIN ); + */ + $search->joinCategoryI18n('asked_locale_i18n', Criteria::INNER_JOIN) + ->addJoinCondition('asked_locale_i18n' ,'`asked_locale_i18n`.LOCALE = ?', 'en_EN', null, \PDO::PARAM_STR); + + $search->withColumn('`asked_locale_i18n`.TITLE', 'i18n_TITLE'); + $search->withColumn('`asked_locale_i18n`.CHAPO', 'i18n_CHAPO'); + $search->withColumn('`asked_locale_i18n`.DESCRIPTION', 'i18n_DESCRIPTION'); + $search->withColumn('`asked_locale_i18n`.POSTSCRIPTUM', 'i18n_POSTSCRIPTUM'); + } else { + $search->joinCategoryI18n('default_locale_i18n') + ->addJoinCondition('default_locale_i18n' ,'`default_locale_i18n`.LOCALE = ?', 'fr_FR', null, \PDO::PARAM_STR); + + $search->joinCategoryI18n('asked_locale_i18n') + ->addJoinCondition('asked_locale_i18n' ,'`asked_locale_i18n`.LOCALE = ?', 'en_EN', null, \PDO::PARAM_STR); + + $search->where('NOT ISNULL(`asked_locale_i18n`.ID)')->_or()->where('NOT ISNULL(`default_locale_i18n`.ID)'); + + $search->withColumn('CASE WHEN ISNULL(`asked_locale_i18n`.ID) THEN `asked_locale_i18n`.TITLE ELSE `asked_locale_i18n`.TITLE END', 'i18n_TITLE'); + $search->withColumn('CASE WHEN ISNULL(`asked_locale_i18n`.ID) THEN `asked_locale_i18n`.CHAPO ELSE `asked_locale_i18n`.CHAPO END', 'i18n_CHAPO'); + $search->withColumn('CASE WHEN ISNULL(`asked_locale_i18n`.ID) THEN `asked_locale_i18n`.DESCRIPTION ELSE `asked_locale_i18n`.DESCRIPTION END', 'i18n_DESCRIPTION'); + $search->withColumn('CASE WHEN ISNULL(`asked_locale_i18n`.ID) THEN `asked_locale_i18n`.POSTSCRIPTUM ELSE `asked_locale_i18n`.POSTSCRIPTUM END', 'i18n_POSTSCRIPTUM'); + } $categories = $this->search($search, $pagination); @@ -171,15 +193,16 @@ class Category extends BaseLoop if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue; + $x = $category->getTitle(); $loopResultRow = new LoopResultRow(); $loopResultRow ->set("ID", $category->getId()) - ->set("TITLE",$category->getTitle()) - ->set("CHAPO", $category->getChapo()) - ->set("DESCRIPTION", $category->getDescription()) - ->set("POSTSCRIPTUM", $category->getPostscriptum()) + ->set("TITLE",$category->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $category->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("PARENT", $category->getParent()) ->set("URL", $category->getUrl()) ->set("PRODUCT_COUNT", $category->countChild()) diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php index 80ae1e75b..1eaf926e0 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php @@ -35,6 +35,7 @@ use Thelia\Log\Tlog; use Thelia\Model\Base\FeatureProductQuery; use Thelia\Model\ConfigQuery; +use Thelia\Model\FeatureAvQuery; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -132,7 +133,12 @@ class FeatureValue extends BaseLoop $loopResultRow->set("PERSONAL_VALUE", $featureValue->getByDefault()); - $featureAvailability = $featureValue->getFeatureAv(); + $featureAvailability = null; + if($featureValue->getFeatureAvId() !== null) { + $featureAvailability = FeatureAvQuery::create() + ->joinWithI18n('fr_FR') + ->findPk($featureValue->getFeatureAvId()); + } $loopResultRow->set("TITLE", ($featureAvailability === null ? '' : $featureAvailability->getTitle())); $loopResultRow->set("CHAPO", ($featureAvailability === null ? '' : $featureAvailability->getChapo())); diff --git a/install/faker.php b/install/faker.php index bd24da2ff..f8d20a53b 100755 --- a/install/faker.php +++ b/install/faker.php @@ -41,56 +41,70 @@ try { ->find(); $feature->delete(); + $feature = Thelia\Model\FeatureI18nQuery::create() + ->find(); + $feature->delete(); + $featureAv = Thelia\Model\FeatureAvQuery::create() ->find(); $featureAv->delete(); + $featureAv = Thelia\Model\FeatureAvI18nQuery::create() + ->find(); + $featureAv->delete(); + $attribute = Thelia\Model\AttributeQuery::create() ->find(); $attribute->delete(); + $attribute = Thelia\Model\AttributeI18nQuery::create() + ->find(); + $attribute->delete(); + $attributeAv = Thelia\Model\AttributeAvQuery::create() ->find(); $attributeAv->delete(); + $attributeAv = Thelia\Model\AttributeAvI18nQuery::create() + ->find(); + $attributeAv->delete(); + $category = Thelia\Model\CategoryQuery::create() ->find(); $category->delete(); + $category = Thelia\Model\CategoryI18nQuery::create() + ->find(); + $category->delete(); + $product = Thelia\Model\ProductQuery::create() ->find(); $product->delete(); + $product = Thelia\Model\ProductI18nQuery::create() + ->find(); + $product->delete(); + $customer = Thelia\Model\CustomerQuery::create() ->find(); $customer->delete(); - $customer = new Thelia\Model\Customer(); - $customer->createOrUpdate( - 1, - "thelia", - "thelia", - "5 rue rochon", - "", - "", - "0102030405", - "0601020304", - "63000", - "clermont-ferrand", - 64, - "test@thelia.net", - "azerty" - ); - - $folder = Thelia\Model\FolderQuery::create() ->find(); $folder->delete(); + $folder = Thelia\Model\FolderI18nQuery::create() + ->find(); + $folder->delete(); + $content = Thelia\Model\ContentQuery::create() ->find(); $content->delete(); + $content = Thelia\Model\ContentI18nQuery::create() + ->find(); + $content->delete(); + $accessory = Thelia\Model\AccessoryQuery::create() ->find(); $accessory->delete(); @@ -105,15 +119,32 @@ try { $stmt = $con->prepare("SET foreign_key_checks = 1"); $stmt->execute(); - + + //customer + $customer = new Thelia\Model\Customer(); + $customer->createOrUpdate( + 1, + "thelia", + "thelia", + "5 rue rochon", + "", + "", + "0102030405", + "0601020304", + "63000", + "clermont-ferrand", + 64, + "test@thelia.net", + "azerty" + ); + //features and features_av $featureList = array(); for($i=0; $i<4; $i++) { $feature = new Thelia\Model\Feature(); $feature->setVisible(rand(1, 10)>7 ? 0 : 1); $feature->setPosition($i); - $feature->setTitle($faker->text(20)); - $feature->setDescription($faker->text(50)); + setI18n($faker, $feature); $feature->save(); $featureId = $feature->getId(); @@ -123,8 +154,7 @@ try { $featureAv = new Thelia\Model\FeatureAv(); $featureAv->setFeature($feature); $featureAv->setPosition($j); - $featureAv->setTitle($faker->text(20)); - $featureAv->setDescription($faker->text(255)); + setI18n($faker, $featureAv); $featureAv->save(); $featureList[$featureId][] = $featureAv->getId(); @@ -136,8 +166,7 @@ try { for($i=0; $i<4; $i++) { $attribute = new Thelia\Model\Attribute(); $attribute->setPosition($i); - $attribute->setTitle($faker->text(20)); - $attribute->setDescription($faker->text(50)); + setI18n($faker, $attribute); $attribute->save(); $attributeId = $attribute->getId(); @@ -147,8 +176,7 @@ try { $attributeAv = new Thelia\Model\AttributeAv(); $attributeAv->setAttribute($attribute); $attributeAv->setPosition($j); - $attributeAv->setTitle($faker->text(20)); - $attributeAv->setDescription($faker->text(255)); + setI18n($faker, $attributeAv); $attributeAv->save(); $attributeList[$attributeId][] = $attributeAv->getId(); @@ -271,8 +299,7 @@ try { $folder->setParent(0); $folder->setVisible(rand(1, 10)>7 ? 0 : 1); $folder->setPosition($i); - $folder->setTitle($faker->text(20)); - $folder->setDescription($faker->text(255)); + setI18n($faker, $folder); $folder->save(); @@ -285,8 +312,7 @@ try { $subfolder->setParent($folder->getId()); $subfolder->setVisible(rand(1, 10)>7 ? 0 : 1); $subfolder->setPosition($j); - $subfolder->setTitle($faker->text(20)); - $subfolder->setDescription($faker->text(255)); + setI18n($faker, $subfolder); $subfolder->save(); @@ -299,8 +325,7 @@ try { $content->addFolder($subfolder); $content->setVisible(rand(1, 10)>7 ? 0 : 1); $content->setPosition($k); - $content->setTitle($faker->text(20)); - $content->setDescription($faker->text(255)); + setI18n($faker, $content); $content->save(); @@ -324,8 +349,7 @@ function createProduct($faker, $category, $position, &$productIdList) $product->addCategory($category); $product->setVisible(rand(1, 10)>7 ? 0 : 1); $product->setPosition($position); - $product->setTitle($faker->text(20)); - $product->setDescription($faker->text(255)); + setI18n($faker, $product); $product->save(); $productId = $product->getId(); @@ -344,8 +368,7 @@ function createCategory($faker, $parent, $position, &$categoryIdList) $category->setParent($parent); $category->setVisible(rand(1, 10)>7 ? 0 : 1); $category->setPosition($position); - $category->setTitle($faker->text(20)); - $category->setDescription($faker->text(255)); + setI18n($faker, $category); $category->save(); $cateogoryId = $category->getId(); @@ -407,3 +430,18 @@ function generate_image($image, $position, $typeobj, $id) { $image->save($image_file); } +function setI18n($faker, &$object) +{ + $localeList = array('fr_FR', 'en_EN'); + + $title = $faker->text(20); + $description = $faker->text(50); + + foreach($localeList as $locale) { + $object->setLocale($locale); + + $object->setTitle($locale . ' : ' . $title); + $object->setDescription($locale . ' : ' . $description); + } +} + From c02e286d0967330cdf75168401647ed7d09f10ab Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 21 Aug 2013 20:03:03 +0200 Subject: [PATCH 017/268] WIP Coupon Implementation CouponInterface 1st class : RemoveXAmount Implementation CouponRuleInterface 1st class : AvailableForTotalAmount --- .../Thelia/Coupon/CouponAdapterInterface.php | 51 ++- core/lib/Thelia/Coupon/CouponBaseAdapter.php | 62 ++- core/lib/Thelia/Coupon/CouponFactory.php | 48 ++- core/lib/Thelia/Coupon/CouponManager.php | 120 +++++- ...Comparable.php => ComparableInterface.php} | 53 +-- .../lib/Thelia/Coupon/Parameter/DateParam.php | 49 +-- .../Thelia/Coupon/Parameter/IntegerParam.php | 97 +++++ .../Thelia/Coupon/Parameter/IntervalParam.php | 47 +- .../Thelia/Coupon/Parameter/PriceParam.php | 116 +++++ .../Thelia/Coupon/Parameter/QuantityParam.php | 78 ++++ .../Coupon/Parameter/RepeatedDateParam.php | 47 +- .../Parameter/RepeatedIntervalParam.php | 48 ++- .../Thelia/Coupon/Parameter/RepeatedParam.php | 97 +++-- .../Thelia/Coupon/Rule/AvailableForDate.php | 68 ++- .../Coupon/Rule/AvailableForLocationX.php | 68 ++- .../Thelia/Coupon/Rule/AvailableForPeriod.php | 68 ++- .../Coupon/Rule/AvailableForRepeatedDate.php | 68 ++- .../Rule/AvailableForRepeatedPeriod.php | 68 ++- .../Coupon/Rule/AvailableForTotalAmount.php | 175 +++++++- .../AvailableForTotalAmountForCategoryY.php | 68 ++- .../Coupon/Rule/AvailableForXArticles.php | 90 ++-- .../Thelia/Coupon/Rule/CouponRuleAbstract.php | 175 +++++--- .../Coupon/Rule/CouponRuleInterface.php | 91 ++++ core/lib/Thelia/Coupon/Rule/Operators.php | 109 +++++ core/lib/Thelia/Coupon/RuleOrganizer.php | 42 +- .../Thelia/Coupon/RuleOrganizerInterface.php | 42 +- .../Coupon/{ => Type}/CouponAbstract.php | 137 ++++-- .../Coupon/{ => Type}/CouponInterface.php | 71 +-- core/lib/Thelia/Coupon/Type/RemoveXAmount.php | 61 +-- .../Coupon/Type/RemoveXAmountForCategoryY.php | 42 +- .../lib/Thelia/Coupon/Type/RemoveXPercent.php | 44 +- .../Type/RemoveXPercentForAttributeY.php | 42 +- .../Type/RemoveXPercentForCategoryY.php | 42 +- ...RemoveXPercentForProductSaleElementIdY.php | 42 +- .../Coupon/Type/RemoveXPercentForProductY.php | 42 +- .../InvalidRuleException.php} | 76 ++-- .../InvalidRuleOperatorException.php | 54 +++ .../Exception/InvalidRuleValueException.php | 54 +++ .../Tests/Coupon/CouponBaseAdapterTest.php | 32 +- .../Thelia/Tests/Coupon/CouponFactoryTest.php | 32 +- .../Thelia/Tests/Coupon/CouponManagerTest.php | 83 +++- .../Tests/Coupon/Parameter/DateParamTest.php | 34 +- .../Coupon/Parameter/IntegerParamTest.php | 128 ++++++ .../Coupon/Parameter/IntervalParamTest.php | 32 +- .../Tests/Coupon/Parameter/PriceParamTest.php | 193 +++++++++ .../Coupon/Parameter/QuantityParamTest.php | 161 +++++++ .../Parameter/RepeatedDateParamTest.php | 32 +- .../Parameter/RepeatedIntervalParamTest.php | 58 ++- .../Rule/AvailableForTotalAmountTest.php | 338 +++++++++++++++ .../Coupon/Rule/AvailableForXArticlesTest.php | 102 +++-- .../Thelia/Tests/Coupon/Rule/OperatorTest.php | 403 ++++++++++++++++++ .../Thelia/Tests/Coupon/RuleOrganizerTest.php | 32 +- .../Type/RemoveXAmountForCategoryYTest.php | 32 +- .../Tests/Coupon/Type/RemoveXAmountTest.php | 265 +++++++++++- .../Type/RemoveXPercentForCategoryYTest.php | 32 +- .../Tests/Coupon/Type/RemoveXPercentTest.php | 32 +- 56 files changed, 3919 insertions(+), 854 deletions(-) rename core/lib/Thelia/Coupon/Parameter/{Comparable.php => ComparableInterface.php} (70%) create mode 100644 core/lib/Thelia/Coupon/Parameter/IntegerParam.php create mode 100644 core/lib/Thelia/Coupon/Parameter/PriceParam.php create mode 100644 core/lib/Thelia/Coupon/Parameter/QuantityParam.php create mode 100644 core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php create mode 100644 core/lib/Thelia/Coupon/Rule/Operators.php rename core/lib/Thelia/Coupon/{ => Type}/CouponAbstract.php (60%) rename core/lib/Thelia/Coupon/{ => Type}/CouponInterface.php (67%) rename core/lib/Thelia/{Coupon/Rule/CuponRuleInterface.php => Exception/InvalidRuleException.php} (60%) create mode 100644 core/lib/Thelia/Exception/InvalidRuleOperatorException.php create mode 100644 core/lib/Thelia/Exception/InvalidRuleValueException.php create mode 100644 core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php create mode 100644 core/lib/Thelia/Tests/Coupon/Rule/OperatorTest.php diff --git a/core/lib/Thelia/Coupon/CouponAdapterInterface.php b/core/lib/Thelia/Coupon/CouponAdapterInterface.php index 06e3a3ca7..0a900183e 100644 --- a/core/lib/Thelia/Coupon/CouponAdapterInterface.php +++ b/core/lib/Thelia/Coupon/CouponAdapterInterface.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon; @@ -84,6 +84,13 @@ interface CouponAdapterInterface * * @return int */ - public function getNbArticlesInTheCart(); + public function getNbArticlesInTheCart(); + + /** + * Return all Coupon given during the Checkout + * + * @return array Array of CouponInterface + */ + public function getCurrentCoupons(); } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponBaseAdapter.php b/core/lib/Thelia/Coupon/CouponBaseAdapter.php index 6908b3317..a79ac5407 100644 --- a/core/lib/Thelia/Coupon/CouponBaseAdapter.php +++ b/core/lib/Thelia/Coupon/CouponBaseAdapter.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon; @@ -104,5 +104,25 @@ class CouponBaseAdapter implements CouponAdapterInterface // TODO: Implement getNbArticlesInTheCart() method. } + /** + * Return all Coupon given during the Checkout + * + * @return array Array of CouponInterface + */ + public function getCurrentCoupons() + { + $couponFactory = new CouponFactory(); + + // @todo Get from Session + $couponCodes = array('XMAS', 'SPRINGBREAK'); + + $coupons = array(); + foreach ($couponCodes as $couponCode) { + $coupons[] = $couponFactory->buildCouponFromCode($couponCode); + } + + return $coupons; + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php index f999eabff..7f74c7f21 100644 --- a/core/lib/Thelia/Coupon/CouponFactory.php +++ b/core/lib/Thelia/Coupon/CouponFactory.php @@ -1,28 +1,30 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon; +use Thelia\Coupon\Type\CouponInterface; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -39,11 +41,11 @@ class CouponFactory /** * Build a CouponInterface from its database data * - * @param int $couponId CouponInterface id + * @param int $couponCode CouponInterface id * * @return CouponInterface ready to be processed */ - public function buildCouponFromId($couponId) + public function buildCouponFromCode($couponCode) { } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index 958f65db5..765068c96 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -1,28 +1,30 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon; +use Thelia\Coupon\Type\CouponInterface; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -42,13 +44,87 @@ class CouponManager /** @var array CouponInterface to process*/ protected $coupons = array(); + /** + * Constructor + * Gather Coupons from Adapter + * via $adapter->getCurrentCoupons(); + * + * @param CouponAdapterInterface $adapter Provide necessary value from Thelia + */ + function __construct($adapter) + { + $this->adapter = $adapter; + $this->coupons = $this->adapter->getCurrentCoupons(); + } + + /** * Get Discount for the given Coupons * + * @api * @return float checkout discount */ public function getDiscount() { - return 10.00; + $discount = 0.00; + + if (count($this->coupons) > 0) { + $couponsKept = $this->sortCoupons(); + $isRemovingPostage = $this->isCouponRemovingPostage($couponsKept); + + if ($isRemovingPostage) { + $postage = $this->adapter->getCheckoutPostagePrice(); + $discount -= $postage; + } + + // Just In Case test + if ($discount >= $this->adapter->getCheckoutTotalPrice()) { + $discount = 0.00; + } + } + + return $discount; + } + + /** + * Check if there is a Coupon removing Postage + * + * @param array $couponsKept Array of CouponInterface sorted + * + * @return bool + */ + protected function isCouponRemovingPostage(array $couponsKept) + { + $isRemovingPostage = false; + + /** @var CouponInterface $coupon */ + foreach ($couponsKept as $coupon) { + if ($coupon->isRemovingPostage()) { + $isRemovingPostage = true; + } + } + + return $isRemovingPostage; + } + + /** + * Sort Coupon to keep + * Coupon not cumulative cancels previous + * + * @return array Array of CouponInterface sorted + */ + protected function sortCoupons() + { + $couponsKept = array(); + + /** @var CouponInterface $coupon */ + foreach ($this->coupons as $coupon) { + if (!$coupon->isCumulative()) { + $couponsKept = array(); + $couponsKept[] = $coupon; + } + } + + return $couponsKept; } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/Comparable.php b/core/lib/Thelia/Coupon/Parameter/ComparableInterface.php similarity index 70% rename from core/lib/Thelia/Coupon/Parameter/Comparable.php rename to core/lib/Thelia/Coupon/Parameter/ComparableInterface.php index 37a7faeab..26bb3ca30 100644 --- a/core/lib/Thelia/Coupon/Parameter/Comparable.php +++ b/core/lib/Thelia/Coupon/Parameter/ComparableInterface.php @@ -1,35 +1,36 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Parameter; /** - * Comparable interface that allows to compare two value objects to each other for similarity. + * Comparable interface + * Allows to compare two value objects to each other for similarity. * - * @author Benjamin Eberlei - * @author Guilherme Blanco + * @author Benjamin Eberlei + * @author Guilherme Blanco */ -interface Comparable +interface ComparableInterface { /** * Compare the current object to the passed $other. @@ -37,7 +38,7 @@ interface Comparable * Returns 0 if they are semantically equal, 1 if the other object * is less than the current one, or -1 if its more than the current one. * - * This method should not check for identity using ===, only for semantical equality for example + * This method should not check for identity using ===, only for semantically equality for example * when two different DateTime instances point to the exact same Date + TZ. * * @param mixed $other Object diff --git a/core/lib/Thelia/Coupon/Parameter/DateParam.php b/core/lib/Thelia/Coupon/Parameter/DateParam.php index 29dab530d..fa4ea7d97 100644 --- a/core/lib/Thelia/Coupon/Parameter/DateParam.php +++ b/core/lib/Thelia/Coupon/Parameter/DateParam.php @@ -1,29 +1,29 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Parameter; -use Thelia\Coupon\Parameter\Comparable; +use Thelia\Coupon\Parameter\ComparableInterface; /** * Created by JetBrains PhpStorm. @@ -36,7 +36,7 @@ use Thelia\Coupon\Parameter\Comparable; * @author Guillaume MOREL * */ -class DateParam implements Comparable +class DateParam implements ComparableInterface { /** @var \DateTime Date */ protected $dateTime = null; @@ -67,11 +67,12 @@ class DateParam implements Comparable * Returns 0 if they are semantically equal, 1 if the other object * is less than the current one, or -1 if its more than the current one. * - * This method should not check for identity using ===, only for semantical equality for example + * This method should not check for identity using ===, only for semantically equality for example * when two different DateTime instances point to the exact same Date + TZ. * * @param mixed $other Object * + * @throws \InvalidArgumentException * @return int */ public function compareTo($other) diff --git a/core/lib/Thelia/Coupon/Parameter/IntegerParam.php b/core/lib/Thelia/Coupon/Parameter/IntegerParam.php new file mode 100644 index 000000000..c4d6ca5e7 --- /dev/null +++ b/core/lib/Thelia/Coupon/Parameter/IntegerParam.php @@ -0,0 +1,97 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon\Parameter; + +use Thelia\Coupon\Parameter\ComparableInterface; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Represent an Integer + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class IntegerParam implements ComparableInterface +{ + /** @var int Integer to compare with */ + protected $integer = 0; + + /** + * Constructor + * + * @param int $integer Integer + */ + public function __construct($integer) + { + $this->integer = $integer; + } + + /** + * Get integer + * + * @return int + */ + public function getInteger() + { + return $this->integer; + } + + + /** + * Compare the current object to the passed $other. + * + * Returns 0 if they are semantically equal, 1 if the other object + * is less than the current one, or -1 if its more than the current one. + * + * This method should not check for identity using ===, only for semantically equality for example + * when two different DateTime instances point to the exact same Date + TZ. + * + * @param mixed $other Object + * + * @throws \InvalidArgumentException + * @return int + */ + public function compareTo($other) + { + if (!is_integer($other)) { + throw new \InvalidArgumentException('IntegerParam can compare only int'); + } + + $ret = -1; + if ($this->integer == $other) { + $ret = 0; + } elseif ($this->integer > $other) { + $ret = 1; + } else { + $ret = -1; + } + + return $ret; + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/IntervalParam.php b/core/lib/Thelia/Coupon/Parameter/IntervalParam.php index 656cf69ca..88444fe36 100644 --- a/core/lib/Thelia/Coupon/Parameter/IntervalParam.php +++ b/core/lib/Thelia/Coupon/Parameter/IntervalParam.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Parameter; @@ -34,7 +34,7 @@ namespace Thelia\Coupon\Parameter; * @author Guillaume MOREL * */ -class IntervalParam implements Comparable +class IntervalParam implements ComparableInterface { /** @var \DatePeriod Date period */ protected $datePeriod = null; @@ -66,11 +66,12 @@ class IntervalParam implements Comparable * Returns 0 if they are semantically equal, 1 if the other object * is less than the current one, or -1 if its more than the current one. * - * This method should not check for identity using ===, only for semantical equality for example + * This method should not check for identity using ===, only for semantically equality for example * when two different DateTime instances point to the exact same Date + TZ. * * @param mixed $other Object * + * @throws \InvalidArgumentException * @return int */ public function compareTo($other) diff --git a/core/lib/Thelia/Coupon/Parameter/PriceParam.php b/core/lib/Thelia/Coupon/Parameter/PriceParam.php new file mode 100644 index 000000000..7d74101a0 --- /dev/null +++ b/core/lib/Thelia/Coupon/Parameter/PriceParam.php @@ -0,0 +1,116 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon\Parameter; + +use Thelia\Coupon\Parameter\ComparableInterface; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Represent a Price + * Positive value with currency + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class PriceParam implements ComparableInterface +{ + /** @var float Positive Float to compare with */ + protected $price = null; + + /** @var string Currency Code ISO 4217 EUR|USD|GBP */ + protected $currency = null; + + /** + * Constructor + * + * @param float $price Positive float + * @param string $currency Currency Code ISO 4217 EUR|USD|GBP + */ + public function __construct($price, $currency) + { + $this->price = $price; + $this->currency = $currency; + } + + /** + * Get currency code + * + * @return string + */ + public function getCurrency() + { + return $this->currency; + } + + /** + * Get price + * + * @return float + */ + public function getPrice() + { + return $this->price; + } + + /** + * Compare the current object to the passed $other. + * + * Returns 0 if they are semantically equal, 1 if the other object + * is less than the current one, or -1 if its more than the current one. + * + * This method should not check for identity using ===, only for semantically equality for example + * when two different DateTime instances point to the exact same Date + TZ. + * + * @param mixed $other Object + * + * @throws \InvalidArgumentException + * @return int + */ + public function compareTo($other) + { + if (!is_float($other)) { + throw new \InvalidArgumentException( + 'PriceParam can compare only positive float' + ); + } + + $epsilon = 0.00001; + + $ret = -1; + if (abs($this->price - $other) < $epsilon) { + $ret = 0; + } elseif ($this->price > $other) { + $ret = 1; + } else { + $ret = -1; + } + + return $ret; + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/QuantityParam.php b/core/lib/Thelia/Coupon/Parameter/QuantityParam.php new file mode 100644 index 000000000..e4dffb221 --- /dev/null +++ b/core/lib/Thelia/Coupon/Parameter/QuantityParam.php @@ -0,0 +1,78 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon\Parameter; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Represent a Quantity + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class QuantityParam extends IntegerParam +{ + + /** + * Constructor + * + * @param int $integer Integer + */ + public function __construct($integer) + { + if ($integer < 0) { + $integer = 0; + } + $this->integer = $integer; + } + + /** + * Compare the current object to the passed $other. + * + * Returns 0 if they are semantically equal, 1 if the other object + * is less than the current one, or -1 if its more than the current one. + * + * This method should not check for identity using ===, only for semantically equality for example + * when two different DateTime instances point to the exact same Date + TZ. + * + * @param mixed $other Object + * + * @throws \InvalidArgumentException + * @return int + */ + public function compareTo($other) + { + if (!is_integer($other) || $other < 0) { + throw new \InvalidArgumentException( + 'IntegerParam can compare only positive int' + ); + } + + return parent::compareTo($other); + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php b/core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php index 150f632b8..dc99a0d26 100644 --- a/core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php +++ b/core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Parameter; @@ -35,7 +35,8 @@ namespace Thelia\Coupon\Parameter; * 1 2 3 4 5 6 * 1 : $this->from Start date of the repetition * *--- : $this->interval Duration of a whole cycle - * x6 : $this->recurrences How many cycle + * x5 : $this->recurrences How many repeated cycle, 1st excluded + * x6 : How many occurrence * * @package Coupon * @author Guillaume MOREL @@ -57,7 +58,7 @@ class RepeatedDateParam extends RepeatedParam * Returns 0 if they are semantically equal, 1 if the other object * is less than the current one, or -1 if its more than the current one. * - * This method should not check for identity using ===, only for semantical equality for example + * This method should not check for identity using ===, only for semantically equality for example * when two different DateTime instances point to the exact same Date + TZ. * * @param mixed $other Object diff --git a/core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php b/core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php index 4bbbd8569..4d857716f 100644 --- a/core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php +++ b/core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Parameter; @@ -35,7 +35,8 @@ namespace Thelia\Coupon\Parameter; * 1 2 3 4 5 6 * 1 : $this->from Start date of the repetition * ****---- : $this->interval Duration of a whole cycle - * x6 : $this->recurrences How many cycle + * x5 : $this->recurrences How many repeated cycle, 1st excluded + * x6 : How many occurrence * **** : $this->durationInDays Duration of a period * * @package Coupon @@ -86,11 +87,12 @@ class RepeatedIntervalParam extends RepeatedParam * Returns 0 if they are semantically equal, 1 if the other object * is less than the current one, or -1 if its more than the current one. * - * This method should not check for identity using ===, only for semantical equality for example + * This method should not check for identity using ===, only for semantically equality for example * when two different DateTime instances point to the exact same Date + TZ. * * @param mixed $other Object * + * @throws \InvalidArgumentException * @return int */ public function compareTo($other) diff --git a/core/lib/Thelia/Coupon/Parameter/RepeatedParam.php b/core/lib/Thelia/Coupon/Parameter/RepeatedParam.php index ed5dcbf03..1d9dd4905 100644 --- a/core/lib/Thelia/Coupon/Parameter/RepeatedParam.php +++ b/core/lib/Thelia/Coupon/Parameter/RepeatedParam.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Parameter; @@ -38,7 +38,7 @@ use DateTime; * @author Guillaume MOREL * */ -abstract class RepeatedParam implements Comparable +abstract class RepeatedParam implements ComparableInterface { /** @var DateTime The start date of the period. */ protected $from = null; @@ -46,7 +46,7 @@ abstract class RepeatedParam implements Comparable /** @var DateInterval The interval between recurrences within the period. */ protected $interval = null; - /** @var int The number of recurrences. */ + /** @var int Nb time the object will be repeated (1st occurrence excluded). */ protected $recurrences = null; /** @var DatePeriod dates recurring at regular intervals, over a given period */ @@ -87,12 +87,13 @@ abstract class RepeatedParam implements Comparable /** * Set the Object to be repeated every days - * Ex : $obj->repeatEveryDay() will be repeated every days indefinitely - * $obj->repeatEveryDay(10) will be repeated every 10 days indefinitely - * $obj->repeatEveryDay(10, 4) will be repeated every 10 days only 4 times + * Ex : $obj->repeatEveryDay() will occur once + * $obj->repeatEveryDay(10) will occur once + * $obj->repeatEveryDay(10, 0) will occur once + * $obj->repeatEveryDay(10, 4) will occur every 10 days 5 times * * @param int $frequency Frequency the object will be repeated - * @param int $nbRepetition Time the object will be repeated (0 = infinite) + * @param int $nbRepetition Time the object will be repeated * * @return $this */ @@ -105,16 +106,17 @@ abstract class RepeatedParam implements Comparable /** * Set the Object to be repeated every week - * Ex : $obj->repeatEveryWeek() will be repeated every week indefinitely - * $obj->repeatEveryWeek(10) will be repeated every 10 weeks (70days) indefinitely - * $obj->repeatEveryWeek(10, 4) will be repeated every 10 weeks (70days) only 4 times + * Ex : $obj->repeatEveryWeek() will occur once + * $obj->repeatEveryWeek(10) will occur once + * $obj->repeatEveryWeek(10, 0) will occur once + * $obj->repeatEveryWeek(10, 4) will occur every 10 weeks (70days) 5 times * * @param int $frequency Frequency the object will be repeated - * @param int $nbRepetition Time the object will be repeated (0 = infinite) + * @param int $nbRepetition Time the object will be repeated * * @return $this */ - public function repeatEveryWeek($frequency = 1, $nbRepetition = null) + public function repeatEveryWeek($frequency = 1, $nbRepetition = 0) { $this->_repeatEveryPeriod($period = 'W', $frequency, $nbRepetition); @@ -123,16 +125,17 @@ abstract class RepeatedParam implements Comparable /** * Set the Object to be repeated every month - * Ex : $obj->repeatEveryWeek() will be repeated every month indefinitely - * $obj->repeatEveryWeek(10) will be repeated every 10 month (70days) indefinitely - * $obj->repeatEveryWeek(10, 4) will be repeated every 10 month (70days) only 4 times + * Ex : $obj->repeatEveryWeek() will occur once + * $obj->repeatEveryWeek(10) will occur once + * $obj->repeatEveryWeek(10, 0) will occur once + * $obj->repeatEveryWeek(10, 4) will occur every 10 month (70days) 5times * * @param int $frequency Frequency the object will be repeated - * @param int $nbRepetition Time the object will be repeated (0 = infinite) + * @param int $nbRepetition Time the object will be repeated * * @return $this */ - public function repeatEveryMonth($frequency = 1, $nbRepetition = null) + public function repeatEveryMonth($frequency = 1, $nbRepetition = 0) { $this->_repeatEveryPeriod($period = 'M', $frequency, $nbRepetition); @@ -141,16 +144,17 @@ abstract class RepeatedParam implements Comparable /** * Set the Object to be repeated every year - * Ex : $obj->repeatEveryWeek() will be repeated every year indefinitely - * $obj->repeatEveryWeek(10) will be repeated every 10 year indefinitely - * $obj->repeatEveryWeek(10, 4) will be repeated every 10 year only 4 times + * Ex : $obj->repeatEveryWeek() will occur once + * $obj->repeatEveryWeek(10) will occur once + * $obj->repeatEveryWeek(10, 0) will occur once + * $obj->repeatEveryWeek(10, 4) will occur every 10 year 5 times * * @param int $frequency Frequency the object will be repeated * @param int $nbRepetition Time the object will be repeated * * @return $this */ - public function repeatEveryYear($frequency = 1, $nbRepetition = null) + public function repeatEveryYear($frequency = 1, $nbRepetition = 0) { $this->_repeatEveryPeriod($period = 'Y', $frequency, $nbRepetition); @@ -159,9 +163,10 @@ abstract class RepeatedParam implements Comparable /** * Set the Object to be repeated every Period - * Ex : $obj->repeatEveryPeriod('D') will be repeated every day once - * $obj->repeatEveryPeriod('W', 10) will be repeated every 10 week once - * $obj->repeatEveryPeriod('M', 10, 4) will be repeated every 10 month only 4 times + * Ex : $obj->repeatEveryPeriod('D') will occur once + * $obj->repeatEveryPeriod('W', 10) will occur once + * $obj->repeatEveryPeriod('W', 10, 0) will occur once + * $obj->repeatEveryPeriod('M', 10, 4) will occur every 10 month 5 times * * @param string $period Period Y|M||D|W * @param int $frequency Frequency the object will be repeated @@ -169,13 +174,13 @@ abstract class RepeatedParam implements Comparable * * @return $this */ - private function _repeatEveryPeriod($period, $frequency = 1, $nbRepetition = null) + private function _repeatEveryPeriod($period, $frequency = 1, $nbRepetition = 0) { if (is_numeric($frequency) && $frequency > 0) { $this->interval = new \DateInterval('P' . $frequency . $period); } - if (is_numeric($nbRepetition) && $nbRepetition > 0) { + if (is_numeric($nbRepetition) && $nbRepetition >= 0) { $this->recurrences = $nbRepetition; } diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForDate.php b/core/lib/Thelia/Coupon/Rule/AvailableForDate.php index f55c48973..800db5066 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForDate.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForDate.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Rule; @@ -34,5 +34,31 @@ namespace Thelia\Coupon\Rule; */ class AvailableForDate extends AvailableForPeriod { + /** + * Generate current Rule validator from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setValidators(CouponAdapterInterface $adapter) + { + parent::setValidators($adapter); // TODO: Change the autogenerated stub + } + /** + * Generate current Rule param to be validated from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setParametersToValidate(CouponAdapterInterface $adapter) + { + parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php b/core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php index c57702b2f..f0ef8926a 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Rule; @@ -34,5 +34,31 @@ namespace Thelia\Coupon\Rule; */ class AvailableForLocationX extends CouponRuleAbstract { + /** + * Generate current Rule validator from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setValidators(CouponAdapterInterface $adapter) + { + parent::setValidators($adapter); // TODO: Change the autogenerated stub + } + /** + * Generate current Rule param to be validated from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setParametersToValidate(CouponAdapterInterface $adapter) + { + parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php b/core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php index 1a2753dc4..fe7347c46 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Rule; @@ -34,5 +34,31 @@ namespace Thelia\Coupon\Rule; */ class AvailableForPeriod extends CouponRuleAbstract { + /** + * Generate current Rule validator from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setValidators(CouponAdapterInterface $adapter) + { + parent::setValidators($adapter); // TODO: Change the autogenerated stub + } + /** + * Generate current Rule param to be validated from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setParametersToValidate(CouponAdapterInterface $adapter) + { + parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php index 7d03a1c5b..21ebd01d3 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Rule; @@ -34,5 +34,31 @@ namespace Thelia\Coupon\Rule; */ class AvailableForRepeatedDate extends AvailableForDate { + /** + * Generate current Rule validator from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setValidators(CouponAdapterInterface $adapter) + { + parent::setValidators($adapter); // TODO: Change the autogenerated stub + } + /** + * Generate current Rule param to be validated from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setParametersToValidate(CouponAdapterInterface $adapter) + { + parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php index 8552947c2..2824b584a 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Rule; @@ -34,5 +34,31 @@ namespace Thelia\Coupon\Rule; */ class AvailableForRepeatedPeriod extends AvailableForPeriod { + /** + * Generate current Rule validator from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setValidators(CouponAdapterInterface $adapter) + { + parent::setValidators($adapter); // TODO: Change the autogenerated stub + } + /** + * Generate current Rule param to be validated from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setParametersToValidate(CouponAdapterInterface $adapter) + { + parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php index b90ef1da5..2f1de57ba 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php @@ -1,38 +1,171 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Rule; +use Symfony\Component\Intl\Exception\NotImplementedException; +use Thelia\Coupon\CouponAdapterInterface; +use Thelia\Coupon\Parameter\PriceParam; +use Thelia\Exception\InvalidRuleOperatorException; +use Thelia\Exception\InvalidRuleValueException; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * + * Rule AvailableForTotalAmount + * Check if a Checkout total amount match criteria + * * @package Coupon * @author Guillaume MOREL * */ class AvailableForTotalAmount extends CouponRuleAbstract { + /** Rule 1st parameter : price */ + CONST PARAM1_PRICE = 'price'; + + /** @var array Available Operators (Operators::CONST) */ + protected $availableOperators = array( + Operators::INFERIOR, + Operators::EQUAL, + Operators::SUPERIOR, + ); + + /** @var PriceParam Price Validator */ + protected $priceValidator = null; + + /** + * Constructor + * + * @param array $validators Parameters validating $paramsToValidate against + * @param array $validated Parameters to be paramsToValidate + */ + public function __construct(array $validators, array $validated = null) + { + parent::__construct($validators, $validated); + + $this->priceValidator = $validators[self::PARAM1_PRICE][self::VALUE]; + } + + + /** + * Check if backoffice inputs are relevant or not + * + * @throws InvalidRuleOperatorException if Operator is not allowed + * @throws InvalidRuleValueException if Value is not allowed + * @return bool + */ + public function checkBackOfficeInput() + { + if (!isset($this->validators) + || empty($this->validators) + ||!isset($this->validators[self::PARAM1_PRICE]) + ||!isset($this->validators[self::PARAM1_PRICE][self::VALUE]) + ||!$this->validators[self::PARAM1_PRICE][self::VALUE] instanceof PriceParam + ) { + throw new InvalidRuleValueException(get_class(), self::PARAM1_PRICE); + } + + $this->checkBackOfficeInputsOperators(); + + /** @var PriceParam $price */ + $price = $this->validators[self::PARAM1_PRICE][self::VALUE]; + + return $this->isPriceValid($price->getPrice()); + } + + /** + * Check if Checkout inputs are relevant or not + * + * @throws InvalidRuleValueException if Value is not allowed + * @return bool + */ + public function checkCheckoutInput() + { + if (!isset($this->paramsToValidate) + || empty($this->paramsToValidate) + ||!isset($this->paramsToValidate[self::PARAM1_PRICE]) + ) { + throw new InvalidRuleValueException(get_class(), self::PARAM1_PRICE); + } + + $quantity = $this->paramsToValidate[self::PARAM1_PRICE]; + + return $this->isPriceValid($quantity); + } + + /** + * Check if a price is valid + * + * @param int $price Price to check + * + * @throws InvalidRuleValueException if Value is not allowed + * @return bool + */ + protected function isPriceValid($price) + { + $priceValidator = $this->priceValidator; + try { + $priceValidator->compareTo($price); + } catch(\InvalidArgumentException $e) { + throw new InvalidRuleValueException(get_class(), self::PARAM1_PRICE); + } + + return true; + } + + /** + * Generate current Rule validator from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setValidators(CouponAdapterInterface $adapter) + { + $adapter->getRule($this); + } + + /** + * Generate current Rule param to be validated from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @return $this + */ + protected function setParametersToValidate(CouponAdapterInterface $adapter) + { + $this->paramsToValidate = array( + self::PARAM1_PRICE => $adapter->getCheckoutTotalPrice() + ); + + return $this; + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php index 08bdc23e5..a4153e5a1 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Rule; @@ -34,5 +34,31 @@ namespace Thelia\Coupon\Rule; */ class AvailableForTotalAmountForCategoryY extends AvailableForTotalAmount { + /** + * Generate current Rule validator from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setValidators(CouponAdapterInterface $adapter) + { + parent::setValidators($adapter); // TODO: Change the autogenerated stub + } + /** + * Generate current Rule param to be validated from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setParametersToValidate(CouponAdapterInterface $adapter) + { + parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php b/core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php index 1fac12f94..7016eda95 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Rule; @@ -39,39 +39,31 @@ use Thelia\Type\IntType; class AvailableForXArticles extends CouponRuleAbstract { /** - * @inheritdoc + * Generate current Rule validator from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this */ - public function checkBackOfficeIntput() + protected function setValidators(CouponAdapterInterface $adapter) { - $ret = false; - $validator = new IntType(); - $firstParam = reset($this->validators); - if ($firstParam) { - $ret = $validator->isValid($firstParam); - } - - return $ret; + parent::setValidators($adapter); // TODO: Change the autogenerated stub } - public function checkCheckoutInput() + /** + * Generate current Rule param to be validated from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setParametersToValidate(CouponAdapterInterface $adapter) { - $ret = false; - $validator = new IntType(); - $firstParam = reset($this->validated); - if ($firstParam) { - $ret = $validator->isValid($firstParam); - } - - return $ret; - } - - public function isMatching() - { - if ($this->checkBackOfficeIntput() && $this->checkCheckoutInput()) { - $firstValidatorsParam = reset($this->validators); - $firstValidatedParam = reset($this->validated); -// if($firstValidatedParam >= $firstValidatedParam) - } + parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php b/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php index 4a01494ae..a8a51cd00 100644 --- a/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php +++ b/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php @@ -1,28 +1,33 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Rule; +use Symfony\Component\Intl\Exception\NotImplementedException; +use Thelia\Coupon\CouponAdapterInterface; +use Thelia\Coupon\Parameter\ComparableInterface; +use Thelia\Exception\InvalidRuleOperatorException; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -34,54 +39,124 @@ namespace Thelia\Coupon\Rule; * @author Guillaume MOREL * */ -class CouponRuleAbstract implements CuponRuleInterface +abstract class CouponRuleAbstract implements CouponRuleInterface { - /** @var array Parameters validating $validated against */ + /** Operator key in $validators */ + CONST OPERATOR = 'operator'; + /** Value key in $validators */ + CONST VALUE = 'value'; + + /** @var array Available Operators (Operators::CONST) */ + protected $availableOperators = array(); + + /** @var array Parameters validating parameters against */ protected $validators = array(); /** @var array Parameters to be validated */ - protected $validated = array(); + protected $paramsToValidate = array(); /** * Constructor + * Ex: + * Param 1 : + * $validators['price']['operator'] = Operators::INFERIOR + * ['value'] = new IntegerParam(10) * - * @param array $validators Parameters validating $validated against - * @param array $validated Parameters to be validated + * Param 2 : + * $paramsToValidate['price'] = 9 + * + * @param array $validators Parameters validating $paramsToValidate against + * @param array $validated Parameters to be paramsToValidate */ - public function __construct(array $validators, array $validated) + public function __construct(array $validators, array $validated = null) { $this->validators = $validators; - $this->validated = $validated; + $this->paramsToValidate = $validated; } /** - * Check if backoffice inputs are relevant or not - * - * @return bool - */ - public function checkBackOfficeIntput() - { - // TODO: Implement checkBackOfficeIntput() method. - } - - /** - * Check if Checkout inputs are relevant or not - * - * @return bool - */ - public function checkCheckoutInput() - { - // TODO: Implement checkCheckoutInput() method. - } - - /** - * Check if the current Checkout matchs this condition + * Check if the current Checkout matches this condition * * @return bool */ public function isMatching() { - // TODO: Implement isMatching() method. + $this->checkBackOfficeInput(); + $this->checkCheckoutInput(); + + $isMatching = true; + foreach ($this->validators as $param => $validator) { + $a = $this->paramsToValidate[$param]; + $operator = $validator[self::OPERATOR]; + /** @var ComparableInterface $b */ + $b = $validator[self::VALUE]; + + if (!Operators::isValidAccordingToOperator($a, $operator, $b)) { + $isMatching = false; + } + } + + return $isMatching; + } + /** + * Return all available Operators for this Rule + * + * @return array Operators::CONST + */ + public function getAvailableOperators() + { + return $this->availableOperators; + } + + /** + * Check if Operators set for this Rule in the BackOffice are legit + * + * @throws InvalidRuleOperatorException if Operator is not allowed + * @return bool + */ + protected function checkBackOfficeInputsOperators() + { + foreach ($this->validators as $key => $param) { + if (!isset($param[self::OPERATOR]) + ||!in_array($param[self::OPERATOR], $this->availableOperators) + ) { + throw new InvalidRuleOperatorException(get_class(), $key); + } + } + return true; + } + + /** + * Generate current Rule validator from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setValidators(CouponAdapterInterface $adapter) + { + throw new NotImplementedException( + 'CouponRuleInterface::setValidators needs to be implemented' + ); + } + + /** + * Generate current Rule param to be validated from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @return $this + */ + protected function setParametersToValidate(CouponAdapterInterface $adapter) + { + throw new NotImplementedException( + 'CouponRuleInterface::setValidators needs to be implemented' + ); + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php b/core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php new file mode 100644 index 000000000..8ab6abe34 --- /dev/null +++ b/core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php @@ -0,0 +1,91 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon\Rule; + +use Thelia\Coupon\CouponAdapterInterface; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Represents a condition of whether the Rule is applied or not + * + * @package Coupon + * @author Guillaume MOREL + * + */ +interface CouponRuleInterface +{ + /** + * Check if backoffice inputs are relevant or not + * + * @return bool + */ + public function checkBackOfficeInput(); + + /** + * Check if Checkout inputs are relevant or not + * + * @return bool + */ + public function checkCheckoutInput(); + + /** + * Check if the current Checkout matches this condition + * + * @return bool + */ + public function isMatching(); + + /** + * Return all available Operators for this Rule + * + * @return array Operators::CONST + */ + public function getAvailableOperators(); + +// /** +// * Generate current Rule validator from adapter +// * Ex : +// * $validator = array( +// * +// * @param CouponAdapterInterface $adapter allowing to gather +// * all necessary Thelia variables +// * +// * @return array Validators : array of ComparableInterface +// */ +// public function getValidators(CouponAdapterInterface $adapter); +// +// /** +// * Retrieve all param to validate from adapter +// * +// * @param CouponAdapterInterface $adapter allowing to gather +// * all necessary Thelia variables +// * +// * @return array Validators : array of ComparableInterface +// */ +// public function getParamToValidate(CouponAdapterInterface $adapter); + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/Operators.php b/core/lib/Thelia/Coupon/Rule/Operators.php new file mode 100644 index 000000000..c11198caf --- /dev/null +++ b/core/lib/Thelia/Coupon/Rule/Operators.php @@ -0,0 +1,109 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon\Rule; + +use Thelia\Coupon\Parameter\ComparableInterface; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Represent available Operations in rule checking + * + * @package Coupon + * @author Guillaume MOREL + * + */ +abstract class Operators +{ + /** Param1 is inferior to Param2 */ + CONST INFERIOR = '<'; + /** Param1 is inferior to Param2 */ + CONST INFERIOR_OR_EQUAL = '<='; + /** Param1 is equal to Param2 */ + CONST EQUAL = '=='; + /** Param1 is superior to Param2 */ + CONST SUPERIOR_OR_EQUAL = '>='; + /** Param1 is superior to Param2 */ + CONST SUPERIOR = '>'; + /** Param1 is different to Param2 */ + CONST DIFFERENT = '!='; + + /** + * Check if a parameter is valid against a ComparableInterface from its operator + * + * @param mixed $a Parameter to validate + * @param string $operator Operator to validate against + * @param ComparableInterface $b Comparable to validate against + * + * @return bool + */ + public static function isValidAccordingToOperator($a, $operator, ComparableInterface $b) + { + $ret = false; + + try { + $comparison = $b->compareTo($a); + } catch (\Exception $e) { + return false; + } + + switch ($operator) { + case self::INFERIOR: + if ($comparison == 1) { + return true; + } + break; + case self::INFERIOR_OR_EQUAL: + if ($comparison == 1 || $comparison == 0) { + return true; + } + break; + case self::EQUAL: + if ($comparison == 0) { + return true; + } + break; + case self::SUPERIOR_OR_EQUAL: + if ($comparison == -1 || $comparison == 0) { + return true; + } + break; + case self::SUPERIOR: + if ($comparison == -1) { + return true; + } + break; + case self::DIFFERENT: + if ($comparison != 0) { + return true; + } + break; + default: + } + + return $ret; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/RuleOrganizer.php b/core/lib/Thelia/Coupon/RuleOrganizer.php index b3699fc6c..4c16ea1ff 100644 --- a/core/lib/Thelia/Coupon/RuleOrganizer.php +++ b/core/lib/Thelia/Coupon/RuleOrganizer.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon; diff --git a/core/lib/Thelia/Coupon/RuleOrganizerInterface.php b/core/lib/Thelia/Coupon/RuleOrganizerInterface.php index bc901d24c..b8b222028 100644 --- a/core/lib/Thelia/Coupon/RuleOrganizerInterface.php +++ b/core/lib/Thelia/Coupon/RuleOrganizerInterface.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon; diff --git a/core/lib/Thelia/Coupon/CouponAbstract.php b/core/lib/Thelia/Coupon/Type/CouponAbstract.php similarity index 60% rename from core/lib/Thelia/Coupon/CouponAbstract.php rename to core/lib/Thelia/Coupon/Type/CouponAbstract.php index b2d4f9268..3ef3166b3 100644 --- a/core/lib/Thelia/Coupon/CouponAbstract.php +++ b/core/lib/Thelia/Coupon/Type/CouponAbstract.php @@ -1,29 +1,33 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ -namespace Thelia\Coupon; +namespace Thelia\Coupon\Type; use Symfony\Component\Intl\Exception\NotImplementedException; +use Thelia\Coupon\CouponAdapterInterface; +use Thelia\Coupon\Rule\CouponRuleInterface; +use Thelia\Coupon\RuleOrganizerInterface; +use Thelia\Exception\InvalidRuleException; /** * Created by JetBrains PhpStorm. @@ -44,6 +48,9 @@ abstract class CouponAbstract implements CouponInterface /** @var RuleOrganizerInterface */ protected $organizer = null; + /** @var array Array of CouponRuleInterface */ + protected $rules = null; + /** @var string Coupon code (ex: XMAS) */ protected $code = null; @@ -62,6 +69,9 @@ abstract class CouponAbstract implements CouponInterface /** @var bool if Coupon is removing postage */ protected $isRemovingPostage = false; + /** @var float Amount that will be removed from the Checkout (Coupon Effect) */ + protected $amount = 0; + /** * Set Adapter containing all relevant data * @@ -154,15 +164,86 @@ abstract class CouponAbstract implements CouponInterface /** * Return effects generated by the coupon - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return \Closure + * A negative value + * @ + * @return float Amount removed from the Total Checkout */ public function getEffect() { - throw new NotImplementedException( - 'Abstract method to implement (CouponAbstract->getEffect)' - ); + return -$this->amount; } + /** + * Return condition to validate the Coupon or not + * + * @return array An array of CouponRuleInterface + */ + public function getRules() + { + $arrayObject = new \ArrayObject($this->rules); + + return $arrayObject->getArrayCopy(); + } + + /** + * Add a Rule to the Coupon + * + * @param CouponRuleInterface $rule Condition needed to match + * in order to get the Coupon effect + * + * @return $this + */ + public function addRule(CouponRuleInterface $rule) + { + $this->rules[] = $rule; + + return $this; + } + + /** + * Replace the existing Rules by those given in parameter + * If one Rule is badly implemented, no Rule will be added + * + * @param array $rules CouponRuleInterface to add + * + * @return $this + * @throws \Thelia\Exception\InvalidRuleException + */ + public function setRules(array $rules) + { + foreach ($rules as $rule) { + if (!$rule instanceof CouponRuleInterface) { + throw new InvalidRuleException(get_class()); + } + } + $this->rules = array(); + foreach ($rules as $rule) { + $this->addRule($rule); + } + + return $this; + } + + /** + * Check if the current Coupon is matching its conditions (Rules) + * Thelia variables are given by the CouponAdapterInterface + * In $this->adapter + * + * @return bool + */ + public function isMatching() + { + $isMatching = true; + + /** @var CouponRuleInterface $rule */ + foreach ($this->rules as $rule) { + if (!$rule->isMatching()) { + $isMatching = false; + } + } + + return $isMatching; + } + + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponInterface.php b/core/lib/Thelia/Coupon/Type/CouponInterface.php similarity index 67% rename from core/lib/Thelia/Coupon/CouponInterface.php rename to core/lib/Thelia/Coupon/Type/CouponInterface.php index ad332ad0a..e2f49e3bb 100644 --- a/core/lib/Thelia/Coupon/CouponInterface.php +++ b/core/lib/Thelia/Coupon/Type/CouponInterface.php @@ -1,27 +1,27 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ -namespace Thelia\Coupon; +namespace Thelia\Coupon\Type; /** * Created by JetBrains PhpStorm. @@ -82,8 +82,31 @@ interface CouponInterface /** * Return effects generated by the coupon + * A negative value * - * @return \Closure + * Effects could also affect something else than the final Checkout price + * CouponAdapter could be use to directly pass a Session value + * some would wish to modify + * Hence affecting a wide variety of Thelia elements + * Ex : $this->adapter->getTheliaInternalValue + * + * @return float Amount removed from the Total Checkout */ public function getEffect(); -} \ No newline at end of file + + /** + * Return condition to validate the Coupon or not + * + * @return array An array of CouponRuleInterface + */ + public function getRules(); + + /** + * Check if the current Coupon is matching its conditions (Rules) + * Thelia variables are given by the CouponAdapterInterface + * In $this->adapter + * + * @return bool + */ + public function isMatching(); +} diff --git a/core/lib/Thelia/Coupon/Type/RemoveXAmount.php b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php index 6c9a6e7ba..d7cfeb989 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXAmount.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php @@ -1,29 +1,29 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Type; -use Thelia\Coupon\CouponAbstract; +use Thelia\Coupon\Type\CouponAbstract; /** * Created by JetBrains PhpStorm. @@ -38,9 +38,6 @@ use Thelia\Coupon\CouponAbstract; */ class RemoveXAmount extends CouponAbstract { - - protected $amount = 0; - /** * Constructor * @@ -65,16 +62,4 @@ class RemoveXAmount extends CouponAbstract $this->amount = $amount; } - /** - * Return effects generated by the coupon - * A negative value - * - * @return float - */ - public function getEffect() - { - return -$this->amount; - } - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Coupon/Type/RemoveXAmountForCategoryY.php b/core/lib/Thelia/Coupon/Type/RemoveXAmountForCategoryY.php index 2cd8e5db6..4a75683bc 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXAmountForCategoryY.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXAmountForCategoryY.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Type; diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php index 3f0fd43fc..5fd25ae8f 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php @@ -1,29 +1,29 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Type; -use Thelia\Coupon\CouponAbstract; +use Thelia\Coupon\Type\CouponAbstract; use Thelia\Exception\MissingAdapterException; /** diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentForAttributeY.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentForAttributeY.php index 643016c93..f0a7ef472 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercentForAttributeY.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercentForAttributeY.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Type; diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentForCategoryY.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentForCategoryY.php index 6ad0d21df..717807da7 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercentForCategoryY.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercentForCategoryY.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Type; diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductSaleElementIdY.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductSaleElementIdY.php index b19913617..bb052cd68 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductSaleElementIdY.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductSaleElementIdY.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Type; diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductY.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductY.php index 494e30fcd..0b88ca44d 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductY.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductY.php @@ -1,25 +1,25 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Coupon\Type; diff --git a/core/lib/Thelia/Coupon/Rule/CuponRuleInterface.php b/core/lib/Thelia/Exception/InvalidRuleException.php similarity index 60% rename from core/lib/Thelia/Coupon/Rule/CuponRuleInterface.php rename to core/lib/Thelia/Exception/InvalidRuleException.php index b0cbfa767..834a6e962 100644 --- a/core/lib/Thelia/Coupon/Rule/CuponRuleInterface.php +++ b/core/lib/Thelia/Exception/InvalidRuleException.php @@ -1,60 +1,54 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ -namespace Thelia\Coupon\Rule; +namespace Thelia\Exception; + +use Thelia\Log\Tlog; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * Represents a condition of whether the Rule is applied or not + * Thrown when a Rule is badly implemented * * @package Coupon * @author Guillaume MOREL * */ -interface CuponRuleInterface +class InvalidRuleException extends \RuntimeException { /** - * Check if backoffice inputs are relevant or not + * InvalidRuleOperatorException thrown when a Rule is badly implemented * - * @return bool + * @param string $className Class name + * @param string $parameter array key parameter */ - public function checkBackOfficeIntput(); + public function __construct($className) { - /** - * Check if Checkout inputs are relevant or not - * - * @return bool - */ - public function checkCheckoutInput(); + $message = 'Invalid Rule given to ' . $className; + Tlog::getInstance()->addError($message); - /** - * Check if the current Checkout matchs this condition - * - * @return bool - */ - public function isMatching(); - -} \ No newline at end of file + parent::__construct($message); + } +} diff --git a/core/lib/Thelia/Exception/InvalidRuleOperatorException.php b/core/lib/Thelia/Exception/InvalidRuleOperatorException.php new file mode 100644 index 000000000..82556b2ef --- /dev/null +++ b/core/lib/Thelia/Exception/InvalidRuleOperatorException.php @@ -0,0 +1,54 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Exception; + +use Thelia\Log\Tlog; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Operator + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class InvalidRuleOperatorException extends \RuntimeException +{ + /** + * InvalidRuleOperatorException thrown when a Rule is given a bad Operator + * + * @param string $className Class name + * @param string $parameter array key parameter + */ + public function __construct($className, $parameter) { + + $message = 'Invalid Operator for Rule ' . $className . ' on parameter ' . $parameter; + Tlog::getInstance()->addError($message); + + parent::__construct($message); + } +} diff --git a/core/lib/Thelia/Exception/InvalidRuleValueException.php b/core/lib/Thelia/Exception/InvalidRuleValueException.php new file mode 100644 index 000000000..cbb86d16f --- /dev/null +++ b/core/lib/Thelia/Exception/InvalidRuleValueException.php @@ -0,0 +1,54 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Exception; + +use Thelia\Log\Tlog; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class InvalidRuleValueException extends \RuntimeException +{ + /** + * InvalidRuleValueException thrown when a Rule is given a bad Parameter + * + * @param string $className Class name + * @param string $parameter array key parameter + */ + public function __construct($className, $parameter) { + + $message = 'Invalid Parameter for Rule ' . $className . ' on parameter ' . $parameter; + Tlog::getInstance()->addError($message); + + parent::__construct($message); + } +} diff --git a/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php b/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php index 57d0ce131..932dba9fc 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php @@ -1,8 +1,38 @@ . */ +/* */ +/**********************************************************************************/ + namespace Thelia\Coupon; /** - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-08-19 at 18:26:01. + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * */ class CouponBaseAdapterTest extends \PHPUnit_Framework_TestCase { diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index 9a637b299..465754cd3 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -1,8 +1,38 @@ . */ +/* */ +/**********************************************************************************/ + namespace Thelia\Coupon; /** - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-08-19 at 18:06:16. + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * */ class CouponFactoryTest extends \PHPUnit_Framework_TestCase { diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index 55b48f4d9..c7d2233f4 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -1,8 +1,38 @@ . */ +/* */ +/**********************************************************************************/ + namespace Thelia\Coupon; /** - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-08-19 at 18:05:02. + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * */ class CouponManagerTest extends \PHPUnit_Framework_TestCase { @@ -39,4 +69,55 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase 'This test has not been implemented yet.' ); } + + /** + * @covers Thelia\Coupon\CouponManager::getDiscount + * @todo Implement testGetDiscount(). + */ + public function testGetDiscountAlwaysInferiorToPrice() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Thelia\Coupon\CouponManager::getDiscount + * @covers Thelia\Coupon\CouponManager::sortCoupons + * @todo Implement testGetDiscount(). + */ + public function testGetDiscountCouponNotCumulativeCancelOthers() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Thelia\Coupon\CouponManager::getDiscount + * @covers Thelia\Coupon\CouponManager::sortCoupons + * @todo Implement testGetDiscount(). + */ + public function testGetDiscountCouponCumulativeCumulatesWithOthers() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Thelia\Coupon\CouponManager::isCouponRemovingPostage + * @covers Thelia\Coupon\CouponManager::sortCoupons + * @todo Implement testGetDiscount(). + */ + public function testIsCouponRemovingPostage() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } } diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php index 7ba6610df..3062568c4 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php @@ -1,11 +1,41 @@ . */ +/* */ +/**********************************************************************************/ + namespace Thelia\Coupon; use InvalidArgumentException; use Thelia\Coupon\Parameter\DateParam; /** - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-08-19 at 18:26:01. + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * */ class DateParamTest extends \PHPUnit_Framework_TestCase { @@ -40,7 +70,7 @@ class DateParamTest extends \PHPUnit_Framework_TestCase * @covers Thelia\Coupon\Parameter\DateParam::compareTo * */ - public function testEquelsDate() + public function testEqualsDate() { $dateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-07-08"); diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php new file mode 100644 index 000000000..bcc24542e --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php @@ -0,0 +1,128 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon; + +use InvalidArgumentException; +use Thelia\Coupon\Parameter\IntegerParam; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class IntegerParamTest extends \PHPUnit_Framework_TestCase +{ + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + } + + /** + * + * @covers Thelia\Coupon\Parameter\IntegerParam::compareTo + * + */ + public function testInferiorInteger() + { + $intValidator = 42; + $intToValidate = 41; + + $integerParam = new IntegerParam($intValidator); + + $expected = 1; + $actual = $integerParam->compareTo($intToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\IntegerParam::compareTo + * + */ + public function testEqualsInteger() + { + $intValidator = 42; + $intToValidate = 42; + + $integerParam = new IntegerParam($intValidator); + + $expected = 0; + $actual = $integerParam->compareTo($intToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\IntegerParam::compareTo + * + */ + public function testSuperiorInteger() + { + $intValidator = 42; + $intToValidate = 43; + + $integerParam = new IntegerParam($intValidator); + + $expected = -1; + $actual = $integerParam->compareTo($intToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\Parameter\IntegerParam::compareTo + * @expectedException InvalidArgumentException + */ + public function testInvalidArgumentException() + { + $intValidator = 42; + $intToValidate = '42'; + + $integerParam = new IntegerParam($intValidator); + + $expected = 0; + $actual = $integerParam->compareTo($intToValidate); + $this->assertEquals($expected, $actual); + } + + + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + +} diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php index 0c1018af5..59583bfe6 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php @@ -1,11 +1,41 @@ . */ +/* */ +/**********************************************************************************/ + namespace Thelia\Coupon; use InvalidArgumentException; use Thelia\Coupon\Parameter\IntervalParam; /** - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-08-19 at 18:26:01. + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * */ class IntervalParamTest extends \PHPUnit_Framework_TestCase { diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php new file mode 100644 index 000000000..c85b5af1a --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php @@ -0,0 +1,193 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon; + +use InvalidArgumentException; +use Thelia\Coupon\Parameter\PriceParam; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class PriceParamTest extends \PHPUnit_Framework_TestCase +{ + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + } + + /** + * + * @covers Thelia\Coupon\Parameter\PriceParam::compareTo + * + */ + public function testInferiorPrice() + { + $priceValidator = 42.50; + $priceToValidate = 1.00; + + $integerParam = new PriceParam($priceValidator, 'EUR'); + + $expected = 1; + $actual = $integerParam->compareTo($priceToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\PriceParam::compareTo + * + */ + public function testInferiorPrice2() + { + $priceValidator = 42.50; + $priceToValidate = 42.49; + + $integerParam = new PriceParam($priceValidator, 'EUR'); + + $expected = 1; + $actual = $integerParam->compareTo($priceToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\PriceParam::compareTo + * + */ + public function testEqualsPrice() + { + $priceValidator = 42.50; + $priceToValidate = 42.50; + + $integerParam = new PriceParam($priceValidator, 'EUR'); + + $expected = 0; + $actual = $integerParam->compareTo($priceToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\PriceParam::compareTo + * + */ + public function testSuperiorPrice() + { + $priceValidator = 42.50; + $priceToValidate = 42.51; + + $integerParam = new PriceParam($priceValidator, 'EUR'); + + $expected = -1; + $actual = $integerParam->compareTo($priceToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\Parameter\PriceParam::compareTo + * @expectedException InvalidArgumentException + */ + public function testInvalidArgumentException() + { + $priceValidator = 42.50; + $priceToValidate = '42.50'; + + $integerParam = new PriceParam($priceValidator, 'EUR'); + + $expected = 0; + $actual = $integerParam->compareTo($priceToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\Parameter\PriceParam::compareTo + * @expectedException InvalidArgumentException + */ + public function testInvalidArgumentException2() + { + $priceValidator = 42.50; + $priceToValidate = -1; + + $integerParam = new PriceParam($priceValidator, 'EUR'); + + $expected = 0; + $actual = $integerParam->compareTo($priceToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\Parameter\PriceParam::compareTo + * @expectedException InvalidArgumentException + */ + public function testInvalidArgumentException3() + { + $priceValidator = 42.50; + $priceToValidate = 0; + + $integerParam = new PriceParam($priceValidator, 'EUR'); + + $expected = 0; + $actual = $integerParam->compareTo($priceToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\Parameter\PriceParam::compareTo + * @expectedException InvalidArgumentException + */ + public function testInvalidArgumentException4() + { + $priceValidator = 42.50; + $priceToValidate = 1; + + $integerParam = new PriceParam($priceValidator, 'EUR'); + + $expected = 0; + $actual = $integerParam->compareTo($priceToValidate); + $this->assertEquals($expected, $actual); + } + + + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + +} diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php new file mode 100644 index 000000000..c7ee0d915 --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php @@ -0,0 +1,161 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon; + +use InvalidArgumentException; +use Thelia\Coupon\Parameter\QuantityParam; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class QuantityParamTest extends \PHPUnit_Framework_TestCase +{ + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + } + + /** + * + * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo + * + */ + public function testInferiorQuantity() + { + $intValidator = 42; + $intToValidate = 0; + + $integerParam = new QuantityParam($intValidator); + + $expected = 1; + $actual = $integerParam->compareTo($intToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo + * + */ + public function testInferiorQuantity2() + { + $intValidator = 42; + $intToValidate = 41; + + $integerParam = new QuantityParam($intValidator); + + $expected = 1; + $actual = $integerParam->compareTo($intToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo + * + */ + public function testEqualsQuantity() + { + $intValidator = 42; + $intToValidate = 42; + + $integerParam = new QuantityParam($intValidator); + + $expected = 0; + $actual = $integerParam->compareTo($intToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo + * + */ + public function testSuperiorQuantity() + { + $intValidator = 42; + $intToValidate = 43; + + $integerParam = new QuantityParam($intValidator); + + $expected = -1; + $actual = $integerParam->compareTo($intToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo + * @expectedException InvalidArgumentException + */ + public function testInvalidArgumentException() + { + $intValidator = 42; + $intToValidate = '42'; + + $integerParam = new QuantityParam($intValidator); + + $expected = 0; + $actual = $integerParam->compareTo($intToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo + * @expectedException InvalidArgumentException + */ + public function testInvalidArgumentException2() + { + $intValidator = 42; + $intToValidate = -1; + + $integerParam = new QuantityParam($intValidator); + + $expected = 0; + $actual = $integerParam->compareTo($intToValidate); + $this->assertEquals($expected, $actual); + } + + + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + +} diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php index 5d5f1badc..5e0bf033d 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php @@ -1,4 +1,26 @@ . */ +/* */ +/**********************************************************************************/ + namespace Thelia\Coupon; use InvalidArgumentException; @@ -6,7 +28,15 @@ use Symfony\Component\Intl\Exception\NotImplementedException; use Thelia\Coupon\Parameter\RepeatedDateParam; /** - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-08-19 at 18:26:01. + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * */ class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase { diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php index 0783bac3e..6830d5670 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php @@ -1,11 +1,41 @@ . */ +/* */ +/**********************************************************************************/ + namespace Thelia\Coupon; use Symfony\Component\Intl\Exception\NotImplementedException; use Thelia\Coupon\Parameter\RepeatedIntervalParam; /** - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-08-19 at 18:26:01. + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * */ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase { @@ -302,18 +332,36 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testSuperiorDateRepeatEveryMonthFourTime() { - $startDateValidator = new \DateTime("2012-10-08"); + $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-10-19"); $duration = 10; + $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam->setFrom($startDateValidator); + $RepeatedIntervalParam->setDurationInDays($duration); + $RepeatedIntervalParam->repeatEveryMonth(1, 0); + + $expected = -1; + $actual = $RepeatedIntervalParam->compareTo($dateToValidate); + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\Parameter\DateParam::compareTo + * @expectedException InvalidArgumentException + */ + public function testInvalidArgumentException() + { + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = 1377012588; + $duration = 10; + $RepeatedIntervalParam = new RepeatedIntervalParam(); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(1, 4); - $expected = -1; - $actual = $RepeatedIntervalParam->compareTo($dateToValidate); - $this->assertEquals($expected, $actual); + $RepeatedIntervalParam->compareTo($dateToValidate); } /** diff --git a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php new file mode 100644 index 000000000..aaf49e352 --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php @@ -0,0 +1,338 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon; + +use Thelia\Coupon\Parameter\PriceParam; +use Thelia\Coupon\Rule\AvailableForTotalAmount; +use Thelia\Coupon\Rule\Operators; +use Thelia\Exception\InvalidRuleOperatorException; +use Thelia\Exception\InvalidRuleValueException; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase +{ + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + } + + protected function generateValidCouponBaseAdapterMock() + { + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->getMock( + 'CouponBaseAdapter', + array('getCheckoutTotalPrice'), + array() + ); + $stubTheliaAdapter->expects($this->any()) + ->method('getCheckoutTotalPrice') + ->will($this->returnValue(421.23)); + + return $stubTheliaAdapter; + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput + * + */ + public function testValidBackOfficeInput() + { + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => array( + AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, + AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + ) + ); + $validated = array( + AvailableForTotalAmount::PARAM1_PRICE => $stubTheliaAdapter->getCheckoutTotalPrice() + ); + $rule = new AvailableForTotalAmount($validators, $validated); + + $expected = true; + $actual = $rule->checkBackOfficeInput(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput + * @expectedException \Thelia\Exception\InvalidRuleOperatorException + * + */ + public function testInValidBackOfficeInputOperator() + { + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => array( + AvailableForTotalAmount::OPERATOR => 'X', + AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + ) + ); + + $validated = array( + AvailableForTotalAmount::PARAM1_PRICE => $stubTheliaAdapter->getCheckoutTotalPrice() + ); + $rule = new AvailableForTotalAmount($validators, $validated); + + $expected = false; + $actual = $rule->checkBackOfficeInput(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput + * @expectedException \Thelia\Exception\InvalidRuleValueException + * + */ + public function testInValidBackOfficeInputValue() + { + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => array( + AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, + AvailableForTotalAmount::VALUE => 421 + ) + ); + + $validated = array( + AvailableForTotalAmount::PARAM1_PRICE => $stubTheliaAdapter->getCheckoutTotalPrice() + ); + $rule = new AvailableForTotalAmount($validators, $validated); + + $expected = false; + $actual = $rule->checkBackOfficeInput(); + $this->assertEquals($expected, $actual); + } + + + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkCheckoutInput + * + */ + public function testValidCheckoutInput() + { + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => array( + AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, + AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + ) + ); + + $validated = array( + AvailableForTotalAmount::PARAM1_PRICE => $stubTheliaAdapter->getCheckoutTotalPrice() + ); + $rule = new AvailableForTotalAmount($validators, $validated); + + $expected = true; + $actual = $rule->checkCheckoutInput(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkCheckoutInput + * @expectedException \Thelia\Exception\InvalidRuleValueException + * + */ + public function testInValidCheckoutInputValue() + { + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => array( + AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, + AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + ) + ); + + $validated = array( + AvailableForTotalAmount::PARAM1_PRICE => 421 + ); + $rule = new AvailableForTotalAmount($validators, $validated); + + $expected = false; + $actual = $rule->checkCheckoutInput(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkCheckoutInput + * @expectedException \Thelia\Exception\InvalidRuleValueException + * + */ + public function testInValidCheckoutInputType() + { + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => array( + AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, + AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + ) + ); + + $validated = array( + AvailableForTotalAmount::PARAM1_PRICE => 421 + ); + $rule = new AvailableForTotalAmount($validators, $validated); + + $expected = false; + $actual = $rule->checkCheckoutInput(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::isMatching + * + */ + public function testMatchingRuleEqual() + { + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => array( + AvailableForTotalAmount::OPERATOR => Operators::EQUAL, + AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + ) + ); + + $validated = array( + AvailableForTotalAmount::PARAM1_PRICE => $stubTheliaAdapter->getCheckoutTotalPrice() + ); + $rule = new AvailableForTotalAmount($validators, $validated); + + $expected = true; + $actual = $rule->isMatching(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::isMatching + * + */ + public function testNotMatchingRuleEqual() + { + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => array( + AvailableForTotalAmount::OPERATOR => Operators::EQUAL, + AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + ) + ); + + $validated = array( + AvailableForTotalAmount::PARAM1_PRICE => 421.22 + ); + $rule = new AvailableForTotalAmount($validators, $validated); + + $expected = false; + $actual = $rule->isMatching(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::isMatching + * + */ + public function testMatchingRuleSuperior() + { + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => array( + AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, + AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + ) + ); + + $validated = array( + AvailableForTotalAmount::PARAM1_PRICE => 421.24 + ); + $rule = new AvailableForTotalAmount($validators, $validated); + + $expected = true; + $actual = $rule->isMatching(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::isMatching + * + */ + public function testNotMatchingRuleSuperior() + { + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => array( + AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, + AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + ) + ); + + $validated = array( + AvailableForTotalAmount::PARAM1_PRICE => 421.23 + ); + $rule = new AvailableForTotalAmount($validators, $validated); + + $expected = false; + $actual = $rule->isMatching(); + $this->assertEquals($expected, $actual); + } + + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + +} diff --git a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php index cb0b59853..2110f76bb 100644 --- a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php +++ b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php @@ -1,10 +1,40 @@ . */ +/* */ +/**********************************************************************************/ + namespace Thelia\Coupon; use Thelia\Coupon\Rule\AvailableForXArticles; /** - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-08-19 at 18:26:01. + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * */ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase { @@ -19,70 +49,70 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase protected function generateValidCouponBaseAdapterMock() { - /** @var CouponAdapterInterface $stubTheliaAdapater */ - $stubTheliaAdapater = $this->getMock( + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->getMock( 'CouponBaseAdapter', array('getNbArticlesInTheCart'), array() ); - $stubTheliaAdapater->expects($this->any()) + $stubTheliaAdapter->expects($this->any()) ->method('getNbArticlesInTheCart') ->will($this->returnValue(4)); - return $stubTheliaAdapater; + return $stubTheliaAdapter; } /** * - * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeIntput + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput * */ public function testValidBackOfficeInput() { - /** @var CouponAdapterInterface $stubTheliaAdapater */ - $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(4); - $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = true; - $actual = $rule->checkBackOfficeIntput(); + $actual = $rule->checkBackOfficeInput(); $this->assertEquals($expected, $actual); } /** * - * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeIntput + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput * */ public function testInValidBackOfficeInput() { - /** @var CouponAdapterInterface $stubTheliaAdapater */ - $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(4.5); - $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; - $actual = $rule->checkBackOfficeIntput(); + $actual = $rule->checkBackOfficeInput(); $this->assertEquals($expected, $actual); $validators = array(-1); - $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; - $actual = $rule->checkBackOfficeIntput(); + $actual = $rule->checkBackOfficeInput(); $this->assertEquals($expected, $actual); $validators = array('bad'); - $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; - $actual = $rule->checkBackOfficeIntput(); + $actual = $rule->checkBackOfficeInput(); $this->assertEquals($expected, $actual); } @@ -95,11 +125,11 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ public function testValidCheckoutInput() { - /** @var CouponAdapterInterface $stubTheliaAdapater */ - $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(4); - $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = true; @@ -114,11 +144,11 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ public function testInValidCheckoutInput() { - /** @var CouponAdapterInterface $stubTheliaAdapater */ - $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(4.5); - $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; @@ -126,7 +156,7 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); $validators = array(-1); - $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; @@ -134,7 +164,7 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); $validators = array('bad'); - $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; @@ -149,11 +179,11 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleEqual() { - /** @var CouponAdapterInterface $stubTheliaAdapater */ - $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(4); - $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = true; @@ -168,11 +198,11 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleSuperior() { - /** @var CouponAdapterInterface $stubTheliaAdapater */ - $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(5); - $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = true; @@ -187,11 +217,11 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRule() { - /** @var CouponAdapterInterface $stubTheliaAdapater */ - $stubTheliaAdapater = $this->generateValidCouponBaseAdapterMock(); + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(3); - $validated = array($stubTheliaAdapater->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; diff --git a/core/lib/Thelia/Tests/Coupon/Rule/OperatorTest.php b/core/lib/Thelia/Tests/Coupon/Rule/OperatorTest.php new file mode 100644 index 000000000..2fbf6f339 --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/Rule/OperatorTest.php @@ -0,0 +1,403 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon; + +use Thelia\Coupon\Parameter\QuantityParam; +use Thelia\Coupon\Rule\Operators; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class OperatorTest extends \PHPUnit_Framework_TestCase +{ + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorInferiorValidBefore() + { + // Given + $a = 11; + $operator = Operators::INFERIOR; + $b = new QuantityParam(12); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertTrue($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorInferiorInvalidEquals() + { + // Given + $a = 12; + $operator = Operators::INFERIOR; + $b = new QuantityParam(12); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertFalse($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorInferiorInvalidAfter() + { + // Given + $a = 13; + $operator = Operators::INFERIOR; + $b = new QuantityParam(12); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertFalse($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorInferiorOrEqualValidEqual() + { + // Given + $a = 11; + $operator = Operators::INFERIOR_OR_EQUAL; + $b = new QuantityParam(11); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertTrue($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorInferiorOrEqualValidBefore() + { + // Given + $a = 10; + $operator = Operators::INFERIOR_OR_EQUAL; + $b = new QuantityParam(11); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertTrue($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorInferiorOrEqualInValidAfter() + { + // Given + $a = 12; + $operator = Operators::INFERIOR_OR_EQUAL; + $b = new QuantityParam(11); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertFalse($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorEqualValidEqual() + { + // Given + $a = 12; + $operator = Operators::EQUAL; + $b = new QuantityParam(12); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertTrue($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorEqualInValidBefore() + { + // Given + $a = 11; + $operator = Operators::EQUAL; + $b = new QuantityParam(12); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertFalse($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorEqualInValidAfter() + { + // Given + $a = 13; + $operator = Operators::EQUAL; + $b = new QuantityParam(12); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertFalse($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorSuperiorOrEqualValidEqual() + { + // Given + $a = 13; + $operator = Operators::SUPERIOR_OR_EQUAL; + $b = new QuantityParam(13); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertTrue($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorSuperiorOrEqualAfter() + { + // Given + $a = 14; + $operator = Operators::SUPERIOR_OR_EQUAL; + $b = new QuantityParam(13); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertTrue($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorSuperiorOrEqualInvalidBefore() + { + // Given + $a = 12; + $operator = Operators::SUPERIOR_OR_EQUAL; + $b = new QuantityParam(13); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertFalse($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorSuperiorValidAfter() + { + // Given + $a = 13; + $operator = Operators::SUPERIOR; + $b = new QuantityParam(12); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertTrue($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorSuperiorInvalidEqual() + { + // Given + $a = 12; + $operator = Operators::SUPERIOR; + $b = new QuantityParam(12); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertFalse($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorSuperiorInvalidBefore() + { + // Given + $a = 11; + $operator = Operators::SUPERIOR; + $b = new QuantityParam(12); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertFalse($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorDifferentValid() + { + // Given + $a = 12; + $operator = Operators::DIFFERENT; + $b = new QuantityParam(11); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertTrue($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorDifferentInvalidEquals() + { + // Given + $a = 11; + $operator = Operators::DIFFERENT; + $b = new QuantityParam(11); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertFalse($actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator + * + */ + public function testOperatorInValid() + { + // Given + $a = 12; + $operator = 'X'; + $b = new QuantityParam(11); + + // When + $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + + // Then + $this->assertFalse($actual); + } + + + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + +} diff --git a/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php b/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php index e892a7b79..5c8dfc983 100644 --- a/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php +++ b/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php @@ -1,8 +1,38 @@ . */ +/* */ +/**********************************************************************************/ + namespace Thelia\Coupon; /** - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-08-19 at 18:27:07. + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * */ class RuleOrganizerTest extends \PHPUnit_Framework_TestCase { diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php index ed8a57833..0178bae10 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php @@ -1,8 +1,38 @@ . */ +/* */ +/**********************************************************************************/ + namespace Thelia\Coupon; /** - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-08-19 at 18:26:01. + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * */ class RemoveXAmountForCategoryYTest extends \PHPUnit_Framework_TestCase { diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php index 27d0e9afb..f9e765b35 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php @@ -1,13 +1,45 @@ . */ +/* */ +/**********************************************************************************/ + namespace Thelia\Coupon; -use PHPUnit_Framework_TestCase; +use Thelia\Coupon\Parameter\PriceParam; +use Thelia\Coupon\Rule\AvailableForTotalAmount; +use Thelia\Coupon\Rule\Operators; use Thelia\Coupon\Type\RemoveXAmount; /** - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-08-19 at 18:26:01. + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * */ -class RemoveXAmountTest extends PHPUnit_Framework_TestCase +class RemoveXAmountTest extends \PHPUnit_Framework_TestCase { CONST VALID_COUPON_CODE = 'XMAS'; @@ -159,6 +191,212 @@ class RemoveXAmountTest extends PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); } + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::addRule + * @covers Thelia\Coupon\type\RemoveXAmount::getRules + * + */ + public function testAddRuleValid() + { + // Given + $rule1 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + Operators::INFERIOR, + 100.23 + ); + $rule2 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + Operators::SUPERIOR, + 421.23 + ); + + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + // When + $coupon->addRule($rule1) + ->addRule($rule2); + + // Then + $expected = 2; + $this->assertCount($expected, $coupon->getRules()); + } + + + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::setRules + * @covers Thelia\Coupon\type\RemoveXAmount::getRules + * + */ + public function testSetRulesValid() + { + // Given + $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + Operators::EQUAL, + 20.00 + ); + $rule1 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + Operators::INFERIOR, + 100.23 + ); + $rule2 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + Operators::SUPERIOR, + 421.23 + ); + + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + // When + $coupon->addRule($rule0) + ->setRules(array($rule1, $rule2)); + + + // Then + $expected = 2; + $this->assertCount($expected, $coupon->getRules()); + } + + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::setRules + * @expectedException \Thelia\Exception\InvalidRuleException + * + */ + public function testSetRulesInvalid() + { + // Given + $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + Operators::EQUAL, + 20.00 + ); + $rule1 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + Operators::INFERIOR, + 100.23 + ); + $rule2 = $this; + + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + // When + $coupon->addRule($rule0) + ->setRules(array($rule1, $rule2)); + } + + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::getEffect + * + */ + public function testGetEffectIfTotalAmountInferiorTo400Valid() + { + // Given + $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + Operators::INFERIOR, + 400.00 + ); + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + // When + $coupon->addRule($rule0); + + // Then + $expected = -30.00; + $actual = $coupon->getEffect(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::getEffect + * + */ + public function testGetEffectIfTotalAmountInferiorOrEqualTo400Valid() + { + // Given + $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + Operators::INFERIOR_OR_EQUAL, + 400.00 + ); + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + // When + $coupon->addRule($rule0); + + // Then + $expected = -30.00; + $actual = $coupon->getEffect(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::getEffect + * + */ + public function testGetEffectIfTotalAmountEqualTo400Valid() + { + // Given + $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + Operators::EQUAL, + 400.00 + ); + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + // When + $coupon->addRule($rule0); + + // Then + $expected = -30.00; + $actual = $coupon->getEffect(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::getEffect + * + */ + public function testGetEffectIfTotalAmountSuperiorOrEqualTo400Valid() + { + // Given + $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + Operators::SUPERIOR_OR_EQUAL, + 400.00 + ); + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + // When + $coupon->addRule($rule0); + + // Then + $expected = -30.00; + $actual = $coupon->getEffect(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\type\RemoveXAmount::getEffect + * + */ + public function testGetEffectIfTotalAmountSuperiorTo400Valid() + { + // Given + $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + Operators::SUPERIOR, + 400.00 + ); + $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + + // When + $coupon->addRule($rule0); + + // Then + $expected = -30.00; + $actual = $coupon->getEffect(); + $this->assertEquals($expected, $actual); + } + + /** * Tears down the fixture, for example, closes a network connection. @@ -168,4 +406,25 @@ class RemoveXAmountTest extends PHPUnit_Framework_TestCase { } + /** + * Generate valid rule AvailableForTotalAmount + * according to given operator and amount + * + * @param string $operator Operators::CONST + * @param float $amount Amount with 2 decimals + * + * @return AvailableForTotalAmount + */ + protected function generateValideRuleAvailableForTotalAmountOperatorTo($operator, $amount) + { + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => array( + AvailableForTotalAmount::OPERATOR => $operator, + AvailableForTotalAmount::VALUE => new PriceParam($amount, 'EUR') + ) + ); + + return new AvailableForTotalAmount($validators); + } + } diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php index f2e36d0bb..39533d62b 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php @@ -1,8 +1,38 @@ . */ +/* */ +/**********************************************************************************/ + namespace Thelia\Coupon; /** - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-08-19 at 18:26:01. + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * */ class RemoveXPercenForCategoryYTest extends \PHPUnit_Framework_TestCase { diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php index 33372cdb2..a2dd87f62 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php @@ -1,11 +1,41 @@ . */ +/* */ +/**********************************************************************************/ + namespace Thelia\Coupon; use PHPUnit_Framework_TestCase; use Thelia\Coupon\Type\RemoveXPercent; /** - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-08-19 at 18:26:01. + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when a Rule receive an invalid Parameter + * + * @package Coupon + * @author Guillaume MOREL + * */ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase { From fab9d2f39a4d77a1834a7c835693df4095592d1a Mon Sep 17 00:00:00 2001 From: gmorel Date: Thu, 22 Aug 2013 14:25:03 +0200 Subject: [PATCH 018/268] WIP Coupon Update Propel2 schema.xml --- local/config/schema.xml | 2173 +++++++++++++++++++-------------------- 1 file changed, 1085 insertions(+), 1088 deletions(-) diff --git a/local/config/schema.xml b/local/config/schema.xml index 59ef62cb9..062e778ad 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1,1089 +1,1086 @@ - + -
    - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - -
    - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - -
    - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - -
    - - - - - - - - - - - - - -
    - - - - - - - - - - - - -
    - - - - - - - - -
    - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + +
    + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + +
    + + + + + + + + + + + +
    + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + \ No newline at end of file From 1734ed1c1f076186611ba8bf99c15dbb2b1e044b Mon Sep 17 00:00:00 2001 From: gmorel Date: Thu, 22 Aug 2013 14:50:38 +0200 Subject: [PATCH 019/268] WIP Coupon Update Coupon Model + SQL en_US changed to en_EN ? --- core/lib/Thelia/Model/Base/Attribute.php | 10 +- core/lib/Thelia/Model/Base/AttributeAv.php | 10 +- .../lib/Thelia/Model/Base/AttributeAvI18n.php | 6 +- .../Thelia/Model/Base/AttributeAvQuery.php | 6 +- core/lib/Thelia/Model/Base/AttributeI18n.php | 6 +- core/lib/Thelia/Model/Base/AttributeQuery.php | 6 +- core/lib/Thelia/Model/Base/Category.php | 10 +- .../Thelia/Model/Base/CategoryDocument.php | 10 +- .../Model/Base/CategoryDocumentI18n.php | 6 +- .../Model/Base/CategoryDocumentQuery.php | 6 +- core/lib/Thelia/Model/Base/CategoryI18n.php | 6 +- core/lib/Thelia/Model/Base/CategoryImage.php | 10 +- .../Thelia/Model/Base/CategoryImageI18n.php | 6 +- .../Thelia/Model/Base/CategoryImageQuery.php | 6 +- core/lib/Thelia/Model/Base/CategoryQuery.php | 6 +- core/lib/Thelia/Model/Base/Config.php | 10 +- core/lib/Thelia/Model/Base/ConfigI18n.php | 6 +- core/lib/Thelia/Model/Base/ConfigQuery.php | 6 +- core/lib/Thelia/Model/Base/Content.php | 10 +- .../lib/Thelia/Model/Base/ContentDocument.php | 10 +- .../Thelia/Model/Base/ContentDocumentI18n.php | 6 +- .../Model/Base/ContentDocumentQuery.php | 6 +- core/lib/Thelia/Model/Base/ContentI18n.php | 6 +- core/lib/Thelia/Model/Base/ContentImage.php | 10 +- .../Thelia/Model/Base/ContentImageI18n.php | 6 +- .../Thelia/Model/Base/ContentImageQuery.php | 6 +- core/lib/Thelia/Model/Base/ContentQuery.php | 6 +- core/lib/Thelia/Model/Base/Country.php | 10 +- core/lib/Thelia/Model/Base/CountryI18n.php | 6 +- core/lib/Thelia/Model/Base/CountryQuery.php | 6 +- core/lib/Thelia/Model/Base/Coupon.php | 1841 ++++++++++++++--- core/lib/Thelia/Model/Base/CouponOrder.php | 79 + .../Thelia/Model/Base/CouponOrderQuery.php | 79 + core/lib/Thelia/Model/Base/CouponQuery.php | 661 ++++-- core/lib/Thelia/Model/Base/Currency.php | 10 +- core/lib/Thelia/Model/Base/CurrencyI18n.php | 6 +- core/lib/Thelia/Model/Base/CurrencyQuery.php | 6 +- core/lib/Thelia/Model/Base/CustomerTitle.php | 10 +- .../Thelia/Model/Base/CustomerTitleI18n.php | 6 +- .../Thelia/Model/Base/CustomerTitleQuery.php | 6 +- core/lib/Thelia/Model/Base/Feature.php | 10 +- core/lib/Thelia/Model/Base/FeatureAv.php | 10 +- core/lib/Thelia/Model/Base/FeatureAvI18n.php | 6 +- core/lib/Thelia/Model/Base/FeatureAvQuery.php | 6 +- core/lib/Thelia/Model/Base/FeatureI18n.php | 6 +- core/lib/Thelia/Model/Base/FeatureQuery.php | 6 +- core/lib/Thelia/Model/Base/Folder.php | 10 +- core/lib/Thelia/Model/Base/FolderDocument.php | 10 +- .../Thelia/Model/Base/FolderDocumentI18n.php | 6 +- .../Thelia/Model/Base/FolderDocumentQuery.php | 6 +- core/lib/Thelia/Model/Base/FolderI18n.php | 6 +- core/lib/Thelia/Model/Base/FolderImage.php | 10 +- .../lib/Thelia/Model/Base/FolderImageI18n.php | 6 +- .../Thelia/Model/Base/FolderImageQuery.php | 6 +- core/lib/Thelia/Model/Base/FolderQuery.php | 6 +- core/lib/Thelia/Model/Base/Group.php | 10 +- core/lib/Thelia/Model/Base/GroupI18n.php | 6 +- core/lib/Thelia/Model/Base/GroupQuery.php | 6 +- core/lib/Thelia/Model/Base/Message.php | 10 +- core/lib/Thelia/Model/Base/MessageI18n.php | 6 +- core/lib/Thelia/Model/Base/MessageQuery.php | 6 +- core/lib/Thelia/Model/Base/Module.php | 10 +- core/lib/Thelia/Model/Base/ModuleI18n.php | 6 +- core/lib/Thelia/Model/Base/ModuleQuery.php | 6 +- core/lib/Thelia/Model/Base/Order.php | 25 + core/lib/Thelia/Model/Base/OrderStatus.php | 10 +- .../lib/Thelia/Model/Base/OrderStatusI18n.php | 6 +- .../Thelia/Model/Base/OrderStatusQuery.php | 6 +- core/lib/Thelia/Model/Base/Product.php | 10 +- .../lib/Thelia/Model/Base/ProductDocument.php | 10 +- .../Thelia/Model/Base/ProductDocumentI18n.php | 6 +- .../Model/Base/ProductDocumentQuery.php | 6 +- core/lib/Thelia/Model/Base/ProductI18n.php | 6 +- core/lib/Thelia/Model/Base/ProductImage.php | 10 +- .../Thelia/Model/Base/ProductImageI18n.php | 6 +- .../Thelia/Model/Base/ProductImageQuery.php | 6 +- core/lib/Thelia/Model/Base/ProductQuery.php | 6 +- core/lib/Thelia/Model/Base/Resource.php | 10 +- core/lib/Thelia/Model/Base/ResourceI18n.php | 6 +- core/lib/Thelia/Model/Base/ResourceQuery.php | 6 +- core/lib/Thelia/Model/Base/Tax.php | 10 +- core/lib/Thelia/Model/Base/TaxI18n.php | 6 +- core/lib/Thelia/Model/Base/TaxQuery.php | 6 +- core/lib/Thelia/Model/Base/TaxRule.php | 10 +- core/lib/Thelia/Model/Base/TaxRuleI18n.php | 6 +- core/lib/Thelia/Model/Base/TaxRuleQuery.php | 6 +- .../Model/Map/AttributeAvI18nTableMap.php | 2 +- .../Thelia/Model/Map/AttributeAvTableMap.php | 2 +- .../Model/Map/AttributeI18nTableMap.php | 2 +- .../Thelia/Model/Map/AttributeTableMap.php | 2 +- .../Map/CategoryDocumentI18nTableMap.php | 2 +- .../Model/Map/CategoryDocumentTableMap.php | 2 +- .../Thelia/Model/Map/CategoryI18nTableMap.php | 2 +- .../Model/Map/CategoryImageI18nTableMap.php | 2 +- .../Model/Map/CategoryImageTableMap.php | 2 +- .../lib/Thelia/Model/Map/CategoryTableMap.php | 2 +- .../Thelia/Model/Map/ConfigI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ConfigTableMap.php | 2 +- .../Model/Map/ContentDocumentI18nTableMap.php | 2 +- .../Model/Map/ContentDocumentTableMap.php | 2 +- .../Thelia/Model/Map/ContentI18nTableMap.php | 2 +- .../Model/Map/ContentImageI18nTableMap.php | 2 +- .../Thelia/Model/Map/ContentImageTableMap.php | 2 +- core/lib/Thelia/Model/Map/ContentTableMap.php | 2 +- .../Thelia/Model/Map/CountryI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/CountryTableMap.php | 2 +- .../Thelia/Model/Map/CouponOrderTableMap.php | 3 +- core/lib/Thelia/Model/Map/CouponTableMap.php | 128 +- .../Thelia/Model/Map/CurrencyI18nTableMap.php | 2 +- .../lib/Thelia/Model/Map/CurrencyTableMap.php | 2 +- .../Model/Map/CustomerTitleI18nTableMap.php | 2 +- .../Model/Map/CustomerTitleTableMap.php | 2 +- .../Model/Map/FeatureAvI18nTableMap.php | 2 +- .../Thelia/Model/Map/FeatureAvTableMap.php | 2 +- .../Thelia/Model/Map/FeatureI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/FeatureTableMap.php | 2 +- .../Model/Map/FolderDocumentI18nTableMap.php | 2 +- .../Model/Map/FolderDocumentTableMap.php | 2 +- .../Thelia/Model/Map/FolderI18nTableMap.php | 2 +- .../Model/Map/FolderImageI18nTableMap.php | 2 +- .../Thelia/Model/Map/FolderImageTableMap.php | 2 +- core/lib/Thelia/Model/Map/FolderTableMap.php | 2 +- .../Thelia/Model/Map/GroupI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/GroupTableMap.php | 2 +- .../Thelia/Model/Map/MessageI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/MessageTableMap.php | 2 +- .../Thelia/Model/Map/ModuleI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ModuleTableMap.php | 2 +- .../Model/Map/OrderStatusI18nTableMap.php | 2 +- .../Thelia/Model/Map/OrderStatusTableMap.php | 2 +- .../Model/Map/ProductDocumentI18nTableMap.php | 2 +- .../Model/Map/ProductDocumentTableMap.php | 2 +- .../Thelia/Model/Map/ProductI18nTableMap.php | 2 +- .../Model/Map/ProductImageI18nTableMap.php | 2 +- .../Thelia/Model/Map/ProductImageTableMap.php | 2 +- core/lib/Thelia/Model/Map/ProductTableMap.php | 2 +- .../Thelia/Model/Map/ResourceI18nTableMap.php | 2 +- .../lib/Thelia/Model/Map/ResourceTableMap.php | 2 +- core/lib/Thelia/Model/Map/TaxI18nTableMap.php | 2 +- .../Thelia/Model/Map/TaxRuleI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/TaxRuleTableMap.php | 2 +- core/lib/Thelia/Model/Map/TaxTableMap.php | 2 +- install/thelia.sql | 144 +- 143 files changed, 2772 insertions(+), 890 deletions(-) diff --git a/core/lib/Thelia/Model/Base/Attribute.php b/core/lib/Thelia/Model/Base/Attribute.php index efe4a631d..2f04404d4 100644 --- a/core/lib/Thelia/Model/Base/Attribute.php +++ b/core/lib/Thelia/Model/Base/Attribute.php @@ -132,7 +132,7 @@ abstract class Attribute implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -2554,7 +2554,7 @@ abstract class Attribute implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collAttributeAvs instanceof Collection) { @@ -2612,7 +2612,7 @@ abstract class Attribute implements ActiveRecordInterface * * @return ChildAttribute The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2636,7 +2636,7 @@ abstract class Attribute implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildAttributeI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collAttributeI18ns) { @@ -2671,7 +2671,7 @@ abstract class Attribute implements ActiveRecordInterface * * @return ChildAttribute The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildAttributeI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/AttributeAv.php b/core/lib/Thelia/Model/Base/AttributeAv.php index 43a1be294..ab39577bd 100644 --- a/core/lib/Thelia/Model/Base/AttributeAv.php +++ b/core/lib/Thelia/Model/Base/AttributeAv.php @@ -122,7 +122,7 @@ abstract class AttributeAv implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1903,7 +1903,7 @@ abstract class AttributeAv implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collAttributeCombinations instanceof Collection) { @@ -1950,7 +1950,7 @@ abstract class AttributeAv implements ActiveRecordInterface * * @return ChildAttributeAv The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1974,7 +1974,7 @@ abstract class AttributeAv implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildAttributeAvI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collAttributeAvI18ns) { @@ -2009,7 +2009,7 @@ abstract class AttributeAv implements ActiveRecordInterface * * @return ChildAttributeAv The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildAttributeAvI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/AttributeAvI18n.php b/core/lib/Thelia/Model/Base/AttributeAvI18n.php index 3e7b9afcd..bcd1c7453 100644 --- a/core/lib/Thelia/Model/Base/AttributeAvI18n.php +++ b/core/lib/Thelia/Model/Base/AttributeAvI18n.php @@ -61,7 +61,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/AttributeAvQuery.php b/core/lib/Thelia/Model/Base/AttributeAvQuery.php index 8ebfaa8c9..4f724b4f4 100644 --- a/core/lib/Thelia/Model/Base/AttributeAvQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeAvQuery.php @@ -841,7 +841,7 @@ abstract class AttributeAvQuery extends ModelCriteria * * @return ChildAttributeAvQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'AttributeAvI18n'; @@ -859,7 +859,7 @@ abstract class AttributeAvQuery extends ModelCriteria * * @return ChildAttributeAvQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -880,7 +880,7 @@ abstract class AttributeAvQuery extends ModelCriteria * * @return ChildAttributeAvI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/AttributeI18n.php b/core/lib/Thelia/Model/Base/AttributeI18n.php index 0e4a1db8f..b8865769c 100644 --- a/core/lib/Thelia/Model/Base/AttributeI18n.php +++ b/core/lib/Thelia/Model/Base/AttributeI18n.php @@ -61,7 +61,7 @@ abstract class AttributeI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class AttributeI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class AttributeI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/AttributeQuery.php b/core/lib/Thelia/Model/Base/AttributeQuery.php index cabbaf7ac..cbb690efb 100644 --- a/core/lib/Thelia/Model/Base/AttributeQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeQuery.php @@ -886,7 +886,7 @@ abstract class AttributeQuery extends ModelCriteria * * @return ChildAttributeQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'AttributeI18n'; @@ -904,7 +904,7 @@ abstract class AttributeQuery extends ModelCriteria * * @return ChildAttributeQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -925,7 +925,7 @@ abstract class AttributeQuery extends ModelCriteria * * @return ChildAttributeI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php index 85a77a061..2f05de899 100644 --- a/core/lib/Thelia/Model/Base/Category.php +++ b/core/lib/Thelia/Model/Base/Category.php @@ -218,7 +218,7 @@ abstract class Category implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -4822,7 +4822,7 @@ abstract class Category implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collProductCategories instanceof Collection) { @@ -4894,7 +4894,7 @@ abstract class Category implements ActiveRecordInterface * * @return ChildCategory The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -4918,7 +4918,7 @@ abstract class Category implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCategoryI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCategoryI18ns) { @@ -4953,7 +4953,7 @@ abstract class Category implements ActiveRecordInterface * * @return ChildCategory The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCategoryI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CategoryDocument.php b/core/lib/Thelia/Model/Base/CategoryDocument.php index 165bfa492..7225ac46f 100644 --- a/core/lib/Thelia/Model/Base/CategoryDocument.php +++ b/core/lib/Thelia/Model/Base/CategoryDocument.php @@ -120,7 +120,7 @@ abstract class CategoryDocument implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1640,7 +1640,7 @@ abstract class CategoryDocument implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collCategoryDocumentI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class CategoryDocument implements ActiveRecordInterface * * @return ChildCategoryDocument The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class CategoryDocument implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCategoryDocumentI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCategoryDocumentI18ns) { @@ -1742,7 +1742,7 @@ abstract class CategoryDocument implements ActiveRecordInterface * * @return ChildCategoryDocument The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCategoryDocumentI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php b/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php index db3189cc3..f361b3184 100644 --- a/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php @@ -61,7 +61,7 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/CategoryDocumentQuery.php b/core/lib/Thelia/Model/Base/CategoryDocumentQuery.php index 8c0a177ac..239ec6c83 100644 --- a/core/lib/Thelia/Model/Base/CategoryDocumentQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryDocumentQuery.php @@ -797,7 +797,7 @@ abstract class CategoryDocumentQuery extends ModelCriteria * * @return ChildCategoryDocumentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CategoryDocumentI18n'; @@ -815,7 +815,7 @@ abstract class CategoryDocumentQuery extends ModelCriteria * * @return ChildCategoryDocumentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class CategoryDocumentQuery extends ModelCriteria * * @return ChildCategoryDocumentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/CategoryI18n.php b/core/lib/Thelia/Model/Base/CategoryI18n.php index 83d62572d..65fa17063 100644 --- a/core/lib/Thelia/Model/Base/CategoryI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryI18n.php @@ -61,7 +61,7 @@ abstract class CategoryI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class CategoryI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class CategoryI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/CategoryImage.php b/core/lib/Thelia/Model/Base/CategoryImage.php index efde7b64a..17c2007f9 100644 --- a/core/lib/Thelia/Model/Base/CategoryImage.php +++ b/core/lib/Thelia/Model/Base/CategoryImage.php @@ -120,7 +120,7 @@ abstract class CategoryImage implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1640,7 +1640,7 @@ abstract class CategoryImage implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collCategoryImageI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class CategoryImage implements ActiveRecordInterface * * @return ChildCategoryImage The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class CategoryImage implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCategoryImageI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCategoryImageI18ns) { @@ -1742,7 +1742,7 @@ abstract class CategoryImage implements ActiveRecordInterface * * @return ChildCategoryImage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCategoryImageI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CategoryImageI18n.php b/core/lib/Thelia/Model/Base/CategoryImageI18n.php index ce61e9836..e59c4caca 100644 --- a/core/lib/Thelia/Model/Base/CategoryImageI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryImageI18n.php @@ -61,7 +61,7 @@ abstract class CategoryImageI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class CategoryImageI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class CategoryImageI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/CategoryImageQuery.php b/core/lib/Thelia/Model/Base/CategoryImageQuery.php index 2130e757b..305b01755 100644 --- a/core/lib/Thelia/Model/Base/CategoryImageQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryImageQuery.php @@ -797,7 +797,7 @@ abstract class CategoryImageQuery extends ModelCriteria * * @return ChildCategoryImageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CategoryImageI18n'; @@ -815,7 +815,7 @@ abstract class CategoryImageQuery extends ModelCriteria * * @return ChildCategoryImageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class CategoryImageQuery extends ModelCriteria * * @return ChildCategoryImageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/CategoryQuery.php b/core/lib/Thelia/Model/Base/CategoryQuery.php index 0b7df33dd..5a9c1165f 100644 --- a/core/lib/Thelia/Model/Base/CategoryQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryQuery.php @@ -1461,7 +1461,7 @@ abstract class CategoryQuery extends ModelCriteria * * @return ChildCategoryQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CategoryI18n'; @@ -1479,7 +1479,7 @@ abstract class CategoryQuery extends ModelCriteria * * @return ChildCategoryQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1500,7 +1500,7 @@ abstract class CategoryQuery extends ModelCriteria * * @return ChildCategoryI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Config.php b/core/lib/Thelia/Model/Base/Config.php index d687ffefe..140cdb82d 100644 --- a/core/lib/Thelia/Model/Base/Config.php +++ b/core/lib/Thelia/Model/Base/Config.php @@ -121,7 +121,7 @@ abstract class Config implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1642,7 +1642,7 @@ abstract class Config implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collConfigI18ns instanceof Collection) { @@ -1684,7 +1684,7 @@ abstract class Config implements ActiveRecordInterface * * @return ChildConfig The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1708,7 +1708,7 @@ abstract class Config implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildConfigI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collConfigI18ns) { @@ -1743,7 +1743,7 @@ abstract class Config implements ActiveRecordInterface * * @return ChildConfig The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildConfigI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ConfigI18n.php b/core/lib/Thelia/Model/Base/ConfigI18n.php index 6247e15d1..e73e27514 100644 --- a/core/lib/Thelia/Model/Base/ConfigI18n.php +++ b/core/lib/Thelia/Model/Base/ConfigI18n.php @@ -61,7 +61,7 @@ abstract class ConfigI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ConfigI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class ConfigI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ConfigQuery.php b/core/lib/Thelia/Model/Base/ConfigQuery.php index ef47308a4..b2ddc3409 100644 --- a/core/lib/Thelia/Model/Base/ConfigQuery.php +++ b/core/lib/Thelia/Model/Base/ConfigQuery.php @@ -749,7 +749,7 @@ abstract class ConfigQuery extends ModelCriteria * * @return ChildConfigQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ConfigI18n'; @@ -767,7 +767,7 @@ abstract class ConfigQuery extends ModelCriteria * * @return ChildConfigQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -788,7 +788,7 @@ abstract class ConfigQuery extends ModelCriteria * * @return ChildConfigI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Content.php b/core/lib/Thelia/Model/Base/Content.php index 96ea69eef..e8514fc08 100644 --- a/core/lib/Thelia/Model/Base/Content.php +++ b/core/lib/Thelia/Model/Base/Content.php @@ -182,7 +182,7 @@ abstract class Content implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -3720,7 +3720,7 @@ abstract class Content implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collContentAssocs instanceof Collection) { @@ -3790,7 +3790,7 @@ abstract class Content implements ActiveRecordInterface * * @return ChildContent The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -3814,7 +3814,7 @@ abstract class Content implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildContentI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collContentI18ns) { @@ -3849,7 +3849,7 @@ abstract class Content implements ActiveRecordInterface * * @return ChildContent The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildContentI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ContentDocument.php b/core/lib/Thelia/Model/Base/ContentDocument.php index 990fc4a9f..7c974c839 100644 --- a/core/lib/Thelia/Model/Base/ContentDocument.php +++ b/core/lib/Thelia/Model/Base/ContentDocument.php @@ -120,7 +120,7 @@ abstract class ContentDocument implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1640,7 +1640,7 @@ abstract class ContentDocument implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collContentDocumentI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class ContentDocument implements ActiveRecordInterface * * @return ChildContentDocument The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class ContentDocument implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildContentDocumentI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collContentDocumentI18ns) { @@ -1742,7 +1742,7 @@ abstract class ContentDocument implements ActiveRecordInterface * * @return ChildContentDocument The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildContentDocumentI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ContentDocumentI18n.php b/core/lib/Thelia/Model/Base/ContentDocumentI18n.php index 2cfc367b0..e275926c5 100644 --- a/core/lib/Thelia/Model/Base/ContentDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/ContentDocumentI18n.php @@ -61,7 +61,7 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ContentDocumentQuery.php b/core/lib/Thelia/Model/Base/ContentDocumentQuery.php index 89cf5d48b..72cc8cae4 100644 --- a/core/lib/Thelia/Model/Base/ContentDocumentQuery.php +++ b/core/lib/Thelia/Model/Base/ContentDocumentQuery.php @@ -797,7 +797,7 @@ abstract class ContentDocumentQuery extends ModelCriteria * * @return ChildContentDocumentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ContentDocumentI18n'; @@ -815,7 +815,7 @@ abstract class ContentDocumentQuery extends ModelCriteria * * @return ChildContentDocumentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class ContentDocumentQuery extends ModelCriteria * * @return ChildContentDocumentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/ContentI18n.php b/core/lib/Thelia/Model/Base/ContentI18n.php index d3974522b..14ff02b39 100644 --- a/core/lib/Thelia/Model/Base/ContentI18n.php +++ b/core/lib/Thelia/Model/Base/ContentI18n.php @@ -61,7 +61,7 @@ abstract class ContentI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ContentI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class ContentI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ContentImage.php b/core/lib/Thelia/Model/Base/ContentImage.php index 22c4bed10..884c20c1e 100644 --- a/core/lib/Thelia/Model/Base/ContentImage.php +++ b/core/lib/Thelia/Model/Base/ContentImage.php @@ -120,7 +120,7 @@ abstract class ContentImage implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1640,7 +1640,7 @@ abstract class ContentImage implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collContentImageI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class ContentImage implements ActiveRecordInterface * * @return ChildContentImage The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class ContentImage implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildContentImageI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collContentImageI18ns) { @@ -1742,7 +1742,7 @@ abstract class ContentImage implements ActiveRecordInterface * * @return ChildContentImage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildContentImageI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ContentImageI18n.php b/core/lib/Thelia/Model/Base/ContentImageI18n.php index d655dec53..9fe9b4147 100644 --- a/core/lib/Thelia/Model/Base/ContentImageI18n.php +++ b/core/lib/Thelia/Model/Base/ContentImageI18n.php @@ -61,7 +61,7 @@ abstract class ContentImageI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ContentImageI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class ContentImageI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ContentImageQuery.php b/core/lib/Thelia/Model/Base/ContentImageQuery.php index f69464dd7..26e0ffe5c 100644 --- a/core/lib/Thelia/Model/Base/ContentImageQuery.php +++ b/core/lib/Thelia/Model/Base/ContentImageQuery.php @@ -797,7 +797,7 @@ abstract class ContentImageQuery extends ModelCriteria * * @return ChildContentImageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ContentImageI18n'; @@ -815,7 +815,7 @@ abstract class ContentImageQuery extends ModelCriteria * * @return ChildContentImageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class ContentImageQuery extends ModelCriteria * * @return ChildContentImageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/ContentQuery.php b/core/lib/Thelia/Model/Base/ContentQuery.php index 2cbbe109b..28d32cbe6 100644 --- a/core/lib/Thelia/Model/Base/ContentQuery.php +++ b/core/lib/Thelia/Model/Base/ContentQuery.php @@ -1294,7 +1294,7 @@ abstract class ContentQuery extends ModelCriteria * * @return ChildContentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ContentI18n'; @@ -1312,7 +1312,7 @@ abstract class ContentQuery extends ModelCriteria * * @return ChildContentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1333,7 +1333,7 @@ abstract class ContentQuery extends ModelCriteria * * @return ChildContentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Country.php b/core/lib/Thelia/Model/Base/Country.php index 704375de2..3c4247896 100644 --- a/core/lib/Thelia/Model/Base/Country.php +++ b/core/lib/Thelia/Model/Base/Country.php @@ -142,7 +142,7 @@ abstract class Country implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -2323,7 +2323,7 @@ abstract class Country implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collTaxRuleCountries instanceof Collection) { @@ -2374,7 +2374,7 @@ abstract class Country implements ActiveRecordInterface * * @return ChildCountry The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2398,7 +2398,7 @@ abstract class Country implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCountryI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCountryI18ns) { @@ -2433,7 +2433,7 @@ abstract class Country implements ActiveRecordInterface * * @return ChildCountry The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCountryI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CountryI18n.php b/core/lib/Thelia/Model/Base/CountryI18n.php index be63955ca..270a9d3f7 100644 --- a/core/lib/Thelia/Model/Base/CountryI18n.php +++ b/core/lib/Thelia/Model/Base/CountryI18n.php @@ -61,7 +61,7 @@ abstract class CountryI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class CountryI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class CountryI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/CountryQuery.php b/core/lib/Thelia/Model/Base/CountryQuery.php index 6c3a1c950..2c709f800 100644 --- a/core/lib/Thelia/Model/Base/CountryQuery.php +++ b/core/lib/Thelia/Model/Base/CountryQuery.php @@ -972,7 +972,7 @@ abstract class CountryQuery extends ModelCriteria * * @return ChildCountryQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CountryI18n'; @@ -990,7 +990,7 @@ abstract class CountryQuery extends ModelCriteria * * @return ChildCountryQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1011,7 +1011,7 @@ abstract class CountryQuery extends ModelCriteria * * @return ChildCountryI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Coupon.php b/core/lib/Thelia/Model/Base/Coupon.php index 2c3dae5c9..89a4dc9e2 100644 --- a/core/lib/Thelia/Model/Base/Coupon.php +++ b/core/lib/Thelia/Model/Base/Coupon.php @@ -18,10 +18,15 @@ use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Coupon as ChildCoupon; +use Thelia\Model\CouponI18n as ChildCouponI18n; +use Thelia\Model\CouponI18nQuery as ChildCouponI18nQuery; +use Thelia\Model\CouponOrder as ChildCouponOrder; +use Thelia\Model\CouponOrderQuery as ChildCouponOrderQuery; use Thelia\Model\CouponQuery as ChildCouponQuery; -use Thelia\Model\CouponRule as ChildCouponRule; -use Thelia\Model\CouponRuleQuery as ChildCouponRuleQuery; +use Thelia\Model\CouponVersion as ChildCouponVersion; +use Thelia\Model\CouponVersionQuery as ChildCouponVersionQuery; use Thelia\Model\Map\CouponTableMap; +use Thelia\Model\Map\CouponVersionTableMap; abstract class Coupon implements ActiveRecordInterface { @@ -70,10 +75,28 @@ abstract class Coupon implements ActiveRecordInterface protected $code; /** - * The value for the action field. + * The value for the type field. * @var string */ - protected $action; + protected $type; + + /** + * The value for the title field. + * @var string + */ + protected $title; + + /** + * The value for the short_description field. + * @var string + */ + protected $short_description; + + /** + * The value for the description field. + * @var string + */ + protected $description; /** * The value for the value field. @@ -82,28 +105,28 @@ abstract class Coupon implements ActiveRecordInterface protected $value; /** - * The value for the used field. + * The value for the is_used field. * @var int */ - protected $used; + protected $is_used; /** - * The value for the available_since field. - * @var string - */ - protected $available_since; - - /** - * The value for the date_limit field. - * @var string - */ - protected $date_limit; - - /** - * The value for the activate field. + * The value for the is_enabled field. * @var int */ - protected $activate; + protected $is_enabled; + + /** + * The value for the expiration_date field. + * @var string + */ + protected $expiration_date; + + /** + * The value for the serialized_rules field. + * @var string + */ + protected $serialized_rules; /** * The value for the created_at field. @@ -118,10 +141,29 @@ abstract class Coupon implements ActiveRecordInterface protected $updated_at; /** - * @var ObjectCollection|ChildCouponRule[] Collection to store aggregation of ChildCouponRule objects. + * The value for the version field. + * Note: this column has a database default value of: 0 + * @var int */ - protected $collCouponRules; - protected $collCouponRulesPartial; + protected $version; + + /** + * @var ObjectCollection|ChildCouponOrder[] Collection to store aggregation of ChildCouponOrder objects. + */ + protected $collCouponOrders; + protected $collCouponOrdersPartial; + + /** + * @var ObjectCollection|ChildCouponI18n[] Collection to store aggregation of ChildCouponI18n objects. + */ + protected $collCouponI18ns; + protected $collCouponI18nsPartial; + + /** + * @var ObjectCollection|ChildCouponVersion[] Collection to store aggregation of ChildCouponVersion objects. + */ + protected $collCouponVersions; + protected $collCouponVersionsPartial; /** * Flag to prevent endless save loop, if this object is referenced @@ -131,17 +173,64 @@ abstract class Coupon implements ActiveRecordInterface */ protected $alreadyInSave = false; + // i18n behavior + + /** + * Current locale + * @var string + */ + protected $currentLocale = 'en_EN'; + + /** + * Current translation objects + * @var array[ChildCouponI18n] + */ + protected $currentTranslations; + + // versionable behavior + + + /** + * @var bool + */ + protected $enforceVersion = false; + /** * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $couponRulesScheduledForDeletion = null; + protected $couponOrdersScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $couponI18nsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $couponVersionsScheduledForDeletion = null; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->version = 0; + } /** * Initializes internal state of Thelia\Model\Base\Coupon object. + * @see applyDefaults() */ public function __construct() { + $this->applyDefaultValues(); } /** @@ -414,14 +503,47 @@ abstract class Coupon implements ActiveRecordInterface } /** - * Get the [action] column value. + * Get the [type] column value. * * @return string */ - public function getAction() + public function getType() { - return $this->action; + return $this->type; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [short_description] column value. + * + * @return string + */ + public function getShortDescription() + { + + return $this->short_description; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; } /** @@ -436,18 +558,29 @@ abstract class Coupon implements ActiveRecordInterface } /** - * Get the [used] column value. + * Get the [is_used] column value. * * @return int */ - public function getUsed() + public function getIsUsed() { - return $this->used; + return $this->is_used; } /** - * Get the [optionally formatted] temporal [available_since] column value. + * Get the [is_enabled] column value. + * + * @return int + */ + public function getIsEnabled() + { + + return $this->is_enabled; + } + + /** + * Get the [optionally formatted] temporal [expiration_date] column value. * * * @param string $format The date/time format string (either date()-style or strftime()-style). @@ -457,44 +590,24 @@ abstract class Coupon implements ActiveRecordInterface * * @throws PropelException - if unable to parse/validate the date/time value. */ - public function getAvailableSince($format = NULL) + public function getExpirationDate($format = NULL) { if ($format === null) { - return $this->available_since; + return $this->expiration_date; } else { - return $this->available_since !== null ? $this->available_since->format($format) : null; + return $this->expiration_date !== null ? $this->expiration_date->format($format) : null; } } /** - * Get the [optionally formatted] temporal [date_limit] column value. + * Get the [serialized_rules] column value. * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. + * @return string */ - public function getDateLimit($format = NULL) - { - if ($format === null) { - return $this->date_limit; - } else { - return $this->date_limit !== null ? $this->date_limit->format($format) : null; - } - } - - /** - * Get the [activate] column value. - * - * @return int - */ - public function getActivate() + public function getSerializedRules() { - return $this->activate; + return $this->serialized_rules; } /** @@ -537,6 +650,17 @@ abstract class Coupon implements ActiveRecordInterface } } + /** + * Get the [version] column value. + * + * @return int + */ + public function getVersion() + { + + return $this->version; + } + /** * Set the value of [id] column. * @@ -580,25 +704,88 @@ abstract class Coupon implements ActiveRecordInterface } // setCode() /** - * Set the value of [action] column. + * Set the value of [type] column. * * @param string $v new value * @return \Thelia\Model\Coupon The current object (for fluent API support) */ - public function setAction($v) + public function setType($v) { if ($v !== null) { $v = (string) $v; } - if ($this->action !== $v) { - $this->action = $v; - $this->modifiedColumns[] = CouponTableMap::ACTION; + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = CouponTableMap::TYPE; } return $this; - } // setAction() + } // setType() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = CouponTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [short_description] column. + * + * @param string $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setShortDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->short_description !== $v) { + $this->short_description = $v; + $this->modifiedColumns[] = CouponTableMap::SHORT_DESCRIPTION; + } + + + return $this; + } // setShortDescription() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CouponTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() /** * Set the value of [value] column. @@ -622,88 +809,88 @@ abstract class Coupon implements ActiveRecordInterface } // setValue() /** - * Set the value of [used] column. + * Set the value of [is_used] column. * * @param int $v new value * @return \Thelia\Model\Coupon The current object (for fluent API support) */ - public function setUsed($v) + public function setIsUsed($v) { if ($v !== null) { $v = (int) $v; } - if ($this->used !== $v) { - $this->used = $v; - $this->modifiedColumns[] = CouponTableMap::USED; + if ($this->is_used !== $v) { + $this->is_used = $v; + $this->modifiedColumns[] = CouponTableMap::IS_USED; } return $this; - } // setUsed() + } // setIsUsed() /** - * Sets the value of [available_since] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\Coupon The current object (for fluent API support) - */ - public function setAvailableSince($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->available_since !== null || $dt !== null) { - if ($dt !== $this->available_since) { - $this->available_since = $dt; - $this->modifiedColumns[] = CouponTableMap::AVAILABLE_SINCE; - } - } // if either are not null - - - return $this; - } // setAvailableSince() - - /** - * Sets the value of [date_limit] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\Coupon The current object (for fluent API support) - */ - public function setDateLimit($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->date_limit !== null || $dt !== null) { - if ($dt !== $this->date_limit) { - $this->date_limit = $dt; - $this->modifiedColumns[] = CouponTableMap::DATE_LIMIT; - } - } // if either are not null - - - return $this; - } // setDateLimit() - - /** - * Set the value of [activate] column. + * Set the value of [is_enabled] column. * * @param int $v new value * @return \Thelia\Model\Coupon The current object (for fluent API support) */ - public function setActivate($v) + public function setIsEnabled($v) { if ($v !== null) { $v = (int) $v; } - if ($this->activate !== $v) { - $this->activate = $v; - $this->modifiedColumns[] = CouponTableMap::ACTIVATE; + if ($this->is_enabled !== $v) { + $this->is_enabled = $v; + $this->modifiedColumns[] = CouponTableMap::IS_ENABLED; } return $this; - } // setActivate() + } // setIsEnabled() + + /** + * Sets the value of [expiration_date] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setExpirationDate($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->expiration_date !== null || $dt !== null) { + if ($dt !== $this->expiration_date) { + $this->expiration_date = $dt; + $this->modifiedColumns[] = CouponTableMap::EXPIRATION_DATE; + } + } // if either are not null + + + return $this; + } // setExpirationDate() + + /** + * Set the value of [serialized_rules] column. + * + * @param string $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setSerializedRules($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->serialized_rules !== $v) { + $this->serialized_rules = $v; + $this->modifiedColumns[] = CouponTableMap::SERIALIZED_RULES; + } + + + return $this; + } // setSerializedRules() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -747,6 +934,27 @@ abstract class Coupon implements ActiveRecordInterface return $this; } // setUpdatedAt() + /** + * Set the value of [version] column. + * + * @param int $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setVersion($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->version !== $v) { + $this->version = $v; + $this->modifiedColumns[] = CouponTableMap::VERSION; + } + + + return $this; + } // setVersion() + /** * Indicates whether the columns in this object are only set to default values. * @@ -757,6 +965,10 @@ abstract class Coupon implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { + if ($this->version !== 0) { + return false; + } + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -790,41 +1002,50 @@ abstract class Coupon implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CouponTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; $this->code = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponTableMap::translateFieldName('Action', TableMap::TYPE_PHPNAME, $indexType)]; - $this->action = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)]; + $this->type = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponTableMap::translateFieldName('ShortDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->short_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; $this->value = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponTableMap::translateFieldName('Used', TableMap::TYPE_PHPNAME, $indexType)]; - $this->used = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponTableMap::translateFieldName('IsUsed', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_used = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponTableMap::translateFieldName('AvailableSince', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponTableMap::translateFieldName('IsEnabled', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_enabled = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponTableMap::translateFieldName('ExpirationDate', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } - $this->available_since = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->expiration_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponTableMap::translateFieldName('DateLimit', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->date_limit = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponTableMap::translateFieldName('SerializedRules', TableMap::TYPE_PHPNAME, $indexType)]; + $this->serialized_rules = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponTableMap::translateFieldName('Activate', TableMap::TYPE_PHPNAME, $indexType)]; - $this->activate = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; $this->resetModified(); $this->setNew(false); @@ -833,7 +1054,7 @@ abstract class Coupon implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 10; // 10 = CouponTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 14; // 14 = CouponTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Coupon object", 0, $e); @@ -894,7 +1115,11 @@ abstract class Coupon implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->collCouponRules = null; + $this->collCouponOrders = null; + + $this->collCouponI18ns = null; + + $this->collCouponVersions = null; } // if (deep) } @@ -964,6 +1189,11 @@ abstract class Coupon implements ActiveRecordInterface $isInsert = $this->isNew(); try { $ret = $this->preSave($con); + // versionable behavior + if ($this->isVersioningNecessary()) { + $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1); + $createVersion = true; // for postSave hook + } if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior @@ -988,6 +1218,10 @@ abstract class Coupon implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); + // versionable behavior + if (isset($createVersion)) { + $this->addVersion($con); + } CouponTableMap::addInstanceToPool($this); } else { $affectedRows = 0; @@ -1029,17 +1263,51 @@ abstract class Coupon implements ActiveRecordInterface $this->resetModified(); } - if ($this->couponRulesScheduledForDeletion !== null) { - if (!$this->couponRulesScheduledForDeletion->isEmpty()) { - \Thelia\Model\CouponRuleQuery::create() - ->filterByPrimaryKeys($this->couponRulesScheduledForDeletion->getPrimaryKeys(false)) + if ($this->couponOrdersScheduledForDeletion !== null) { + if (!$this->couponOrdersScheduledForDeletion->isEmpty()) { + \Thelia\Model\CouponOrderQuery::create() + ->filterByPrimaryKeys($this->couponOrdersScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->couponRulesScheduledForDeletion = null; + $this->couponOrdersScheduledForDeletion = null; } } - if ($this->collCouponRules !== null) { - foreach ($this->collCouponRules as $referrerFK) { + if ($this->collCouponOrders !== null) { + foreach ($this->collCouponOrders as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->couponI18nsScheduledForDeletion !== null) { + if (!$this->couponI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\CouponI18nQuery::create() + ->filterByPrimaryKeys($this->couponI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->couponI18nsScheduledForDeletion = null; + } + } + + if ($this->collCouponI18ns !== null) { + foreach ($this->collCouponI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->couponVersionsScheduledForDeletion !== null) { + if (!$this->couponVersionsScheduledForDeletion->isEmpty()) { + \Thelia\Model\CouponVersionQuery::create() + ->filterByPrimaryKeys($this->couponVersionsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->couponVersionsScheduledForDeletion = null; + } + } + + if ($this->collCouponVersions !== null) { + foreach ($this->collCouponVersions as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1078,23 +1346,32 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::CODE)) { $modifiedColumns[':p' . $index++] = 'CODE'; } - if ($this->isColumnModified(CouponTableMap::ACTION)) { - $modifiedColumns[':p' . $index++] = 'ACTION'; + if ($this->isColumnModified(CouponTableMap::TYPE)) { + $modifiedColumns[':p' . $index++] = 'TYPE'; + } + if ($this->isColumnModified(CouponTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(CouponTableMap::SHORT_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'SHORT_DESCRIPTION'; + } + if ($this->isColumnModified(CouponTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; } if ($this->isColumnModified(CouponTableMap::VALUE)) { $modifiedColumns[':p' . $index++] = 'VALUE'; } - if ($this->isColumnModified(CouponTableMap::USED)) { - $modifiedColumns[':p' . $index++] = 'USED'; + if ($this->isColumnModified(CouponTableMap::IS_USED)) { + $modifiedColumns[':p' . $index++] = 'IS_USED'; } - if ($this->isColumnModified(CouponTableMap::AVAILABLE_SINCE)) { - $modifiedColumns[':p' . $index++] = 'AVAILABLE_SINCE'; + if ($this->isColumnModified(CouponTableMap::IS_ENABLED)) { + $modifiedColumns[':p' . $index++] = 'IS_ENABLED'; } - if ($this->isColumnModified(CouponTableMap::DATE_LIMIT)) { - $modifiedColumns[':p' . $index++] = 'DATE_LIMIT'; + if ($this->isColumnModified(CouponTableMap::EXPIRATION_DATE)) { + $modifiedColumns[':p' . $index++] = 'EXPIRATION_DATE'; } - if ($this->isColumnModified(CouponTableMap::ACTIVATE)) { - $modifiedColumns[':p' . $index++] = 'ACTIVATE'; + if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES)) { + $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES'; } if ($this->isColumnModified(CouponTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -1102,6 +1379,9 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } + if ($this->isColumnModified(CouponTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; + } $sql = sprintf( 'INSERT INTO coupon (%s) VALUES (%s)', @@ -1119,23 +1399,32 @@ abstract class Coupon implements ActiveRecordInterface case 'CODE': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case 'ACTION': - $stmt->bindValue($identifier, $this->action, PDO::PARAM_STR); + case 'TYPE': + $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'SHORT_DESCRIPTION': + $stmt->bindValue($identifier, $this->short_description, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; case 'VALUE': $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); break; - case 'USED': - $stmt->bindValue($identifier, $this->used, PDO::PARAM_INT); + case 'IS_USED': + $stmt->bindValue($identifier, $this->is_used, PDO::PARAM_INT); break; - case 'AVAILABLE_SINCE': - $stmt->bindValue($identifier, $this->available_since ? $this->available_since->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + case 'IS_ENABLED': + $stmt->bindValue($identifier, $this->is_enabled, PDO::PARAM_INT); break; - case 'DATE_LIMIT': - $stmt->bindValue($identifier, $this->date_limit ? $this->date_limit->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + case 'EXPIRATION_DATE': + $stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case 'ACTIVATE': - $stmt->bindValue($identifier, $this->activate, PDO::PARAM_INT); + case 'SERIALIZED_RULES': + $stmt->bindValue($identifier, $this->serialized_rules, PDO::PARAM_STR); break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); @@ -1143,6 +1432,9 @@ abstract class Coupon implements ActiveRecordInterface case 'UPDATED_AT': $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; + case 'VERSION': + $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); + break; } } $stmt->execute(); @@ -1212,29 +1504,41 @@ abstract class Coupon implements ActiveRecordInterface return $this->getCode(); break; case 2: - return $this->getAction(); + return $this->getType(); break; case 3: - return $this->getValue(); + return $this->getTitle(); break; case 4: - return $this->getUsed(); + return $this->getShortDescription(); break; case 5: - return $this->getAvailableSince(); + return $this->getDescription(); break; case 6: - return $this->getDateLimit(); + return $this->getValue(); break; case 7: - return $this->getActivate(); + return $this->getIsUsed(); break; case 8: - return $this->getCreatedAt(); + return $this->getIsEnabled(); break; case 9: + return $this->getExpirationDate(); + break; + case 10: + return $this->getSerializedRules(); + break; + case 11: + return $this->getCreatedAt(); + break; + case 12: return $this->getUpdatedAt(); break; + case 13: + return $this->getVersion(); + break; default: return null; break; @@ -1266,14 +1570,18 @@ abstract class Coupon implements ActiveRecordInterface $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getCode(), - $keys[2] => $this->getAction(), - $keys[3] => $this->getValue(), - $keys[4] => $this->getUsed(), - $keys[5] => $this->getAvailableSince(), - $keys[6] => $this->getDateLimit(), - $keys[7] => $this->getActivate(), - $keys[8] => $this->getCreatedAt(), - $keys[9] => $this->getUpdatedAt(), + $keys[2] => $this->getType(), + $keys[3] => $this->getTitle(), + $keys[4] => $this->getShortDescription(), + $keys[5] => $this->getDescription(), + $keys[6] => $this->getValue(), + $keys[7] => $this->getIsUsed(), + $keys[8] => $this->getIsEnabled(), + $keys[9] => $this->getExpirationDate(), + $keys[10] => $this->getSerializedRules(), + $keys[11] => $this->getCreatedAt(), + $keys[12] => $this->getUpdatedAt(), + $keys[13] => $this->getVersion(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1282,8 +1590,14 @@ abstract class Coupon implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->collCouponRules) { - $result['CouponRules'] = $this->collCouponRules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collCouponOrders) { + $result['CouponOrders'] = $this->collCouponOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCouponI18ns) { + $result['CouponI18ns'] = $this->collCouponI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCouponVersions) { + $result['CouponVersions'] = $this->collCouponVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1326,29 +1640,41 @@ abstract class Coupon implements ActiveRecordInterface $this->setCode($value); break; case 2: - $this->setAction($value); + $this->setType($value); break; case 3: - $this->setValue($value); + $this->setTitle($value); break; case 4: - $this->setUsed($value); + $this->setShortDescription($value); break; case 5: - $this->setAvailableSince($value); + $this->setDescription($value); break; case 6: - $this->setDateLimit($value); + $this->setValue($value); break; case 7: - $this->setActivate($value); + $this->setIsUsed($value); break; case 8: - $this->setCreatedAt($value); + $this->setIsEnabled($value); break; case 9: + $this->setExpirationDate($value); + break; + case 10: + $this->setSerializedRules($value); + break; + case 11: + $this->setCreatedAt($value); + break; + case 12: $this->setUpdatedAt($value); break; + case 13: + $this->setVersion($value); + break; } // switch() } @@ -1375,14 +1701,18 @@ abstract class Coupon implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setAction($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setValue($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUsed($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setAvailableSince($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDateLimit($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setActivate($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]); + if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setShortDescription($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDescription($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setValue($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setIsUsed($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setIsEnabled($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setExpirationDate($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setSerializedRules($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setCreatedAt($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setUpdatedAt($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setVersion($arr[$keys[13]]); } /** @@ -1396,14 +1726,18 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::ID)) $criteria->add(CouponTableMap::ID, $this->id); if ($this->isColumnModified(CouponTableMap::CODE)) $criteria->add(CouponTableMap::CODE, $this->code); - if ($this->isColumnModified(CouponTableMap::ACTION)) $criteria->add(CouponTableMap::ACTION, $this->action); + if ($this->isColumnModified(CouponTableMap::TYPE)) $criteria->add(CouponTableMap::TYPE, $this->type); + if ($this->isColumnModified(CouponTableMap::TITLE)) $criteria->add(CouponTableMap::TITLE, $this->title); + if ($this->isColumnModified(CouponTableMap::SHORT_DESCRIPTION)) $criteria->add(CouponTableMap::SHORT_DESCRIPTION, $this->short_description); + if ($this->isColumnModified(CouponTableMap::DESCRIPTION)) $criteria->add(CouponTableMap::DESCRIPTION, $this->description); if ($this->isColumnModified(CouponTableMap::VALUE)) $criteria->add(CouponTableMap::VALUE, $this->value); - if ($this->isColumnModified(CouponTableMap::USED)) $criteria->add(CouponTableMap::USED, $this->used); - if ($this->isColumnModified(CouponTableMap::AVAILABLE_SINCE)) $criteria->add(CouponTableMap::AVAILABLE_SINCE, $this->available_since); - if ($this->isColumnModified(CouponTableMap::DATE_LIMIT)) $criteria->add(CouponTableMap::DATE_LIMIT, $this->date_limit); - if ($this->isColumnModified(CouponTableMap::ACTIVATE)) $criteria->add(CouponTableMap::ACTIVATE, $this->activate); + if ($this->isColumnModified(CouponTableMap::IS_USED)) $criteria->add(CouponTableMap::IS_USED, $this->is_used); + if ($this->isColumnModified(CouponTableMap::IS_ENABLED)) $criteria->add(CouponTableMap::IS_ENABLED, $this->is_enabled); + if ($this->isColumnModified(CouponTableMap::EXPIRATION_DATE)) $criteria->add(CouponTableMap::EXPIRATION_DATE, $this->expiration_date); + if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES)) $criteria->add(CouponTableMap::SERIALIZED_RULES, $this->serialized_rules); if ($this->isColumnModified(CouponTableMap::CREATED_AT)) $criteria->add(CouponTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) $criteria->add(CouponTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(CouponTableMap::VERSION)) $criteria->add(CouponTableMap::VERSION, $this->version); return $criteria; } @@ -1468,23 +1802,39 @@ abstract class Coupon implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setCode($this->getCode()); - $copyObj->setAction($this->getAction()); + $copyObj->setType($this->getType()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setShortDescription($this->getShortDescription()); + $copyObj->setDescription($this->getDescription()); $copyObj->setValue($this->getValue()); - $copyObj->setUsed($this->getUsed()); - $copyObj->setAvailableSince($this->getAvailableSince()); - $copyObj->setDateLimit($this->getDateLimit()); - $copyObj->setActivate($this->getActivate()); + $copyObj->setIsUsed($this->getIsUsed()); + $copyObj->setIsEnabled($this->getIsEnabled()); + $copyObj->setExpirationDate($this->getExpirationDate()); + $copyObj->setSerializedRules($this->getSerializedRules()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); + $copyObj->setVersion($this->getVersion()); if ($deepCopy) { // important: temporarily setNew(false) because this affects the behavior of // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getCouponRules() as $relObj) { + foreach ($this->getCouponOrders() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCouponRule($relObj->copy($deepCopy)); + $copyObj->addCouponOrder($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCouponI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCouponI18n($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCouponVersions() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCouponVersion($relObj->copy($deepCopy)); } } @@ -1529,37 +1879,43 @@ abstract class Coupon implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('CouponRule' == $relationName) { - return $this->initCouponRules(); + if ('CouponOrder' == $relationName) { + return $this->initCouponOrders(); + } + if ('CouponI18n' == $relationName) { + return $this->initCouponI18ns(); + } + if ('CouponVersion' == $relationName) { + return $this->initCouponVersions(); } } /** - * Clears out the collCouponRules collection + * Clears out the collCouponOrders collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addCouponRules() + * @see addCouponOrders() */ - public function clearCouponRules() + public function clearCouponOrders() { - $this->collCouponRules = null; // important to set this to NULL since that means it is uninitialized + $this->collCouponOrders = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collCouponRules collection loaded partially. + * Reset is the collCouponOrders collection loaded partially. */ - public function resetPartialCouponRules($v = true) + public function resetPartialCouponOrders($v = true) { - $this->collCouponRulesPartial = $v; + $this->collCouponOrdersPartial = $v; } /** - * Initializes the collCouponRules collection. + * Initializes the collCouponOrders collection. * - * By default this just sets the collCouponRules collection to an empty array (like clearcollCouponRules()); + * By default this just sets the collCouponOrders collection to an empty array (like clearcollCouponOrders()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1568,17 +1924,17 @@ abstract class Coupon implements ActiveRecordInterface * * @return void */ - public function initCouponRules($overrideExisting = true) + public function initCouponOrders($overrideExisting = true) { - if (null !== $this->collCouponRules && !$overrideExisting) { + if (null !== $this->collCouponOrders && !$overrideExisting) { return; } - $this->collCouponRules = new ObjectCollection(); - $this->collCouponRules->setModel('\Thelia\Model\CouponRule'); + $this->collCouponOrders = new ObjectCollection(); + $this->collCouponOrders->setModel('\Thelia\Model\CouponOrder'); } /** - * Gets an array of ChildCouponRule objects which contain a foreign key that references this object. + * Gets an array of ChildCouponOrder objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1588,109 +1944,109 @@ abstract class Coupon implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildCouponRule[] List of ChildCouponRule objects + * @return Collection|ChildCouponOrder[] List of ChildCouponOrder objects * @throws PropelException */ - public function getCouponRules($criteria = null, ConnectionInterface $con = null) + public function getCouponOrders($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collCouponRulesPartial && !$this->isNew(); - if (null === $this->collCouponRules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCouponRules) { + $partial = $this->collCouponOrdersPartial && !$this->isNew(); + if (null === $this->collCouponOrders || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponOrders) { // return empty collection - $this->initCouponRules(); + $this->initCouponOrders(); } else { - $collCouponRules = ChildCouponRuleQuery::create(null, $criteria) + $collCouponOrders = ChildCouponOrderQuery::create(null, $criteria) ->filterByCoupon($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collCouponRulesPartial && count($collCouponRules)) { - $this->initCouponRules(false); + if (false !== $this->collCouponOrdersPartial && count($collCouponOrders)) { + $this->initCouponOrders(false); - foreach ($collCouponRules as $obj) { - if (false == $this->collCouponRules->contains($obj)) { - $this->collCouponRules->append($obj); + foreach ($collCouponOrders as $obj) { + if (false == $this->collCouponOrders->contains($obj)) { + $this->collCouponOrders->append($obj); } } - $this->collCouponRulesPartial = true; + $this->collCouponOrdersPartial = true; } - $collCouponRules->getInternalIterator()->rewind(); + $collCouponOrders->getInternalIterator()->rewind(); - return $collCouponRules; + return $collCouponOrders; } - if ($partial && $this->collCouponRules) { - foreach ($this->collCouponRules as $obj) { + if ($partial && $this->collCouponOrders) { + foreach ($this->collCouponOrders as $obj) { if ($obj->isNew()) { - $collCouponRules[] = $obj; + $collCouponOrders[] = $obj; } } } - $this->collCouponRules = $collCouponRules; - $this->collCouponRulesPartial = false; + $this->collCouponOrders = $collCouponOrders; + $this->collCouponOrdersPartial = false; } } - return $this->collCouponRules; + return $this->collCouponOrders; } /** - * Sets a collection of CouponRule objects related by a one-to-many relationship + * Sets a collection of CouponOrder objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $couponRules A Propel collection. + * @param Collection $couponOrders A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildCoupon The current object (for fluent API support) */ - public function setCouponRules(Collection $couponRules, ConnectionInterface $con = null) + public function setCouponOrders(Collection $couponOrders, ConnectionInterface $con = null) { - $couponRulesToDelete = $this->getCouponRules(new Criteria(), $con)->diff($couponRules); + $couponOrdersToDelete = $this->getCouponOrders(new Criteria(), $con)->diff($couponOrders); - $this->couponRulesScheduledForDeletion = $couponRulesToDelete; + $this->couponOrdersScheduledForDeletion = $couponOrdersToDelete; - foreach ($couponRulesToDelete as $couponRuleRemoved) { - $couponRuleRemoved->setCoupon(null); + foreach ($couponOrdersToDelete as $couponOrderRemoved) { + $couponOrderRemoved->setCoupon(null); } - $this->collCouponRules = null; - foreach ($couponRules as $couponRule) { - $this->addCouponRule($couponRule); + $this->collCouponOrders = null; + foreach ($couponOrders as $couponOrder) { + $this->addCouponOrder($couponOrder); } - $this->collCouponRules = $couponRules; - $this->collCouponRulesPartial = false; + $this->collCouponOrders = $couponOrders; + $this->collCouponOrdersPartial = false; return $this; } /** - * Returns the number of related CouponRule objects. + * Returns the number of related CouponOrder objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related CouponRule objects. + * @return int Count of related CouponOrder objects. * @throws PropelException */ - public function countCouponRules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countCouponOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collCouponRulesPartial && !$this->isNew(); - if (null === $this->collCouponRules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCouponRules) { + $partial = $this->collCouponOrdersPartial && !$this->isNew(); + if (null === $this->collCouponOrders || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponOrders) { return 0; } if ($partial && !$criteria) { - return count($this->getCouponRules()); + return count($this->getCouponOrders()); } - $query = ChildCouponRuleQuery::create(null, $criteria); + $query = ChildCouponOrderQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1700,53 +2056,524 @@ abstract class Coupon implements ActiveRecordInterface ->count($con); } - return count($this->collCouponRules); + return count($this->collCouponOrders); } /** - * Method called to associate a ChildCouponRule object to this object - * through the ChildCouponRule foreign key attribute. + * Method called to associate a ChildCouponOrder object to this object + * through the ChildCouponOrder foreign key attribute. * - * @param ChildCouponRule $l ChildCouponRule + * @param ChildCouponOrder $l ChildCouponOrder * @return \Thelia\Model\Coupon The current object (for fluent API support) */ - public function addCouponRule(ChildCouponRule $l) + public function addCouponOrder(ChildCouponOrder $l) { - if ($this->collCouponRules === null) { - $this->initCouponRules(); - $this->collCouponRulesPartial = true; + if ($this->collCouponOrders === null) { + $this->initCouponOrders(); + $this->collCouponOrdersPartial = true; } - if (!in_array($l, $this->collCouponRules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddCouponRule($l); + if (!in_array($l, $this->collCouponOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCouponOrder($l); } return $this; } /** - * @param CouponRule $couponRule The couponRule object to add. + * @param CouponOrder $couponOrder The couponOrder object to add. */ - protected function doAddCouponRule($couponRule) + protected function doAddCouponOrder($couponOrder) { - $this->collCouponRules[]= $couponRule; - $couponRule->setCoupon($this); + $this->collCouponOrders[]= $couponOrder; + $couponOrder->setCoupon($this); } /** - * @param CouponRule $couponRule The couponRule object to remove. + * @param CouponOrder $couponOrder The couponOrder object to remove. * @return ChildCoupon The current object (for fluent API support) */ - public function removeCouponRule($couponRule) + public function removeCouponOrder($couponOrder) { - if ($this->getCouponRules()->contains($couponRule)) { - $this->collCouponRules->remove($this->collCouponRules->search($couponRule)); - if (null === $this->couponRulesScheduledForDeletion) { - $this->couponRulesScheduledForDeletion = clone $this->collCouponRules; - $this->couponRulesScheduledForDeletion->clear(); + if ($this->getCouponOrders()->contains($couponOrder)) { + $this->collCouponOrders->remove($this->collCouponOrders->search($couponOrder)); + if (null === $this->couponOrdersScheduledForDeletion) { + $this->couponOrdersScheduledForDeletion = clone $this->collCouponOrders; + $this->couponOrdersScheduledForDeletion->clear(); } - $this->couponRulesScheduledForDeletion[]= clone $couponRule; - $couponRule->setCoupon(null); + $this->couponOrdersScheduledForDeletion[]= clone $couponOrder; + $couponOrder->setCoupon(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Coupon is new, it will return + * an empty collection; or if this Coupon has previously + * been saved, it will retrieve related CouponOrders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Coupon. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildCouponOrder[] List of ChildCouponOrder objects + */ + public function getCouponOrdersJoinOrder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildCouponOrderQuery::create(null, $criteria); + $query->joinWith('Order', $joinBehavior); + + return $this->getCouponOrders($query, $con); + } + + /** + * Clears out the collCouponI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCouponI18ns() + */ + public function clearCouponI18ns() + { + $this->collCouponI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCouponI18ns collection loaded partially. + */ + public function resetPartialCouponI18ns($v = true) + { + $this->collCouponI18nsPartial = $v; + } + + /** + * Initializes the collCouponI18ns collection. + * + * By default this just sets the collCouponI18ns collection to an empty array (like clearcollCouponI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCouponI18ns($overrideExisting = true) + { + if (null !== $this->collCouponI18ns && !$overrideExisting) { + return; + } + $this->collCouponI18ns = new ObjectCollection(); + $this->collCouponI18ns->setModel('\Thelia\Model\CouponI18n'); + } + + /** + * Gets an array of ChildCouponI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildCoupon is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCouponI18n[] List of ChildCouponI18n objects + * @throws PropelException + */ + public function getCouponI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCouponI18nsPartial && !$this->isNew(); + if (null === $this->collCouponI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponI18ns) { + // return empty collection + $this->initCouponI18ns(); + } else { + $collCouponI18ns = ChildCouponI18nQuery::create(null, $criteria) + ->filterByCoupon($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCouponI18nsPartial && count($collCouponI18ns)) { + $this->initCouponI18ns(false); + + foreach ($collCouponI18ns as $obj) { + if (false == $this->collCouponI18ns->contains($obj)) { + $this->collCouponI18ns->append($obj); + } + } + + $this->collCouponI18nsPartial = true; + } + + $collCouponI18ns->getInternalIterator()->rewind(); + + return $collCouponI18ns; + } + + if ($partial && $this->collCouponI18ns) { + foreach ($this->collCouponI18ns as $obj) { + if ($obj->isNew()) { + $collCouponI18ns[] = $obj; + } + } + } + + $this->collCouponI18ns = $collCouponI18ns; + $this->collCouponI18nsPartial = false; + } + } + + return $this->collCouponI18ns; + } + + /** + * Sets a collection of CouponI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $couponI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCoupon The current object (for fluent API support) + */ + public function setCouponI18ns(Collection $couponI18ns, ConnectionInterface $con = null) + { + $couponI18nsToDelete = $this->getCouponI18ns(new Criteria(), $con)->diff($couponI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->couponI18nsScheduledForDeletion = clone $couponI18nsToDelete; + + foreach ($couponI18nsToDelete as $couponI18nRemoved) { + $couponI18nRemoved->setCoupon(null); + } + + $this->collCouponI18ns = null; + foreach ($couponI18ns as $couponI18n) { + $this->addCouponI18n($couponI18n); + } + + $this->collCouponI18ns = $couponI18ns; + $this->collCouponI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related CouponI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CouponI18n objects. + * @throws PropelException + */ + public function countCouponI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCouponI18nsPartial && !$this->isNew(); + if (null === $this->collCouponI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCouponI18ns()); + } + + $query = ChildCouponI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCoupon($this) + ->count($con); + } + + return count($this->collCouponI18ns); + } + + /** + * Method called to associate a ChildCouponI18n object to this object + * through the ChildCouponI18n foreign key attribute. + * + * @param ChildCouponI18n $l ChildCouponI18n + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function addCouponI18n(ChildCouponI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collCouponI18ns === null) { + $this->initCouponI18ns(); + $this->collCouponI18nsPartial = true; + } + + if (!in_array($l, $this->collCouponI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCouponI18n($l); + } + + return $this; + } + + /** + * @param CouponI18n $couponI18n The couponI18n object to add. + */ + protected function doAddCouponI18n($couponI18n) + { + $this->collCouponI18ns[]= $couponI18n; + $couponI18n->setCoupon($this); + } + + /** + * @param CouponI18n $couponI18n The couponI18n object to remove. + * @return ChildCoupon The current object (for fluent API support) + */ + public function removeCouponI18n($couponI18n) + { + if ($this->getCouponI18ns()->contains($couponI18n)) { + $this->collCouponI18ns->remove($this->collCouponI18ns->search($couponI18n)); + if (null === $this->couponI18nsScheduledForDeletion) { + $this->couponI18nsScheduledForDeletion = clone $this->collCouponI18ns; + $this->couponI18nsScheduledForDeletion->clear(); + } + $this->couponI18nsScheduledForDeletion[]= clone $couponI18n; + $couponI18n->setCoupon(null); + } + + return $this; + } + + /** + * Clears out the collCouponVersions collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCouponVersions() + */ + public function clearCouponVersions() + { + $this->collCouponVersions = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCouponVersions collection loaded partially. + */ + public function resetPartialCouponVersions($v = true) + { + $this->collCouponVersionsPartial = $v; + } + + /** + * Initializes the collCouponVersions collection. + * + * By default this just sets the collCouponVersions collection to an empty array (like clearcollCouponVersions()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCouponVersions($overrideExisting = true) + { + if (null !== $this->collCouponVersions && !$overrideExisting) { + return; + } + $this->collCouponVersions = new ObjectCollection(); + $this->collCouponVersions->setModel('\Thelia\Model\CouponVersion'); + } + + /** + * Gets an array of ChildCouponVersion objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildCoupon is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCouponVersion[] List of ChildCouponVersion objects + * @throws PropelException + */ + public function getCouponVersions($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCouponVersionsPartial && !$this->isNew(); + if (null === $this->collCouponVersions || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponVersions) { + // return empty collection + $this->initCouponVersions(); + } else { + $collCouponVersions = ChildCouponVersionQuery::create(null, $criteria) + ->filterByCoupon($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCouponVersionsPartial && count($collCouponVersions)) { + $this->initCouponVersions(false); + + foreach ($collCouponVersions as $obj) { + if (false == $this->collCouponVersions->contains($obj)) { + $this->collCouponVersions->append($obj); + } + } + + $this->collCouponVersionsPartial = true; + } + + $collCouponVersions->getInternalIterator()->rewind(); + + return $collCouponVersions; + } + + if ($partial && $this->collCouponVersions) { + foreach ($this->collCouponVersions as $obj) { + if ($obj->isNew()) { + $collCouponVersions[] = $obj; + } + } + } + + $this->collCouponVersions = $collCouponVersions; + $this->collCouponVersionsPartial = false; + } + } + + return $this->collCouponVersions; + } + + /** + * Sets a collection of CouponVersion objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $couponVersions A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCoupon The current object (for fluent API support) + */ + public function setCouponVersions(Collection $couponVersions, ConnectionInterface $con = null) + { + $couponVersionsToDelete = $this->getCouponVersions(new Criteria(), $con)->diff($couponVersions); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->couponVersionsScheduledForDeletion = clone $couponVersionsToDelete; + + foreach ($couponVersionsToDelete as $couponVersionRemoved) { + $couponVersionRemoved->setCoupon(null); + } + + $this->collCouponVersions = null; + foreach ($couponVersions as $couponVersion) { + $this->addCouponVersion($couponVersion); + } + + $this->collCouponVersions = $couponVersions; + $this->collCouponVersionsPartial = false; + + return $this; + } + + /** + * Returns the number of related CouponVersion objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CouponVersion objects. + * @throws PropelException + */ + public function countCouponVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCouponVersionsPartial && !$this->isNew(); + if (null === $this->collCouponVersions || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponVersions) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCouponVersions()); + } + + $query = ChildCouponVersionQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCoupon($this) + ->count($con); + } + + return count($this->collCouponVersions); + } + + /** + * Method called to associate a ChildCouponVersion object to this object + * through the ChildCouponVersion foreign key attribute. + * + * @param ChildCouponVersion $l ChildCouponVersion + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function addCouponVersion(ChildCouponVersion $l) + { + if ($this->collCouponVersions === null) { + $this->initCouponVersions(); + $this->collCouponVersionsPartial = true; + } + + if (!in_array($l, $this->collCouponVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCouponVersion($l); + } + + return $this; + } + + /** + * @param CouponVersion $couponVersion The couponVersion object to add. + */ + protected function doAddCouponVersion($couponVersion) + { + $this->collCouponVersions[]= $couponVersion; + $couponVersion->setCoupon($this); + } + + /** + * @param CouponVersion $couponVersion The couponVersion object to remove. + * @return ChildCoupon The current object (for fluent API support) + */ + public function removeCouponVersion($couponVersion) + { + if ($this->getCouponVersions()->contains($couponVersion)) { + $this->collCouponVersions->remove($this->collCouponVersions->search($couponVersion)); + if (null === $this->couponVersionsScheduledForDeletion) { + $this->couponVersionsScheduledForDeletion = clone $this->collCouponVersions; + $this->couponVersionsScheduledForDeletion->clear(); + } + $this->couponVersionsScheduledForDeletion[]= clone $couponVersion; + $couponVersion->setCoupon(null); } return $this; @@ -1759,16 +2586,21 @@ abstract class Coupon implements ActiveRecordInterface { $this->id = null; $this->code = null; - $this->action = null; + $this->type = null; + $this->title = null; + $this->short_description = null; + $this->description = null; $this->value = null; - $this->used = null; - $this->available_since = null; - $this->date_limit = null; - $this->activate = null; + $this->is_used = null; + $this->is_enabled = null; + $this->expiration_date = null; + $this->serialized_rules = null; $this->created_at = null; $this->updated_at = null; + $this->version = null; $this->alreadyInSave = false; $this->clearAllReferences(); + $this->applyDefaultValues(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); @@ -1786,17 +2618,39 @@ abstract class Coupon implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collCouponRules) { - foreach ($this->collCouponRules as $o) { + if ($this->collCouponOrders) { + foreach ($this->collCouponOrders as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCouponI18ns) { + foreach ($this->collCouponI18ns as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCouponVersions) { + foreach ($this->collCouponVersions as $o) { $o->clearAllReferences($deep); } } } // if ($deep) - if ($this->collCouponRules instanceof Collection) { - $this->collCouponRules->clearIterator(); + // i18n behavior + $this->currentLocale = 'en_EN'; + $this->currentTranslations = null; + + if ($this->collCouponOrders instanceof Collection) { + $this->collCouponOrders->clearIterator(); } - $this->collCouponRules = null; + $this->collCouponOrders = null; + if ($this->collCouponI18ns instanceof Collection) { + $this->collCouponI18ns->clearIterator(); + } + $this->collCouponI18ns = null; + if ($this->collCouponVersions instanceof Collection) { + $this->collCouponVersions->clearIterator(); + } + $this->collCouponVersions = null; } /** @@ -1823,6 +2677,397 @@ abstract class Coupon implements ActiveRecordInterface return $this; } + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildCoupon The current object (for fluent API support) + */ + public function setLocale($locale = 'en_EN') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCouponI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collCouponI18ns) { + foreach ($this->collCouponI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildCouponI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildCouponI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addCouponI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCoupon The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildCouponI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collCouponI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collCouponI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCouponI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + // versionable behavior + + /** + * Enforce a new Version of this object upon next save. + * + * @return \Thelia\Model\Coupon + */ + public function enforceVersioning() + { + $this->enforceVersion = true; + + return $this; + } + + /** + * Checks whether the current state must be recorded as a version + * + * @return boolean + */ + public function isVersioningNecessary($con = null) + { + if ($this->alreadyInSave) { + return false; + } + + if ($this->enforceVersion) { + return true; + } + + if (ChildCouponQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) { + return true; + } + + return false; + } + + /** + * Creates a version of the current object and saves it. + * + * @param ConnectionInterface $con the connection to use + * + * @return ChildCouponVersion A version object + */ + public function addVersion($con = null) + { + $this->enforceVersion = false; + + $version = new ChildCouponVersion(); + $version->setId($this->getId()); + $version->setCode($this->getCode()); + $version->setType($this->getType()); + $version->setTitle($this->getTitle()); + $version->setShortDescription($this->getShortDescription()); + $version->setDescription($this->getDescription()); + $version->setValue($this->getValue()); + $version->setIsUsed($this->getIsUsed()); + $version->setIsEnabled($this->getIsEnabled()); + $version->setExpirationDate($this->getExpirationDate()); + $version->setSerializedRules($this->getSerializedRules()); + $version->setCreatedAt($this->getCreatedAt()); + $version->setUpdatedAt($this->getUpdatedAt()); + $version->setVersion($this->getVersion()); + $version->setCoupon($this); + $version->save($con); + + return $version; + } + + /** + * Sets the properties of the current object to the value they had at a specific version + * + * @param integer $versionNumber The version number to read + * @param ConnectionInterface $con The connection to use + * + * @return ChildCoupon The current object (for fluent API support) + */ + public function toVersion($versionNumber, $con = null) + { + $version = $this->getOneVersion($versionNumber, $con); + if (!$version) { + throw new PropelException(sprintf('No ChildCoupon object found with version %d', $version)); + } + $this->populateFromVersion($version, $con); + + return $this; + } + + /** + * Sets the properties of the current object to the value they had at a specific version + * + * @param ChildCouponVersion $version The version object to use + * @param ConnectionInterface $con the connection to use + * @param array $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects. + * + * @return ChildCoupon The current object (for fluent API support) + */ + public function populateFromVersion($version, $con = null, &$loadedObjects = array()) + { + $loadedObjects['ChildCoupon'][$version->getId()][$version->getVersion()] = $this; + $this->setId($version->getId()); + $this->setCode($version->getCode()); + $this->setType($version->getType()); + $this->setTitle($version->getTitle()); + $this->setShortDescription($version->getShortDescription()); + $this->setDescription($version->getDescription()); + $this->setValue($version->getValue()); + $this->setIsUsed($version->getIsUsed()); + $this->setIsEnabled($version->getIsEnabled()); + $this->setExpirationDate($version->getExpirationDate()); + $this->setSerializedRules($version->getSerializedRules()); + $this->setCreatedAt($version->getCreatedAt()); + $this->setUpdatedAt($version->getUpdatedAt()); + $this->setVersion($version->getVersion()); + + return $this; + } + + /** + * Gets the latest persisted version number for the current object + * + * @param ConnectionInterface $con the connection to use + * + * @return integer + */ + public function getLastVersionNumber($con = null) + { + $v = ChildCouponVersionQuery::create() + ->filterByCoupon($this) + ->orderByVersion('desc') + ->findOne($con); + if (!$v) { + return 0; + } + + return $v->getVersion(); + } + + /** + * Checks whether the current object is the latest one + * + * @param ConnectionInterface $con the connection to use + * + * @return Boolean + */ + public function isLastVersion($con = null) + { + return $this->getLastVersionNumber($con) == $this->getVersion(); + } + + /** + * Retrieves a version object for this entity and a version number + * + * @param integer $versionNumber The version number to read + * @param ConnectionInterface $con the connection to use + * + * @return ChildCouponVersion A version object + */ + public function getOneVersion($versionNumber, $con = null) + { + return ChildCouponVersionQuery::create() + ->filterByCoupon($this) + ->filterByVersion($versionNumber) + ->findOne($con); + } + + /** + * Gets all the versions of this object, in incremental order + * + * @param ConnectionInterface $con the connection to use + * + * @return ObjectCollection A list of ChildCouponVersion objects + */ + public function getAllVersions($con = null) + { + $criteria = new Criteria(); + $criteria->addAscendingOrderByColumn(CouponVersionTableMap::VERSION); + + return $this->getCouponVersions($criteria, $con); + } + + /** + * Compares the current object with another of its version. + * + * print_r($book->compareVersion(1)); + * => array( + * '1' => array('Title' => 'Book title at version 1'), + * '2' => array('Title' => 'Book title at version 2') + * ); + * + * + * @param integer $versionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. + * + * @return array A list of differences + */ + public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array()) + { + $fromVersion = $this->toArray(); + $toVersion = $this->getOneVersion($versionNumber, $con)->toArray(); + + return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns); + } + + /** + * Compares two versions of the current object. + * + * print_r($book->compareVersions(1, 2)); + * => array( + * '1' => array('Title' => 'Book title at version 1'), + * '2' => array('Title' => 'Book title at version 2') + * ); + * + * + * @param integer $fromVersionNumber + * @param integer $toVersionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. + * + * @return array A list of differences + */ + public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array()) + { + $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray(); + $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray(); + + return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns); + } + + /** + * Computes the diff between two versions. + * + * print_r($book->computeDiff(1, 2)); + * => array( + * '1' => array('Title' => 'Book title at version 1'), + * '2' => array('Title' => 'Book title at version 2') + * ); + * + * + * @param array $fromVersion An array representing the original version. + * @param array $toVersion An array representing the destination version. + * @param string $keys Main key used for the result diff (versions|columns). + * @param array $ignoredColumns The columns to exclude from the diff. + * + * @return array A list of differences + */ + protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array()) + { + $fromVersionNumber = $fromVersion['Version']; + $toVersionNumber = $toVersion['Version']; + $ignoredColumns = array_merge(array( + 'Version', + ), $ignoredColumns); + $diff = array(); + foreach ($fromVersion as $key => $value) { + if (in_array($key, $ignoredColumns)) { + continue; + } + if ($toVersion[$key] != $value) { + switch ($keys) { + case 'versions': + $diff[$fromVersionNumber][$key] = $value; + $diff[$toVersionNumber][$key] = $toVersion[$key]; + break; + default: + $diff[$key] = array( + $fromVersionNumber => $value, + $toVersionNumber => $toVersion[$key], + ); + break; + } + } + } + + return $diff; + } + /** + * retrieve the last $number versions. + * + * @param Integer $number the number of record to return. + * @return PropelCollection|array \Thelia\Model\CouponVersion[] List of \Thelia\Model\CouponVersion objects + */ + public function getLastVersions($number = 10, $criteria = null, $con = null) + { + $criteria = ChildCouponVersionQuery::create(null, $criteria); + $criteria->addDescendingOrderByColumn(CouponVersionTableMap::VERSION); + $criteria->limit($number); + + return $this->getCouponVersions($criteria, $con); + } /** * Code to be run before persisting the object * @param ConnectionInterface $con diff --git a/core/lib/Thelia/Model/Base/CouponOrder.php b/core/lib/Thelia/Model/Base/CouponOrder.php index 32ae68fde..7d3c413b6 100644 --- a/core/lib/Thelia/Model/Base/CouponOrder.php +++ b/core/lib/Thelia/Model/Base/CouponOrder.php @@ -16,8 +16,10 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; +use Thelia\Model\Coupon as ChildCoupon; use Thelia\Model\CouponOrder as ChildCouponOrder; use Thelia\Model\CouponOrderQuery as ChildCouponOrderQuery; +use Thelia\Model\CouponQuery as ChildCouponQuery; use Thelia\Model\Order as ChildOrder; use Thelia\Model\OrderQuery as ChildOrderQuery; use Thelia\Model\Map\CouponOrderTableMap; @@ -97,6 +99,11 @@ abstract class CouponOrder implements ActiveRecordInterface */ protected $aOrder; + /** + * @var Coupon + */ + protected $aCoupon; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -506,6 +513,10 @@ abstract class CouponOrder implements ActiveRecordInterface $this->modifiedColumns[] = CouponOrderTableMap::CODE; } + if ($this->aCoupon !== null && $this->aCoupon->getCode() !== $v) { + $this->aCoupon = null; + } + return $this; } // setCode() @@ -666,6 +677,9 @@ abstract class CouponOrder implements ActiveRecordInterface if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) { $this->aOrder = null; } + if ($this->aCoupon !== null && $this->code !== $this->aCoupon->getCode()) { + $this->aCoupon = null; + } } // ensureConsistency /** @@ -706,6 +720,7 @@ abstract class CouponOrder implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? $this->aOrder = null; + $this->aCoupon = null; } // if (deep) } @@ -840,6 +855,13 @@ abstract class CouponOrder implements ActiveRecordInterface $this->setOrder($this->aOrder); } + if ($this->aCoupon !== null) { + if ($this->aCoupon->isModified() || $this->aCoupon->isNew()) { + $affectedRows += $this->aCoupon->save($con); + } + $this->setCoupon($this->aCoupon); + } + if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -1050,6 +1072,9 @@ abstract class CouponOrder implements ActiveRecordInterface if (null !== $this->aOrder) { $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } + if (null !== $this->aCoupon) { + $result['Coupon'] = $this->aCoupon->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } } return $result; @@ -1296,6 +1321,59 @@ abstract class CouponOrder implements ActiveRecordInterface return $this->aOrder; } + /** + * Declares an association between this object and a ChildCoupon object. + * + * @param ChildCoupon $v + * @return \Thelia\Model\CouponOrder The current object (for fluent API support) + * @throws PropelException + */ + public function setCoupon(ChildCoupon $v = null) + { + if ($v === null) { + $this->setCode(NULL); + } else { + $this->setCode($v->getCode()); + } + + $this->aCoupon = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCoupon object, it will not be re-added. + if ($v !== null) { + $v->addCouponOrder($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCoupon object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCoupon The associated ChildCoupon object. + * @throws PropelException + */ + public function getCoupon(ConnectionInterface $con = null) + { + if ($this->aCoupon === null && (($this->code !== "" && $this->code !== null))) { + $this->aCoupon = ChildCouponQuery::create() + ->filterByCouponOrder($this) // here + ->findOne($con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCoupon->addCouponOrders($this); + */ + } + + return $this->aCoupon; + } + /** * Clears the current object and sets all attributes to their default values */ @@ -1329,6 +1407,7 @@ abstract class CouponOrder implements ActiveRecordInterface } // if ($deep) $this->aOrder = null; + $this->aCoupon = null; } /** diff --git a/core/lib/Thelia/Model/Base/CouponOrderQuery.php b/core/lib/Thelia/Model/Base/CouponOrderQuery.php index 6897f56dd..e3a95ea1a 100644 --- a/core/lib/Thelia/Model/Base/CouponOrderQuery.php +++ b/core/lib/Thelia/Model/Base/CouponOrderQuery.php @@ -43,6 +43,10 @@ use Thelia\Model\Map\CouponOrderTableMap; * @method ChildCouponOrderQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation * @method ChildCouponOrderQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation * + * @method ChildCouponOrderQuery leftJoinCoupon($relationAlias = null) Adds a LEFT JOIN clause to the query using the Coupon relation + * @method ChildCouponOrderQuery rightJoinCoupon($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Coupon relation + * @method ChildCouponOrderQuery innerJoinCoupon($relationAlias = null) Adds a INNER JOIN clause to the query using the Coupon relation + * * @method ChildCouponOrder findOne(ConnectionInterface $con = null) Return the first ChildCouponOrder matching the query * @method ChildCouponOrder findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCouponOrder matching the query, or a new ChildCouponOrder object populated from the query conditions when no match is found * @@ -551,6 +555,81 @@ abstract class CouponOrderQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery'); } + /** + * Filter the query by a related \Thelia\Model\Coupon object + * + * @param \Thelia\Model\Coupon|ObjectCollection $coupon The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function filterByCoupon($coupon, $comparison = null) + { + if ($coupon instanceof \Thelia\Model\Coupon) { + return $this + ->addUsingAlias(CouponOrderTableMap::CODE, $coupon->getCode(), $comparison); + } elseif ($coupon instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CouponOrderTableMap::CODE, $coupon->toKeyValue('PrimaryKey', 'Code'), $comparison); + } else { + throw new PropelException('filterByCoupon() only accepts arguments of type \Thelia\Model\Coupon or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Coupon relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function joinCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Coupon'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Coupon'); + } + + return $this; + } + + /** + * Use the Coupon relation Coupon object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CouponQuery A secondary query class using the current class as primary query + */ + public function useCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCoupon($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery'); + } + /** * Exclude object from result * diff --git a/core/lib/Thelia/Model/Base/CouponQuery.php b/core/lib/Thelia/Model/Base/CouponQuery.php index 23fdd2e4c..fa5700786 100644 --- a/core/lib/Thelia/Model/Base/CouponQuery.php +++ b/core/lib/Thelia/Model/Base/CouponQuery.php @@ -13,6 +13,7 @@ use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; use Thelia\Model\Coupon as ChildCoupon; +use Thelia\Model\CouponI18nQuery as ChildCouponI18nQuery; use Thelia\Model\CouponQuery as ChildCouponQuery; use Thelia\Model\Map\CouponTableMap; @@ -23,63 +24,94 @@ use Thelia\Model\Map\CouponTableMap; * * @method ChildCouponQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildCouponQuery orderByCode($order = Criteria::ASC) Order by the code column - * @method ChildCouponQuery orderByAction($order = Criteria::ASC) Order by the action column + * @method ChildCouponQuery orderByType($order = Criteria::ASC) Order by the type column + * @method ChildCouponQuery orderByTitle($order = Criteria::ASC) Order by the title column + * @method ChildCouponQuery orderByShortDescription($order = Criteria::ASC) Order by the short_description column + * @method ChildCouponQuery orderByDescription($order = Criteria::ASC) Order by the description column * @method ChildCouponQuery orderByValue($order = Criteria::ASC) Order by the value column - * @method ChildCouponQuery orderByUsed($order = Criteria::ASC) Order by the used column - * @method ChildCouponQuery orderByAvailableSince($order = Criteria::ASC) Order by the available_since column - * @method ChildCouponQuery orderByDateLimit($order = Criteria::ASC) Order by the date_limit column - * @method ChildCouponQuery orderByActivate($order = Criteria::ASC) Order by the activate column + * @method ChildCouponQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column + * @method ChildCouponQuery orderByIsEnabled($order = Criteria::ASC) Order by the is_enabled column + * @method ChildCouponQuery orderByExpirationDate($order = Criteria::ASC) Order by the expiration_date column + * @method ChildCouponQuery orderBySerializedRules($order = Criteria::ASC) Order by the serialized_rules column * @method ChildCouponQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCouponQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column + * @method ChildCouponQuery orderByVersion($order = Criteria::ASC) Order by the version column * * @method ChildCouponQuery groupById() Group by the id column * @method ChildCouponQuery groupByCode() Group by the code column - * @method ChildCouponQuery groupByAction() Group by the action column + * @method ChildCouponQuery groupByType() Group by the type column + * @method ChildCouponQuery groupByTitle() Group by the title column + * @method ChildCouponQuery groupByShortDescription() Group by the short_description column + * @method ChildCouponQuery groupByDescription() Group by the description column * @method ChildCouponQuery groupByValue() Group by the value column - * @method ChildCouponQuery groupByUsed() Group by the used column - * @method ChildCouponQuery groupByAvailableSince() Group by the available_since column - * @method ChildCouponQuery groupByDateLimit() Group by the date_limit column - * @method ChildCouponQuery groupByActivate() Group by the activate column + * @method ChildCouponQuery groupByIsUsed() Group by the is_used column + * @method ChildCouponQuery groupByIsEnabled() Group by the is_enabled column + * @method ChildCouponQuery groupByExpirationDate() Group by the expiration_date column + * @method ChildCouponQuery groupBySerializedRules() Group by the serialized_rules column * @method ChildCouponQuery groupByCreatedAt() Group by the created_at column * @method ChildCouponQuery groupByUpdatedAt() Group by the updated_at column + * @method ChildCouponQuery groupByVersion() Group by the version column * * @method ChildCouponQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method ChildCouponQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildCouponQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildCouponQuery leftJoinCouponRule($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponRule relation - * @method ChildCouponQuery rightJoinCouponRule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponRule relation - * @method ChildCouponQuery innerJoinCouponRule($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponRule relation + * @method ChildCouponQuery leftJoinCouponOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponOrder relation + * @method ChildCouponQuery rightJoinCouponOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponOrder relation + * @method ChildCouponQuery innerJoinCouponOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponOrder relation + * + * @method ChildCouponQuery leftJoinCouponI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponI18n relation + * @method ChildCouponQuery rightJoinCouponI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponI18n relation + * @method ChildCouponQuery innerJoinCouponI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponI18n relation + * + * @method ChildCouponQuery leftJoinCouponVersion($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponVersion relation + * @method ChildCouponQuery rightJoinCouponVersion($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponVersion relation + * @method ChildCouponQuery innerJoinCouponVersion($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponVersion relation * * @method ChildCoupon findOne(ConnectionInterface $con = null) Return the first ChildCoupon matching the query * @method ChildCoupon findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCoupon matching the query, or a new ChildCoupon object populated from the query conditions when no match is found * * @method ChildCoupon findOneById(int $id) Return the first ChildCoupon filtered by the id column * @method ChildCoupon findOneByCode(string $code) Return the first ChildCoupon filtered by the code column - * @method ChildCoupon findOneByAction(string $action) Return the first ChildCoupon filtered by the action column + * @method ChildCoupon findOneByType(string $type) Return the first ChildCoupon filtered by the type column + * @method ChildCoupon findOneByTitle(string $title) Return the first ChildCoupon filtered by the title column + * @method ChildCoupon findOneByShortDescription(string $short_description) Return the first ChildCoupon filtered by the short_description column + * @method ChildCoupon findOneByDescription(string $description) Return the first ChildCoupon filtered by the description column * @method ChildCoupon findOneByValue(double $value) Return the first ChildCoupon filtered by the value column - * @method ChildCoupon findOneByUsed(int $used) Return the first ChildCoupon filtered by the used column - * @method ChildCoupon findOneByAvailableSince(string $available_since) Return the first ChildCoupon filtered by the available_since column - * @method ChildCoupon findOneByDateLimit(string $date_limit) Return the first ChildCoupon filtered by the date_limit column - * @method ChildCoupon findOneByActivate(int $activate) Return the first ChildCoupon filtered by the activate column + * @method ChildCoupon findOneByIsUsed(int $is_used) Return the first ChildCoupon filtered by the is_used column + * @method ChildCoupon findOneByIsEnabled(int $is_enabled) Return the first ChildCoupon filtered by the is_enabled column + * @method ChildCoupon findOneByExpirationDate(string $expiration_date) Return the first ChildCoupon filtered by the expiration_date column + * @method ChildCoupon findOneBySerializedRules(string $serialized_rules) Return the first ChildCoupon filtered by the serialized_rules column * @method ChildCoupon findOneByCreatedAt(string $created_at) Return the first ChildCoupon filtered by the created_at column * @method ChildCoupon findOneByUpdatedAt(string $updated_at) Return the first ChildCoupon filtered by the updated_at column + * @method ChildCoupon findOneByVersion(int $version) Return the first ChildCoupon filtered by the version column * * @method array findById(int $id) Return ChildCoupon objects filtered by the id column * @method array findByCode(string $code) Return ChildCoupon objects filtered by the code column - * @method array findByAction(string $action) Return ChildCoupon objects filtered by the action column + * @method array findByType(string $type) Return ChildCoupon objects filtered by the type column + * @method array findByTitle(string $title) Return ChildCoupon objects filtered by the title column + * @method array findByShortDescription(string $short_description) Return ChildCoupon objects filtered by the short_description column + * @method array findByDescription(string $description) Return ChildCoupon objects filtered by the description column * @method array findByValue(double $value) Return ChildCoupon objects filtered by the value column - * @method array findByUsed(int $used) Return ChildCoupon objects filtered by the used column - * @method array findByAvailableSince(string $available_since) Return ChildCoupon objects filtered by the available_since column - * @method array findByDateLimit(string $date_limit) Return ChildCoupon objects filtered by the date_limit column - * @method array findByActivate(int $activate) Return ChildCoupon objects filtered by the activate column + * @method array findByIsUsed(int $is_used) Return ChildCoupon objects filtered by the is_used column + * @method array findByIsEnabled(int $is_enabled) Return ChildCoupon objects filtered by the is_enabled column + * @method array findByExpirationDate(string $expiration_date) Return ChildCoupon objects filtered by the expiration_date column + * @method array findBySerializedRules(string $serialized_rules) Return ChildCoupon objects filtered by the serialized_rules column * @method array findByCreatedAt(string $created_at) Return ChildCoupon objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCoupon objects filtered by the updated_at column + * @method array findByVersion(int $version) Return ChildCoupon objects filtered by the version column * */ abstract class CouponQuery extends ModelCriteria { + // versionable behavior + + /** + * Whether the versioning is enabled + */ + static $isVersioningEnabled = true; + /** * Initializes internal state of \Thelia\Model\Base\CouponQuery object. * @@ -163,7 +195,7 @@ abstract class CouponQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CODE, ACTION, VALUE, USED, AVAILABLE_SINCE, DATE_LIMIT, ACTIVATE, CREATED_AT, UPDATED_AT FROM coupon WHERE ID = :p0'; + $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, VALUE, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES, CREATED_AT, UPDATED_AT, VERSION FROM coupon WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -323,32 +355,119 @@ abstract class CouponQuery extends ModelCriteria } /** - * Filter the query on the action column + * Filter the query on the type column * * Example usage: * - * $query->filterByAction('fooValue'); // WHERE action = 'fooValue' - * $query->filterByAction('%fooValue%'); // WHERE action LIKE '%fooValue%' + * $query->filterByType('fooValue'); // WHERE type = 'fooValue' + * $query->filterByType('%fooValue%'); // WHERE type LIKE '%fooValue%' * * - * @param string $action The value to use as filter. + * @param string $type The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterByAction($action = null, $comparison = null) + public function filterByType($type = null, $comparison = null) { if (null === $comparison) { - if (is_array($action)) { + if (is_array($type)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $action)) { - $action = str_replace('*', '%', $action); + } elseif (preg_match('/[\%\*]/', $type)) { + $type = str_replace('*', '%', $type); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(CouponTableMap::ACTION, $action, $comparison); + return $this->addUsingAlias(CouponTableMap::TYPE, $type, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the short_description column + * + * Example usage: + * + * $query->filterByShortDescription('fooValue'); // WHERE short_description = 'fooValue' + * $query->filterByShortDescription('%fooValue%'); // WHERE short_description LIKE '%fooValue%' + * + * + * @param string $shortDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByShortDescription($shortDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($shortDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $shortDescription)) { + $shortDescription = str_replace('*', '%', $shortDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponTableMap::SHORT_DESCRIPTION, $shortDescription, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponTableMap::DESCRIPTION, $description, $comparison); } /** @@ -393,16 +512,16 @@ abstract class CouponQuery extends ModelCriteria } /** - * Filter the query on the used column + * Filter the query on the is_used column * * Example usage: * - * $query->filterByUsed(1234); // WHERE used = 1234 - * $query->filterByUsed(array(12, 34)); // WHERE used IN (12, 34) - * $query->filterByUsed(array('min' => 12)); // WHERE used > 12 + * $query->filterByIsUsed(1234); // WHERE is_used = 1234 + * $query->filterByIsUsed(array(12, 34)); // WHERE is_used IN (12, 34) + * $query->filterByIsUsed(array('min' => 12)); // WHERE is_used > 12 * * - * @param mixed $used The value to use as filter. + * @param mixed $isUsed The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -410,16 +529,16 @@ abstract class CouponQuery extends ModelCriteria * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterByUsed($used = null, $comparison = null) + public function filterByIsUsed($isUsed = null, $comparison = null) { - if (is_array($used)) { + if (is_array($isUsed)) { $useMinMax = false; - if (isset($used['min'])) { - $this->addUsingAlias(CouponTableMap::USED, $used['min'], Criteria::GREATER_EQUAL); + if (isset($isUsed['min'])) { + $this->addUsingAlias(CouponTableMap::IS_USED, $isUsed['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($used['max'])) { - $this->addUsingAlias(CouponTableMap::USED, $used['max'], Criteria::LESS_EQUAL); + if (isset($isUsed['max'])) { + $this->addUsingAlias(CouponTableMap::IS_USED, $isUsed['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -430,20 +549,61 @@ abstract class CouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponTableMap::USED, $used, $comparison); + return $this->addUsingAlias(CouponTableMap::IS_USED, $isUsed, $comparison); } /** - * Filter the query on the available_since column + * Filter the query on the is_enabled column * * Example usage: * - * $query->filterByAvailableSince('2011-03-14'); // WHERE available_since = '2011-03-14' - * $query->filterByAvailableSince('now'); // WHERE available_since = '2011-03-14' - * $query->filterByAvailableSince(array('max' => 'yesterday')); // WHERE available_since > '2011-03-13' + * $query->filterByIsEnabled(1234); // WHERE is_enabled = 1234 + * $query->filterByIsEnabled(array(12, 34)); // WHERE is_enabled IN (12, 34) + * $query->filterByIsEnabled(array('min' => 12)); // WHERE is_enabled > 12 * * - * @param mixed $availableSince The value to use as filter. + * @param mixed $isEnabled The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByIsEnabled($isEnabled = null, $comparison = null) + { + if (is_array($isEnabled)) { + $useMinMax = false; + if (isset($isEnabled['min'])) { + $this->addUsingAlias(CouponTableMap::IS_ENABLED, $isEnabled['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isEnabled['max'])) { + $this->addUsingAlias(CouponTableMap::IS_ENABLED, $isEnabled['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponTableMap::IS_ENABLED, $isEnabled, $comparison); + } + + /** + * Filter the query on the expiration_date column + * + * Example usage: + * + * $query->filterByExpirationDate('2011-03-14'); // WHERE expiration_date = '2011-03-14' + * $query->filterByExpirationDate('now'); // WHERE expiration_date = '2011-03-14' + * $query->filterByExpirationDate(array('max' => 'yesterday')); // WHERE expiration_date > '2011-03-13' + * + * + * @param mixed $expirationDate The value to use as filter. * Values can be integers (unix timestamps), DateTime objects, or strings. * Empty strings are treated as NULL. * Use scalar values for equality. @@ -453,16 +613,16 @@ abstract class CouponQuery extends ModelCriteria * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterByAvailableSince($availableSince = null, $comparison = null) + public function filterByExpirationDate($expirationDate = null, $comparison = null) { - if (is_array($availableSince)) { + if (is_array($expirationDate)) { $useMinMax = false; - if (isset($availableSince['min'])) { - $this->addUsingAlias(CouponTableMap::AVAILABLE_SINCE, $availableSince['min'], Criteria::GREATER_EQUAL); + if (isset($expirationDate['min'])) { + $this->addUsingAlias(CouponTableMap::EXPIRATION_DATE, $expirationDate['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($availableSince['max'])) { - $this->addUsingAlias(CouponTableMap::AVAILABLE_SINCE, $availableSince['max'], Criteria::LESS_EQUAL); + if (isset($expirationDate['max'])) { + $this->addUsingAlias(CouponTableMap::EXPIRATION_DATE, $expirationDate['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -473,91 +633,36 @@ abstract class CouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponTableMap::AVAILABLE_SINCE, $availableSince, $comparison); + return $this->addUsingAlias(CouponTableMap::EXPIRATION_DATE, $expirationDate, $comparison); } /** - * Filter the query on the date_limit column + * Filter the query on the serialized_rules column * * Example usage: * - * $query->filterByDateLimit('2011-03-14'); // WHERE date_limit = '2011-03-14' - * $query->filterByDateLimit('now'); // WHERE date_limit = '2011-03-14' - * $query->filterByDateLimit(array('max' => 'yesterday')); // WHERE date_limit > '2011-03-13' + * $query->filterBySerializedRules('fooValue'); // WHERE serialized_rules = 'fooValue' + * $query->filterBySerializedRules('%fooValue%'); // WHERE serialized_rules LIKE '%fooValue%' * * - * @param mixed $dateLimit The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $serializedRules The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterByDateLimit($dateLimit = null, $comparison = null) + public function filterBySerializedRules($serializedRules = null, $comparison = null) { - if (is_array($dateLimit)) { - $useMinMax = false; - if (isset($dateLimit['min'])) { - $this->addUsingAlias(CouponTableMap::DATE_LIMIT, $dateLimit['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dateLimit['max'])) { - $this->addUsingAlias(CouponTableMap::DATE_LIMIT, $dateLimit['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { + if (null === $comparison) { + if (is_array($serializedRules)) { $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $serializedRules)) { + $serializedRules = str_replace('*', '%', $serializedRules); + $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(CouponTableMap::DATE_LIMIT, $dateLimit, $comparison); - } - - /** - * Filter the query on the activate column - * - * Example usage: - * - * $query->filterByActivate(1234); // WHERE activate = 1234 - * $query->filterByActivate(array(12, 34)); // WHERE activate IN (12, 34) - * $query->filterByActivate(array('min' => 12)); // WHERE activate > 12 - * - * - * @param mixed $activate The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCouponQuery The current query, for fluid interface - */ - public function filterByActivate($activate = null, $comparison = null) - { - if (is_array($activate)) { - $useMinMax = false; - if (isset($activate['min'])) { - $this->addUsingAlias(CouponTableMap::ACTIVATE, $activate['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($activate['max'])) { - $this->addUsingAlias(CouponTableMap::ACTIVATE, $activate['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponTableMap::ACTIVATE, $activate, $comparison); + return $this->addUsingAlias(CouponTableMap::SERIALIZED_RULES, $serializedRules, $comparison); } /** @@ -647,40 +752,81 @@ abstract class CouponQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\CouponRule object + * Filter the query on the version column * - * @param \Thelia\Model\CouponRule|ObjectCollection $couponRule the related object to use as filter + * Example usage: + * + * $query->filterByVersion(1234); // WHERE version = 1234 + * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * + * + * @param mixed $version The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByVersion($version = null, $comparison = null) + { + if (is_array($version)) { + $useMinMax = false; + if (isset($version['min'])) { + $this->addUsingAlias(CouponTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($version['max'])) { + $this->addUsingAlias(CouponTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponTableMap::VERSION, $version, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\CouponOrder object + * + * @param \Thelia\Model\CouponOrder|ObjectCollection $couponOrder the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterByCouponRule($couponRule, $comparison = null) + public function filterByCouponOrder($couponOrder, $comparison = null) { - if ($couponRule instanceof \Thelia\Model\CouponRule) { + if ($couponOrder instanceof \Thelia\Model\CouponOrder) { return $this - ->addUsingAlias(CouponTableMap::ID, $couponRule->getCouponId(), $comparison); - } elseif ($couponRule instanceof ObjectCollection) { + ->addUsingAlias(CouponTableMap::CODE, $couponOrder->getCode(), $comparison); + } elseif ($couponOrder instanceof ObjectCollection) { return $this - ->useCouponRuleQuery() - ->filterByPrimaryKeys($couponRule->getPrimaryKeys()) + ->useCouponOrderQuery() + ->filterByPrimaryKeys($couponOrder->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByCouponRule() only accepts arguments of type \Thelia\Model\CouponRule or Collection'); + throw new PropelException('filterByCouponOrder() only accepts arguments of type \Thelia\Model\CouponOrder or Collection'); } } /** - * Adds a JOIN clause to the query using the CouponRule relation + * Adds a JOIN clause to the query using the CouponOrder relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildCouponQuery The current query, for fluid interface */ - public function joinCouponRule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinCouponOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CouponRule'); + $relationMap = $tableMap->getRelation('CouponOrder'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -695,14 +841,14 @@ abstract class CouponQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'CouponRule'); + $this->addJoinObject($join, 'CouponOrder'); } return $this; } /** - * Use the CouponRule relation CouponRule object + * Use the CouponOrder relation CouponOrder object * * @see useQuery() * @@ -710,13 +856,159 @@ abstract class CouponQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\CouponRuleQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\CouponOrderQuery A secondary query class using the current class as primary query */ - public function useCouponRuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useCouponOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinCouponRule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CouponRule', '\Thelia\Model\CouponRuleQuery'); + ->joinCouponOrder($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CouponOrder', '\Thelia\Model\CouponOrderQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\CouponI18n object + * + * @param \Thelia\Model\CouponI18n|ObjectCollection $couponI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByCouponI18n($couponI18n, $comparison = null) + { + if ($couponI18n instanceof \Thelia\Model\CouponI18n) { + return $this + ->addUsingAlias(CouponTableMap::ID, $couponI18n->getId(), $comparison); + } elseif ($couponI18n instanceof ObjectCollection) { + return $this + ->useCouponI18nQuery() + ->filterByPrimaryKeys($couponI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCouponI18n() only accepts arguments of type \Thelia\Model\CouponI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CouponI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function joinCouponI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CouponI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CouponI18n'); + } + + return $this; + } + + /** + * Use the CouponI18n relation CouponI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CouponI18nQuery A secondary query class using the current class as primary query + */ + public function useCouponI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinCouponI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CouponI18n', '\Thelia\Model\CouponI18nQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\CouponVersion object + * + * @param \Thelia\Model\CouponVersion|ObjectCollection $couponVersion the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByCouponVersion($couponVersion, $comparison = null) + { + if ($couponVersion instanceof \Thelia\Model\CouponVersion) { + return $this + ->addUsingAlias(CouponTableMap::ID, $couponVersion->getId(), $comparison); + } elseif ($couponVersion instanceof ObjectCollection) { + return $this + ->useCouponVersionQuery() + ->filterByPrimaryKeys($couponVersion->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCouponVersion() only accepts arguments of type \Thelia\Model\CouponVersion or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CouponVersion relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function joinCouponVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CouponVersion'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CouponVersion'); + } + + return $this; + } + + /** + * Use the CouponVersion relation CouponVersion object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CouponVersionQuery A secondary query class using the current class as primary query + */ + public function useCouponVersionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCouponVersion($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CouponVersion', '\Thelia\Model\CouponVersionQuery'); } /** @@ -876,4 +1168,89 @@ abstract class CouponQuery extends ModelCriteria return $this->addAscendingOrderByColumn(CouponTableMap::CREATED_AT); } + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'CouponI18n'; + + return $this + ->joinCouponI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('CouponI18n'); + $this->with['CouponI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCouponI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CouponI18n', '\Thelia\Model\CouponI18nQuery'); + } + + // versionable behavior + + /** + * Checks whether versioning is enabled + * + * @return boolean + */ + static public function isVersioningEnabled() + { + return self::$isVersioningEnabled; + } + + /** + * Enables versioning + */ + static public function enableVersioning() + { + self::$isVersioningEnabled = true; + } + + /** + * Disables versioning + */ + static public function disableVersioning() + { + self::$isVersioningEnabled = false; + } + } // CouponQuery diff --git a/core/lib/Thelia/Model/Base/Currency.php b/core/lib/Thelia/Model/Base/Currency.php index 77718992f..a5ada0790 100644 --- a/core/lib/Thelia/Model/Base/Currency.php +++ b/core/lib/Thelia/Model/Base/Currency.php @@ -149,7 +149,7 @@ abstract class Currency implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -2681,7 +2681,7 @@ abstract class Currency implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collOrders instanceof Collection) { @@ -2735,7 +2735,7 @@ abstract class Currency implements ActiveRecordInterface * * @return ChildCurrency The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2759,7 +2759,7 @@ abstract class Currency implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCurrencyI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCurrencyI18ns) { @@ -2794,7 +2794,7 @@ abstract class Currency implements ActiveRecordInterface * * @return ChildCurrency The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCurrencyI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CurrencyI18n.php b/core/lib/Thelia/Model/Base/CurrencyI18n.php index eb86a87c4..52cd7fc5b 100644 --- a/core/lib/Thelia/Model/Base/CurrencyI18n.php +++ b/core/lib/Thelia/Model/Base/CurrencyI18n.php @@ -61,7 +61,7 @@ abstract class CurrencyI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -93,7 +93,7 @@ abstract class CurrencyI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -462,7 +462,7 @@ abstract class CurrencyI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/CurrencyQuery.php b/core/lib/Thelia/Model/Base/CurrencyQuery.php index eb4b1b2f7..9b4ecf51e 100644 --- a/core/lib/Thelia/Model/Base/CurrencyQuery.php +++ b/core/lib/Thelia/Model/Base/CurrencyQuery.php @@ -1025,7 +1025,7 @@ abstract class CurrencyQuery extends ModelCriteria * * @return ChildCurrencyQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CurrencyI18n'; @@ -1043,7 +1043,7 @@ abstract class CurrencyQuery extends ModelCriteria * * @return ChildCurrencyQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1064,7 +1064,7 @@ abstract class CurrencyQuery extends ModelCriteria * * @return ChildCurrencyI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/CustomerTitle.php b/core/lib/Thelia/Model/Base/CustomerTitle.php index 5f8b11dd9..7f4c30d09 100644 --- a/core/lib/Thelia/Model/Base/CustomerTitle.php +++ b/core/lib/Thelia/Model/Base/CustomerTitle.php @@ -124,7 +124,7 @@ abstract class CustomerTitle implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -2106,7 +2106,7 @@ abstract class CustomerTitle implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collCustomers instanceof Collection) { @@ -2156,7 +2156,7 @@ abstract class CustomerTitle implements ActiveRecordInterface * * @return ChildCustomerTitle The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2180,7 +2180,7 @@ abstract class CustomerTitle implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCustomerTitleI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCustomerTitleI18ns) { @@ -2215,7 +2215,7 @@ abstract class CustomerTitle implements ActiveRecordInterface * * @return ChildCustomerTitle The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCustomerTitleI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CustomerTitleI18n.php b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php index c68b87123..38e47ecda 100644 --- a/core/lib/Thelia/Model/Base/CustomerTitleI18n.php +++ b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php @@ -61,7 +61,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -99,7 +99,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -500,7 +500,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php index ea34c8c91..1c4be4081 100644 --- a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php @@ -825,7 +825,7 @@ abstract class CustomerTitleQuery extends ModelCriteria * * @return ChildCustomerTitleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CustomerTitleI18n'; @@ -843,7 +843,7 @@ abstract class CustomerTitleQuery extends ModelCriteria * * @return ChildCustomerTitleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -864,7 +864,7 @@ abstract class CustomerTitleQuery extends ModelCriteria * * @return ChildCustomerTitleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Feature.php b/core/lib/Thelia/Model/Base/Feature.php index 0dddd14e0..826de003f 100644 --- a/core/lib/Thelia/Model/Base/Feature.php +++ b/core/lib/Thelia/Model/Base/Feature.php @@ -139,7 +139,7 @@ abstract class Feature implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -2628,7 +2628,7 @@ abstract class Feature implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collFeatureAvs instanceof Collection) { @@ -2686,7 +2686,7 @@ abstract class Feature implements ActiveRecordInterface * * @return ChildFeature The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2710,7 +2710,7 @@ abstract class Feature implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildFeatureI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFeatureI18ns) { @@ -2745,7 +2745,7 @@ abstract class Feature implements ActiveRecordInterface * * @return ChildFeature The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildFeatureI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/FeatureAv.php b/core/lib/Thelia/Model/Base/FeatureAv.php index b09a27cec..818f352a0 100644 --- a/core/lib/Thelia/Model/Base/FeatureAv.php +++ b/core/lib/Thelia/Model/Base/FeatureAv.php @@ -122,7 +122,7 @@ abstract class FeatureAv implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1900,7 +1900,7 @@ abstract class FeatureAv implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collFeatureProducts instanceof Collection) { @@ -1947,7 +1947,7 @@ abstract class FeatureAv implements ActiveRecordInterface * * @return ChildFeatureAv The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1971,7 +1971,7 @@ abstract class FeatureAv implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildFeatureAvI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFeatureAvI18ns) { @@ -2006,7 +2006,7 @@ abstract class FeatureAv implements ActiveRecordInterface * * @return ChildFeatureAv The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildFeatureAvI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/FeatureAvI18n.php b/core/lib/Thelia/Model/Base/FeatureAvI18n.php index 7cbca8129..aa524c430 100644 --- a/core/lib/Thelia/Model/Base/FeatureAvI18n.php +++ b/core/lib/Thelia/Model/Base/FeatureAvI18n.php @@ -61,7 +61,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/FeatureAvQuery.php b/core/lib/Thelia/Model/Base/FeatureAvQuery.php index fb3796c97..6b3af4ed9 100644 --- a/core/lib/Thelia/Model/Base/FeatureAvQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureAvQuery.php @@ -841,7 +841,7 @@ abstract class FeatureAvQuery extends ModelCriteria * * @return ChildFeatureAvQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FeatureAvI18n'; @@ -859,7 +859,7 @@ abstract class FeatureAvQuery extends ModelCriteria * * @return ChildFeatureAvQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -880,7 +880,7 @@ abstract class FeatureAvQuery extends ModelCriteria * * @return ChildFeatureAvI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/FeatureI18n.php b/core/lib/Thelia/Model/Base/FeatureI18n.php index 0ede8eddb..b6070932e 100644 --- a/core/lib/Thelia/Model/Base/FeatureI18n.php +++ b/core/lib/Thelia/Model/Base/FeatureI18n.php @@ -61,7 +61,7 @@ abstract class FeatureI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class FeatureI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class FeatureI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/FeatureQuery.php b/core/lib/Thelia/Model/Base/FeatureQuery.php index 9b00e812e..f1fc81a3f 100644 --- a/core/lib/Thelia/Model/Base/FeatureQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureQuery.php @@ -931,7 +931,7 @@ abstract class FeatureQuery extends ModelCriteria * * @return ChildFeatureQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FeatureI18n'; @@ -949,7 +949,7 @@ abstract class FeatureQuery extends ModelCriteria * * @return ChildFeatureQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -970,7 +970,7 @@ abstract class FeatureQuery extends ModelCriteria * * @return ChildFeatureI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Folder.php b/core/lib/Thelia/Model/Base/Folder.php index 6ee28e7ff..1b0c80d94 100644 --- a/core/lib/Thelia/Model/Base/Folder.php +++ b/core/lib/Thelia/Model/Base/Folder.php @@ -180,7 +180,7 @@ abstract class Folder implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -3460,7 +3460,7 @@ abstract class Folder implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collRewritings instanceof Collection) { @@ -3526,7 +3526,7 @@ abstract class Folder implements ActiveRecordInterface * * @return ChildFolder The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -3550,7 +3550,7 @@ abstract class Folder implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildFolderI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFolderI18ns) { @@ -3585,7 +3585,7 @@ abstract class Folder implements ActiveRecordInterface * * @return ChildFolder The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildFolderI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/FolderDocument.php b/core/lib/Thelia/Model/Base/FolderDocument.php index 31e7c57a6..25b68a842 100644 --- a/core/lib/Thelia/Model/Base/FolderDocument.php +++ b/core/lib/Thelia/Model/Base/FolderDocument.php @@ -120,7 +120,7 @@ abstract class FolderDocument implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1640,7 +1640,7 @@ abstract class FolderDocument implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collFolderDocumentI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class FolderDocument implements ActiveRecordInterface * * @return ChildFolderDocument The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class FolderDocument implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildFolderDocumentI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFolderDocumentI18ns) { @@ -1742,7 +1742,7 @@ abstract class FolderDocument implements ActiveRecordInterface * * @return ChildFolderDocument The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildFolderDocumentI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/FolderDocumentI18n.php b/core/lib/Thelia/Model/Base/FolderDocumentI18n.php index d39a49af7..520160758 100644 --- a/core/lib/Thelia/Model/Base/FolderDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/FolderDocumentI18n.php @@ -61,7 +61,7 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/FolderDocumentQuery.php b/core/lib/Thelia/Model/Base/FolderDocumentQuery.php index b1c41a29e..85ed5c241 100644 --- a/core/lib/Thelia/Model/Base/FolderDocumentQuery.php +++ b/core/lib/Thelia/Model/Base/FolderDocumentQuery.php @@ -797,7 +797,7 @@ abstract class FolderDocumentQuery extends ModelCriteria * * @return ChildFolderDocumentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FolderDocumentI18n'; @@ -815,7 +815,7 @@ abstract class FolderDocumentQuery extends ModelCriteria * * @return ChildFolderDocumentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class FolderDocumentQuery extends ModelCriteria * * @return ChildFolderDocumentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/FolderI18n.php b/core/lib/Thelia/Model/Base/FolderI18n.php index fcdc66705..35e69d6a6 100644 --- a/core/lib/Thelia/Model/Base/FolderI18n.php +++ b/core/lib/Thelia/Model/Base/FolderI18n.php @@ -61,7 +61,7 @@ abstract class FolderI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class FolderI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class FolderI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/FolderImage.php b/core/lib/Thelia/Model/Base/FolderImage.php index 46c39060d..73bfd11b8 100644 --- a/core/lib/Thelia/Model/Base/FolderImage.php +++ b/core/lib/Thelia/Model/Base/FolderImage.php @@ -120,7 +120,7 @@ abstract class FolderImage implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1640,7 +1640,7 @@ abstract class FolderImage implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collFolderImageI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class FolderImage implements ActiveRecordInterface * * @return ChildFolderImage The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class FolderImage implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildFolderImageI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFolderImageI18ns) { @@ -1742,7 +1742,7 @@ abstract class FolderImage implements ActiveRecordInterface * * @return ChildFolderImage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildFolderImageI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/FolderImageI18n.php b/core/lib/Thelia/Model/Base/FolderImageI18n.php index d5cc004d1..9096c8542 100644 --- a/core/lib/Thelia/Model/Base/FolderImageI18n.php +++ b/core/lib/Thelia/Model/Base/FolderImageI18n.php @@ -61,7 +61,7 @@ abstract class FolderImageI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class FolderImageI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class FolderImageI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/FolderImageQuery.php b/core/lib/Thelia/Model/Base/FolderImageQuery.php index ca12e098e..4ea930e20 100644 --- a/core/lib/Thelia/Model/Base/FolderImageQuery.php +++ b/core/lib/Thelia/Model/Base/FolderImageQuery.php @@ -797,7 +797,7 @@ abstract class FolderImageQuery extends ModelCriteria * * @return ChildFolderImageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FolderImageI18n'; @@ -815,7 +815,7 @@ abstract class FolderImageQuery extends ModelCriteria * * @return ChildFolderImageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class FolderImageQuery extends ModelCriteria * * @return ChildFolderImageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/FolderQuery.php b/core/lib/Thelia/Model/Base/FolderQuery.php index 893bb9819..22d2f3735 100644 --- a/core/lib/Thelia/Model/Base/FolderQuery.php +++ b/core/lib/Thelia/Model/Base/FolderQuery.php @@ -1262,7 +1262,7 @@ abstract class FolderQuery extends ModelCriteria * * @return ChildFolderQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FolderI18n'; @@ -1280,7 +1280,7 @@ abstract class FolderQuery extends ModelCriteria * * @return ChildFolderQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1301,7 +1301,7 @@ abstract class FolderQuery extends ModelCriteria * * @return ChildFolderI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Group.php b/core/lib/Thelia/Model/Base/Group.php index 9cfde2bdc..6b66d5f39 100644 --- a/core/lib/Thelia/Model/Base/Group.php +++ b/core/lib/Thelia/Model/Base/Group.php @@ -139,7 +139,7 @@ abstract class Group implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -2786,7 +2786,7 @@ abstract class Group implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collAdminGroups instanceof Collection) { @@ -2848,7 +2848,7 @@ abstract class Group implements ActiveRecordInterface * * @return ChildGroup The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2872,7 +2872,7 @@ abstract class Group implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildGroupI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collGroupI18ns) { @@ -2907,7 +2907,7 @@ abstract class Group implements ActiveRecordInterface * * @return ChildGroup The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildGroupI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/GroupI18n.php b/core/lib/Thelia/Model/Base/GroupI18n.php index 4de63ea63..de90d8863 100644 --- a/core/lib/Thelia/Model/Base/GroupI18n.php +++ b/core/lib/Thelia/Model/Base/GroupI18n.php @@ -61,7 +61,7 @@ abstract class GroupI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class GroupI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class GroupI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/GroupQuery.php b/core/lib/Thelia/Model/Base/GroupQuery.php index d0eded79b..8ca963848 100644 --- a/core/lib/Thelia/Model/Base/GroupQuery.php +++ b/core/lib/Thelia/Model/Base/GroupQuery.php @@ -891,7 +891,7 @@ abstract class GroupQuery extends ModelCriteria * * @return ChildGroupQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'GroupI18n'; @@ -909,7 +909,7 @@ abstract class GroupQuery extends ModelCriteria * * @return ChildGroupQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -930,7 +930,7 @@ abstract class GroupQuery extends ModelCriteria * * @return ChildGroupI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Message.php b/core/lib/Thelia/Model/Base/Message.php index a2327f388..f39e4ecbe 100644 --- a/core/lib/Thelia/Model/Base/Message.php +++ b/core/lib/Thelia/Model/Base/Message.php @@ -141,7 +141,7 @@ abstract class Message implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -2056,7 +2056,7 @@ abstract class Message implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collMessageI18ns instanceof Collection) { @@ -2102,7 +2102,7 @@ abstract class Message implements ActiveRecordInterface * * @return ChildMessage The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2126,7 +2126,7 @@ abstract class Message implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildMessageI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collMessageI18ns) { @@ -2161,7 +2161,7 @@ abstract class Message implements ActiveRecordInterface * * @return ChildMessage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildMessageI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/MessageI18n.php b/core/lib/Thelia/Model/Base/MessageI18n.php index 4d1a532fe..545e75244 100644 --- a/core/lib/Thelia/Model/Base/MessageI18n.php +++ b/core/lib/Thelia/Model/Base/MessageI18n.php @@ -61,7 +61,7 @@ abstract class MessageI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -105,7 +105,7 @@ abstract class MessageI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -538,7 +538,7 @@ abstract class MessageI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/MessageQuery.php b/core/lib/Thelia/Model/Base/MessageQuery.php index cf0155f36..938a16aab 100644 --- a/core/lib/Thelia/Model/Base/MessageQuery.php +++ b/core/lib/Thelia/Model/Base/MessageQuery.php @@ -913,7 +913,7 @@ abstract class MessageQuery extends ModelCriteria * * @return ChildMessageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'MessageI18n'; @@ -931,7 +931,7 @@ abstract class MessageQuery extends ModelCriteria * * @return ChildMessageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -952,7 +952,7 @@ abstract class MessageQuery extends ModelCriteria * * @return ChildMessageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Module.php b/core/lib/Thelia/Model/Base/Module.php index c1ee2ed8d..ebe4b4c18 100644 --- a/core/lib/Thelia/Model/Base/Module.php +++ b/core/lib/Thelia/Model/Base/Module.php @@ -127,7 +127,7 @@ abstract class Module implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1910,7 +1910,7 @@ abstract class Module implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collGroupModules instanceof Collection) { @@ -1956,7 +1956,7 @@ abstract class Module implements ActiveRecordInterface * * @return ChildModule The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1980,7 +1980,7 @@ abstract class Module implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildModuleI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collModuleI18ns) { @@ -2015,7 +2015,7 @@ abstract class Module implements ActiveRecordInterface * * @return ChildModule The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildModuleI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ModuleI18n.php b/core/lib/Thelia/Model/Base/ModuleI18n.php index fbb4293ba..54cf305e4 100644 --- a/core/lib/Thelia/Model/Base/ModuleI18n.php +++ b/core/lib/Thelia/Model/Base/ModuleI18n.php @@ -61,7 +61,7 @@ abstract class ModuleI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ModuleI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class ModuleI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ModuleQuery.php b/core/lib/Thelia/Model/Base/ModuleQuery.php index e1bd9de68..7db21ca22 100644 --- a/core/lib/Thelia/Model/Base/ModuleQuery.php +++ b/core/lib/Thelia/Model/Base/ModuleQuery.php @@ -838,7 +838,7 @@ abstract class ModuleQuery extends ModelCriteria * * @return ChildModuleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ModuleI18n'; @@ -856,7 +856,7 @@ abstract class ModuleQuery extends ModelCriteria * * @return ChildModuleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -877,7 +877,7 @@ abstract class ModuleQuery extends ModelCriteria * * @return ChildModuleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Order.php b/core/lib/Thelia/Model/Base/Order.php index b815aff34..ccf7922f3 100644 --- a/core/lib/Thelia/Model/Base/Order.php +++ b/core/lib/Thelia/Model/Base/Order.php @@ -2842,6 +2842,31 @@ abstract class Order implements ActiveRecordInterface return $this; } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Order is new, it will return + * an empty collection; or if this Order has previously + * been saved, it will retrieve related CouponOrders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Order. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildCouponOrder[] List of ChildCouponOrder objects + */ + public function getCouponOrdersJoinCoupon($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildCouponOrderQuery::create(null, $criteria); + $query->joinWith('Coupon', $joinBehavior); + + return $this->getCouponOrders($query, $con); + } + /** * Clears the current object and sets all attributes to their default values */ diff --git a/core/lib/Thelia/Model/Base/OrderStatus.php b/core/lib/Thelia/Model/Base/OrderStatus.php index fc4a224d1..15ce7fbf7 100644 --- a/core/lib/Thelia/Model/Base/OrderStatus.php +++ b/core/lib/Thelia/Model/Base/OrderStatus.php @@ -109,7 +109,7 @@ abstract class OrderStatus implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1812,7 +1812,7 @@ abstract class OrderStatus implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collOrders instanceof Collection) { @@ -1858,7 +1858,7 @@ abstract class OrderStatus implements ActiveRecordInterface * * @return ChildOrderStatus The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1882,7 +1882,7 @@ abstract class OrderStatus implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildOrderStatusI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collOrderStatusI18ns) { @@ -1917,7 +1917,7 @@ abstract class OrderStatus implements ActiveRecordInterface * * @return ChildOrderStatus The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildOrderStatusI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/OrderStatusI18n.php b/core/lib/Thelia/Model/Base/OrderStatusI18n.php index 76ec4a28a..1f98739f0 100644 --- a/core/lib/Thelia/Model/Base/OrderStatusI18n.php +++ b/core/lib/Thelia/Model/Base/OrderStatusI18n.php @@ -61,7 +61,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/OrderStatusQuery.php b/core/lib/Thelia/Model/Base/OrderStatusQuery.php index 908efd6b6..07fcdb8dc 100644 --- a/core/lib/Thelia/Model/Base/OrderStatusQuery.php +++ b/core/lib/Thelia/Model/Base/OrderStatusQuery.php @@ -703,7 +703,7 @@ abstract class OrderStatusQuery extends ModelCriteria * * @return ChildOrderStatusQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'OrderStatusI18n'; @@ -721,7 +721,7 @@ abstract class OrderStatusQuery extends ModelCriteria * * @return ChildOrderStatusQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -742,7 +742,7 @@ abstract class OrderStatusQuery extends ModelCriteria * * @return ChildOrderStatusI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php index 9a1828e25..905436e1f 100644 --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -250,7 +250,7 @@ abstract class Product implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -5815,7 +5815,7 @@ abstract class Product implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collProductCategories instanceof Collection) { @@ -5914,7 +5914,7 @@ abstract class Product implements ActiveRecordInterface * * @return ChildProduct The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -5938,7 +5938,7 @@ abstract class Product implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildProductI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collProductI18ns) { @@ -5973,7 +5973,7 @@ abstract class Product implements ActiveRecordInterface * * @return ChildProduct The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildProductI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ProductDocument.php b/core/lib/Thelia/Model/Base/ProductDocument.php index 58c9999ed..16503b9fb 100644 --- a/core/lib/Thelia/Model/Base/ProductDocument.php +++ b/core/lib/Thelia/Model/Base/ProductDocument.php @@ -120,7 +120,7 @@ abstract class ProductDocument implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1640,7 +1640,7 @@ abstract class ProductDocument implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collProductDocumentI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class ProductDocument implements ActiveRecordInterface * * @return ChildProductDocument The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class ProductDocument implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildProductDocumentI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collProductDocumentI18ns) { @@ -1742,7 +1742,7 @@ abstract class ProductDocument implements ActiveRecordInterface * * @return ChildProductDocument The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildProductDocumentI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ProductDocumentI18n.php b/core/lib/Thelia/Model/Base/ProductDocumentI18n.php index 2c5ca4d0c..f6c8436f8 100644 --- a/core/lib/Thelia/Model/Base/ProductDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/ProductDocumentI18n.php @@ -61,7 +61,7 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ProductDocumentQuery.php b/core/lib/Thelia/Model/Base/ProductDocumentQuery.php index 06af05a9c..32321554d 100644 --- a/core/lib/Thelia/Model/Base/ProductDocumentQuery.php +++ b/core/lib/Thelia/Model/Base/ProductDocumentQuery.php @@ -797,7 +797,7 @@ abstract class ProductDocumentQuery extends ModelCriteria * * @return ChildProductDocumentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ProductDocumentI18n'; @@ -815,7 +815,7 @@ abstract class ProductDocumentQuery extends ModelCriteria * * @return ChildProductDocumentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class ProductDocumentQuery extends ModelCriteria * * @return ChildProductDocumentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/ProductI18n.php b/core/lib/Thelia/Model/Base/ProductI18n.php index b0c74bb54..7b6e65976 100644 --- a/core/lib/Thelia/Model/Base/ProductI18n.php +++ b/core/lib/Thelia/Model/Base/ProductI18n.php @@ -61,7 +61,7 @@ abstract class ProductI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ProductI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class ProductI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ProductImage.php b/core/lib/Thelia/Model/Base/ProductImage.php index 0b4030ccb..364e6f00b 100644 --- a/core/lib/Thelia/Model/Base/ProductImage.php +++ b/core/lib/Thelia/Model/Base/ProductImage.php @@ -120,7 +120,7 @@ abstract class ProductImage implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1640,7 +1640,7 @@ abstract class ProductImage implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collProductImageI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class ProductImage implements ActiveRecordInterface * * @return ChildProductImage The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class ProductImage implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildProductImageI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collProductImageI18ns) { @@ -1742,7 +1742,7 @@ abstract class ProductImage implements ActiveRecordInterface * * @return ChildProductImage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildProductImageI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ProductImageI18n.php b/core/lib/Thelia/Model/Base/ProductImageI18n.php index 634f726a3..064f09986 100644 --- a/core/lib/Thelia/Model/Base/ProductImageI18n.php +++ b/core/lib/Thelia/Model/Base/ProductImageI18n.php @@ -61,7 +61,7 @@ abstract class ProductImageI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ProductImageI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class ProductImageI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ProductImageQuery.php b/core/lib/Thelia/Model/Base/ProductImageQuery.php index 94cb1b361..e351c6f40 100644 --- a/core/lib/Thelia/Model/Base/ProductImageQuery.php +++ b/core/lib/Thelia/Model/Base/ProductImageQuery.php @@ -797,7 +797,7 @@ abstract class ProductImageQuery extends ModelCriteria * * @return ChildProductImageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ProductImageI18n'; @@ -815,7 +815,7 @@ abstract class ProductImageQuery extends ModelCriteria * * @return ChildProductImageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class ProductImageQuery extends ModelCriteria * * @return ChildProductImageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/ProductQuery.php b/core/lib/Thelia/Model/Base/ProductQuery.php index 3df8ecbae..9d4685f38 100644 --- a/core/lib/Thelia/Model/Base/ProductQuery.php +++ b/core/lib/Thelia/Model/Base/ProductQuery.php @@ -1872,7 +1872,7 @@ abstract class ProductQuery extends ModelCriteria * * @return ChildProductQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ProductI18n'; @@ -1890,7 +1890,7 @@ abstract class ProductQuery extends ModelCriteria * * @return ChildProductQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1911,7 +1911,7 @@ abstract class ProductQuery extends ModelCriteria * * @return ChildProductI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Resource.php b/core/lib/Thelia/Model/Base/Resource.php index c6c527134..827de2643 100644 --- a/core/lib/Thelia/Model/Base/Resource.php +++ b/core/lib/Thelia/Model/Base/Resource.php @@ -116,7 +116,7 @@ abstract class Resource implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1968,7 +1968,7 @@ abstract class Resource implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collGroupResources instanceof Collection) { @@ -2018,7 +2018,7 @@ abstract class Resource implements ActiveRecordInterface * * @return ChildResource The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2042,7 +2042,7 @@ abstract class Resource implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildResourceI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collResourceI18ns) { @@ -2077,7 +2077,7 @@ abstract class Resource implements ActiveRecordInterface * * @return ChildResource The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildResourceI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ResourceI18n.php b/core/lib/Thelia/Model/Base/ResourceI18n.php index c060e8776..b740bd858 100644 --- a/core/lib/Thelia/Model/Base/ResourceI18n.php +++ b/core/lib/Thelia/Model/Base/ResourceI18n.php @@ -61,7 +61,7 @@ abstract class ResourceI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ResourceI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -576,7 +576,7 @@ abstract class ResourceI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ResourceQuery.php b/core/lib/Thelia/Model/Base/ResourceQuery.php index 6559d6522..e12ee8f53 100644 --- a/core/lib/Thelia/Model/Base/ResourceQuery.php +++ b/core/lib/Thelia/Model/Base/ResourceQuery.php @@ -720,7 +720,7 @@ abstract class ResourceQuery extends ModelCriteria * * @return ChildResourceQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ResourceI18n'; @@ -738,7 +738,7 @@ abstract class ResourceQuery extends ModelCriteria * * @return ChildResourceQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -759,7 +759,7 @@ abstract class ResourceQuery extends ModelCriteria * * @return ChildResourceI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Tax.php b/core/lib/Thelia/Model/Base/Tax.php index 3e405414c..f3717366f 100644 --- a/core/lib/Thelia/Model/Base/Tax.php +++ b/core/lib/Thelia/Model/Base/Tax.php @@ -109,7 +109,7 @@ abstract class Tax implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -1762,7 +1762,7 @@ abstract class Tax implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collTaxRuleCountries instanceof Collection) { @@ -1808,7 +1808,7 @@ abstract class Tax implements ActiveRecordInterface * * @return ChildTax The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1832,7 +1832,7 @@ abstract class Tax implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildTaxI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collTaxI18ns) { @@ -1867,7 +1867,7 @@ abstract class Tax implements ActiveRecordInterface * * @return ChildTax The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildTaxI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/TaxI18n.php b/core/lib/Thelia/Model/Base/TaxI18n.php index f8577e860..8fdec086d 100644 --- a/core/lib/Thelia/Model/Base/TaxI18n.php +++ b/core/lib/Thelia/Model/Base/TaxI18n.php @@ -61,7 +61,7 @@ abstract class TaxI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -99,7 +99,7 @@ abstract class TaxI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -500,7 +500,7 @@ abstract class TaxI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/TaxQuery.php b/core/lib/Thelia/Model/Base/TaxQuery.php index 307ace57c..0a61cbb3c 100644 --- a/core/lib/Thelia/Model/Base/TaxQuery.php +++ b/core/lib/Thelia/Model/Base/TaxQuery.php @@ -715,7 +715,7 @@ abstract class TaxQuery extends ModelCriteria * * @return ChildTaxQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'TaxI18n'; @@ -733,7 +733,7 @@ abstract class TaxQuery extends ModelCriteria * * @return ChildTaxQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -754,7 +754,7 @@ abstract class TaxQuery extends ModelCriteria * * @return ChildTaxI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/TaxRule.php b/core/lib/Thelia/Model/Base/TaxRule.php index bf318498c..101471313 100644 --- a/core/lib/Thelia/Model/Base/TaxRule.php +++ b/core/lib/Thelia/Model/Base/TaxRule.php @@ -129,7 +129,7 @@ abstract class TaxRule implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -2146,7 +2146,7 @@ abstract class TaxRule implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collProducts instanceof Collection) { @@ -2196,7 +2196,7 @@ abstract class TaxRule implements ActiveRecordInterface * * @return ChildTaxRule The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2220,7 +2220,7 @@ abstract class TaxRule implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildTaxRuleI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collTaxRuleI18ns) { @@ -2255,7 +2255,7 @@ abstract class TaxRule implements ActiveRecordInterface * * @return ChildTaxRule The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildTaxRuleI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/TaxRuleI18n.php b/core/lib/Thelia/Model/Base/TaxRuleI18n.php index 51bab6a77..86215b335 100644 --- a/core/lib/Thelia/Model/Base/TaxRuleI18n.php +++ b/core/lib/Thelia/Model/Base/TaxRuleI18n.php @@ -61,7 +61,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -87,7 +87,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -424,7 +424,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/TaxRuleQuery.php b/core/lib/Thelia/Model/Base/TaxRuleQuery.php index 2fb478b7a..36f2edd99 100644 --- a/core/lib/Thelia/Model/Base/TaxRuleQuery.php +++ b/core/lib/Thelia/Model/Base/TaxRuleQuery.php @@ -846,7 +846,7 @@ abstract class TaxRuleQuery extends ModelCriteria * * @return ChildTaxRuleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'TaxRuleI18n'; @@ -864,7 +864,7 @@ abstract class TaxRuleQuery extends ModelCriteria * * @return ChildTaxRuleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -885,7 +885,7 @@ abstract class TaxRuleQuery extends ModelCriteria * * @return ChildTaxRuleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php b/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php index 02a20540e..14fc79eeb 100644 --- a/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php @@ -151,7 +151,7 @@ class AttributeAvI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_av', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/AttributeAvTableMap.php b/core/lib/Thelia/Model/Map/AttributeAvTableMap.php index 0c5c2e1c9..138f0fa9c 100644 --- a/core/lib/Thelia/Model/Map/AttributeAvTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeAvTableMap.php @@ -106,7 +106,7 @@ class AttributeAvTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php b/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php index 8471d3e26..b60cae5b8 100644 --- a/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php @@ -151,7 +151,7 @@ class AttributeI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/AttributeTableMap.php b/core/lib/Thelia/Model/Map/AttributeTableMap.php index 773e13cab..dca811cbc 100644 --- a/core/lib/Thelia/Model/Map/AttributeTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeTableMap.php @@ -101,7 +101,7 @@ class AttributeTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CategoryDocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryDocumentI18nTableMap.php index 956afae4a..1ad7dfe2f 100644 --- a/core/lib/Thelia/Model/Map/CategoryDocumentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryDocumentI18nTableMap.php @@ -151,7 +151,7 @@ class CategoryDocumentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category_document', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/CategoryDocumentTableMap.php b/core/lib/Thelia/Model/Map/CategoryDocumentTableMap.php index 8b307ea1e..83e748a1e 100644 --- a/core/lib/Thelia/Model/Map/CategoryDocumentTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryDocumentTableMap.php @@ -111,7 +111,7 @@ class CategoryDocumentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php index 8c52aa7b2..1611b2ebf 100644 --- a/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php @@ -151,7 +151,7 @@ class CategoryI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/CategoryImageI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryImageI18nTableMap.php index 1d27e16ad..1c59c9db2 100644 --- a/core/lib/Thelia/Model/Map/CategoryImageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryImageI18nTableMap.php @@ -151,7 +151,7 @@ class CategoryImageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category_image', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/CategoryImageTableMap.php b/core/lib/Thelia/Model/Map/CategoryImageTableMap.php index 1c7694d05..9eafe2ade 100644 --- a/core/lib/Thelia/Model/Map/CategoryImageTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryImageTableMap.php @@ -111,7 +111,7 @@ class CategoryImageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CategoryTableMap.php b/core/lib/Thelia/Model/Map/CategoryTableMap.php index 5e02d04c5..c3526ec5d 100644 --- a/core/lib/Thelia/Model/Map/CategoryTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryTableMap.php @@ -126,7 +126,7 @@ class CategoryTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php b/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php index b953b0ac9..a83f87b76 100644 --- a/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php @@ -151,7 +151,7 @@ class ConfigI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'config', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ConfigTableMap.php b/core/lib/Thelia/Model/Map/ConfigTableMap.php index ebd5d6edf..8bd68a964 100644 --- a/core/lib/Thelia/Model/Map/ConfigTableMap.php +++ b/core/lib/Thelia/Model/Map/ConfigTableMap.php @@ -116,7 +116,7 @@ class ConfigTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ContentDocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentDocumentI18nTableMap.php index 7ebde93e6..a6ff890d7 100644 --- a/core/lib/Thelia/Model/Map/ContentDocumentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentDocumentI18nTableMap.php @@ -151,7 +151,7 @@ class ContentDocumentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content_document', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ContentDocumentTableMap.php b/core/lib/Thelia/Model/Map/ContentDocumentTableMap.php index 3d876a570..4344b70ae 100644 --- a/core/lib/Thelia/Model/Map/ContentDocumentTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentDocumentTableMap.php @@ -111,7 +111,7 @@ class ContentDocumentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ContentI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php index f718623b0..ee9122a6c 100644 --- a/core/lib/Thelia/Model/Map/ContentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php @@ -151,7 +151,7 @@ class ContentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ContentImageI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentImageI18nTableMap.php index 759349d27..6ff343d16 100644 --- a/core/lib/Thelia/Model/Map/ContentImageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentImageI18nTableMap.php @@ -151,7 +151,7 @@ class ContentImageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content_image', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ContentImageTableMap.php b/core/lib/Thelia/Model/Map/ContentImageTableMap.php index f731c51a8..c95761ab2 100644 --- a/core/lib/Thelia/Model/Map/ContentImageTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentImageTableMap.php @@ -111,7 +111,7 @@ class ContentImageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ContentTableMap.php b/core/lib/Thelia/Model/Map/ContentTableMap.php index 4a489cedb..724c839a1 100644 --- a/core/lib/Thelia/Model/Map/ContentTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentTableMap.php @@ -121,7 +121,7 @@ class ContentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CountryI18nTableMap.php b/core/lib/Thelia/Model/Map/CountryI18nTableMap.php index 272231464..cc60b09d2 100644 --- a/core/lib/Thelia/Model/Map/CountryI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CountryI18nTableMap.php @@ -151,7 +151,7 @@ class CountryI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'country', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/CountryTableMap.php b/core/lib/Thelia/Model/Map/CountryTableMap.php index e7c356f08..2e4931e37 100644 --- a/core/lib/Thelia/Model/Map/CountryTableMap.php +++ b/core/lib/Thelia/Model/Map/CountryTableMap.php @@ -116,7 +116,7 @@ class CountryTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CouponOrderTableMap.php b/core/lib/Thelia/Model/Map/CouponOrderTableMap.php index 9d91ef068..1826bcb70 100644 --- a/core/lib/Thelia/Model/Map/CouponOrderTableMap.php +++ b/core/lib/Thelia/Model/Map/CouponOrderTableMap.php @@ -152,7 +152,7 @@ class CouponOrderTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); + $this->addForeignKey('CODE', 'Code', 'VARCHAR', 'coupon', 'CODE', true, 45, null); $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); @@ -164,6 +164,7 @@ class CouponOrderTableMap extends TableMap public function buildRelations() { $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Coupon', '\\Thelia\\Model\\Coupon', RelationMap::MANY_TO_ONE, array('code' => 'code', ), null, null); } // buildRelations() /** diff --git a/core/lib/Thelia/Model/Map/CouponTableMap.php b/core/lib/Thelia/Model/Map/CouponTableMap.php index d1ff79ac0..7e576a585 100644 --- a/core/lib/Thelia/Model/Map/CouponTableMap.php +++ b/core/lib/Thelia/Model/Map/CouponTableMap.php @@ -57,7 +57,7 @@ class CouponTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 10; + const NUM_COLUMNS = 14; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CouponTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 10; + const NUM_HYDRATE_COLUMNS = 14; /** * the column name for the ID field @@ -80,9 +80,24 @@ class CouponTableMap extends TableMap const CODE = 'coupon.CODE'; /** - * the column name for the ACTION field + * the column name for the TYPE field */ - const ACTION = 'coupon.ACTION'; + const TYPE = 'coupon.TYPE'; + + /** + * the column name for the TITLE field + */ + const TITLE = 'coupon.TITLE'; + + /** + * the column name for the SHORT_DESCRIPTION field + */ + const SHORT_DESCRIPTION = 'coupon.SHORT_DESCRIPTION'; + + /** + * the column name for the DESCRIPTION field + */ + const DESCRIPTION = 'coupon.DESCRIPTION'; /** * the column name for the VALUE field @@ -90,24 +105,24 @@ class CouponTableMap extends TableMap const VALUE = 'coupon.VALUE'; /** - * the column name for the USED field + * the column name for the IS_USED field */ - const USED = 'coupon.USED'; + const IS_USED = 'coupon.IS_USED'; /** - * the column name for the AVAILABLE_SINCE field + * the column name for the IS_ENABLED field */ - const AVAILABLE_SINCE = 'coupon.AVAILABLE_SINCE'; + const IS_ENABLED = 'coupon.IS_ENABLED'; /** - * the column name for the DATE_LIMIT field + * the column name for the EXPIRATION_DATE field */ - const DATE_LIMIT = 'coupon.DATE_LIMIT'; + const EXPIRATION_DATE = 'coupon.EXPIRATION_DATE'; /** - * the column name for the ACTIVATE field + * the column name for the SERIALIZED_RULES field */ - const ACTIVATE = 'coupon.ACTIVATE'; + const SERIALIZED_RULES = 'coupon.SERIALIZED_RULES'; /** * the column name for the CREATED_AT field @@ -119,11 +134,25 @@ class CouponTableMap extends TableMap */ const UPDATED_AT = 'coupon.UPDATED_AT'; + /** + * the column name for the VERSION field + */ + const VERSION = 'coupon.VERSION'; + /** * The default string format for model objects of the related table */ const DEFAULT_STRING_FORMAT = 'YAML'; + // i18n behavior + + /** + * The default locale to use for translations. + * + * @var string + */ + const DEFAULT_LOCALE = 'en_EN'; + /** * holds an array of fieldnames * @@ -131,12 +160,12 @@ class CouponTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Code', 'Action', 'Value', 'Used', 'AvailableSince', 'DateLimit', 'Activate', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'code', 'action', 'value', 'used', 'availableSince', 'dateLimit', 'activate', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::ACTION, CouponTableMap::VALUE, CouponTableMap::USED, CouponTableMap::AVAILABLE_SINCE, CouponTableMap::DATE_LIMIT, CouponTableMap::ACTIVATE, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'ACTION', 'VALUE', 'USED', 'AVAILABLE_SINCE', 'DATE_LIMIT', 'ACTIVATE', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'code', 'action', 'value', 'used', 'available_since', 'date_limit', 'activate', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Value', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'CreatedAt', 'UpdatedAt', 'Version', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'value', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'createdAt', 'updatedAt', 'version', ), + self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::TITLE, CouponTableMap::SHORT_DESCRIPTION, CouponTableMap::DESCRIPTION, CouponTableMap::VALUE, CouponTableMap::IS_USED, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::SERIALIZED_RULES, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'VALUE', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), + self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'value', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'created_at', 'updated_at', 'version', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) ); /** @@ -146,12 +175,12 @@ class CouponTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Action' => 2, 'Value' => 3, 'Used' => 4, 'AvailableSince' => 5, 'DateLimit' => 6, 'Activate' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'action' => 2, 'value' => 3, 'used' => 4, 'availableSince' => 5, 'dateLimit' => 6, 'activate' => 7, 'createdAt' => 8, 'updatedAt' => 9, ), - self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::ACTION => 2, CouponTableMap::VALUE => 3, CouponTableMap::USED => 4, CouponTableMap::AVAILABLE_SINCE => 5, CouponTableMap::DATE_LIMIT => 6, CouponTableMap::ACTIVATE => 7, CouponTableMap::CREATED_AT => 8, CouponTableMap::UPDATED_AT => 9, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'ACTION' => 2, 'VALUE' => 3, 'USED' => 4, 'AVAILABLE_SINCE' => 5, 'DATE_LIMIT' => 6, 'ACTIVATE' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ), - self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'action' => 2, 'value' => 3, 'used' => 4, 'available_since' => 5, 'date_limit' => 6, 'activate' => 7, 'created_at' => 8, 'updated_at' => 9, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Value' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRules' => 10, 'CreatedAt' => 11, 'UpdatedAt' => 12, 'Version' => 13, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'value' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRules' => 10, 'createdAt' => 11, 'updatedAt' => 12, 'version' => 13, ), + self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::TITLE => 3, CouponTableMap::SHORT_DESCRIPTION => 4, CouponTableMap::DESCRIPTION => 5, CouponTableMap::VALUE => 6, CouponTableMap::IS_USED => 7, CouponTableMap::IS_ENABLED => 8, CouponTableMap::EXPIRATION_DATE => 9, CouponTableMap::SERIALIZED_RULES => 10, CouponTableMap::CREATED_AT => 11, CouponTableMap::UPDATED_AT => 12, CouponTableMap::VERSION => 13, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'VALUE' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES' => 10, 'CREATED_AT' => 11, 'UPDATED_AT' => 12, 'VERSION' => 13, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'value' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules' => 10, 'created_at' => 11, 'updated_at' => 12, 'version' => 13, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) ); /** @@ -172,14 +201,18 @@ class CouponTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); - $this->addColumn('ACTION', 'Action', 'VARCHAR', true, 255, null); + $this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null); + $this->addColumn('TITLE', 'Title', 'VARCHAR', true, 255, null); + $this->addColumn('SHORT_DESCRIPTION', 'ShortDescription', 'LONGVARCHAR', true, null, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', true, null, null); $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null); - $this->addColumn('USED', 'Used', 'TINYINT', false, null, null); - $this->addColumn('AVAILABLE_SINCE', 'AvailableSince', 'TIMESTAMP', false, null, null); - $this->addColumn('DATE_LIMIT', 'DateLimit', 'TIMESTAMP', false, null, null); - $this->addColumn('ACTIVATE', 'Activate', 'TINYINT', false, null, null); + $this->addColumn('IS_USED', 'IsUsed', 'TINYINT', true, null, null); + $this->addColumn('IS_ENABLED', 'IsEnabled', 'TINYINT', true, null, null); + $this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null); + $this->addColumn('SERIALIZED_RULES', 'SerializedRules', 'LONGVARCHAR', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0); } // initialize() /** @@ -187,7 +220,9 @@ class CouponTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('CouponRule', '\\Thelia\\Model\\CouponRule', RelationMap::ONE_TO_MANY, array('id' => 'coupon_id', ), 'CASCADE', 'RESTRICT', 'CouponRules'); + $this->addRelation('CouponOrder', '\\Thelia\\Model\\CouponOrder', RelationMap::ONE_TO_MANY, array('code' => 'code', ), null, null, 'CouponOrders'); + $this->addRelation('CouponI18n', '\\Thelia\\Model\\CouponI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CouponI18ns'); + $this->addRelation('CouponVersion', '\\Thelia\\Model\\CouponVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CouponVersions'); } // buildRelations() /** @@ -200,6 +235,8 @@ class CouponTableMap extends TableMap { return array( 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => '', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'false', 'log_created_by' => 'false', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), ); } // getBehaviors() /** @@ -209,7 +246,8 @@ class CouponTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CouponRuleTableMap::clearInstancePool(); + CouponI18nTableMap::clearInstancePool(); + CouponVersionTableMap::clearInstancePool(); } /** @@ -352,25 +390,33 @@ class CouponTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(CouponTableMap::ID); $criteria->addSelectColumn(CouponTableMap::CODE); - $criteria->addSelectColumn(CouponTableMap::ACTION); + $criteria->addSelectColumn(CouponTableMap::TYPE); + $criteria->addSelectColumn(CouponTableMap::TITLE); + $criteria->addSelectColumn(CouponTableMap::SHORT_DESCRIPTION); + $criteria->addSelectColumn(CouponTableMap::DESCRIPTION); $criteria->addSelectColumn(CouponTableMap::VALUE); - $criteria->addSelectColumn(CouponTableMap::USED); - $criteria->addSelectColumn(CouponTableMap::AVAILABLE_SINCE); - $criteria->addSelectColumn(CouponTableMap::DATE_LIMIT); - $criteria->addSelectColumn(CouponTableMap::ACTIVATE); + $criteria->addSelectColumn(CouponTableMap::IS_USED); + $criteria->addSelectColumn(CouponTableMap::IS_ENABLED); + $criteria->addSelectColumn(CouponTableMap::EXPIRATION_DATE); + $criteria->addSelectColumn(CouponTableMap::SERIALIZED_RULES); $criteria->addSelectColumn(CouponTableMap::CREATED_AT); $criteria->addSelectColumn(CouponTableMap::UPDATED_AT); + $criteria->addSelectColumn(CouponTableMap::VERSION); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.ACTION'); + $criteria->addSelectColumn($alias . '.TYPE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.SHORT_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.VALUE'); - $criteria->addSelectColumn($alias . '.USED'); - $criteria->addSelectColumn($alias . '.AVAILABLE_SINCE'); - $criteria->addSelectColumn($alias . '.DATE_LIMIT'); - $criteria->addSelectColumn($alias . '.ACTIVATE'); + $criteria->addSelectColumn($alias . '.IS_USED'); + $criteria->addSelectColumn($alias . '.IS_ENABLED'); + $criteria->addSelectColumn($alias . '.EXPIRATION_DATE'); + $criteria->addSelectColumn($alias . '.SERIALIZED_RULES'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.VERSION'); } } diff --git a/core/lib/Thelia/Model/Map/CurrencyI18nTableMap.php b/core/lib/Thelia/Model/Map/CurrencyI18nTableMap.php index c7e4725c1..d280f8601 100644 --- a/core/lib/Thelia/Model/Map/CurrencyI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CurrencyI18nTableMap.php @@ -136,7 +136,7 @@ class CurrencyI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'currency', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('NAME', 'Name', 'VARCHAR', false, 45, null); } // initialize() diff --git a/core/lib/Thelia/Model/Map/CurrencyTableMap.php b/core/lib/Thelia/Model/Map/CurrencyTableMap.php index b37a6b30a..08ecf6966 100644 --- a/core/lib/Thelia/Model/Map/CurrencyTableMap.php +++ b/core/lib/Thelia/Model/Map/CurrencyTableMap.php @@ -121,7 +121,7 @@ class CurrencyTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php index 5344099c5..d403756fa 100644 --- a/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php @@ -141,7 +141,7 @@ class CustomerTitleI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'customer_title', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('SHORT', 'Short', 'VARCHAR', false, 10, null); $this->addColumn('LONG', 'Long', 'VARCHAR', false, 45, null); } // initialize() diff --git a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php index c10ce2500..2769f365e 100644 --- a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php @@ -106,7 +106,7 @@ class CustomerTitleTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php index ba592b4b0..b3114e7ba 100644 --- a/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php @@ -151,7 +151,7 @@ class FeatureAvI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_av', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FeatureAvTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvTableMap.php index 4dd944bb7..0559f7ce6 100644 --- a/core/lib/Thelia/Model/Map/FeatureAvTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureAvTableMap.php @@ -106,7 +106,7 @@ class FeatureAvTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php index dba05fb67..af0dfc263 100644 --- a/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php @@ -151,7 +151,7 @@ class FeatureI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FeatureTableMap.php b/core/lib/Thelia/Model/Map/FeatureTableMap.php index 76c2fe724..7d0af0d45 100644 --- a/core/lib/Thelia/Model/Map/FeatureTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureTableMap.php @@ -106,7 +106,7 @@ class FeatureTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FolderDocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderDocumentI18nTableMap.php index 28dab9d8f..5875031fb 100644 --- a/core/lib/Thelia/Model/Map/FolderDocumentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderDocumentI18nTableMap.php @@ -151,7 +151,7 @@ class FolderDocumentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder_document', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FolderDocumentTableMap.php b/core/lib/Thelia/Model/Map/FolderDocumentTableMap.php index 1d0e3b74a..467b7a65b 100644 --- a/core/lib/Thelia/Model/Map/FolderDocumentTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderDocumentTableMap.php @@ -111,7 +111,7 @@ class FolderDocumentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FolderI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php index d10344811..fc85b17ec 100644 --- a/core/lib/Thelia/Model/Map/FolderI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php @@ -151,7 +151,7 @@ class FolderI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FolderImageI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderImageI18nTableMap.php index f0f87fd85..1c89165a4 100644 --- a/core/lib/Thelia/Model/Map/FolderImageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderImageI18nTableMap.php @@ -151,7 +151,7 @@ class FolderImageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder_image', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FolderImageTableMap.php b/core/lib/Thelia/Model/Map/FolderImageTableMap.php index 6dc186658..c559f9437 100644 --- a/core/lib/Thelia/Model/Map/FolderImageTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderImageTableMap.php @@ -111,7 +111,7 @@ class FolderImageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FolderTableMap.php b/core/lib/Thelia/Model/Map/FolderTableMap.php index 1bfe2cd6e..08871715b 100644 --- a/core/lib/Thelia/Model/Map/FolderTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderTableMap.php @@ -126,7 +126,7 @@ class FolderTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/GroupI18nTableMap.php b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php index 57788593a..585127821 100644 --- a/core/lib/Thelia/Model/Map/GroupI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php @@ -151,7 +151,7 @@ class GroupI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'group', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/GroupTableMap.php b/core/lib/Thelia/Model/Map/GroupTableMap.php index 881a2fa84..a8c830005 100644 --- a/core/lib/Thelia/Model/Map/GroupTableMap.php +++ b/core/lib/Thelia/Model/Map/GroupTableMap.php @@ -101,7 +101,7 @@ class GroupTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/MessageI18nTableMap.php b/core/lib/Thelia/Model/Map/MessageI18nTableMap.php index bb9bfdd2e..f084515c0 100644 --- a/core/lib/Thelia/Model/Map/MessageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/MessageI18nTableMap.php @@ -146,7 +146,7 @@ class MessageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'message', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'LONGVARCHAR', false, null, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('DESCRIPTION_HTML', 'DescriptionHtml', 'CLOB', false, null, null); diff --git a/core/lib/Thelia/Model/Map/MessageTableMap.php b/core/lib/Thelia/Model/Map/MessageTableMap.php index 392dac824..de2a205f9 100644 --- a/core/lib/Thelia/Model/Map/MessageTableMap.php +++ b/core/lib/Thelia/Model/Map/MessageTableMap.php @@ -126,7 +126,7 @@ class MessageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php b/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php index a8e680f1c..67b7a34ef 100644 --- a/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php @@ -151,7 +151,7 @@ class ModuleI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'module', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ModuleTableMap.php b/core/lib/Thelia/Model/Map/ModuleTableMap.php index cccaa890a..5370c1da1 100644 --- a/core/lib/Thelia/Model/Map/ModuleTableMap.php +++ b/core/lib/Thelia/Model/Map/ModuleTableMap.php @@ -116,7 +116,7 @@ class ModuleTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php index 1b2052c2e..5d78c474c 100644 --- a/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php @@ -151,7 +151,7 @@ class OrderStatusI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order_status', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php index 18406d9aa..eecfe5a03 100644 --- a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php @@ -101,7 +101,7 @@ class OrderStatusTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ProductDocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductDocumentI18nTableMap.php index 09e1dc0e4..103914ee6 100644 --- a/core/lib/Thelia/Model/Map/ProductDocumentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductDocumentI18nTableMap.php @@ -151,7 +151,7 @@ class ProductDocumentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product_document', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ProductDocumentTableMap.php b/core/lib/Thelia/Model/Map/ProductDocumentTableMap.php index ff50bad77..f1420cc43 100644 --- a/core/lib/Thelia/Model/Map/ProductDocumentTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductDocumentTableMap.php @@ -111,7 +111,7 @@ class ProductDocumentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php index 79a01514a..8da33f15d 100644 --- a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php @@ -151,7 +151,7 @@ class ProductI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ProductImageI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductImageI18nTableMap.php index 39ad567f9..de3455c07 100644 --- a/core/lib/Thelia/Model/Map/ProductImageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductImageI18nTableMap.php @@ -151,7 +151,7 @@ class ProductImageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product_image', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ProductImageTableMap.php b/core/lib/Thelia/Model/Map/ProductImageTableMap.php index 36aabed3e..945799020 100644 --- a/core/lib/Thelia/Model/Map/ProductImageTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductImageTableMap.php @@ -111,7 +111,7 @@ class ProductImageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php index 75bf5e4e6..ef2cc7ca0 100644 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -131,7 +131,7 @@ class ProductTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php b/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php index ec22e2fd3..8a8ce501a 100644 --- a/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php @@ -151,7 +151,7 @@ class ResourceI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'resource', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ResourceTableMap.php b/core/lib/Thelia/Model/Map/ResourceTableMap.php index 8d7708ddd..e56960892 100644 --- a/core/lib/Thelia/Model/Map/ResourceTableMap.php +++ b/core/lib/Thelia/Model/Map/ResourceTableMap.php @@ -101,7 +101,7 @@ class ResourceTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php index a06230c37..2c4c92f4f 100644 --- a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php @@ -141,7 +141,7 @@ class TaxI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); } // initialize() diff --git a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php index 1f0ed1e96..689f30728 100644 --- a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php @@ -131,7 +131,7 @@ class TaxRuleI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); } // initialize() /** diff --git a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php index cc5f628b9..9b862de99 100644 --- a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php @@ -111,7 +111,7 @@ class TaxRuleTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/TaxTableMap.php b/core/lib/Thelia/Model/Map/TaxTableMap.php index 6d43f20e9..b941e7b52 100644 --- a/core/lib/Thelia/Model/Map/TaxTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxTableMap.php @@ -101,7 +101,7 @@ class TaxTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/install/thelia.sql b/install/thelia.sql index 9188f164d..502bbd036 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -1117,42 +1117,22 @@ CREATE TABLE `coupon` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `code` VARCHAR(45) NOT NULL, - `action` VARCHAR(255) NOT NULL, + `type` VARCHAR(255) NOT NULL, + `title` VARCHAR(255) NOT NULL, + `short_description` TEXT NOT NULL, + `description` LONGTEXT NOT NULL, `value` FLOAT NOT NULL, - `used` TINYINT, - `available_since` DATETIME, - `date_limit` DATETIME, - `activate` TINYINT, + `is_used` TINYINT NOT NULL, + `is_enabled` TINYINT NOT NULL, + `expiration_date` DATETIME NOT NULL, + `serialized_rules` TEXT NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, + `version` INTEGER DEFAULT 0, PRIMARY KEY (`id`), UNIQUE INDEX `code_UNIQUE` (`code`) ) ENGINE=InnoDB; --- --------------------------------------------------------------------- --- coupon_rule --- --------------------------------------------------------------------- - -DROP TABLE IF EXISTS `coupon_rule`; - -CREATE TABLE `coupon_rule` -( - `id` INTEGER NOT NULL AUTO_INCREMENT, - `coupon_id` INTEGER NOT NULL, - `controller` VARCHAR(255), - `operation` VARCHAR(255), - `value` FLOAT, - `created_at` DATETIME, - `updated_at` DATETIME, - PRIMARY KEY (`id`), - INDEX `idx_coupon_rule_coupon_id` (`coupon_id`), - CONSTRAINT `fk_coupon_rule_coupon_id` - FOREIGN KEY (`coupon_id`) - REFERENCES `coupon` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE -) ENGINE=InnoDB; - -- --------------------------------------------------------------------- -- coupon_order -- --------------------------------------------------------------------- @@ -1169,11 +1149,15 @@ CREATE TABLE `coupon_order` `updated_at` DATETIME, PRIMARY KEY (`id`), INDEX `idx_coupon_order_order_id` (`order_id`), + INDEX `fk_coupon_order_coupon_idx` (`code`), CONSTRAINT `fk_coupon_order_order_id` FOREIGN KEY (`order_id`) REFERENCES `order` (`id`) ON UPDATE RESTRICT - ON DELETE CASCADE + ON DELETE CASCADE, + CONSTRAINT `fk_coupon_order_coupon` + FOREIGN KEY (`code`) + REFERENCES `coupon` (`code`) ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -1466,7 +1450,7 @@ DROP TABLE IF EXISTS `category_i18n`; CREATE TABLE `category_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1487,7 +1471,7 @@ DROP TABLE IF EXISTS `product_i18n`; CREATE TABLE `product_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1508,7 +1492,7 @@ DROP TABLE IF EXISTS `country_i18n`; CREATE TABLE `country_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1529,7 +1513,7 @@ DROP TABLE IF EXISTS `tax_i18n`; CREATE TABLE `tax_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` TEXT, PRIMARY KEY (`id`,`locale`), @@ -1548,7 +1532,7 @@ DROP TABLE IF EXISTS `tax_rule_i18n`; CREATE TABLE `tax_rule_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, PRIMARY KEY (`id`,`locale`), CONSTRAINT `tax_rule_i18n_FK_1` FOREIGN KEY (`id`) @@ -1565,7 +1549,7 @@ DROP TABLE IF EXISTS `feature_i18n`; CREATE TABLE `feature_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1586,7 +1570,7 @@ DROP TABLE IF EXISTS `feature_av_i18n`; CREATE TABLE `feature_av_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1607,7 +1591,7 @@ DROP TABLE IF EXISTS `attribute_i18n`; CREATE TABLE `attribute_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1628,7 +1612,7 @@ DROP TABLE IF EXISTS `attribute_av_i18n`; CREATE TABLE `attribute_av_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1649,7 +1633,7 @@ DROP TABLE IF EXISTS `config_i18n`; CREATE TABLE `config_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1670,7 +1654,7 @@ DROP TABLE IF EXISTS `customer_title_i18n`; CREATE TABLE `customer_title_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `short` VARCHAR(10), `long` VARCHAR(45), PRIMARY KEY (`id`,`locale`), @@ -1689,7 +1673,7 @@ DROP TABLE IF EXISTS `folder_i18n`; CREATE TABLE `folder_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1710,7 +1694,7 @@ DROP TABLE IF EXISTS `content_i18n`; CREATE TABLE `content_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1731,7 +1715,7 @@ DROP TABLE IF EXISTS `product_image_i18n`; CREATE TABLE `product_image_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1752,7 +1736,7 @@ DROP TABLE IF EXISTS `product_document_i18n`; CREATE TABLE `product_document_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1773,7 +1757,7 @@ DROP TABLE IF EXISTS `currency_i18n`; CREATE TABLE `currency_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `name` VARCHAR(45), PRIMARY KEY (`id`,`locale`), CONSTRAINT `currency_i18n_FK_1` @@ -1791,7 +1775,7 @@ DROP TABLE IF EXISTS `order_status_i18n`; CREATE TABLE `order_status_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1812,7 +1796,7 @@ DROP TABLE IF EXISTS `module_i18n`; CREATE TABLE `module_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1833,7 +1817,7 @@ DROP TABLE IF EXISTS `group_i18n`; CREATE TABLE `group_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1854,7 +1838,7 @@ DROP TABLE IF EXISTS `resource_i18n`; CREATE TABLE `resource_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1875,7 +1859,7 @@ DROP TABLE IF EXISTS `message_i18n`; CREATE TABLE `message_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` TEXT, `description` LONGTEXT, `description_html` LONGTEXT, @@ -1886,6 +1870,23 @@ CREATE TABLE `message_i18n` ON DELETE CASCADE ) ENGINE=InnoDB; +-- --------------------------------------------------------------------- +-- coupon_i18n +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `coupon_i18n`; + +CREATE TABLE `coupon_i18n` +( + `id` INTEGER NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, + PRIMARY KEY (`id`,`locale`), + CONSTRAINT `coupon_i18n_FK_1` + FOREIGN KEY (`id`) + REFERENCES `coupon` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + -- --------------------------------------------------------------------- -- category_image_i18n -- --------------------------------------------------------------------- @@ -1895,7 +1896,7 @@ DROP TABLE IF EXISTS `category_image_i18n`; CREATE TABLE `category_image_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1916,7 +1917,7 @@ DROP TABLE IF EXISTS `folder_image_i18n`; CREATE TABLE `folder_image_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1937,7 +1938,7 @@ DROP TABLE IF EXISTS `content_image_i18n`; CREATE TABLE `content_image_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1958,7 +1959,7 @@ DROP TABLE IF EXISTS `category_document_i18n`; CREATE TABLE `category_document_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1979,7 +1980,7 @@ DROP TABLE IF EXISTS `content_document_i18n`; CREATE TABLE `content_document_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -2000,7 +2001,7 @@ DROP TABLE IF EXISTS `folder_document_i18n`; CREATE TABLE `folder_document_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -2132,5 +2133,34 @@ CREATE TABLE `message_version` ON DELETE CASCADE ) ENGINE=InnoDB; +-- --------------------------------------------------------------------- +-- coupon_version +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `coupon_version`; + +CREATE TABLE `coupon_version` +( + `id` INTEGER NOT NULL, + `code` VARCHAR(45) NOT NULL, + `type` VARCHAR(255) NOT NULL, + `title` VARCHAR(255) NOT NULL, + `short_description` TEXT NOT NULL, + `description` LONGTEXT NOT NULL, + `value` FLOAT NOT NULL, + `is_used` TINYINT NOT NULL, + `is_enabled` TINYINT NOT NULL, + `expiration_date` DATETIME NOT NULL, + `serialized_rules` TEXT NOT NULL, + `created_at` DATETIME, + `updated_at` DATETIME, + `version` INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (`id`,`version`), + CONSTRAINT `coupon_version_FK_1` + FOREIGN KEY (`id`) + REFERENCES `coupon` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + # This restores the fkey checks, after having unset them earlier SET FOREIGN_KEY_CHECKS = 1; From 17cc6faec38c4f23712e6392d537f462002cc0a0 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Thu, 22 Aug 2013 15:03:31 +0200 Subject: [PATCH 020/268] front end translation management in loops apply propel patch https://github.com/propelorm/Propel2/commit/6be7fa1c394712dcfd146004452c99757b81bf10 --- .../Thelia/Core/Template/Loop/Attribute.php | 31 ++++---- .../Template/Loop/AttributeAvailability.php | 31 ++++---- .../Template/Loop/AttributeCombination.php | 61 ++++++++++------ .../Thelia/Core/Template/Loop/Category.php | 51 ++++--------- .../lib/Thelia/Core/Template/Loop/Content.php | 29 +++----- .../lib/Thelia/Core/Template/Loop/Country.php | 30 +++----- .../lib/Thelia/Core/Template/Loop/Feature.php | 31 ++++---- .../Template/Loop/FeatureAvailability.php | 31 ++++---- .../Core/Template/Loop/FeatureValue.php | 41 ++++++----- core/lib/Thelia/Core/Template/Loop/Folder.php | 35 +++++---- .../lib/Thelia/Core/Template/Loop/Product.php | 27 +++---- .../Core/Template/Loop/ProductSaleElement.php | 10 --- core/lib/Thelia/Core/Template/Loop/Title.php | 25 +++---- core/lib/Thelia/Model/Base/Accessory.php | 2 +- core/lib/Thelia/Model/Base/Address.php | 2 +- core/lib/Thelia/Model/Base/Admin.php | 2 +- core/lib/Thelia/Model/Base/AdminGroup.php | 2 +- core/lib/Thelia/Model/Base/AdminLog.php | 2 +- core/lib/Thelia/Model/Base/Area.php | 2 +- core/lib/Thelia/Model/Base/Attribute.php | 12 +-- core/lib/Thelia/Model/Base/AttributeAv.php | 12 +-- .../lib/Thelia/Model/Base/AttributeAvI18n.php | 8 +- .../Thelia/Model/Base/AttributeAvQuery.php | 6 +- .../Thelia/Model/Base/AttributeCategory.php | 2 +- .../Model/Base/AttributeCombination.php | 2 +- core/lib/Thelia/Model/Base/AttributeI18n.php | 8 +- core/lib/Thelia/Model/Base/AttributeQuery.php | 6 +- core/lib/Thelia/Model/Base/Cart.php | 2 +- core/lib/Thelia/Model/Base/CartItem.php | 2 +- core/lib/Thelia/Model/Base/Category.php | 12 +-- .../Thelia/Model/Base/CategoryDocument.php | 12 +-- .../Model/Base/CategoryDocumentI18n.php | 8 +- .../Model/Base/CategoryDocumentQuery.php | 6 +- core/lib/Thelia/Model/Base/CategoryI18n.php | 8 +- core/lib/Thelia/Model/Base/CategoryImage.php | 12 +-- .../Thelia/Model/Base/CategoryImageI18n.php | 8 +- .../Thelia/Model/Base/CategoryImageQuery.php | 6 +- core/lib/Thelia/Model/Base/CategoryQuery.php | 6 +- .../lib/Thelia/Model/Base/CategoryVersion.php | 2 +- core/lib/Thelia/Model/Base/Config.php | 12 +-- core/lib/Thelia/Model/Base/ConfigI18n.php | 8 +- core/lib/Thelia/Model/Base/ConfigQuery.php | 6 +- core/lib/Thelia/Model/Base/Content.php | 12 +-- core/lib/Thelia/Model/Base/ContentAssoc.php | 2 +- .../lib/Thelia/Model/Base/ContentDocument.php | 12 +-- .../Thelia/Model/Base/ContentDocumentI18n.php | 8 +- .../Model/Base/ContentDocumentQuery.php | 6 +- core/lib/Thelia/Model/Base/ContentFolder.php | 2 +- core/lib/Thelia/Model/Base/ContentI18n.php | 8 +- core/lib/Thelia/Model/Base/ContentImage.php | 12 +-- .../Thelia/Model/Base/ContentImageI18n.php | 8 +- .../Thelia/Model/Base/ContentImageQuery.php | 6 +- core/lib/Thelia/Model/Base/ContentQuery.php | 6 +- core/lib/Thelia/Model/Base/ContentVersion.php | 2 +- core/lib/Thelia/Model/Base/Country.php | 12 +-- core/lib/Thelia/Model/Base/CountryI18n.php | 8 +- core/lib/Thelia/Model/Base/CountryQuery.php | 6 +- core/lib/Thelia/Model/Base/Coupon.php | 2 +- core/lib/Thelia/Model/Base/CouponOrder.php | 2 +- core/lib/Thelia/Model/Base/CouponRule.php | 2 +- core/lib/Thelia/Model/Base/Currency.php | 12 +-- core/lib/Thelia/Model/Base/CurrencyI18n.php | 8 +- core/lib/Thelia/Model/Base/CurrencyQuery.php | 6 +- core/lib/Thelia/Model/Base/Customer.php | 2 +- core/lib/Thelia/Model/Base/CustomerTitle.php | 12 +-- .../Thelia/Model/Base/CustomerTitleI18n.php | 8 +- .../Thelia/Model/Base/CustomerTitleQuery.php | 6 +- core/lib/Thelia/Model/Base/Delivzone.php | 2 +- core/lib/Thelia/Model/Base/Feature.php | 12 +-- core/lib/Thelia/Model/Base/FeatureAv.php | 12 +-- core/lib/Thelia/Model/Base/FeatureAvI18n.php | 8 +- core/lib/Thelia/Model/Base/FeatureAvQuery.php | 6 +- .../lib/Thelia/Model/Base/FeatureCategory.php | 2 +- core/lib/Thelia/Model/Base/FeatureI18n.php | 8 +- core/lib/Thelia/Model/Base/FeatureProduct.php | 2 +- core/lib/Thelia/Model/Base/FeatureQuery.php | 6 +- core/lib/Thelia/Model/Base/Folder.php | 12 +-- core/lib/Thelia/Model/Base/FolderDocument.php | 12 +-- .../Thelia/Model/Base/FolderDocumentI18n.php | 8 +- .../Thelia/Model/Base/FolderDocumentQuery.php | 6 +- core/lib/Thelia/Model/Base/FolderI18n.php | 8 +- core/lib/Thelia/Model/Base/FolderImage.php | 12 +-- .../lib/Thelia/Model/Base/FolderImageI18n.php | 8 +- .../Thelia/Model/Base/FolderImageQuery.php | 6 +- core/lib/Thelia/Model/Base/FolderQuery.php | 6 +- core/lib/Thelia/Model/Base/FolderVersion.php | 2 +- core/lib/Thelia/Model/Base/Group.php | 12 +-- core/lib/Thelia/Model/Base/GroupI18n.php | 8 +- core/lib/Thelia/Model/Base/GroupModule.php | 2 +- core/lib/Thelia/Model/Base/GroupQuery.php | 6 +- core/lib/Thelia/Model/Base/GroupResource.php | 2 +- core/lib/Thelia/Model/Base/Lang.php | 2 +- core/lib/Thelia/Model/Base/Message.php | 12 +-- core/lib/Thelia/Model/Base/MessageI18n.php | 8 +- core/lib/Thelia/Model/Base/MessageQuery.php | 6 +- core/lib/Thelia/Model/Base/MessageVersion.php | 2 +- core/lib/Thelia/Model/Base/Module.php | 12 +-- core/lib/Thelia/Model/Base/ModuleI18n.php | 8 +- core/lib/Thelia/Model/Base/ModuleQuery.php | 6 +- core/lib/Thelia/Model/Base/Order.php | 2 +- core/lib/Thelia/Model/Base/OrderAddress.php | 2 +- core/lib/Thelia/Model/Base/OrderFeature.php | 2 +- core/lib/Thelia/Model/Base/OrderProduct.php | 2 +- core/lib/Thelia/Model/Base/OrderStatus.php | 12 +-- .../lib/Thelia/Model/Base/OrderStatusI18n.php | 8 +- .../Thelia/Model/Base/OrderStatusQuery.php | 6 +- core/lib/Thelia/Model/Base/Product.php | 12 +-- .../lib/Thelia/Model/Base/ProductCategory.php | 2 +- .../lib/Thelia/Model/Base/ProductDocument.php | 12 +-- .../Thelia/Model/Base/ProductDocumentI18n.php | 8 +- .../Model/Base/ProductDocumentQuery.php | 6 +- core/lib/Thelia/Model/Base/ProductI18n.php | 8 +- core/lib/Thelia/Model/Base/ProductImage.php | 12 +-- .../Thelia/Model/Base/ProductImageI18n.php | 8 +- .../Thelia/Model/Base/ProductImageQuery.php | 6 +- core/lib/Thelia/Model/Base/ProductPrice.php | 2 +- core/lib/Thelia/Model/Base/ProductQuery.php | 6 +- .../Thelia/Model/Base/ProductSaleElements.php | 2 +- core/lib/Thelia/Model/Base/ProductVersion.php | 2 +- core/lib/Thelia/Model/Base/Resource.php | 12 +-- core/lib/Thelia/Model/Base/ResourceI18n.php | 8 +- core/lib/Thelia/Model/Base/ResourceQuery.php | 6 +- core/lib/Thelia/Model/Base/Rewriting.php | 2 +- core/lib/Thelia/Model/Base/Tax.php | 12 +-- core/lib/Thelia/Model/Base/TaxI18n.php | 8 +- core/lib/Thelia/Model/Base/TaxQuery.php | 6 +- core/lib/Thelia/Model/Base/TaxRule.php | 12 +-- core/lib/Thelia/Model/Base/TaxRuleCountry.php | 2 +- core/lib/Thelia/Model/Base/TaxRuleI18n.php | 8 +- core/lib/Thelia/Model/Base/TaxRuleQuery.php | 6 +- .../Model/Map/AttributeAvI18nTableMap.php | 2 +- .../Thelia/Model/Map/AttributeAvTableMap.php | 2 +- .../Model/Map/AttributeI18nTableMap.php | 2 +- .../Thelia/Model/Map/AttributeTableMap.php | 2 +- .../Map/CategoryDocumentI18nTableMap.php | 2 +- .../Model/Map/CategoryDocumentTableMap.php | 2 +- .../Thelia/Model/Map/CategoryI18nTableMap.php | 2 +- .../Model/Map/CategoryImageI18nTableMap.php | 2 +- .../Model/Map/CategoryImageTableMap.php | 2 +- .../lib/Thelia/Model/Map/CategoryTableMap.php | 2 +- .../Thelia/Model/Map/ConfigI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ConfigTableMap.php | 2 +- .../Model/Map/ContentDocumentI18nTableMap.php | 2 +- .../Model/Map/ContentDocumentTableMap.php | 2 +- .../Thelia/Model/Map/ContentI18nTableMap.php | 2 +- .../Model/Map/ContentImageI18nTableMap.php | 2 +- .../Thelia/Model/Map/ContentImageTableMap.php | 2 +- core/lib/Thelia/Model/Map/ContentTableMap.php | 2 +- .../Thelia/Model/Map/CountryI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/CountryTableMap.php | 2 +- .../Thelia/Model/Map/CurrencyI18nTableMap.php | 2 +- .../lib/Thelia/Model/Map/CurrencyTableMap.php | 2 +- .../Model/Map/CustomerTitleI18nTableMap.php | 2 +- .../Model/Map/CustomerTitleTableMap.php | 2 +- .../Model/Map/FeatureAvI18nTableMap.php | 2 +- .../Thelia/Model/Map/FeatureAvTableMap.php | 2 +- .../Thelia/Model/Map/FeatureI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/FeatureTableMap.php | 2 +- .../Model/Map/FolderDocumentI18nTableMap.php | 2 +- .../Model/Map/FolderDocumentTableMap.php | 2 +- .../Thelia/Model/Map/FolderI18nTableMap.php | 2 +- .../Model/Map/FolderImageI18nTableMap.php | 2 +- .../Thelia/Model/Map/FolderImageTableMap.php | 2 +- core/lib/Thelia/Model/Map/FolderTableMap.php | 2 +- .../Thelia/Model/Map/GroupI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/GroupTableMap.php | 2 +- .../Thelia/Model/Map/MessageI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/MessageTableMap.php | 2 +- .../Thelia/Model/Map/ModuleI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ModuleTableMap.php | 2 +- .../Model/Map/OrderStatusI18nTableMap.php | 2 +- .../Thelia/Model/Map/OrderStatusTableMap.php | 2 +- .../Model/Map/ProductDocumentI18nTableMap.php | 2 +- .../Model/Map/ProductDocumentTableMap.php | 2 +- .../Thelia/Model/Map/ProductI18nTableMap.php | 2 +- .../Model/Map/ProductImageI18nTableMap.php | 2 +- .../Thelia/Model/Map/ProductImageTableMap.php | 2 +- core/lib/Thelia/Model/Map/ProductTableMap.php | 2 +- .../Thelia/Model/Map/ResourceI18nTableMap.php | 2 +- .../lib/Thelia/Model/Map/ResourceTableMap.php | 2 +- core/lib/Thelia/Model/Map/TaxI18nTableMap.php | 2 +- .../Thelia/Model/Map/TaxRuleI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/TaxRuleTableMap.php | 2 +- core/lib/Thelia/Model/Map/TaxTableMap.php | 2 +- .../Thelia/Model/Tools/ModelCriteriaTools.php | 73 +++++++++++++++++++ 185 files changed, 702 insertions(+), 686 deletions(-) create mode 100755 core/lib/Thelia/Model/Tools/ModelCriteriaTools.php diff --git a/core/lib/Thelia/Core/Template/Loop/Attribute.php b/core/lib/Thelia/Core/Template/Loop/Attribute.php index 1c7b23acf..84549aaa5 100755 --- a/core/lib/Thelia/Core/Template/Loop/Attribute.php +++ b/core/lib/Thelia/Core/Template/Loop/Attribute.php @@ -33,6 +33,8 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; +use Thelia\Model\Tools\ModelCriteriaTools; + use Thelia\Model\Base\CategoryQuery; use Thelia\Model\Base\ProductCategoryQuery; use Thelia\Model\Base\AttributeQuery; @@ -83,6 +85,9 @@ class Attribute extends BaseLoop { $search = AttributeQuery::create(); + /* manage translations */ + ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $id = $this->getId(); if (null !== $id) { @@ -124,10 +129,10 @@ class Attribute extends BaseLoop foreach($orders as $order) { switch ($order) { case "alpha": - $search->addAscendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE); + $search->addAscendingOrderByColumn('i18n_TITLE'); break; case "alpha_reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE); + $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "manual": $search->orderByPosition(Criteria::ASC); @@ -138,28 +143,18 @@ class Attribute extends BaseLoop } } - /** - * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - $search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - ); - + /* perform search */ $attributes = $this->search($search, $pagination); $loopResult = new LoopResult(); foreach ($attributes as $attribute) { $loopResultRow = new LoopResultRow(); - $loopResultRow->set("ID", $attribute->getId()); - $loopResultRow->set("TITLE",$attribute->getTitle()); - $loopResultRow->set("CHAPO", $attribute->getChapo()); - $loopResultRow->set("DESCRIPTION", $attribute->getDescription()); - $loopResultRow->set("POSTSCRIPTUM", $attribute->getPostscriptum()); + $loopResultRow->set("ID", $attribute->getId()) + ->set("TITLE",$attribute->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $attribute->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $attribute->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $attribute->getVirtualColumn('i18n_POSTSCRIPTUM')); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php index 1033bf450..ade493efa 100755 --- a/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php +++ b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php @@ -33,6 +33,8 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; +use Thelia\Model\Tools\ModelCriteriaTools; + use Thelia\Model\Base\AttributeAvQuery; use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; @@ -76,6 +78,9 @@ class AttributeAvailability extends BaseLoop { $search = AttributeAvQuery::create(); + /* manage translations */ + ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $id = $this->getId(); if (null !== $id) { @@ -99,10 +104,10 @@ class AttributeAvailability extends BaseLoop foreach($orders as $order) { switch ($order) { case "alpha": - $search->addAscendingOrderByColumn(\Thelia\Model\Map\AttributeAvI18nTableMap::TITLE); + $search->addAscendingOrderByColumn('i18n_TITLE'); break; case "alpha_reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\Map\AttributeAvI18nTableMap::TITLE); + $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "manual": $search->orderByPosition(Criteria::ASC); @@ -113,28 +118,18 @@ class AttributeAvailability extends BaseLoop } } - /** - * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - $search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - ); - + /* perform search */ $attributesAv = $this->search($search, $pagination); $loopResult = new LoopResult(); foreach ($attributesAv as $attributeAv) { $loopResultRow = new LoopResultRow(); - $loopResultRow->set("ID", $attributeAv->getId()); - $loopResultRow->set("TITLE",$attributeAv->getTitle()); - $loopResultRow->set("CHAPO", $attributeAv->getChapo()); - $loopResultRow->set("DESCRIPTION", $attributeAv->getDescription()); - $loopResultRow->set("POSTSCRIPTUM", $attributeAv->getPostscriptum()); + $loopResultRow->set("ID", $attributeAv->getId()) + ->set("TITLE",$attributeAv->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $attributeAv->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $attributeAv->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $attributeAv->getVirtualColumn('i18n_POSTSCRIPTUM')); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php b/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php index f0b54c4f3..e6cc804da 100755 --- a/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php +++ b/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php @@ -33,7 +33,11 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; +use Thelia\Model\Tools\ModelCriteriaTools; + use Thelia\Model\Base\AttributeCombinationQuery; +use Thelia\Model\Map\AttributeAvTableMap; +use Thelia\Model\Map\AttributeTableMap; use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -58,9 +62,9 @@ class AttributeCombination extends BaseLoop new Argument( 'order', new TypeCollection( - new Type\EnumListType(array('attribute_availability', 'attribute_availability_reverse', 'attribute', 'attribute_reverse')) + new Type\EnumListType(array('alpha', 'alpha_reverse')) ), - 'attribute' + 'alpha' ) ); } @@ -74,6 +78,26 @@ class AttributeCombination extends BaseLoop { $search = AttributeCombinationQuery::create(); + /* manage attribute translations */ + ModelCriteriaTools::getI18n( + $search, + ConfigQuery::read("default_lang_without_translation", 1), + $this->request->getSession()->getLocale(), + array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), + AttributeTableMap::TABLE_NAME, + 'ATTRIBUTE_ID' + ); + + /* manage attributeAv translations */ + ModelCriteriaTools::getI18n( + $search, + ConfigQuery::read("default_lang_without_translation", 1), + $this->request->getSession()->getLocale(), + array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), + AttributeAvTableMap::TABLE_NAME, + 'ATTRIBUTE_AV_ID' + ); + $productSaleElement = $this->getProduct_sale_element(); $search->filterByProductSaleElementsId($productSaleElement, Criteria::EQUAL); @@ -82,17 +106,11 @@ class AttributeCombination extends BaseLoop foreach($orders as $order) { switch ($order) { - case "attribute_availability": - //$search->addAscendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE); + case "alpha": + $search->addAscendingOrderByColumn(AttributeTableMap::TABLE_NAME . '_i18n_TITLE'); break; - case "attribute_availability_reverse": - //$search->addDescendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE); - break; - case "attribute": - //$search->orderByPosition(Criteria::ASC); - break; - case "attribute_reverse": - //$search->orderByPosition(Criteria::DESC); + case "alpha_reverse": + $search->addDescendingOrderByColumn(AttributeTableMap::TABLE_NAME . '_i18n_TITLE'); break; } } @@ -104,18 +122,15 @@ class AttributeCombination extends BaseLoop foreach ($attributeCombinations as $attributeCombination) { $loopResultRow = new LoopResultRow(); - $attribute = $attributeCombination->getAttribute(); - $attributeAvailability = $attributeCombination->getAttributeAv(); - $loopResultRow - ->set("ATTRIBUTE_TITLE", $attribute->getTitle()) - ->set("ATTRIBUTE_CHAPO", $attribute->getChapo()) - ->set("ATTRIBUTE_DESCRIPTION", $attribute->getDescription()) - ->set("ATTRIBUTE_POSTSCRIPTUM", $attribute->getPostscriptum()) - ->set("ATTRIBUTE_AVAILABILITY_TITLE", $attributeAvailability->getTitle()) - ->set("ATTRIBUTE_AVAILABILITY_CHAPO", $attributeAvailability->getChapo()) - ->set("ATTRIBUTE_AVAILABILITY_DESCRIPTION", $attributeAvailability->getDescription()) - ->set("ATTRIBUTE_AVAILABILITY_POSTSCRIPTUM", $attributeAvailability->getPostscriptum()); + ->set("ATTRIBUTE_TITLE", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_TITLE')) + ->set("ATTRIBUTE_CHAPO", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_CHAPO')) + ->set("ATTRIBUTE_DESCRIPTION", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_DESCRIPTION')) + ->set("ATTRIBUTE_POSTSCRIPTUM", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM')) + ->set("ATTRIBUTE_AVAILABILITY_TITLE", $attributeCombination->getVirtualColumn(AttributeAvTableMap::TABLE_NAME . '_i18n_TITLE')) + ->set("ATTRIBUTE_AVAILABILITY_CHAPO", $attributeCombination->getVirtualColumn(AttributeAvTableMap::TABLE_NAME . '_i18n_CHAPO')) + ->set("ATTRIBUTE_AVAILABILITY_DESCRIPTION", $attributeCombination->getVirtualColumn(AttributeAvTableMap::TABLE_NAME . '_i18n_DESCRIPTION')) + ->set("ATTRIBUTE_AVAILABILITY_POSTSCRIPTUM", $attributeCombination->getVirtualColumn(AttributeAvTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM')); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index b0f9e2862..1233ccd4e 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -32,6 +32,8 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; +use Thelia\Model\Tools\ModelCriteriaTools; + use Thelia\Model\CategoryQuery; use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; @@ -95,6 +97,9 @@ class Category extends BaseLoop { $search = CategoryQuery::create(); + /* manage translations */ + ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $id = $this->getId(); if (!is_null($id)) { @@ -131,10 +136,10 @@ class Category extends BaseLoop foreach($orders as $order) { switch ($order) { case "alpha": - $search->addAscendingOrderByColumn(\Thelia\Model\Map\CategoryI18nTableMap::TITLE); + $search->addAscendingOrderByColumn('i18n_TITLE'); break; case "alpha_reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\Map\CategoryI18nTableMap::TITLE); + $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "manual_reverse": $search->orderByPosition(Criteria::DESC); @@ -150,50 +155,20 @@ class Category extends BaseLoop } } - /** - * \Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - if(ConfigQuery::read("default_lang_without_translation", 1) == 0) { - /* - * don't use the following to be able to use the same getter than below - * $search->joinWithI18n( $this->request->getSession()->getLocale(), Criteria::INNER_JOIN ); - */ - $search->joinCategoryI18n('asked_locale_i18n', Criteria::INNER_JOIN) - ->addJoinCondition('asked_locale_i18n' ,'`asked_locale_i18n`.LOCALE = ?', 'en_EN', null, \PDO::PARAM_STR); - - $search->withColumn('`asked_locale_i18n`.TITLE', 'i18n_TITLE'); - $search->withColumn('`asked_locale_i18n`.CHAPO', 'i18n_CHAPO'); - $search->withColumn('`asked_locale_i18n`.DESCRIPTION', 'i18n_DESCRIPTION'); - $search->withColumn('`asked_locale_i18n`.POSTSCRIPTUM', 'i18n_POSTSCRIPTUM'); - } else { - $search->joinCategoryI18n('default_locale_i18n') - ->addJoinCondition('default_locale_i18n' ,'`default_locale_i18n`.LOCALE = ?', 'fr_FR', null, \PDO::PARAM_STR); - - $search->joinCategoryI18n('asked_locale_i18n') - ->addJoinCondition('asked_locale_i18n' ,'`asked_locale_i18n`.LOCALE = ?', 'en_EN', null, \PDO::PARAM_STR); - - $search->where('NOT ISNULL(`asked_locale_i18n`.ID)')->_or()->where('NOT ISNULL(`default_locale_i18n`.ID)'); - - $search->withColumn('CASE WHEN ISNULL(`asked_locale_i18n`.ID) THEN `asked_locale_i18n`.TITLE ELSE `asked_locale_i18n`.TITLE END', 'i18n_TITLE'); - $search->withColumn('CASE WHEN ISNULL(`asked_locale_i18n`.ID) THEN `asked_locale_i18n`.CHAPO ELSE `asked_locale_i18n`.CHAPO END', 'i18n_CHAPO'); - $search->withColumn('CASE WHEN ISNULL(`asked_locale_i18n`.ID) THEN `asked_locale_i18n`.DESCRIPTION ELSE `asked_locale_i18n`.DESCRIPTION END', 'i18n_DESCRIPTION'); - $search->withColumn('CASE WHEN ISNULL(`asked_locale_i18n`.ID) THEN `asked_locale_i18n`.POSTSCRIPTUM ELSE `asked_locale_i18n`.POSTSCRIPTUM END', 'i18n_POSTSCRIPTUM'); - } - + /* perform search */ $categories = $this->search($search, $pagination); + /* @todo */ $notEmpty = $this->getNot_empty(); $loopResult = new LoopResult(); foreach ($categories as $category) { - if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue; - - $x = $category->getTitle(); + /* + * no cause pagination lost : + * if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue; + */ $loopResultRow = new LoopResultRow(); diff --git a/core/lib/Thelia/Core/Template/Loop/Content.php b/core/lib/Thelia/Core/Template/Loop/Content.php index 15bb2068c..3a81ff9f2 100755 --- a/core/lib/Thelia/Core/Template/Loop/Content.php +++ b/core/lib/Thelia/Core/Template/Loop/Content.php @@ -31,6 +31,8 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Model\Tools\ModelCriteriaTools; + use Thelia\Model\FolderQuery; use Thelia\Model\Map\ContentTableMap; use Thelia\Model\ContentFolderQuery; @@ -85,6 +87,9 @@ class Content extends BaseLoop { $search = ContentQuery::create(); + /* manage translations */ + ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $id = $this->getId(); if (!is_null($id)) { @@ -153,10 +158,10 @@ class Content extends BaseLoop foreach ($orders as $order) { switch ($order) { case "alpha": - $search->addAscendingOrderByColumn(\Thelia\Model\Map\ContentI18nTableMap::TITLE); + $search->addAscendingOrderByColumn('i18n_TITLE'); break; case "alpha-reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\Map\ContentI18nTableMap::TITLE); + $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "manual": if(null === $folder || count($folder) != 1) @@ -199,17 +204,7 @@ class Content extends BaseLoop ); } - /** - * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - $search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - ); - + /* perform search */ $search->groupBy(ContentTableMap::ID); $contents = $this->search($search, $pagination); @@ -220,10 +215,10 @@ class Content extends BaseLoop $loopResultRow = new LoopResultRow(); $loopResultRow->set("ID", $content->getId()) - ->set("TITLE",$content->getTitle()) - ->set("CHAPO", $content->getChapo()) - ->set("DESCRIPTION", $content->getDescription()) - ->set("POSTSCRIPTUM", $content->getPostscriptum()) + ->set("TITLE",$content->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $content->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $content->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $content->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("POSITION", $content->getPosition()) ; diff --git a/core/lib/Thelia/Core/Template/Loop/Country.php b/core/lib/Thelia/Core/Template/Loop/Country.php index 475a4608b..73e1fd410 100755 --- a/core/lib/Thelia/Core/Template/Loop/Country.php +++ b/core/lib/Thelia/Core/Template/Loop/Country.php @@ -31,6 +31,8 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Model\Tools\ModelCriteriaTools; + use Thelia\Model\CountryQuery; use Thelia\Model\ConfigQuery; @@ -68,6 +70,9 @@ class Country extends BaseLoop { $search = CountryQuery::create(); + /* manage translations */ + ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $id = $this->getId(); if (null !== $id) { @@ -94,31 +99,20 @@ class Country extends BaseLoop $search->filterById($exclude, Criteria::NOT_IN); } - /** - * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - $search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - ); - - $search->addAscendingOrderByColumn(\Thelia\Model\Map\CountryI18nTableMap::TITLE); + $search->addAscendingOrderByColumn('i18n_TITLE'); + /* perform search */ $countries = $this->search($search, $pagination); $loopResult = new LoopResult(); foreach ($countries as $country) { $loopResultRow = new LoopResultRow(); - $loopResultRow->set("ID", $country->getId()); - $loopResultRow->set("AREA", $country->getAreaId()); - $loopResultRow->set("TITLE", $country->getTitle()); - $loopResultRow->set("CHAPO", $country->getChapo()); - $loopResultRow->set("DESCRIPTION", $country->getDescription()); - $loopResultRow->set("POSTSCRIPTUM", $country->getPostscriptum()); + $loopResultRow->set("ID", $country->getId()) + ->set("TITLE",$country->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $country->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $country->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $country->getVirtualColumn('i18n_POSTSCRIPTUM')); $loopResultRow->set("ISOCODE", $country->getIsocode()); $loopResultRow->set("ISOALPHA2", $country->getIsoalpha2()); $loopResultRow->set("ISOALPHA3", $country->getIsoalpha3()); diff --git a/core/lib/Thelia/Core/Template/Loop/Feature.php b/core/lib/Thelia/Core/Template/Loop/Feature.php index cf8dcc563..0693a303a 100755 --- a/core/lib/Thelia/Core/Template/Loop/Feature.php +++ b/core/lib/Thelia/Core/Template/Loop/Feature.php @@ -31,6 +31,8 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Model\Tools\ModelCriteriaTools; + use Thelia\Model\Base\CategoryQuery; use Thelia\Model\Base\ProductCategoryQuery; use Thelia\Model\Base\FeatureQuery; @@ -81,6 +83,9 @@ class Feature extends BaseLoop { $search = FeatureQuery::create(); + /* manage translations */ + ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $id = $this->getId(); if (null !== $id) { @@ -122,10 +127,10 @@ class Feature extends BaseLoop foreach ($orders as $order) { switch ($order) { case "alpha": - $search->addAscendingOrderByColumn(\Thelia\Model\Map\FeatureI18nTableMap::TITLE); + $search->addAscendingOrderByColumn('i18n_TITLE'); break; case "alpha-reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\Map\FeatureI18nTableMap::TITLE); + $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "manual": $search->orderByPosition(Criteria::ASC); @@ -136,28 +141,18 @@ class Feature extends BaseLoop } } - /** - * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - $search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - ); - + /* perform search */ $features = $this->search($search, $pagination); $loopResult = new LoopResult(); foreach ($features as $feature) { $loopResultRow = new LoopResultRow(); - $loopResultRow->set("ID", $feature->getId()); - $loopResultRow->set("TITLE",$feature->getTitle()); - $loopResultRow->set("CHAPO", $feature->getChapo()); - $loopResultRow->set("DESCRIPTION", $feature->getDescription()); - $loopResultRow->set("POSTSCRIPTUM", $feature->getPostscriptum()); + $loopResultRow->set("ID", $feature->getId()) + ->set("TITLE",$feature->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $feature->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $feature->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $feature->getVirtualColumn('i18n_POSTSCRIPTUM')); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php index 35e586df1..272bb5211 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php @@ -31,6 +31,8 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Model\Tools\ModelCriteriaTools; + use Thelia\Model\Base\FeatureAvQuery; use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; @@ -74,6 +76,9 @@ class FeatureAvailability extends BaseLoop { $search = FeatureAvQuery::create(); + /* manage translations */ + ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $id = $this->getId(); if (null !== $id) { @@ -97,10 +102,10 @@ class FeatureAvailability extends BaseLoop foreach ($orders as $order) { switch ($order) { case "alpha": - $search->addAscendingOrderByColumn(\Thelia\Model\Map\FeatureAvI18nTableMap::TITLE); + $search->addAscendingOrderByColumn('i18n_TITLE'); break; case "alpha-reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\Map\FeatureAvI18nTableMap::TITLE); + $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "manual": $search->orderByPosition(Criteria::ASC); @@ -111,28 +116,18 @@ class FeatureAvailability extends BaseLoop } } - /** - * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - $search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - ); - + /* perform search */ $featuresAv = $this->search($search, $pagination); $loopResult = new LoopResult(); foreach ($featuresAv as $featureAv) { $loopResultRow = new LoopResultRow(); - $loopResultRow->set("ID", $featureAv->getId()); - $loopResultRow->set("TITLE",$featureAv->getTitle()); - $loopResultRow->set("CHAPO", $featureAv->getChapo()); - $loopResultRow->set("DESCRIPTION", $featureAv->getDescription()); - $loopResultRow->set("POSTSCRIPTUM", $featureAv->getPostscriptum()); + $loopResultRow->set("ID", $featureAv->getId()) + ->set("TITLE",$featureAv->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $featureAv->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $featureAv->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $featureAv->getVirtualColumn('i18n_POSTSCRIPTUM')); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php index 1eaf926e0..358b8d339 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php @@ -33,9 +33,12 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; +use Thelia\Model\Tools\ModelCriteriaTools; + use Thelia\Model\Base\FeatureProductQuery; use Thelia\Model\ConfigQuery; -use Thelia\Model\FeatureAvQuery; +use Thelia\Model\Map\FeatureAvTableMap; +use Thelia\Model\Map\FeatureProductTableMap; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -80,6 +83,16 @@ class FeatureValue extends BaseLoop { $search = FeatureProductQuery::create(); + /* manage featureAv translations */ + ModelCriteriaTools::getI18n( + $search, + ConfigQuery::read("default_lang_without_translation", 1), + $this->request->getSession()->getLocale(), + array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), + FeatureAvTableMap::TABLE_NAME, + 'FEATURE_AV_ID' + ); + $feature = $this->getFeature(); $search->filterByFeatureId($feature, Criteria::EQUAL); @@ -109,16 +122,16 @@ class FeatureValue extends BaseLoop foreach($orders as $order) { switch ($order) { case "alpha": - //$search->addAscendingOrderByColumn(\Thelia\Model\Map\FeatureI18nTableMap::TITLE); + $search->addAscendingOrderByColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE'); break; case "alpha_reverse": - //$search->addDescendingOrderByColumn(\Thelia\Model\Map\FeatureI18nTableMap::TITLE); + $search->addDescendingOrderByColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE'); break; case "manual": - //$search->orderByPosition(Criteria::ASC); + $search->orderByPosition(Criteria::ASC); break; case "manual_reverse": - //$search->orderByPosition(Criteria::DESC); + $search->orderByPosition(Criteria::DESC); break; } } @@ -131,19 +144,11 @@ class FeatureValue extends BaseLoop $loopResultRow = new LoopResultRow(); $loopResultRow->set("ID", $featureValue->getId()); - $loopResultRow->set("PERSONAL_VALUE", $featureValue->getByDefault()); - - $featureAvailability = null; - if($featureValue->getFeatureAvId() !== null) { - $featureAvailability = FeatureAvQuery::create() - ->joinWithI18n('fr_FR') - ->findPk($featureValue->getFeatureAvId()); - } - - $loopResultRow->set("TITLE", ($featureAvailability === null ? '' : $featureAvailability->getTitle())); - $loopResultRow->set("CHAPO", ($featureAvailability === null ? '' : $featureAvailability->getChapo())); - $loopResultRow->set("DESCRIPTION", ($featureAvailability === null ? '' : $featureAvailability->getDescription())); - $loopResultRow->set("POSTSCRIPTUM", ($featureAvailability === null ? '' : $featureAvailability->getPostscriptum())); + $loopResultRow->set("PERSONAL_VALUE", $featureValue->getByDefault()) + ->set("TITLE",$featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE')) + ->set("CHAPO", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_CHAPO')) + ->set("DESCRIPTION", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM')); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php index e41361d0a..7062a55b4 100755 --- a/core/lib/Thelia/Core/Template/Loop/Folder.php +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -32,6 +32,8 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; +use Thelia\Model\Tools\ModelCriteriaTools; + use Thelia\Model\FolderQuery; use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; @@ -77,6 +79,9 @@ class Folder extends BaseLoop { $search = FolderQuery::create(); + /* manage translations */ + ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $id = $this->getId(); if (!is_null($id)) { @@ -114,10 +119,10 @@ class Folder extends BaseLoop foreach($orders as $order) { switch ($order) { case "alpha": - $search->addAscendingOrderByColumn(\Thelia\Model\Map\FolderI18nTableMap::TITLE); + $search->addAscendingOrderByColumn('i18n_TITLE'); break; case "alpha_reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\Map\FolderI18nTableMap::TITLE); + $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "manual_reverse": $search->orderByPosition(Criteria::DESC); @@ -133,35 +138,29 @@ class Folder extends BaseLoop } } - /** - * \Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - $search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - ); - + /* perform search */ $folders = $this->search($search, $pagination); + /* @todo */ $notEmpty = $this->getNot_empty(); $loopResult = new LoopResult(); foreach ($folders as $folder) { - if ($notEmpty && $folder->countAllProducts() == 0) continue; + /* + * no cause pagination lost : + * if ($notEmpty && $folder->countAllProducts() == 0) continue; + */ $loopResultRow = new LoopResultRow(); $loopResultRow ->set("ID", $folder->getId()) - ->set("TITLE",$folder->getTitle()) - ->set("CHAPO", $folder->getChapo()) - ->set("DESCRIPTION", $folder->getDescription()) - ->set("POSTSCRIPTUM", $folder->getPostscriptum()) + ->set("TITLE",$folder->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $folder->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $folder->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("PARENT", $folder->getParent()) ->set("CONTENT_COUNT", $folder->countChild()) ->set("VISIBLE", $folder->getVisible() ? "1" : "0") diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 74eda3a00..9c22a4987 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -33,6 +33,8 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; +use Thelia\Model\Tools\ModelCriteriaTools; + use Thelia\Model\CategoryQuery; use Thelia\Model\Map\FeatureProductTableMap; use Thelia\Model\Map\ProductPriceTableMap; @@ -135,16 +137,8 @@ class Product extends BaseLoop { $search = ProductQuery::create(); - /** - * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - $search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - ); + /* manage translations */ + ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); $attributeNonStrictMatch = $this->getAttribute_non_strict_match(); $isPSELeftJoinList = array(); @@ -460,10 +454,10 @@ class Product extends BaseLoop foreach($orders as $order) { switch ($order) { case "alpha": - $search->addAscendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE); + $search->addAscendingOrderByColumn('i18n_TITLE'); break; case "alpha_reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE); + $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "min_price": $search->addAscendingOrderByColumn('real_lowest_price', Criteria::ASC); @@ -506,6 +500,7 @@ class Product extends BaseLoop } } + /* perform search */ $products = $this->search($search, $pagination); $loopResult = new LoopResult(); @@ -515,10 +510,10 @@ class Product extends BaseLoop $loopResultRow->set("ID", $product->getId()) ->set("REF",$product->getRef()) - ->set("TITLE",$product->getTitle()) - ->set("CHAPO", $product->getChapo()) - ->set("DESCRIPTION", $product->getDescription()) - ->set("POSTSCRIPTUM", $product->getPostscriptum()) + ->set("TITLE",$product->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("BEST_PRICE", $product->getVirtualColumn('real_lowest_price')) ->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo')) ->set("IS_NEW", $product->getVirtualColumn('main_product_is_new')) diff --git a/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php b/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php index 36b234c33..1db2bcda2 100755 --- a/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php +++ b/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php @@ -132,16 +132,6 @@ class ProductSaleElements extends BaseLoop ->set("PRICE", $PSEValue->getVirtualColumn('price_PRICE')) ->set("PROMO_PRICE", $PSEValue->getVirtualColumn('price_PROMO_PRICE')); - //$price = $PSEValue->getAttributeAv(); - - /* - $attributeAvailability = $PSEValue->getAttributeAv(); - - $loopResultRow->set("TITLE", ($attributeAvailability === null ? '' : $attributeAvailability->getTitle())); - $loopResultRow->set("CHAPO", ($attributeAvailability === null ? '' : $attributeAvailability->getChapo())); - $loopResultRow->set("DESCRIPTION", ($attributeAvailability === null ? '' : $attributeAvailability->getDescription())); - $loopResultRow->set("POSTSCRIPTUM", ($attributeAvailability === null ? '' : $attributeAvailability->getPostscriptum()));*/ - $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Title.php b/core/lib/Thelia/Core/Template/Loop/Title.php index b4b7c5421..843e29334 100755 --- a/core/lib/Thelia/Core/Template/Loop/Title.php +++ b/core/lib/Thelia/Core/Template/Loop/Title.php @@ -31,6 +31,8 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Model\Tools\ModelCriteriaTools; + use Thelia\Model\CustomerTitleQuery; use Thelia\Model\ConfigQuery; @@ -64,35 +66,28 @@ class Title extends BaseLoop { $search = CustomerTitleQuery::create(); + /* manage translations */ + ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), array('SHORT', 'LONG')); + $id = $this->getId(); if (null !== $id) { $search->filterById($id, Criteria::IN); } - /** - * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - $search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - ); - $search->orderByPosition(); + /* perform search */ $titles = $this->search($search, $pagination); $loopResult = new LoopResult(); foreach ($titles as $title) { $loopResultRow = new LoopResultRow(); - $loopResultRow->set("ID", $title->getId()); - $loopResultRow->set("DEFAULT", $title->getByDefault()); - $loopResultRow->set("SHORT", $title->getShort()); - $loopResultRow->set("LONG", $title->getLong()); + $loopResultRow->set("ID", $title->getId()) + ->set("DEFAULT", $title->getByDefault()) + ->set("SHORT", $title->getVirtualColumn('i18n_SHORT')) + ->set("LONG", $title->getVirtualColumn('i18n_LONG')); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Model/Base/Accessory.php b/core/lib/Thelia/Model/Base/Accessory.php index f4110b19e..183f59947 100755 --- a/core/lib/Thelia/Model/Base/Accessory.php +++ b/core/lib/Thelia/Model/Base/Accessory.php @@ -266,7 +266,7 @@ abstract class Accessory implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Address.php b/core/lib/Thelia/Model/Base/Address.php index 45cad61aa..a6ab068d1 100755 --- a/core/lib/Thelia/Model/Base/Address.php +++ b/core/lib/Thelia/Model/Base/Address.php @@ -388,7 +388,7 @@ abstract class Address implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Admin.php b/core/lib/Thelia/Model/Base/Admin.php index b1241473e..6110aee7a 100755 --- a/core/lib/Thelia/Model/Base/Admin.php +++ b/core/lib/Thelia/Model/Base/Admin.php @@ -300,7 +300,7 @@ abstract class Admin implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/AdminGroup.php b/core/lib/Thelia/Model/Base/AdminGroup.php index 60141e3f8..9eadbb107 100755 --- a/core/lib/Thelia/Model/Base/AdminGroup.php +++ b/core/lib/Thelia/Model/Base/AdminGroup.php @@ -262,7 +262,7 @@ abstract class AdminGroup implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/AdminLog.php b/core/lib/Thelia/Model/Base/AdminLog.php index c83be20ee..ae828e4bb 100755 --- a/core/lib/Thelia/Model/Base/AdminLog.php +++ b/core/lib/Thelia/Model/Base/AdminLog.php @@ -266,7 +266,7 @@ abstract class AdminLog implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Area.php b/core/lib/Thelia/Model/Base/Area.php index fbd3199f4..08fc8be42 100755 --- a/core/lib/Thelia/Model/Base/Area.php +++ b/core/lib/Thelia/Model/Base/Area.php @@ -277,7 +277,7 @@ abstract class Area implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Attribute.php b/core/lib/Thelia/Model/Base/Attribute.php index efe4a631d..21fb3389a 100755 --- a/core/lib/Thelia/Model/Base/Attribute.php +++ b/core/lib/Thelia/Model/Base/Attribute.php @@ -132,7 +132,7 @@ abstract class Attribute implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -326,7 +326,7 @@ abstract class Attribute implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -2554,7 +2554,7 @@ abstract class Attribute implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collAttributeAvs instanceof Collection) { @@ -2612,7 +2612,7 @@ abstract class Attribute implements ActiveRecordInterface * * @return ChildAttribute The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2636,7 +2636,7 @@ abstract class Attribute implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildAttributeI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collAttributeI18ns) { @@ -2671,7 +2671,7 @@ abstract class Attribute implements ActiveRecordInterface * * @return ChildAttribute The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildAttributeI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/AttributeAv.php b/core/lib/Thelia/Model/Base/AttributeAv.php index 43a1be294..817c9738d 100755 --- a/core/lib/Thelia/Model/Base/AttributeAv.php +++ b/core/lib/Thelia/Model/Base/AttributeAv.php @@ -122,7 +122,7 @@ abstract class AttributeAv implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -298,7 +298,7 @@ abstract class AttributeAv implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1903,7 +1903,7 @@ abstract class AttributeAv implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collAttributeCombinations instanceof Collection) { @@ -1950,7 +1950,7 @@ abstract class AttributeAv implements ActiveRecordInterface * * @return ChildAttributeAv The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1974,7 +1974,7 @@ abstract class AttributeAv implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildAttributeAvI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collAttributeAvI18ns) { @@ -2009,7 +2009,7 @@ abstract class AttributeAv implements ActiveRecordInterface * * @return ChildAttributeAv The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildAttributeAvI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/AttributeAvI18n.php b/core/lib/Thelia/Model/Base/AttributeAvI18n.php index 3e7b9afcd..8b2b14a32 100755 --- a/core/lib/Thelia/Model/Base/AttributeAvI18n.php +++ b/core/lib/Thelia/Model/Base/AttributeAvI18n.php @@ -61,7 +61,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/AttributeAvQuery.php b/core/lib/Thelia/Model/Base/AttributeAvQuery.php index 8ebfaa8c9..4f724b4f4 100755 --- a/core/lib/Thelia/Model/Base/AttributeAvQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeAvQuery.php @@ -841,7 +841,7 @@ abstract class AttributeAvQuery extends ModelCriteria * * @return ChildAttributeAvQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'AttributeAvI18n'; @@ -859,7 +859,7 @@ abstract class AttributeAvQuery extends ModelCriteria * * @return ChildAttributeAvQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -880,7 +880,7 @@ abstract class AttributeAvQuery extends ModelCriteria * * @return ChildAttributeAvI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/AttributeCategory.php b/core/lib/Thelia/Model/Base/AttributeCategory.php index 691fa43ad..da702559a 100755 --- a/core/lib/Thelia/Model/Base/AttributeCategory.php +++ b/core/lib/Thelia/Model/Base/AttributeCategory.php @@ -262,7 +262,7 @@ abstract class AttributeCategory implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/AttributeCombination.php b/core/lib/Thelia/Model/Base/AttributeCombination.php index ea2ade03c..ef840a5a1 100755 --- a/core/lib/Thelia/Model/Base/AttributeCombination.php +++ b/core/lib/Thelia/Model/Base/AttributeCombination.php @@ -269,7 +269,7 @@ abstract class AttributeCombination implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/AttributeI18n.php b/core/lib/Thelia/Model/Base/AttributeI18n.php index 0e4a1db8f..8a0456192 100755 --- a/core/lib/Thelia/Model/Base/AttributeI18n.php +++ b/core/lib/Thelia/Model/Base/AttributeI18n.php @@ -61,7 +61,7 @@ abstract class AttributeI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class AttributeI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class AttributeI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class AttributeI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/AttributeQuery.php b/core/lib/Thelia/Model/Base/AttributeQuery.php index cabbaf7ac..cbb690efb 100755 --- a/core/lib/Thelia/Model/Base/AttributeQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeQuery.php @@ -886,7 +886,7 @@ abstract class AttributeQuery extends ModelCriteria * * @return ChildAttributeQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'AttributeI18n'; @@ -904,7 +904,7 @@ abstract class AttributeQuery extends ModelCriteria * * @return ChildAttributeQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -925,7 +925,7 @@ abstract class AttributeQuery extends ModelCriteria * * @return ChildAttributeI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Cart.php b/core/lib/Thelia/Model/Base/Cart.php index 910bdf0e0..20a2d9a5c 100755 --- a/core/lib/Thelia/Model/Base/Cart.php +++ b/core/lib/Thelia/Model/Base/Cart.php @@ -307,7 +307,7 @@ abstract class Cart implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/CartItem.php b/core/lib/Thelia/Model/Base/CartItem.php index 3c5711022..827a4c5ec 100755 --- a/core/lib/Thelia/Model/Base/CartItem.php +++ b/core/lib/Thelia/Model/Base/CartItem.php @@ -313,7 +313,7 @@ abstract class CartItem implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php index 85a77a061..6a4445db4 100755 --- a/core/lib/Thelia/Model/Base/Category.php +++ b/core/lib/Thelia/Model/Base/Category.php @@ -218,7 +218,7 @@ abstract class Category implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -475,7 +475,7 @@ abstract class Category implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -4822,7 +4822,7 @@ abstract class Category implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collProductCategories instanceof Collection) { @@ -4894,7 +4894,7 @@ abstract class Category implements ActiveRecordInterface * * @return ChildCategory The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -4918,7 +4918,7 @@ abstract class Category implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCategoryI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCategoryI18ns) { @@ -4953,7 +4953,7 @@ abstract class Category implements ActiveRecordInterface * * @return ChildCategory The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCategoryI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CategoryDocument.php b/core/lib/Thelia/Model/Base/CategoryDocument.php index 165bfa492..a5493815d 100755 --- a/core/lib/Thelia/Model/Base/CategoryDocument.php +++ b/core/lib/Thelia/Model/Base/CategoryDocument.php @@ -120,7 +120,7 @@ abstract class CategoryDocument implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -290,7 +290,7 @@ abstract class CategoryDocument implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1640,7 +1640,7 @@ abstract class CategoryDocument implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collCategoryDocumentI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class CategoryDocument implements ActiveRecordInterface * * @return ChildCategoryDocument The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class CategoryDocument implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCategoryDocumentI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCategoryDocumentI18ns) { @@ -1742,7 +1742,7 @@ abstract class CategoryDocument implements ActiveRecordInterface * * @return ChildCategoryDocument The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCategoryDocumentI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php b/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php index db3189cc3..2d5f76fcf 100755 --- a/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php @@ -61,7 +61,7 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/CategoryDocumentQuery.php b/core/lib/Thelia/Model/Base/CategoryDocumentQuery.php index 8c0a177ac..239ec6c83 100755 --- a/core/lib/Thelia/Model/Base/CategoryDocumentQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryDocumentQuery.php @@ -797,7 +797,7 @@ abstract class CategoryDocumentQuery extends ModelCriteria * * @return ChildCategoryDocumentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CategoryDocumentI18n'; @@ -815,7 +815,7 @@ abstract class CategoryDocumentQuery extends ModelCriteria * * @return ChildCategoryDocumentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class CategoryDocumentQuery extends ModelCriteria * * @return ChildCategoryDocumentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/CategoryI18n.php b/core/lib/Thelia/Model/Base/CategoryI18n.php index 83d62572d..3e3d36521 100755 --- a/core/lib/Thelia/Model/Base/CategoryI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryI18n.php @@ -61,7 +61,7 @@ abstract class CategoryI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class CategoryI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class CategoryI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class CategoryI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/CategoryImage.php b/core/lib/Thelia/Model/Base/CategoryImage.php index efde7b64a..6fd905453 100755 --- a/core/lib/Thelia/Model/Base/CategoryImage.php +++ b/core/lib/Thelia/Model/Base/CategoryImage.php @@ -120,7 +120,7 @@ abstract class CategoryImage implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -290,7 +290,7 @@ abstract class CategoryImage implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1640,7 +1640,7 @@ abstract class CategoryImage implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collCategoryImageI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class CategoryImage implements ActiveRecordInterface * * @return ChildCategoryImage The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class CategoryImage implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCategoryImageI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCategoryImageI18ns) { @@ -1742,7 +1742,7 @@ abstract class CategoryImage implements ActiveRecordInterface * * @return ChildCategoryImage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCategoryImageI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CategoryImageI18n.php b/core/lib/Thelia/Model/Base/CategoryImageI18n.php index ce61e9836..0c65b8036 100755 --- a/core/lib/Thelia/Model/Base/CategoryImageI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryImageI18n.php @@ -61,7 +61,7 @@ abstract class CategoryImageI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class CategoryImageI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class CategoryImageI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class CategoryImageI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/CategoryImageQuery.php b/core/lib/Thelia/Model/Base/CategoryImageQuery.php index 2130e757b..305b01755 100755 --- a/core/lib/Thelia/Model/Base/CategoryImageQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryImageQuery.php @@ -797,7 +797,7 @@ abstract class CategoryImageQuery extends ModelCriteria * * @return ChildCategoryImageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CategoryImageI18n'; @@ -815,7 +815,7 @@ abstract class CategoryImageQuery extends ModelCriteria * * @return ChildCategoryImageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class CategoryImageQuery extends ModelCriteria * * @return ChildCategoryImageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/CategoryQuery.php b/core/lib/Thelia/Model/Base/CategoryQuery.php index 0b7df33dd..5a9c1165f 100755 --- a/core/lib/Thelia/Model/Base/CategoryQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryQuery.php @@ -1461,7 +1461,7 @@ abstract class CategoryQuery extends ModelCriteria * * @return ChildCategoryQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CategoryI18n'; @@ -1479,7 +1479,7 @@ abstract class CategoryQuery extends ModelCriteria * * @return ChildCategoryQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1500,7 +1500,7 @@ abstract class CategoryQuery extends ModelCriteria * * @return ChildCategoryI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/CategoryVersion.php b/core/lib/Thelia/Model/Base/CategoryVersion.php index d8dfe76e0..416ad95d5 100755 --- a/core/lib/Thelia/Model/Base/CategoryVersion.php +++ b/core/lib/Thelia/Model/Base/CategoryVersion.php @@ -292,7 +292,7 @@ abstract class CategoryVersion implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Config.php b/core/lib/Thelia/Model/Base/Config.php index d687ffefe..b4d909de4 100755 --- a/core/lib/Thelia/Model/Base/Config.php +++ b/core/lib/Thelia/Model/Base/Config.php @@ -121,7 +121,7 @@ abstract class Config implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -305,7 +305,7 @@ abstract class Config implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1642,7 +1642,7 @@ abstract class Config implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collConfigI18ns instanceof Collection) { @@ -1684,7 +1684,7 @@ abstract class Config implements ActiveRecordInterface * * @return ChildConfig The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1708,7 +1708,7 @@ abstract class Config implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildConfigI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collConfigI18ns) { @@ -1743,7 +1743,7 @@ abstract class Config implements ActiveRecordInterface * * @return ChildConfig The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildConfigI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ConfigI18n.php b/core/lib/Thelia/Model/Base/ConfigI18n.php index 6247e15d1..57c72ace8 100755 --- a/core/lib/Thelia/Model/Base/ConfigI18n.php +++ b/core/lib/Thelia/Model/Base/ConfigI18n.php @@ -61,7 +61,7 @@ abstract class ConfigI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ConfigI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class ConfigI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class ConfigI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ConfigQuery.php b/core/lib/Thelia/Model/Base/ConfigQuery.php index ef47308a4..b2ddc3409 100755 --- a/core/lib/Thelia/Model/Base/ConfigQuery.php +++ b/core/lib/Thelia/Model/Base/ConfigQuery.php @@ -749,7 +749,7 @@ abstract class ConfigQuery extends ModelCriteria * * @return ChildConfigQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ConfigI18n'; @@ -767,7 +767,7 @@ abstract class ConfigQuery extends ModelCriteria * * @return ChildConfigQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -788,7 +788,7 @@ abstract class ConfigQuery extends ModelCriteria * * @return ChildConfigI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Content.php b/core/lib/Thelia/Model/Base/Content.php index 96ea69eef..59745e39c 100755 --- a/core/lib/Thelia/Model/Base/Content.php +++ b/core/lib/Thelia/Model/Base/Content.php @@ -182,7 +182,7 @@ abstract class Content implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -415,7 +415,7 @@ abstract class Content implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -3720,7 +3720,7 @@ abstract class Content implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collContentAssocs instanceof Collection) { @@ -3790,7 +3790,7 @@ abstract class Content implements ActiveRecordInterface * * @return ChildContent The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -3814,7 +3814,7 @@ abstract class Content implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildContentI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collContentI18ns) { @@ -3849,7 +3849,7 @@ abstract class Content implements ActiveRecordInterface * * @return ChildContent The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildContentI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ContentAssoc.php b/core/lib/Thelia/Model/Base/ContentAssoc.php index eaa1cb9b7..eb3645c0b 100755 --- a/core/lib/Thelia/Model/Base/ContentAssoc.php +++ b/core/lib/Thelia/Model/Base/ContentAssoc.php @@ -281,7 +281,7 @@ abstract class ContentAssoc implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/ContentDocument.php b/core/lib/Thelia/Model/Base/ContentDocument.php index 990fc4a9f..01f631208 100755 --- a/core/lib/Thelia/Model/Base/ContentDocument.php +++ b/core/lib/Thelia/Model/Base/ContentDocument.php @@ -120,7 +120,7 @@ abstract class ContentDocument implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -290,7 +290,7 @@ abstract class ContentDocument implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1640,7 +1640,7 @@ abstract class ContentDocument implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collContentDocumentI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class ContentDocument implements ActiveRecordInterface * * @return ChildContentDocument The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class ContentDocument implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildContentDocumentI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collContentDocumentI18ns) { @@ -1742,7 +1742,7 @@ abstract class ContentDocument implements ActiveRecordInterface * * @return ChildContentDocument The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildContentDocumentI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ContentDocumentI18n.php b/core/lib/Thelia/Model/Base/ContentDocumentI18n.php index 2cfc367b0..f11cd8a08 100755 --- a/core/lib/Thelia/Model/Base/ContentDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/ContentDocumentI18n.php @@ -61,7 +61,7 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ContentDocumentQuery.php b/core/lib/Thelia/Model/Base/ContentDocumentQuery.php index 89cf5d48b..72cc8cae4 100755 --- a/core/lib/Thelia/Model/Base/ContentDocumentQuery.php +++ b/core/lib/Thelia/Model/Base/ContentDocumentQuery.php @@ -797,7 +797,7 @@ abstract class ContentDocumentQuery extends ModelCriteria * * @return ChildContentDocumentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ContentDocumentI18n'; @@ -815,7 +815,7 @@ abstract class ContentDocumentQuery extends ModelCriteria * * @return ChildContentDocumentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class ContentDocumentQuery extends ModelCriteria * * @return ChildContentDocumentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/ContentFolder.php b/core/lib/Thelia/Model/Base/ContentFolder.php index 52f5fa88a..51d72b974 100755 --- a/core/lib/Thelia/Model/Base/ContentFolder.php +++ b/core/lib/Thelia/Model/Base/ContentFolder.php @@ -256,7 +256,7 @@ abstract class ContentFolder implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/ContentI18n.php b/core/lib/Thelia/Model/Base/ContentI18n.php index d3974522b..244862800 100755 --- a/core/lib/Thelia/Model/Base/ContentI18n.php +++ b/core/lib/Thelia/Model/Base/ContentI18n.php @@ -61,7 +61,7 @@ abstract class ContentI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ContentI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class ContentI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class ContentI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ContentImage.php b/core/lib/Thelia/Model/Base/ContentImage.php index 22c4bed10..33e1eca09 100755 --- a/core/lib/Thelia/Model/Base/ContentImage.php +++ b/core/lib/Thelia/Model/Base/ContentImage.php @@ -120,7 +120,7 @@ abstract class ContentImage implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -290,7 +290,7 @@ abstract class ContentImage implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1640,7 +1640,7 @@ abstract class ContentImage implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collContentImageI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class ContentImage implements ActiveRecordInterface * * @return ChildContentImage The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class ContentImage implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildContentImageI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collContentImageI18ns) { @@ -1742,7 +1742,7 @@ abstract class ContentImage implements ActiveRecordInterface * * @return ChildContentImage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildContentImageI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ContentImageI18n.php b/core/lib/Thelia/Model/Base/ContentImageI18n.php index d655dec53..cba4fba17 100755 --- a/core/lib/Thelia/Model/Base/ContentImageI18n.php +++ b/core/lib/Thelia/Model/Base/ContentImageI18n.php @@ -61,7 +61,7 @@ abstract class ContentImageI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ContentImageI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class ContentImageI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class ContentImageI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ContentImageQuery.php b/core/lib/Thelia/Model/Base/ContentImageQuery.php index f69464dd7..26e0ffe5c 100755 --- a/core/lib/Thelia/Model/Base/ContentImageQuery.php +++ b/core/lib/Thelia/Model/Base/ContentImageQuery.php @@ -797,7 +797,7 @@ abstract class ContentImageQuery extends ModelCriteria * * @return ChildContentImageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ContentImageI18n'; @@ -815,7 +815,7 @@ abstract class ContentImageQuery extends ModelCriteria * * @return ChildContentImageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class ContentImageQuery extends ModelCriteria * * @return ChildContentImageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/ContentQuery.php b/core/lib/Thelia/Model/Base/ContentQuery.php index 2cbbe109b..28d32cbe6 100755 --- a/core/lib/Thelia/Model/Base/ContentQuery.php +++ b/core/lib/Thelia/Model/Base/ContentQuery.php @@ -1294,7 +1294,7 @@ abstract class ContentQuery extends ModelCriteria * * @return ChildContentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ContentI18n'; @@ -1312,7 +1312,7 @@ abstract class ContentQuery extends ModelCriteria * * @return ChildContentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1333,7 +1333,7 @@ abstract class ContentQuery extends ModelCriteria * * @return ChildContentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/ContentVersion.php b/core/lib/Thelia/Model/Base/ContentVersion.php index ca9189608..ef2897030 100755 --- a/core/lib/Thelia/Model/Base/ContentVersion.php +++ b/core/lib/Thelia/Model/Base/ContentVersion.php @@ -286,7 +286,7 @@ abstract class ContentVersion implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Country.php b/core/lib/Thelia/Model/Base/Country.php index 704375de2..3794bff3c 100755 --- a/core/lib/Thelia/Model/Base/Country.php +++ b/core/lib/Thelia/Model/Base/Country.php @@ -142,7 +142,7 @@ abstract class Country implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -324,7 +324,7 @@ abstract class Country implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -2323,7 +2323,7 @@ abstract class Country implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collTaxRuleCountries instanceof Collection) { @@ -2374,7 +2374,7 @@ abstract class Country implements ActiveRecordInterface * * @return ChildCountry The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2398,7 +2398,7 @@ abstract class Country implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCountryI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCountryI18ns) { @@ -2433,7 +2433,7 @@ abstract class Country implements ActiveRecordInterface * * @return ChildCountry The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCountryI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CountryI18n.php b/core/lib/Thelia/Model/Base/CountryI18n.php index be63955ca..fbba979a1 100755 --- a/core/lib/Thelia/Model/Base/CountryI18n.php +++ b/core/lib/Thelia/Model/Base/CountryI18n.php @@ -61,7 +61,7 @@ abstract class CountryI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class CountryI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class CountryI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class CountryI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/CountryQuery.php b/core/lib/Thelia/Model/Base/CountryQuery.php index 6c3a1c950..2c709f800 100755 --- a/core/lib/Thelia/Model/Base/CountryQuery.php +++ b/core/lib/Thelia/Model/Base/CountryQuery.php @@ -972,7 +972,7 @@ abstract class CountryQuery extends ModelCriteria * * @return ChildCountryQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CountryI18n'; @@ -990,7 +990,7 @@ abstract class CountryQuery extends ModelCriteria * * @return ChildCountryQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1011,7 +1011,7 @@ abstract class CountryQuery extends ModelCriteria * * @return ChildCountryI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Coupon.php b/core/lib/Thelia/Model/Base/Coupon.php index 2c3dae5c9..a339fa835 100755 --- a/core/lib/Thelia/Model/Base/Coupon.php +++ b/core/lib/Thelia/Model/Base/Coupon.php @@ -293,7 +293,7 @@ abstract class Coupon implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/CouponOrder.php b/core/lib/Thelia/Model/Base/CouponOrder.php index 32ae68fde..71a71f673 100755 --- a/core/lib/Thelia/Model/Base/CouponOrder.php +++ b/core/lib/Thelia/Model/Base/CouponOrder.php @@ -261,7 +261,7 @@ abstract class CouponOrder implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/CouponRule.php b/core/lib/Thelia/Model/Base/CouponRule.php index 5602b0044..8a34f5d0b 100755 --- a/core/lib/Thelia/Model/Base/CouponRule.php +++ b/core/lib/Thelia/Model/Base/CouponRule.php @@ -267,7 +267,7 @@ abstract class CouponRule implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Currency.php b/core/lib/Thelia/Model/Base/Currency.php index 77718992f..f99288679 100755 --- a/core/lib/Thelia/Model/Base/Currency.php +++ b/core/lib/Thelia/Model/Base/Currency.php @@ -149,7 +149,7 @@ abstract class Currency implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -337,7 +337,7 @@ abstract class Currency implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -2681,7 +2681,7 @@ abstract class Currency implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collOrders instanceof Collection) { @@ -2735,7 +2735,7 @@ abstract class Currency implements ActiveRecordInterface * * @return ChildCurrency The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2759,7 +2759,7 @@ abstract class Currency implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCurrencyI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCurrencyI18ns) { @@ -2794,7 +2794,7 @@ abstract class Currency implements ActiveRecordInterface * * @return ChildCurrency The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCurrencyI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CurrencyI18n.php b/core/lib/Thelia/Model/Base/CurrencyI18n.php index eb86a87c4..931c3acbf 100755 --- a/core/lib/Thelia/Model/Base/CurrencyI18n.php +++ b/core/lib/Thelia/Model/Base/CurrencyI18n.php @@ -61,7 +61,7 @@ abstract class CurrencyI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -93,7 +93,7 @@ abstract class CurrencyI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -254,7 +254,7 @@ abstract class CurrencyI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -462,7 +462,7 @@ abstract class CurrencyI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/CurrencyQuery.php b/core/lib/Thelia/Model/Base/CurrencyQuery.php index eb4b1b2f7..9b4ecf51e 100755 --- a/core/lib/Thelia/Model/Base/CurrencyQuery.php +++ b/core/lib/Thelia/Model/Base/CurrencyQuery.php @@ -1025,7 +1025,7 @@ abstract class CurrencyQuery extends ModelCriteria * * @return ChildCurrencyQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CurrencyI18n'; @@ -1043,7 +1043,7 @@ abstract class CurrencyQuery extends ModelCriteria * * @return ChildCurrencyQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1064,7 +1064,7 @@ abstract class CurrencyQuery extends ModelCriteria * * @return ChildCurrencyI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Customer.php b/core/lib/Thelia/Model/Base/Customer.php index c3315ac6f..3d87f3e28 100755 --- a/core/lib/Thelia/Model/Base/Customer.php +++ b/core/lib/Thelia/Model/Base/Customer.php @@ -352,7 +352,7 @@ abstract class Customer implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/CustomerTitle.php b/core/lib/Thelia/Model/Base/CustomerTitle.php index 5f8b11dd9..dcf271206 100755 --- a/core/lib/Thelia/Model/Base/CustomerTitle.php +++ b/core/lib/Thelia/Model/Base/CustomerTitle.php @@ -124,7 +124,7 @@ abstract class CustomerTitle implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -319,7 +319,7 @@ abstract class CustomerTitle implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -2106,7 +2106,7 @@ abstract class CustomerTitle implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collCustomers instanceof Collection) { @@ -2156,7 +2156,7 @@ abstract class CustomerTitle implements ActiveRecordInterface * * @return ChildCustomerTitle The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2180,7 +2180,7 @@ abstract class CustomerTitle implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCustomerTitleI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCustomerTitleI18ns) { @@ -2215,7 +2215,7 @@ abstract class CustomerTitle implements ActiveRecordInterface * * @return ChildCustomerTitle The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCustomerTitleI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CustomerTitleI18n.php b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php index c68b87123..4ea186061 100755 --- a/core/lib/Thelia/Model/Base/CustomerTitleI18n.php +++ b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php @@ -61,7 +61,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -99,7 +99,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -260,7 +260,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -500,7 +500,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php index ea34c8c91..1c4be4081 100755 --- a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php @@ -825,7 +825,7 @@ abstract class CustomerTitleQuery extends ModelCriteria * * @return ChildCustomerTitleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CustomerTitleI18n'; @@ -843,7 +843,7 @@ abstract class CustomerTitleQuery extends ModelCriteria * * @return ChildCustomerTitleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -864,7 +864,7 @@ abstract class CustomerTitleQuery extends ModelCriteria * * @return ChildCustomerTitleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Delivzone.php b/core/lib/Thelia/Model/Base/Delivzone.php index 08125044e..deb21997e 100755 --- a/core/lib/Thelia/Model/Base/Delivzone.php +++ b/core/lib/Thelia/Model/Base/Delivzone.php @@ -255,7 +255,7 @@ abstract class Delivzone implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Feature.php b/core/lib/Thelia/Model/Base/Feature.php index 0dddd14e0..070bac50b 100755 --- a/core/lib/Thelia/Model/Base/Feature.php +++ b/core/lib/Thelia/Model/Base/Feature.php @@ -139,7 +139,7 @@ abstract class Feature implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -346,7 +346,7 @@ abstract class Feature implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -2628,7 +2628,7 @@ abstract class Feature implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collFeatureAvs instanceof Collection) { @@ -2686,7 +2686,7 @@ abstract class Feature implements ActiveRecordInterface * * @return ChildFeature The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2710,7 +2710,7 @@ abstract class Feature implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildFeatureI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFeatureI18ns) { @@ -2745,7 +2745,7 @@ abstract class Feature implements ActiveRecordInterface * * @return ChildFeature The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildFeatureI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/FeatureAv.php b/core/lib/Thelia/Model/Base/FeatureAv.php index b09a27cec..14e6cd35c 100755 --- a/core/lib/Thelia/Model/Base/FeatureAv.php +++ b/core/lib/Thelia/Model/Base/FeatureAv.php @@ -122,7 +122,7 @@ abstract class FeatureAv implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -298,7 +298,7 @@ abstract class FeatureAv implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1900,7 +1900,7 @@ abstract class FeatureAv implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collFeatureProducts instanceof Collection) { @@ -1947,7 +1947,7 @@ abstract class FeatureAv implements ActiveRecordInterface * * @return ChildFeatureAv The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1971,7 +1971,7 @@ abstract class FeatureAv implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildFeatureAvI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFeatureAvI18ns) { @@ -2006,7 +2006,7 @@ abstract class FeatureAv implements ActiveRecordInterface * * @return ChildFeatureAv The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildFeatureAvI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/FeatureAvI18n.php b/core/lib/Thelia/Model/Base/FeatureAvI18n.php index 7cbca8129..a508d6075 100755 --- a/core/lib/Thelia/Model/Base/FeatureAvI18n.php +++ b/core/lib/Thelia/Model/Base/FeatureAvI18n.php @@ -61,7 +61,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/FeatureAvQuery.php b/core/lib/Thelia/Model/Base/FeatureAvQuery.php index fb3796c97..6b3af4ed9 100755 --- a/core/lib/Thelia/Model/Base/FeatureAvQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureAvQuery.php @@ -841,7 +841,7 @@ abstract class FeatureAvQuery extends ModelCriteria * * @return ChildFeatureAvQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FeatureAvI18n'; @@ -859,7 +859,7 @@ abstract class FeatureAvQuery extends ModelCriteria * * @return ChildFeatureAvQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -880,7 +880,7 @@ abstract class FeatureAvQuery extends ModelCriteria * * @return ChildFeatureAvI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/FeatureCategory.php b/core/lib/Thelia/Model/Base/FeatureCategory.php index f3ce14349..035e077d2 100755 --- a/core/lib/Thelia/Model/Base/FeatureCategory.php +++ b/core/lib/Thelia/Model/Base/FeatureCategory.php @@ -262,7 +262,7 @@ abstract class FeatureCategory implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/FeatureI18n.php b/core/lib/Thelia/Model/Base/FeatureI18n.php index 0ede8eddb..06964ee19 100755 --- a/core/lib/Thelia/Model/Base/FeatureI18n.php +++ b/core/lib/Thelia/Model/Base/FeatureI18n.php @@ -61,7 +61,7 @@ abstract class FeatureI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class FeatureI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class FeatureI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class FeatureI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/FeatureProduct.php b/core/lib/Thelia/Model/Base/FeatureProduct.php index b68f4acd2..4af200d51 100755 --- a/core/lib/Thelia/Model/Base/FeatureProduct.php +++ b/core/lib/Thelia/Model/Base/FeatureProduct.php @@ -287,7 +287,7 @@ abstract class FeatureProduct implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/FeatureQuery.php b/core/lib/Thelia/Model/Base/FeatureQuery.php index 9b00e812e..f1fc81a3f 100755 --- a/core/lib/Thelia/Model/Base/FeatureQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureQuery.php @@ -931,7 +931,7 @@ abstract class FeatureQuery extends ModelCriteria * * @return ChildFeatureQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FeatureI18n'; @@ -949,7 +949,7 @@ abstract class FeatureQuery extends ModelCriteria * * @return ChildFeatureQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -970,7 +970,7 @@ abstract class FeatureQuery extends ModelCriteria * * @return ChildFeatureI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Folder.php b/core/lib/Thelia/Model/Base/Folder.php index 6ee28e7ff..8899ae6be 100755 --- a/core/lib/Thelia/Model/Base/Folder.php +++ b/core/lib/Thelia/Model/Base/Folder.php @@ -180,7 +180,7 @@ abstract class Folder implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -407,7 +407,7 @@ abstract class Folder implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -3460,7 +3460,7 @@ abstract class Folder implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collRewritings instanceof Collection) { @@ -3526,7 +3526,7 @@ abstract class Folder implements ActiveRecordInterface * * @return ChildFolder The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -3550,7 +3550,7 @@ abstract class Folder implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildFolderI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFolderI18ns) { @@ -3585,7 +3585,7 @@ abstract class Folder implements ActiveRecordInterface * * @return ChildFolder The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildFolderI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/FolderDocument.php b/core/lib/Thelia/Model/Base/FolderDocument.php index 31e7c57a6..fbe0c91b1 100755 --- a/core/lib/Thelia/Model/Base/FolderDocument.php +++ b/core/lib/Thelia/Model/Base/FolderDocument.php @@ -120,7 +120,7 @@ abstract class FolderDocument implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -290,7 +290,7 @@ abstract class FolderDocument implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1640,7 +1640,7 @@ abstract class FolderDocument implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collFolderDocumentI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class FolderDocument implements ActiveRecordInterface * * @return ChildFolderDocument The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class FolderDocument implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildFolderDocumentI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFolderDocumentI18ns) { @@ -1742,7 +1742,7 @@ abstract class FolderDocument implements ActiveRecordInterface * * @return ChildFolderDocument The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildFolderDocumentI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/FolderDocumentI18n.php b/core/lib/Thelia/Model/Base/FolderDocumentI18n.php index d39a49af7..57a38034f 100755 --- a/core/lib/Thelia/Model/Base/FolderDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/FolderDocumentI18n.php @@ -61,7 +61,7 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/FolderDocumentQuery.php b/core/lib/Thelia/Model/Base/FolderDocumentQuery.php index b1c41a29e..85ed5c241 100755 --- a/core/lib/Thelia/Model/Base/FolderDocumentQuery.php +++ b/core/lib/Thelia/Model/Base/FolderDocumentQuery.php @@ -797,7 +797,7 @@ abstract class FolderDocumentQuery extends ModelCriteria * * @return ChildFolderDocumentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FolderDocumentI18n'; @@ -815,7 +815,7 @@ abstract class FolderDocumentQuery extends ModelCriteria * * @return ChildFolderDocumentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class FolderDocumentQuery extends ModelCriteria * * @return ChildFolderDocumentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/FolderI18n.php b/core/lib/Thelia/Model/Base/FolderI18n.php index fcdc66705..12d627cac 100755 --- a/core/lib/Thelia/Model/Base/FolderI18n.php +++ b/core/lib/Thelia/Model/Base/FolderI18n.php @@ -61,7 +61,7 @@ abstract class FolderI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class FolderI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class FolderI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class FolderI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/FolderImage.php b/core/lib/Thelia/Model/Base/FolderImage.php index 46c39060d..f1eb8a5ab 100755 --- a/core/lib/Thelia/Model/Base/FolderImage.php +++ b/core/lib/Thelia/Model/Base/FolderImage.php @@ -120,7 +120,7 @@ abstract class FolderImage implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -290,7 +290,7 @@ abstract class FolderImage implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1640,7 +1640,7 @@ abstract class FolderImage implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collFolderImageI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class FolderImage implements ActiveRecordInterface * * @return ChildFolderImage The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class FolderImage implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildFolderImageI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFolderImageI18ns) { @@ -1742,7 +1742,7 @@ abstract class FolderImage implements ActiveRecordInterface * * @return ChildFolderImage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildFolderImageI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/FolderImageI18n.php b/core/lib/Thelia/Model/Base/FolderImageI18n.php index d5cc004d1..894b6ec0f 100755 --- a/core/lib/Thelia/Model/Base/FolderImageI18n.php +++ b/core/lib/Thelia/Model/Base/FolderImageI18n.php @@ -61,7 +61,7 @@ abstract class FolderImageI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class FolderImageI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class FolderImageI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class FolderImageI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/FolderImageQuery.php b/core/lib/Thelia/Model/Base/FolderImageQuery.php index ca12e098e..4ea930e20 100755 --- a/core/lib/Thelia/Model/Base/FolderImageQuery.php +++ b/core/lib/Thelia/Model/Base/FolderImageQuery.php @@ -797,7 +797,7 @@ abstract class FolderImageQuery extends ModelCriteria * * @return ChildFolderImageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FolderImageI18n'; @@ -815,7 +815,7 @@ abstract class FolderImageQuery extends ModelCriteria * * @return ChildFolderImageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class FolderImageQuery extends ModelCriteria * * @return ChildFolderImageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/FolderQuery.php b/core/lib/Thelia/Model/Base/FolderQuery.php index 893bb9819..22d2f3735 100755 --- a/core/lib/Thelia/Model/Base/FolderQuery.php +++ b/core/lib/Thelia/Model/Base/FolderQuery.php @@ -1262,7 +1262,7 @@ abstract class FolderQuery extends ModelCriteria * * @return ChildFolderQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FolderI18n'; @@ -1280,7 +1280,7 @@ abstract class FolderQuery extends ModelCriteria * * @return ChildFolderQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1301,7 +1301,7 @@ abstract class FolderQuery extends ModelCriteria * * @return ChildFolderI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/FolderVersion.php b/core/lib/Thelia/Model/Base/FolderVersion.php index 4f6305b7e..ec588dcbd 100755 --- a/core/lib/Thelia/Model/Base/FolderVersion.php +++ b/core/lib/Thelia/Model/Base/FolderVersion.php @@ -292,7 +292,7 @@ abstract class FolderVersion implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Group.php b/core/lib/Thelia/Model/Base/Group.php index 9cfde2bdc..eed65d778 100755 --- a/core/lib/Thelia/Model/Base/Group.php +++ b/core/lib/Thelia/Model/Base/Group.php @@ -139,7 +139,7 @@ abstract class Group implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -339,7 +339,7 @@ abstract class Group implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -2786,7 +2786,7 @@ abstract class Group implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collAdminGroups instanceof Collection) { @@ -2848,7 +2848,7 @@ abstract class Group implements ActiveRecordInterface * * @return ChildGroup The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2872,7 +2872,7 @@ abstract class Group implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildGroupI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collGroupI18ns) { @@ -2907,7 +2907,7 @@ abstract class Group implements ActiveRecordInterface * * @return ChildGroup The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildGroupI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/GroupI18n.php b/core/lib/Thelia/Model/Base/GroupI18n.php index 4de63ea63..4ba0aac29 100755 --- a/core/lib/Thelia/Model/Base/GroupI18n.php +++ b/core/lib/Thelia/Model/Base/GroupI18n.php @@ -61,7 +61,7 @@ abstract class GroupI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class GroupI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class GroupI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class GroupI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/GroupModule.php b/core/lib/Thelia/Model/Base/GroupModule.php index 620ca9c91..82d6056f2 100755 --- a/core/lib/Thelia/Model/Base/GroupModule.php +++ b/core/lib/Thelia/Model/Base/GroupModule.php @@ -282,7 +282,7 @@ abstract class GroupModule implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/GroupQuery.php b/core/lib/Thelia/Model/Base/GroupQuery.php index d0eded79b..8ca963848 100755 --- a/core/lib/Thelia/Model/Base/GroupQuery.php +++ b/core/lib/Thelia/Model/Base/GroupQuery.php @@ -891,7 +891,7 @@ abstract class GroupQuery extends ModelCriteria * * @return ChildGroupQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'GroupI18n'; @@ -909,7 +909,7 @@ abstract class GroupQuery extends ModelCriteria * * @return ChildGroupQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -930,7 +930,7 @@ abstract class GroupQuery extends ModelCriteria * * @return ChildGroupI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/GroupResource.php b/core/lib/Thelia/Model/Base/GroupResource.php index 84d6006b0..ea6c0ff47 100755 --- a/core/lib/Thelia/Model/Base/GroupResource.php +++ b/core/lib/Thelia/Model/Base/GroupResource.php @@ -290,7 +290,7 @@ abstract class GroupResource implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Lang.php b/core/lib/Thelia/Model/Base/Lang.php index 3379594ef..293b0f3a7 100755 --- a/core/lib/Thelia/Model/Base/Lang.php +++ b/core/lib/Thelia/Model/Base/Lang.php @@ -272,7 +272,7 @@ abstract class Lang implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Message.php b/core/lib/Thelia/Model/Base/Message.php index a2327f388..5245c3765 100755 --- a/core/lib/Thelia/Model/Base/Message.php +++ b/core/lib/Thelia/Model/Base/Message.php @@ -141,7 +141,7 @@ abstract class Message implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -338,7 +338,7 @@ abstract class Message implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -2056,7 +2056,7 @@ abstract class Message implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collMessageI18ns instanceof Collection) { @@ -2102,7 +2102,7 @@ abstract class Message implements ActiveRecordInterface * * @return ChildMessage The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2126,7 +2126,7 @@ abstract class Message implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildMessageI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collMessageI18ns) { @@ -2161,7 +2161,7 @@ abstract class Message implements ActiveRecordInterface * * @return ChildMessage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildMessageI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/MessageI18n.php b/core/lib/Thelia/Model/Base/MessageI18n.php index 4d1a532fe..575e22907 100755 --- a/core/lib/Thelia/Model/Base/MessageI18n.php +++ b/core/lib/Thelia/Model/Base/MessageI18n.php @@ -61,7 +61,7 @@ abstract class MessageI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -105,7 +105,7 @@ abstract class MessageI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -266,7 +266,7 @@ abstract class MessageI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -538,7 +538,7 @@ abstract class MessageI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/MessageQuery.php b/core/lib/Thelia/Model/Base/MessageQuery.php index cf0155f36..938a16aab 100755 --- a/core/lib/Thelia/Model/Base/MessageQuery.php +++ b/core/lib/Thelia/Model/Base/MessageQuery.php @@ -913,7 +913,7 @@ abstract class MessageQuery extends ModelCriteria * * @return ChildMessageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'MessageI18n'; @@ -931,7 +931,7 @@ abstract class MessageQuery extends ModelCriteria * * @return ChildMessageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -952,7 +952,7 @@ abstract class MessageQuery extends ModelCriteria * * @return ChildMessageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/MessageVersion.php b/core/lib/Thelia/Model/Base/MessageVersion.php index 0781a503a..e425b5c50 100755 --- a/core/lib/Thelia/Model/Base/MessageVersion.php +++ b/core/lib/Thelia/Model/Base/MessageVersion.php @@ -292,7 +292,7 @@ abstract class MessageVersion implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Module.php b/core/lib/Thelia/Model/Base/Module.php index c1ee2ed8d..76c391207 100755 --- a/core/lib/Thelia/Model/Base/Module.php +++ b/core/lib/Thelia/Model/Base/Module.php @@ -127,7 +127,7 @@ abstract class Module implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -303,7 +303,7 @@ abstract class Module implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1910,7 +1910,7 @@ abstract class Module implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collGroupModules instanceof Collection) { @@ -1956,7 +1956,7 @@ abstract class Module implements ActiveRecordInterface * * @return ChildModule The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1980,7 +1980,7 @@ abstract class Module implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildModuleI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collModuleI18ns) { @@ -2015,7 +2015,7 @@ abstract class Module implements ActiveRecordInterface * * @return ChildModule The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildModuleI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ModuleI18n.php b/core/lib/Thelia/Model/Base/ModuleI18n.php index fbb4293ba..d31dda0ba 100755 --- a/core/lib/Thelia/Model/Base/ModuleI18n.php +++ b/core/lib/Thelia/Model/Base/ModuleI18n.php @@ -61,7 +61,7 @@ abstract class ModuleI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ModuleI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class ModuleI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class ModuleI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ModuleQuery.php b/core/lib/Thelia/Model/Base/ModuleQuery.php index e1bd9de68..7db21ca22 100755 --- a/core/lib/Thelia/Model/Base/ModuleQuery.php +++ b/core/lib/Thelia/Model/Base/ModuleQuery.php @@ -838,7 +838,7 @@ abstract class ModuleQuery extends ModelCriteria * * @return ChildModuleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ModuleI18n'; @@ -856,7 +856,7 @@ abstract class ModuleQuery extends ModelCriteria * * @return ChildModuleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -877,7 +877,7 @@ abstract class ModuleQuery extends ModelCriteria * * @return ChildModuleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Order.php b/core/lib/Thelia/Model/Base/Order.php index b815aff34..6932ec6c4 100755 --- a/core/lib/Thelia/Model/Base/Order.php +++ b/core/lib/Thelia/Model/Base/Order.php @@ -388,7 +388,7 @@ abstract class Order implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/OrderAddress.php b/core/lib/Thelia/Model/Base/OrderAddress.php index b5ff32951..d0220d4e0 100755 --- a/core/lib/Thelia/Model/Base/OrderAddress.php +++ b/core/lib/Thelia/Model/Base/OrderAddress.php @@ -329,7 +329,7 @@ abstract class OrderAddress implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/OrderFeature.php b/core/lib/Thelia/Model/Base/OrderFeature.php index 49c1a0911..e2b52e6b1 100755 --- a/core/lib/Thelia/Model/Base/OrderFeature.php +++ b/core/lib/Thelia/Model/Base/OrderFeature.php @@ -261,7 +261,7 @@ abstract class OrderFeature implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/OrderProduct.php b/core/lib/Thelia/Model/Base/OrderProduct.php index b448e4e0c..2bf9c7ace 100755 --- a/core/lib/Thelia/Model/Base/OrderProduct.php +++ b/core/lib/Thelia/Model/Base/OrderProduct.php @@ -312,7 +312,7 @@ abstract class OrderProduct implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/OrderStatus.php b/core/lib/Thelia/Model/Base/OrderStatus.php index fc4a224d1..99bb87879 100755 --- a/core/lib/Thelia/Model/Base/OrderStatus.php +++ b/core/lib/Thelia/Model/Base/OrderStatus.php @@ -109,7 +109,7 @@ abstract class OrderStatus implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -285,7 +285,7 @@ abstract class OrderStatus implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1812,7 +1812,7 @@ abstract class OrderStatus implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collOrders instanceof Collection) { @@ -1858,7 +1858,7 @@ abstract class OrderStatus implements ActiveRecordInterface * * @return ChildOrderStatus The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1882,7 +1882,7 @@ abstract class OrderStatus implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildOrderStatusI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collOrderStatusI18ns) { @@ -1917,7 +1917,7 @@ abstract class OrderStatus implements ActiveRecordInterface * * @return ChildOrderStatus The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildOrderStatusI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/OrderStatusI18n.php b/core/lib/Thelia/Model/Base/OrderStatusI18n.php index 76ec4a28a..249944854 100755 --- a/core/lib/Thelia/Model/Base/OrderStatusI18n.php +++ b/core/lib/Thelia/Model/Base/OrderStatusI18n.php @@ -61,7 +61,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/OrderStatusQuery.php b/core/lib/Thelia/Model/Base/OrderStatusQuery.php index 908efd6b6..07fcdb8dc 100755 --- a/core/lib/Thelia/Model/Base/OrderStatusQuery.php +++ b/core/lib/Thelia/Model/Base/OrderStatusQuery.php @@ -703,7 +703,7 @@ abstract class OrderStatusQuery extends ModelCriteria * * @return ChildOrderStatusQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'OrderStatusI18n'; @@ -721,7 +721,7 @@ abstract class OrderStatusQuery extends ModelCriteria * * @return ChildOrderStatusQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -742,7 +742,7 @@ abstract class OrderStatusQuery extends ModelCriteria * * @return ChildOrderStatusI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php index 9a1828e25..867f7dd50 100755 --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -250,7 +250,7 @@ abstract class Product implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -526,7 +526,7 @@ abstract class Product implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -5815,7 +5815,7 @@ abstract class Product implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collProductCategories instanceof Collection) { @@ -5914,7 +5914,7 @@ abstract class Product implements ActiveRecordInterface * * @return ChildProduct The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -5938,7 +5938,7 @@ abstract class Product implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildProductI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collProductI18ns) { @@ -5973,7 +5973,7 @@ abstract class Product implements ActiveRecordInterface * * @return ChildProduct The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildProductI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ProductCategory.php b/core/lib/Thelia/Model/Base/ProductCategory.php index 74affb0c0..62a6ea425 100755 --- a/core/lib/Thelia/Model/Base/ProductCategory.php +++ b/core/lib/Thelia/Model/Base/ProductCategory.php @@ -256,7 +256,7 @@ abstract class ProductCategory implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/ProductDocument.php b/core/lib/Thelia/Model/Base/ProductDocument.php index 58c9999ed..96a584dab 100755 --- a/core/lib/Thelia/Model/Base/ProductDocument.php +++ b/core/lib/Thelia/Model/Base/ProductDocument.php @@ -120,7 +120,7 @@ abstract class ProductDocument implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -290,7 +290,7 @@ abstract class ProductDocument implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1640,7 +1640,7 @@ abstract class ProductDocument implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collProductDocumentI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class ProductDocument implements ActiveRecordInterface * * @return ChildProductDocument The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class ProductDocument implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildProductDocumentI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collProductDocumentI18ns) { @@ -1742,7 +1742,7 @@ abstract class ProductDocument implements ActiveRecordInterface * * @return ChildProductDocument The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildProductDocumentI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ProductDocumentI18n.php b/core/lib/Thelia/Model/Base/ProductDocumentI18n.php index 2c5ca4d0c..ba04b5ccc 100755 --- a/core/lib/Thelia/Model/Base/ProductDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/ProductDocumentI18n.php @@ -61,7 +61,7 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ProductDocumentQuery.php b/core/lib/Thelia/Model/Base/ProductDocumentQuery.php index 06af05a9c..32321554d 100755 --- a/core/lib/Thelia/Model/Base/ProductDocumentQuery.php +++ b/core/lib/Thelia/Model/Base/ProductDocumentQuery.php @@ -797,7 +797,7 @@ abstract class ProductDocumentQuery extends ModelCriteria * * @return ChildProductDocumentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ProductDocumentI18n'; @@ -815,7 +815,7 @@ abstract class ProductDocumentQuery extends ModelCriteria * * @return ChildProductDocumentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class ProductDocumentQuery extends ModelCriteria * * @return ChildProductDocumentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/ProductI18n.php b/core/lib/Thelia/Model/Base/ProductI18n.php index b0c74bb54..ee7514fd4 100755 --- a/core/lib/Thelia/Model/Base/ProductI18n.php +++ b/core/lib/Thelia/Model/Base/ProductI18n.php @@ -61,7 +61,7 @@ abstract class ProductI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ProductI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class ProductI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class ProductI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ProductImage.php b/core/lib/Thelia/Model/Base/ProductImage.php index 0b4030ccb..152a298a5 100755 --- a/core/lib/Thelia/Model/Base/ProductImage.php +++ b/core/lib/Thelia/Model/Base/ProductImage.php @@ -120,7 +120,7 @@ abstract class ProductImage implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -290,7 +290,7 @@ abstract class ProductImage implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1640,7 +1640,7 @@ abstract class ProductImage implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collProductImageI18ns instanceof Collection) { @@ -1683,7 +1683,7 @@ abstract class ProductImage implements ActiveRecordInterface * * @return ChildProductImage The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1707,7 +1707,7 @@ abstract class ProductImage implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildProductImageI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collProductImageI18ns) { @@ -1742,7 +1742,7 @@ abstract class ProductImage implements ActiveRecordInterface * * @return ChildProductImage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildProductImageI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ProductImageI18n.php b/core/lib/Thelia/Model/Base/ProductImageI18n.php index 634f726a3..c84f99af2 100755 --- a/core/lib/Thelia/Model/Base/ProductImageI18n.php +++ b/core/lib/Thelia/Model/Base/ProductImageI18n.php @@ -61,7 +61,7 @@ abstract class ProductImageI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ProductImageI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class ProductImageI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class ProductImageI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ProductImageQuery.php b/core/lib/Thelia/Model/Base/ProductImageQuery.php index 94cb1b361..e351c6f40 100755 --- a/core/lib/Thelia/Model/Base/ProductImageQuery.php +++ b/core/lib/Thelia/Model/Base/ProductImageQuery.php @@ -797,7 +797,7 @@ abstract class ProductImageQuery extends ModelCriteria * * @return ChildProductImageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ProductImageI18n'; @@ -815,7 +815,7 @@ abstract class ProductImageQuery extends ModelCriteria * * @return ChildProductImageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -836,7 +836,7 @@ abstract class ProductImageQuery extends ModelCriteria * * @return ChildProductImageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/ProductPrice.php b/core/lib/Thelia/Model/Base/ProductPrice.php index dab6e47a4..15502a385 100755 --- a/core/lib/Thelia/Model/Base/ProductPrice.php +++ b/core/lib/Thelia/Model/Base/ProductPrice.php @@ -274,7 +274,7 @@ abstract class ProductPrice implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/ProductQuery.php b/core/lib/Thelia/Model/Base/ProductQuery.php index 3df8ecbae..9d4685f38 100755 --- a/core/lib/Thelia/Model/Base/ProductQuery.php +++ b/core/lib/Thelia/Model/Base/ProductQuery.php @@ -1872,7 +1872,7 @@ abstract class ProductQuery extends ModelCriteria * * @return ChildProductQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ProductI18n'; @@ -1890,7 +1890,7 @@ abstract class ProductQuery extends ModelCriteria * * @return ChildProductQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1911,7 +1911,7 @@ abstract class ProductQuery extends ModelCriteria * * @return ChildProductI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/ProductSaleElements.php b/core/lib/Thelia/Model/Base/ProductSaleElements.php index 22a8c9752..f79d9a246 100755 --- a/core/lib/Thelia/Model/Base/ProductSaleElements.php +++ b/core/lib/Thelia/Model/Base/ProductSaleElements.php @@ -332,7 +332,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/ProductVersion.php b/core/lib/Thelia/Model/Base/ProductVersion.php index 1779cee20..071dfc742 100755 --- a/core/lib/Thelia/Model/Base/ProductVersion.php +++ b/core/lib/Thelia/Model/Base/ProductVersion.php @@ -300,7 +300,7 @@ abstract class ProductVersion implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Resource.php b/core/lib/Thelia/Model/Base/Resource.php index c6c527134..b513ea326 100755 --- a/core/lib/Thelia/Model/Base/Resource.php +++ b/core/lib/Thelia/Model/Base/Resource.php @@ -116,7 +116,7 @@ abstract class Resource implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -298,7 +298,7 @@ abstract class Resource implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1968,7 +1968,7 @@ abstract class Resource implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collGroupResources instanceof Collection) { @@ -2018,7 +2018,7 @@ abstract class Resource implements ActiveRecordInterface * * @return ChildResource The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2042,7 +2042,7 @@ abstract class Resource implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildResourceI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collResourceI18ns) { @@ -2077,7 +2077,7 @@ abstract class Resource implements ActiveRecordInterface * * @return ChildResource The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildResourceI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ResourceI18n.php b/core/lib/Thelia/Model/Base/ResourceI18n.php index c060e8776..4419f7fc8 100755 --- a/core/lib/Thelia/Model/Base/ResourceI18n.php +++ b/core/lib/Thelia/Model/Base/ResourceI18n.php @@ -61,7 +61,7 @@ abstract class ResourceI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ResourceI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -272,7 +272,7 @@ abstract class ResourceI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -576,7 +576,7 @@ abstract class ResourceI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/ResourceQuery.php b/core/lib/Thelia/Model/Base/ResourceQuery.php index 6559d6522..e12ee8f53 100755 --- a/core/lib/Thelia/Model/Base/ResourceQuery.php +++ b/core/lib/Thelia/Model/Base/ResourceQuery.php @@ -720,7 +720,7 @@ abstract class ResourceQuery extends ModelCriteria * * @return ChildResourceQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ResourceI18n'; @@ -738,7 +738,7 @@ abstract class ResourceQuery extends ModelCriteria * * @return ChildResourceQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -759,7 +759,7 @@ abstract class ResourceQuery extends ModelCriteria * * @return ChildResourceI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Rewriting.php b/core/lib/Thelia/Model/Base/Rewriting.php index 12229c438..c8109458d 100755 --- a/core/lib/Thelia/Model/Base/Rewriting.php +++ b/core/lib/Thelia/Model/Base/Rewriting.php @@ -294,7 +294,7 @@ abstract class Rewriting implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/Tax.php b/core/lib/Thelia/Model/Base/Tax.php index 3e405414c..c1ddbf23a 100755 --- a/core/lib/Thelia/Model/Base/Tax.php +++ b/core/lib/Thelia/Model/Base/Tax.php @@ -109,7 +109,7 @@ abstract class Tax implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -285,7 +285,7 @@ abstract class Tax implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -1762,7 +1762,7 @@ abstract class Tax implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collTaxRuleCountries instanceof Collection) { @@ -1808,7 +1808,7 @@ abstract class Tax implements ActiveRecordInterface * * @return ChildTax The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1832,7 +1832,7 @@ abstract class Tax implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildTaxI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collTaxI18ns) { @@ -1867,7 +1867,7 @@ abstract class Tax implements ActiveRecordInterface * * @return ChildTax The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildTaxI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/TaxI18n.php b/core/lib/Thelia/Model/Base/TaxI18n.php index f8577e860..a066fe4a8 100755 --- a/core/lib/Thelia/Model/Base/TaxI18n.php +++ b/core/lib/Thelia/Model/Base/TaxI18n.php @@ -61,7 +61,7 @@ abstract class TaxI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -99,7 +99,7 @@ abstract class TaxI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -260,7 +260,7 @@ abstract class TaxI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -500,7 +500,7 @@ abstract class TaxI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/TaxQuery.php b/core/lib/Thelia/Model/Base/TaxQuery.php index 307ace57c..0a61cbb3c 100755 --- a/core/lib/Thelia/Model/Base/TaxQuery.php +++ b/core/lib/Thelia/Model/Base/TaxQuery.php @@ -715,7 +715,7 @@ abstract class TaxQuery extends ModelCriteria * * @return ChildTaxQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'TaxI18n'; @@ -733,7 +733,7 @@ abstract class TaxQuery extends ModelCriteria * * @return ChildTaxQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -754,7 +754,7 @@ abstract class TaxQuery extends ModelCriteria * * @return ChildTaxI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/TaxRule.php b/core/lib/Thelia/Model/Base/TaxRule.php index bf318498c..e363541d7 100755 --- a/core/lib/Thelia/Model/Base/TaxRule.php +++ b/core/lib/Thelia/Model/Base/TaxRule.php @@ -129,7 +129,7 @@ abstract class TaxRule implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_US'; + protected $currentLocale = 'en_EN'; /** * Current translation objects @@ -311,7 +311,7 @@ abstract class TaxRule implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -2146,7 +2146,7 @@ abstract class TaxRule implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; if ($this->collProducts instanceof Collection) { @@ -2196,7 +2196,7 @@ abstract class TaxRule implements ActiveRecordInterface * * @return ChildTaxRule The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2220,7 +2220,7 @@ abstract class TaxRule implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildTaxRuleI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collTaxRuleI18ns) { @@ -2255,7 +2255,7 @@ abstract class TaxRule implements ActiveRecordInterface * * @return ChildTaxRule The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildTaxRuleI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/TaxRuleCountry.php b/core/lib/Thelia/Model/Base/TaxRuleCountry.php index b5ae7941b..66f6f585b 100755 --- a/core/lib/Thelia/Model/Base/TaxRuleCountry.php +++ b/core/lib/Thelia/Model/Base/TaxRuleCountry.php @@ -281,7 +281,7 @@ abstract class TaxRuleCountry implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** diff --git a/core/lib/Thelia/Model/Base/TaxRuleI18n.php b/core/lib/Thelia/Model/Base/TaxRuleI18n.php index 51bab6a77..f685dd3cc 100755 --- a/core/lib/Thelia/Model/Base/TaxRuleI18n.php +++ b/core/lib/Thelia/Model/Base/TaxRuleI18n.php @@ -61,7 +61,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_US' + * Note: this column has a database default value of: 'en_EN' * @var string */ protected $locale; @@ -87,7 +87,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_US'; + $this->locale = 'en_EN'; } /** @@ -248,7 +248,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return isset($this->virtualColumns[$name]); + return array_key_exists($name, $this->virtualColumns); } /** @@ -424,7 +424,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_US') { + if ($this->locale !== 'en_EN') { return false; } diff --git a/core/lib/Thelia/Model/Base/TaxRuleQuery.php b/core/lib/Thelia/Model/Base/TaxRuleQuery.php index 2fb478b7a..36f2edd99 100755 --- a/core/lib/Thelia/Model/Base/TaxRuleQuery.php +++ b/core/lib/Thelia/Model/Base/TaxRuleQuery.php @@ -846,7 +846,7 @@ abstract class TaxRuleQuery extends ModelCriteria * * @return ChildTaxRuleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'TaxRuleI18n'; @@ -864,7 +864,7 @@ abstract class TaxRuleQuery extends ModelCriteria * * @return ChildTaxRuleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -885,7 +885,7 @@ abstract class TaxRuleQuery extends ModelCriteria * * @return ChildTaxRuleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php b/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php index 02a20540e..14fc79eeb 100755 --- a/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php @@ -151,7 +151,7 @@ class AttributeAvI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_av', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/AttributeAvTableMap.php b/core/lib/Thelia/Model/Map/AttributeAvTableMap.php index 0c5c2e1c9..138f0fa9c 100755 --- a/core/lib/Thelia/Model/Map/AttributeAvTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeAvTableMap.php @@ -106,7 +106,7 @@ class AttributeAvTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php b/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php index 8471d3e26..b60cae5b8 100755 --- a/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php @@ -151,7 +151,7 @@ class AttributeI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/AttributeTableMap.php b/core/lib/Thelia/Model/Map/AttributeTableMap.php index 773e13cab..dca811cbc 100755 --- a/core/lib/Thelia/Model/Map/AttributeTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeTableMap.php @@ -101,7 +101,7 @@ class AttributeTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CategoryDocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryDocumentI18nTableMap.php index 956afae4a..1ad7dfe2f 100755 --- a/core/lib/Thelia/Model/Map/CategoryDocumentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryDocumentI18nTableMap.php @@ -151,7 +151,7 @@ class CategoryDocumentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category_document', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/CategoryDocumentTableMap.php b/core/lib/Thelia/Model/Map/CategoryDocumentTableMap.php index 8b307ea1e..83e748a1e 100755 --- a/core/lib/Thelia/Model/Map/CategoryDocumentTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryDocumentTableMap.php @@ -111,7 +111,7 @@ class CategoryDocumentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php index 8c52aa7b2..1611b2ebf 100755 --- a/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php @@ -151,7 +151,7 @@ class CategoryI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/CategoryImageI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryImageI18nTableMap.php index 1d27e16ad..1c59c9db2 100755 --- a/core/lib/Thelia/Model/Map/CategoryImageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryImageI18nTableMap.php @@ -151,7 +151,7 @@ class CategoryImageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category_image', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/CategoryImageTableMap.php b/core/lib/Thelia/Model/Map/CategoryImageTableMap.php index 1c7694d05..9eafe2ade 100755 --- a/core/lib/Thelia/Model/Map/CategoryImageTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryImageTableMap.php @@ -111,7 +111,7 @@ class CategoryImageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CategoryTableMap.php b/core/lib/Thelia/Model/Map/CategoryTableMap.php index 5e02d04c5..c3526ec5d 100755 --- a/core/lib/Thelia/Model/Map/CategoryTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryTableMap.php @@ -126,7 +126,7 @@ class CategoryTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php b/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php index b953b0ac9..a83f87b76 100755 --- a/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php @@ -151,7 +151,7 @@ class ConfigI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'config', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ConfigTableMap.php b/core/lib/Thelia/Model/Map/ConfigTableMap.php index ebd5d6edf..8bd68a964 100755 --- a/core/lib/Thelia/Model/Map/ConfigTableMap.php +++ b/core/lib/Thelia/Model/Map/ConfigTableMap.php @@ -116,7 +116,7 @@ class ConfigTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ContentDocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentDocumentI18nTableMap.php index 7ebde93e6..a6ff890d7 100755 --- a/core/lib/Thelia/Model/Map/ContentDocumentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentDocumentI18nTableMap.php @@ -151,7 +151,7 @@ class ContentDocumentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content_document', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ContentDocumentTableMap.php b/core/lib/Thelia/Model/Map/ContentDocumentTableMap.php index 3d876a570..4344b70ae 100755 --- a/core/lib/Thelia/Model/Map/ContentDocumentTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentDocumentTableMap.php @@ -111,7 +111,7 @@ class ContentDocumentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ContentI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php index f718623b0..ee9122a6c 100755 --- a/core/lib/Thelia/Model/Map/ContentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php @@ -151,7 +151,7 @@ class ContentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ContentImageI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentImageI18nTableMap.php index 759349d27..6ff343d16 100755 --- a/core/lib/Thelia/Model/Map/ContentImageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentImageI18nTableMap.php @@ -151,7 +151,7 @@ class ContentImageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content_image', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ContentImageTableMap.php b/core/lib/Thelia/Model/Map/ContentImageTableMap.php index f731c51a8..c95761ab2 100755 --- a/core/lib/Thelia/Model/Map/ContentImageTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentImageTableMap.php @@ -111,7 +111,7 @@ class ContentImageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ContentTableMap.php b/core/lib/Thelia/Model/Map/ContentTableMap.php index 4a489cedb..724c839a1 100755 --- a/core/lib/Thelia/Model/Map/ContentTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentTableMap.php @@ -121,7 +121,7 @@ class ContentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CountryI18nTableMap.php b/core/lib/Thelia/Model/Map/CountryI18nTableMap.php index 272231464..cc60b09d2 100755 --- a/core/lib/Thelia/Model/Map/CountryI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CountryI18nTableMap.php @@ -151,7 +151,7 @@ class CountryI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'country', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/CountryTableMap.php b/core/lib/Thelia/Model/Map/CountryTableMap.php index e7c356f08..2e4931e37 100755 --- a/core/lib/Thelia/Model/Map/CountryTableMap.php +++ b/core/lib/Thelia/Model/Map/CountryTableMap.php @@ -116,7 +116,7 @@ class CountryTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CurrencyI18nTableMap.php b/core/lib/Thelia/Model/Map/CurrencyI18nTableMap.php index c7e4725c1..d280f8601 100755 --- a/core/lib/Thelia/Model/Map/CurrencyI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CurrencyI18nTableMap.php @@ -136,7 +136,7 @@ class CurrencyI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'currency', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('NAME', 'Name', 'VARCHAR', false, 45, null); } // initialize() diff --git a/core/lib/Thelia/Model/Map/CurrencyTableMap.php b/core/lib/Thelia/Model/Map/CurrencyTableMap.php index b37a6b30a..08ecf6966 100755 --- a/core/lib/Thelia/Model/Map/CurrencyTableMap.php +++ b/core/lib/Thelia/Model/Map/CurrencyTableMap.php @@ -121,7 +121,7 @@ class CurrencyTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php index 5344099c5..d403756fa 100755 --- a/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php @@ -141,7 +141,7 @@ class CustomerTitleI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'customer_title', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('SHORT', 'Short', 'VARCHAR', false, 10, null); $this->addColumn('LONG', 'Long', 'VARCHAR', false, 45, null); } // initialize() diff --git a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php index c10ce2500..2769f365e 100755 --- a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php @@ -106,7 +106,7 @@ class CustomerTitleTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php index ba592b4b0..b3114e7ba 100755 --- a/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php @@ -151,7 +151,7 @@ class FeatureAvI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_av', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FeatureAvTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvTableMap.php index 4dd944bb7..0559f7ce6 100755 --- a/core/lib/Thelia/Model/Map/FeatureAvTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureAvTableMap.php @@ -106,7 +106,7 @@ class FeatureAvTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php index dba05fb67..af0dfc263 100755 --- a/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php @@ -151,7 +151,7 @@ class FeatureI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FeatureTableMap.php b/core/lib/Thelia/Model/Map/FeatureTableMap.php index 76c2fe724..7d0af0d45 100755 --- a/core/lib/Thelia/Model/Map/FeatureTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureTableMap.php @@ -106,7 +106,7 @@ class FeatureTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FolderDocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderDocumentI18nTableMap.php index 28dab9d8f..5875031fb 100755 --- a/core/lib/Thelia/Model/Map/FolderDocumentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderDocumentI18nTableMap.php @@ -151,7 +151,7 @@ class FolderDocumentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder_document', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FolderDocumentTableMap.php b/core/lib/Thelia/Model/Map/FolderDocumentTableMap.php index 1d0e3b74a..467b7a65b 100755 --- a/core/lib/Thelia/Model/Map/FolderDocumentTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderDocumentTableMap.php @@ -111,7 +111,7 @@ class FolderDocumentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FolderI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php index d10344811..fc85b17ec 100755 --- a/core/lib/Thelia/Model/Map/FolderI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php @@ -151,7 +151,7 @@ class FolderI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FolderImageI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderImageI18nTableMap.php index f0f87fd85..1c89165a4 100755 --- a/core/lib/Thelia/Model/Map/FolderImageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderImageI18nTableMap.php @@ -151,7 +151,7 @@ class FolderImageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder_image', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FolderImageTableMap.php b/core/lib/Thelia/Model/Map/FolderImageTableMap.php index 6dc186658..c559f9437 100755 --- a/core/lib/Thelia/Model/Map/FolderImageTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderImageTableMap.php @@ -111,7 +111,7 @@ class FolderImageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FolderTableMap.php b/core/lib/Thelia/Model/Map/FolderTableMap.php index 1bfe2cd6e..08871715b 100755 --- a/core/lib/Thelia/Model/Map/FolderTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderTableMap.php @@ -126,7 +126,7 @@ class FolderTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/GroupI18nTableMap.php b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php index 57788593a..585127821 100755 --- a/core/lib/Thelia/Model/Map/GroupI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php @@ -151,7 +151,7 @@ class GroupI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'group', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/GroupTableMap.php b/core/lib/Thelia/Model/Map/GroupTableMap.php index 881a2fa84..a8c830005 100755 --- a/core/lib/Thelia/Model/Map/GroupTableMap.php +++ b/core/lib/Thelia/Model/Map/GroupTableMap.php @@ -101,7 +101,7 @@ class GroupTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/MessageI18nTableMap.php b/core/lib/Thelia/Model/Map/MessageI18nTableMap.php index bb9bfdd2e..f084515c0 100755 --- a/core/lib/Thelia/Model/Map/MessageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/MessageI18nTableMap.php @@ -146,7 +146,7 @@ class MessageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'message', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'LONGVARCHAR', false, null, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('DESCRIPTION_HTML', 'DescriptionHtml', 'CLOB', false, null, null); diff --git a/core/lib/Thelia/Model/Map/MessageTableMap.php b/core/lib/Thelia/Model/Map/MessageTableMap.php index 392dac824..de2a205f9 100755 --- a/core/lib/Thelia/Model/Map/MessageTableMap.php +++ b/core/lib/Thelia/Model/Map/MessageTableMap.php @@ -126,7 +126,7 @@ class MessageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php b/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php index a8e680f1c..67b7a34ef 100755 --- a/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php @@ -151,7 +151,7 @@ class ModuleI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'module', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ModuleTableMap.php b/core/lib/Thelia/Model/Map/ModuleTableMap.php index cccaa890a..5370c1da1 100755 --- a/core/lib/Thelia/Model/Map/ModuleTableMap.php +++ b/core/lib/Thelia/Model/Map/ModuleTableMap.php @@ -116,7 +116,7 @@ class ModuleTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php index 1b2052c2e..5d78c474c 100755 --- a/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php @@ -151,7 +151,7 @@ class OrderStatusI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order_status', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php index 18406d9aa..eecfe5a03 100755 --- a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php @@ -101,7 +101,7 @@ class OrderStatusTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ProductDocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductDocumentI18nTableMap.php index 09e1dc0e4..103914ee6 100755 --- a/core/lib/Thelia/Model/Map/ProductDocumentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductDocumentI18nTableMap.php @@ -151,7 +151,7 @@ class ProductDocumentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product_document', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ProductDocumentTableMap.php b/core/lib/Thelia/Model/Map/ProductDocumentTableMap.php index ff50bad77..f1420cc43 100755 --- a/core/lib/Thelia/Model/Map/ProductDocumentTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductDocumentTableMap.php @@ -111,7 +111,7 @@ class ProductDocumentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php index 79a01514a..8da33f15d 100755 --- a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php @@ -151,7 +151,7 @@ class ProductI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ProductImageI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductImageI18nTableMap.php index 39ad567f9..de3455c07 100755 --- a/core/lib/Thelia/Model/Map/ProductImageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductImageI18nTableMap.php @@ -151,7 +151,7 @@ class ProductImageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product_image', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ProductImageTableMap.php b/core/lib/Thelia/Model/Map/ProductImageTableMap.php index 36aabed3e..945799020 100755 --- a/core/lib/Thelia/Model/Map/ProductImageTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductImageTableMap.php @@ -111,7 +111,7 @@ class ProductImageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php index 75bf5e4e6..ef2cc7ca0 100755 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -131,7 +131,7 @@ class ProductTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php b/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php index ec22e2fd3..8a8ce501a 100755 --- a/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php @@ -151,7 +151,7 @@ class ResourceI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'resource', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ResourceTableMap.php b/core/lib/Thelia/Model/Map/ResourceTableMap.php index 8d7708ddd..e56960892 100755 --- a/core/lib/Thelia/Model/Map/ResourceTableMap.php +++ b/core/lib/Thelia/Model/Map/ResourceTableMap.php @@ -101,7 +101,7 @@ class ResourceTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php index a06230c37..2c4c92f4f 100755 --- a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php @@ -141,7 +141,7 @@ class TaxI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); } // initialize() diff --git a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php index 1f0ed1e96..689f30728 100755 --- a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php @@ -131,7 +131,7 @@ class TaxRuleI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); } // initialize() /** diff --git a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php index cc5f628b9..9b862de99 100755 --- a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php @@ -111,7 +111,7 @@ class TaxRuleTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/TaxTableMap.php b/core/lib/Thelia/Model/Map/TaxTableMap.php index 6d43f20e9..b941e7b52 100755 --- a/core/lib/Thelia/Model/Map/TaxTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxTableMap.php @@ -101,7 +101,7 @@ class TaxTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_LOCALE = 'en_EN'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php new file mode 100755 index 000000000..fd04ef3d9 --- /dev/null +++ b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php @@ -0,0 +1,73 @@ + + */ +class ModelCriteriaTools +{ + /** + * @param ModelCriteria $search + * @param $defaultLangWithoutTranslation + * @param $askedLocale + * @param array $columns + * @param null $foreignTable + * @param string $foreignKey + */ + public static function getI18n(ModelCriteria &$search, $defaultLangWithoutTranslation, $askedLocale, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') + { + if($foreignTable === null) { + $foreignTable = $search->getTableMap()->getName(); + $aliasPrefix = ''; + } else { + $aliasPrefix = $foreignTable . '_'; + } + + $askedLocaleI18nAlias = 'asked_locale_i18n'; + $defaultLocaleI18nAlias = 'default_locale_i18n'; + + if($defaultLangWithoutTranslation == 0) { + $askedLocaleJoin = new Join(); + $askedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $askedLocaleI18nAlias); + $askedLocaleJoin->setJoinType(Criteria::INNER_JOIN); + + $search->addJoinObject($askedLocaleJoin, $askedLocaleI18nAlias) + ->addJoinCondition($askedLocaleI18nAlias ,'`' . $askedLocaleI18nAlias . '`.LOCALE = ?', $askedLocale, null, \PDO::PARAM_STR); + + foreach($columns as $column) { + $search->withColumn('`' . $askedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column); + } + } else { + $defaultLocale = LangQuery::create()->findOneById($defaultLangWithoutTranslation)->getLocale(); + + $defaultLocaleJoin = new Join(); + $defaultLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $defaultLocaleI18nAlias); + $defaultLocaleJoin->setJoinType(Criteria::LEFT_JOIN); + + $search->addJoinObject($defaultLocaleJoin, $defaultLocaleI18nAlias) + ->addJoinCondition($defaultLocaleI18nAlias ,'`' . $defaultLocaleI18nAlias . '`.LOCALE = ?', $defaultLocale, null, \PDO::PARAM_STR); + + $askedLocaleJoin = new Join(); + $askedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $askedLocaleI18nAlias); + $askedLocaleJoin->setJoinType(Criteria::LEFT_JOIN); + + $search->addJoinObject($askedLocaleJoin, $askedLocaleI18nAlias) + ->addJoinCondition($askedLocaleI18nAlias ,'`' . $askedLocaleI18nAlias . '`.LOCALE = ?', $askedLocale, null, \PDO::PARAM_STR); + + $search->where('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.ID)')->_or()->where('NOT ISNULL(`' . $defaultLocaleI18nAlias . '`.ID)'); + + foreach($columns as $column) { + $search->withColumn('CASE WHEN NOT ISNULL(`' . $askedLocaleI18nAlias . '`.ID) THEN `' . $askedLocaleI18nAlias . '`.`' . $column . '` ELSE `' . $defaultLocaleI18nAlias . '`.`' . $column . '` END', $aliasPrefix . 'i18n_' . $column); + } + } + } +} From a9944c73f2bf92df7484019332414cddef0ca229 Mon Sep 17 00:00:00 2001 From: gmorel Date: Thu, 22 Aug 2013 15:18:43 +0200 Subject: [PATCH 021/268] WIP Coupon Use of the Serializer Symfony Component --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 67fb90100..3597db33d 100755 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "simplepie/simplepie": "dev-master", - "imagine/imagine": "dev-master" + "imagine/imagine": "dev-master", + "symfony/serializer": "2.2.*" }, "require-dev" : { "phpunit/phpunit": "3.7.*", From ec3ab5c3aa4a288bca6c357bbb2a3355966d970c Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Thu, 22 Aug 2013 17:47:46 +0200 Subject: [PATCH 022/268] currency loop --- .../lib/Thelia/Core/Template/Loop/Country.php | 1 - .../Thelia/Core/Template/Loop/Currency.php | 112 ++++++++++++++++++ .../Tests/Core/Template/Loop/CurrencyTest.php | 51 ++++++++ 3 files changed, 163 insertions(+), 1 deletion(-) create mode 100755 core/lib/Thelia/Core/Template/Loop/Currency.php create mode 100755 core/lib/Thelia/Tests/Core/Template/Loop/CurrencyTest.php diff --git a/core/lib/Thelia/Core/Template/Loop/Country.php b/core/lib/Thelia/Core/Template/Loop/Country.php index 73e1fd410..d25951fb8 100755 --- a/core/lib/Thelia/Core/Template/Loop/Country.php +++ b/core/lib/Thelia/Core/Template/Loop/Country.php @@ -53,7 +53,6 @@ class Country extends BaseLoop protected function getArgDefinitions() { return new ArgumentCollection( - Argument::createIntTypeArgument('limit', 500), // overwrite orginal param to increase the limit Argument::createIntListTypeArgument('id'), Argument::createIntListTypeArgument('area'), Argument::createBooleanTypeArgument('with_area'), diff --git a/core/lib/Thelia/Core/Template/Loop/Currency.php b/core/lib/Thelia/Core/Template/Loop/Currency.php new file mode 100755 index 000000000..08eacca08 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Currency.php @@ -0,0 +1,112 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\Tools\ModelCriteriaTools; + +use Thelia\Model\CurrencyQuery; +use Thelia\Model\ConfigQuery; + +/** + * + * Currency loop + * + * + * Class Currency + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Currency extends BaseLoop +{ + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + Argument::createIntListTypeArgument('exclude'), + Argument::createBooleanTypeArgument('default_only', false) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = CurrencyQuery::create(); + + /* manage translations */ + ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), array('NAME')); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $exclude = $this->getExclude(); + + if (!is_null($exclude)) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $default_only = $this->getDefaultOnly(); + + if ($default_only === true) { + $search->filterByByDefault(true); + } + + $search->orderByPosition(); + + /* perform search */ + $currencies = $this->search($search, $pagination); + + $loopResult = new LoopResult(); + + foreach ($currencies as $currency) { + $loopResultRow = new LoopResultRow(); + $loopResultRow->set("ID", $currency->getId()) + ->set("NAME",$currency->getVirtualColumn('i18n_NAME')) + ->set("ISOCODE", $currency->getCode()) + ->set("RATE", $currency->getRate()) + ->set("IS_DEFAULT", $currency->getByDefault()); + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/CurrencyTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/CurrencyTest.php new file mode 100755 index 000000000..95dd5a5c6 --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/CurrencyTest.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\Currency; + +/** + * + * @author Etienne Roudeix + * + */ +class CurrencyTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\Currency'; + } + + public function getTestedInstance() + { + return new Currency($this->request, $this->dispatcher, $this->securityContext); + } + + public function getMandatoryArguments() + { + return array(); + } +} From 7ef0339784da77643d8904d93bd1e3bfb62306c7 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Thu, 22 Aug 2013 17:54:19 +0200 Subject: [PATCH 023/268] associated content for categories and products tables --- core/lib/Thelia/Model/Base/Category.php | 619 +++--- core/lib/Thelia/Model/Base/CategoryQuery.php | 154 +- core/lib/Thelia/Model/Base/Content.php | 916 +++++--- core/lib/Thelia/Model/Base/ContentAssoc.php | 1688 --------------- .../Thelia/Model/Base/ContentAssocQuery.php | 930 --------- core/lib/Thelia/Model/Base/ContentQuery.php | 231 ++- core/lib/Thelia/Model/Base/Coupon.php | 1841 ++++++++++++++--- core/lib/Thelia/Model/Base/CouponOrder.php | 79 + .../Thelia/Model/Base/CouponOrderQuery.php | 79 + core/lib/Thelia/Model/Base/CouponQuery.php | 661 ++++-- core/lib/Thelia/Model/Base/Order.php | 25 + core/lib/Thelia/Model/Base/Product.php | 619 +++--- core/lib/Thelia/Model/Base/ProductQuery.php | 154 +- core/lib/Thelia/Model/ContentAssoc.php | 9 - core/lib/Thelia/Model/ContentAssocQuery.php | 20 - .../lib/Thelia/Model/Map/CategoryTableMap.php | 4 +- .../Thelia/Model/Map/ContentAssocTableMap.php | 465 ----- core/lib/Thelia/Model/Map/ContentTableMap.php | 6 +- .../Thelia/Model/Map/CouponOrderTableMap.php | 3 +- core/lib/Thelia/Model/Map/CouponTableMap.php | 128 +- core/lib/Thelia/Model/Map/ProductTableMap.php | 4 +- install/thelia.sql | 238 ++- local/config/schema.xml | 99 +- 23 files changed, 4037 insertions(+), 4935 deletions(-) delete mode 100755 core/lib/Thelia/Model/Base/ContentAssoc.php delete mode 100755 core/lib/Thelia/Model/Base/ContentAssocQuery.php delete mode 100755 core/lib/Thelia/Model/ContentAssoc.php delete mode 100755 core/lib/Thelia/Model/ContentAssocQuery.php delete mode 100755 core/lib/Thelia/Model/Map/ContentAssocTableMap.php diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php index 6a4445db4..1bafdae8c 100755 --- a/core/lib/Thelia/Model/Base/Category.php +++ b/core/lib/Thelia/Model/Base/Category.php @@ -22,6 +22,8 @@ use Thelia\Model\AttributeCategory as ChildAttributeCategory; use Thelia\Model\AttributeCategoryQuery as ChildAttributeCategoryQuery; use Thelia\Model\AttributeQuery as ChildAttributeQuery; use Thelia\Model\Category as ChildCategory; +use Thelia\Model\CategoryAssociatedContent as ChildCategoryAssociatedContent; +use Thelia\Model\CategoryAssociatedContentQuery as ChildCategoryAssociatedContentQuery; use Thelia\Model\CategoryDocument as ChildCategoryDocument; use Thelia\Model\CategoryDocumentQuery as ChildCategoryDocumentQuery; use Thelia\Model\CategoryI18n as ChildCategoryI18n; @@ -31,8 +33,6 @@ use Thelia\Model\CategoryImageQuery as ChildCategoryImageQuery; use Thelia\Model\CategoryQuery as ChildCategoryQuery; use Thelia\Model\CategoryVersion as ChildCategoryVersion; use Thelia\Model\CategoryVersionQuery as ChildCategoryVersionQuery; -use Thelia\Model\ContentAssoc as ChildContentAssoc; -use Thelia\Model\ContentAssocQuery as ChildContentAssocQuery; use Thelia\Model\Feature as ChildFeature; use Thelia\Model\FeatureCategory as ChildFeatureCategory; use Thelia\Model\FeatureCategoryQuery as ChildFeatureCategoryQuery; @@ -153,12 +153,6 @@ abstract class Category implements ActiveRecordInterface protected $collAttributeCategories; protected $collAttributeCategoriesPartial; - /** - * @var ObjectCollection|ChildContentAssoc[] Collection to store aggregation of ChildContentAssoc objects. - */ - protected $collContentAssocs; - protected $collContentAssocsPartial; - /** * @var ObjectCollection|ChildRewriting[] Collection to store aggregation of ChildRewriting objects. */ @@ -177,6 +171,12 @@ abstract class Category implements ActiveRecordInterface protected $collCategoryDocuments; protected $collCategoryDocumentsPartial; + /** + * @var ObjectCollection|ChildCategoryAssociatedContent[] Collection to store aggregation of ChildCategoryAssociatedContent objects. + */ + protected $collCategoryAssociatedContents; + protected $collCategoryAssociatedContentsPartial; + /** * @var ObjectCollection|ChildCategoryI18n[] Collection to store aggregation of ChildCategoryI18n objects. */ @@ -270,12 +270,6 @@ abstract class Category implements ActiveRecordInterface */ protected $attributeCategoriesScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $contentAssocsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -294,6 +288,12 @@ abstract class Category implements ActiveRecordInterface */ protected $categoryDocumentsScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $categoryAssociatedContentsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -1039,14 +1039,14 @@ abstract class Category implements ActiveRecordInterface $this->collAttributeCategories = null; - $this->collContentAssocs = null; - $this->collRewritings = null; $this->collCategoryImages = null; $this->collCategoryDocuments = null; + $this->collCategoryAssociatedContents = null; + $this->collCategoryI18ns = null; $this->collCategoryVersions = null; @@ -1331,23 +1331,6 @@ abstract class Category implements ActiveRecordInterface } } - if ($this->contentAssocsScheduledForDeletion !== null) { - if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - \Thelia\Model\ContentAssocQuery::create() - ->filterByPrimaryKeys($this->contentAssocsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->contentAssocsScheduledForDeletion = null; - } - } - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->rewritingsScheduledForDeletion !== null) { if (!$this->rewritingsScheduledForDeletion->isEmpty()) { \Thelia\Model\RewritingQuery::create() @@ -1399,6 +1382,23 @@ abstract class Category implements ActiveRecordInterface } } + if ($this->categoryAssociatedContentsScheduledForDeletion !== null) { + if (!$this->categoryAssociatedContentsScheduledForDeletion->isEmpty()) { + \Thelia\Model\CategoryAssociatedContentQuery::create() + ->filterByPrimaryKeys($this->categoryAssociatedContentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->categoryAssociatedContentsScheduledForDeletion = null; + } + } + + if ($this->collCategoryAssociatedContents !== null) { + foreach ($this->collCategoryAssociatedContents as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->categoryI18nsScheduledForDeletion !== null) { if (!$this->categoryI18nsScheduledForDeletion->isEmpty()) { \Thelia\Model\CategoryI18nQuery::create() @@ -1668,9 +1668,6 @@ abstract class Category implements ActiveRecordInterface if (null !== $this->collAttributeCategories) { $result['AttributeCategories'] = $this->collAttributeCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collContentAssocs) { - $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collRewritings) { $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1680,6 +1677,9 @@ abstract class Category implements ActiveRecordInterface if (null !== $this->collCategoryDocuments) { $result['CategoryDocuments'] = $this->collCategoryDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collCategoryAssociatedContents) { + $result['CategoryAssociatedContents'] = $this->collCategoryAssociatedContents->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collCategoryI18ns) { $result['CategoryI18ns'] = $this->collCategoryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1895,12 +1895,6 @@ abstract class Category implements ActiveRecordInterface } } - foreach ($this->getContentAssocs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentAssoc($relObj->copy($deepCopy)); - } - } - foreach ($this->getRewritings() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addRewriting($relObj->copy($deepCopy)); @@ -1919,6 +1913,12 @@ abstract class Category implements ActiveRecordInterface } } + foreach ($this->getCategoryAssociatedContents() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCategoryAssociatedContent($relObj->copy($deepCopy)); + } + } + foreach ($this->getCategoryI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCategoryI18n($relObj->copy($deepCopy)); @@ -1981,9 +1981,6 @@ abstract class Category implements ActiveRecordInterface if ('AttributeCategory' == $relationName) { return $this->initAttributeCategories(); } - if ('ContentAssoc' == $relationName) { - return $this->initContentAssocs(); - } if ('Rewriting' == $relationName) { return $this->initRewritings(); } @@ -1993,6 +1990,9 @@ abstract class Category implements ActiveRecordInterface if ('CategoryDocument' == $relationName) { return $this->initCategoryDocuments(); } + if ('CategoryAssociatedContent' == $relationName) { + return $this->initCategoryAssociatedContents(); + } if ('CategoryI18n' == $relationName) { return $this->initCategoryI18ns(); } @@ -2733,274 +2733,6 @@ abstract class Category implements ActiveRecordInterface return $this->getAttributeCategories($query, $con); } - /** - * Clears out the collContentAssocs collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addContentAssocs() - */ - public function clearContentAssocs() - { - $this->collContentAssocs = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collContentAssocs collection loaded partially. - */ - public function resetPartialContentAssocs($v = true) - { - $this->collContentAssocsPartial = $v; - } - - /** - * Initializes the collContentAssocs collection. - * - * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentAssocs($overrideExisting = true) - { - if (null !== $this->collContentAssocs && !$overrideExisting) { - return; - } - $this->collContentAssocs = new ObjectCollection(); - $this->collContentAssocs->setModel('\Thelia\Model\ContentAssoc'); - } - - /** - * Gets an array of ChildContentAssoc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildCategory is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - * @throws PropelException - */ - public function getContentAssocs($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - // return empty collection - $this->initContentAssocs(); - } else { - $collContentAssocs = ChildContentAssocQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { - $this->initContentAssocs(false); - - foreach ($collContentAssocs as $obj) { - if (false == $this->collContentAssocs->contains($obj)) { - $this->collContentAssocs->append($obj); - } - } - - $this->collContentAssocsPartial = true; - } - - $collContentAssocs->getInternalIterator()->rewind(); - - return $collContentAssocs; - } - - if ($partial && $this->collContentAssocs) { - foreach ($this->collContentAssocs as $obj) { - if ($obj->isNew()) { - $collContentAssocs[] = $obj; - } - } - } - - $this->collContentAssocs = $collContentAssocs; - $this->collContentAssocsPartial = false; - } - } - - return $this->collContentAssocs; - } - - /** - * Sets a collection of ContentAssoc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $contentAssocs A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildCategory The current object (for fluent API support) - */ - public function setContentAssocs(Collection $contentAssocs, ConnectionInterface $con = null) - { - $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - - - $this->contentAssocsScheduledForDeletion = $contentAssocsToDelete; - - foreach ($contentAssocsToDelete as $contentAssocRemoved) { - $contentAssocRemoved->setCategory(null); - } - - $this->collContentAssocs = null; - foreach ($contentAssocs as $contentAssoc) { - $this->addContentAssoc($contentAssoc); - } - - $this->collContentAssocs = $contentAssocs; - $this->collContentAssocsPartial = false; - - return $this; - } - - /** - * Returns the number of related ContentAssoc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related ContentAssoc objects. - * @throws PropelException - */ - public function countContentAssocs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getContentAssocs()); - } - - $query = ChildContentAssocQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collContentAssocs); - } - - /** - * Method called to associate a ChildContentAssoc object to this object - * through the ChildContentAssoc foreign key attribute. - * - * @param ChildContentAssoc $l ChildContentAssoc - * @return \Thelia\Model\Category The current object (for fluent API support) - */ - public function addContentAssoc(ChildContentAssoc $l) - { - if ($this->collContentAssocs === null) { - $this->initContentAssocs(); - $this->collContentAssocsPartial = true; - } - - if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddContentAssoc($l); - } - - return $this; - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to add. - */ - protected function doAddContentAssoc($contentAssoc) - { - $this->collContentAssocs[]= $contentAssoc; - $contentAssoc->setCategory($this); - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to remove. - * @return ChildCategory The current object (for fluent API support) - */ - public function removeContentAssoc($contentAssoc) - { - if ($this->getContentAssocs()->contains($contentAssoc)) { - $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc)); - if (null === $this->contentAssocsScheduledForDeletion) { - $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs; - $this->contentAssocsScheduledForDeletion->clear(); - } - $this->contentAssocsScheduledForDeletion[]= $contentAssoc; - $contentAssoc->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - */ - public function getContentAssocsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildContentAssocQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getContentAssocs($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - */ - public function getContentAssocsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildContentAssocQuery::create(null, $criteria); - $query->joinWith('Content', $joinBehavior); - - return $this->getContentAssocs($query, $con); - } - /** * Clears out the collRewritings collection * @@ -3730,6 +3462,249 @@ abstract class Category implements ActiveRecordInterface return $this; } + /** + * Clears out the collCategoryAssociatedContents collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCategoryAssociatedContents() + */ + public function clearCategoryAssociatedContents() + { + $this->collCategoryAssociatedContents = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCategoryAssociatedContents collection loaded partially. + */ + public function resetPartialCategoryAssociatedContents($v = true) + { + $this->collCategoryAssociatedContentsPartial = $v; + } + + /** + * Initializes the collCategoryAssociatedContents collection. + * + * By default this just sets the collCategoryAssociatedContents collection to an empty array (like clearcollCategoryAssociatedContents()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCategoryAssociatedContents($overrideExisting = true) + { + if (null !== $this->collCategoryAssociatedContents && !$overrideExisting) { + return; + } + $this->collCategoryAssociatedContents = new ObjectCollection(); + $this->collCategoryAssociatedContents->setModel('\Thelia\Model\CategoryAssociatedContent'); + } + + /** + * Gets an array of ChildCategoryAssociatedContent objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildCategory is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCategoryAssociatedContent[] List of ChildCategoryAssociatedContent objects + * @throws PropelException + */ + public function getCategoryAssociatedContents($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCategoryAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collCategoryAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryAssociatedContents) { + // return empty collection + $this->initCategoryAssociatedContents(); + } else { + $collCategoryAssociatedContents = ChildCategoryAssociatedContentQuery::create(null, $criteria) + ->filterByCategory($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCategoryAssociatedContentsPartial && count($collCategoryAssociatedContents)) { + $this->initCategoryAssociatedContents(false); + + foreach ($collCategoryAssociatedContents as $obj) { + if (false == $this->collCategoryAssociatedContents->contains($obj)) { + $this->collCategoryAssociatedContents->append($obj); + } + } + + $this->collCategoryAssociatedContentsPartial = true; + } + + $collCategoryAssociatedContents->getInternalIterator()->rewind(); + + return $collCategoryAssociatedContents; + } + + if ($partial && $this->collCategoryAssociatedContents) { + foreach ($this->collCategoryAssociatedContents as $obj) { + if ($obj->isNew()) { + $collCategoryAssociatedContents[] = $obj; + } + } + } + + $this->collCategoryAssociatedContents = $collCategoryAssociatedContents; + $this->collCategoryAssociatedContentsPartial = false; + } + } + + return $this->collCategoryAssociatedContents; + } + + /** + * Sets a collection of CategoryAssociatedContent objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $categoryAssociatedContents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) + */ + public function setCategoryAssociatedContents(Collection $categoryAssociatedContents, ConnectionInterface $con = null) + { + $categoryAssociatedContentsToDelete = $this->getCategoryAssociatedContents(new Criteria(), $con)->diff($categoryAssociatedContents); + + + $this->categoryAssociatedContentsScheduledForDeletion = $categoryAssociatedContentsToDelete; + + foreach ($categoryAssociatedContentsToDelete as $categoryAssociatedContentRemoved) { + $categoryAssociatedContentRemoved->setCategory(null); + } + + $this->collCategoryAssociatedContents = null; + foreach ($categoryAssociatedContents as $categoryAssociatedContent) { + $this->addCategoryAssociatedContent($categoryAssociatedContent); + } + + $this->collCategoryAssociatedContents = $categoryAssociatedContents; + $this->collCategoryAssociatedContentsPartial = false; + + return $this; + } + + /** + * Returns the number of related CategoryAssociatedContent objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CategoryAssociatedContent objects. + * @throws PropelException + */ + public function countCategoryAssociatedContents(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCategoryAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collCategoryAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryAssociatedContents) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCategoryAssociatedContents()); + } + + $query = ChildCategoryAssociatedContentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); + } + + return count($this->collCategoryAssociatedContents); + } + + /** + * Method called to associate a ChildCategoryAssociatedContent object to this object + * through the ChildCategoryAssociatedContent foreign key attribute. + * + * @param ChildCategoryAssociatedContent $l ChildCategoryAssociatedContent + * @return \Thelia\Model\Category The current object (for fluent API support) + */ + public function addCategoryAssociatedContent(ChildCategoryAssociatedContent $l) + { + if ($this->collCategoryAssociatedContents === null) { + $this->initCategoryAssociatedContents(); + $this->collCategoryAssociatedContentsPartial = true; + } + + if (!in_array($l, $this->collCategoryAssociatedContents->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCategoryAssociatedContent($l); + } + + return $this; + } + + /** + * @param CategoryAssociatedContent $categoryAssociatedContent The categoryAssociatedContent object to add. + */ + protected function doAddCategoryAssociatedContent($categoryAssociatedContent) + { + $this->collCategoryAssociatedContents[]= $categoryAssociatedContent; + $categoryAssociatedContent->setCategory($this); + } + + /** + * @param CategoryAssociatedContent $categoryAssociatedContent The categoryAssociatedContent object to remove. + * @return ChildCategory The current object (for fluent API support) + */ + public function removeCategoryAssociatedContent($categoryAssociatedContent) + { + if ($this->getCategoryAssociatedContents()->contains($categoryAssociatedContent)) { + $this->collCategoryAssociatedContents->remove($this->collCategoryAssociatedContents->search($categoryAssociatedContent)); + if (null === $this->categoryAssociatedContentsScheduledForDeletion) { + $this->categoryAssociatedContentsScheduledForDeletion = clone $this->collCategoryAssociatedContents; + $this->categoryAssociatedContentsScheduledForDeletion->clear(); + } + $this->categoryAssociatedContentsScheduledForDeletion[]= clone $categoryAssociatedContent; + $categoryAssociatedContent->setCategory(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Category is new, it will return + * an empty collection; or if this Category has previously + * been saved, it will retrieve related CategoryAssociatedContents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Category. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildCategoryAssociatedContent[] List of ChildCategoryAssociatedContent objects + */ + public function getCategoryAssociatedContentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildCategoryAssociatedContentQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); + + return $this->getCategoryAssociatedContents($query, $con); + } + /** * Clears out the collCategoryI18ns collection * @@ -4774,11 +4749,6 @@ abstract class Category implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collContentAssocs) { - foreach ($this->collContentAssocs as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collRewritings) { foreach ($this->collRewritings as $o) { $o->clearAllReferences($deep); @@ -4794,6 +4764,11 @@ abstract class Category implements ActiveRecordInterface $o->clearAllReferences($deep); } } + if ($this->collCategoryAssociatedContents) { + foreach ($this->collCategoryAssociatedContents as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collCategoryI18ns) { foreach ($this->collCategoryI18ns as $o) { $o->clearAllReferences($deep); @@ -4837,10 +4812,6 @@ abstract class Category implements ActiveRecordInterface $this->collAttributeCategories->clearIterator(); } $this->collAttributeCategories = null; - if ($this->collContentAssocs instanceof Collection) { - $this->collContentAssocs->clearIterator(); - } - $this->collContentAssocs = null; if ($this->collRewritings instanceof Collection) { $this->collRewritings->clearIterator(); } @@ -4853,6 +4824,10 @@ abstract class Category implements ActiveRecordInterface $this->collCategoryDocuments->clearIterator(); } $this->collCategoryDocuments = null; + if ($this->collCategoryAssociatedContents instanceof Collection) { + $this->collCategoryAssociatedContents->clearIterator(); + } + $this->collCategoryAssociatedContents = null; if ($this->collCategoryI18ns instanceof Collection) { $this->collCategoryI18ns->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/CategoryQuery.php b/core/lib/Thelia/Model/Base/CategoryQuery.php index 5a9c1165f..4c823a223 100755 --- a/core/lib/Thelia/Model/Base/CategoryQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryQuery.php @@ -58,10 +58,6 @@ use Thelia\Model\Map\CategoryTableMap; * @method ChildCategoryQuery rightJoinAttributeCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCategory relation * @method ChildCategoryQuery innerJoinAttributeCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCategory relation * - * @method ChildCategoryQuery leftJoinContentAssoc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentAssoc relation - * @method ChildCategoryQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation - * @method ChildCategoryQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation - * * @method ChildCategoryQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation * @method ChildCategoryQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation * @method ChildCategoryQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation @@ -74,6 +70,10 @@ use Thelia\Model\Map\CategoryTableMap; * @method ChildCategoryQuery rightJoinCategoryDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryDocument relation * @method ChildCategoryQuery innerJoinCategoryDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryDocument relation * + * @method ChildCategoryQuery leftJoinCategoryAssociatedContent($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryAssociatedContent relation + * @method ChildCategoryQuery rightJoinCategoryAssociatedContent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryAssociatedContent relation + * @method ChildCategoryQuery innerJoinCategoryAssociatedContent($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryAssociatedContent relation + * * @method ChildCategoryQuery leftJoinCategoryI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryI18n relation * @method ChildCategoryQuery rightJoinCategoryI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryI18n relation * @method ChildCategoryQuery innerJoinCategoryI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryI18n relation @@ -870,79 +870,6 @@ abstract class CategoryQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery'); } - /** - * Filter the query by a related \Thelia\Model\ContentAssoc object - * - * @param \Thelia\Model\ContentAssoc|ObjectCollection $contentAssoc the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function filterByContentAssoc($contentAssoc, $comparison = null) - { - if ($contentAssoc instanceof \Thelia\Model\ContentAssoc) { - return $this - ->addUsingAlias(CategoryTableMap::ID, $contentAssoc->getCategoryId(), $comparison); - } elseif ($contentAssoc instanceof ObjectCollection) { - return $this - ->useContentAssocQuery() - ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type \Thelia\Model\ContentAssoc or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentAssoc relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentAssoc'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentAssoc'); - } - - return $this; - } - - /** - * Use the ContentAssoc relation ContentAssoc object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query - */ - public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContentAssoc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); - } - /** * Filter the query by a related \Thelia\Model\Rewriting object * @@ -1162,6 +1089,79 @@ abstract class CategoryQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'CategoryDocument', '\Thelia\Model\CategoryDocumentQuery'); } + /** + * Filter the query by a related \Thelia\Model\CategoryAssociatedContent object + * + * @param \Thelia\Model\CategoryAssociatedContent|ObjectCollection $categoryAssociatedContent the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryQuery The current query, for fluid interface + */ + public function filterByCategoryAssociatedContent($categoryAssociatedContent, $comparison = null) + { + if ($categoryAssociatedContent instanceof \Thelia\Model\CategoryAssociatedContent) { + return $this + ->addUsingAlias(CategoryTableMap::ID, $categoryAssociatedContent->getCategoryId(), $comparison); + } elseif ($categoryAssociatedContent instanceof ObjectCollection) { + return $this + ->useCategoryAssociatedContentQuery() + ->filterByPrimaryKeys($categoryAssociatedContent->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCategoryAssociatedContent() only accepts arguments of type \Thelia\Model\CategoryAssociatedContent or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CategoryAssociatedContent relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryQuery The current query, for fluid interface + */ + public function joinCategoryAssociatedContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CategoryAssociatedContent'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CategoryAssociatedContent'); + } + + return $this; + } + + /** + * Use the CategoryAssociatedContent relation CategoryAssociatedContent object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryAssociatedContentQuery A secondary query class using the current class as primary query + */ + public function useCategoryAssociatedContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCategoryAssociatedContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CategoryAssociatedContent', '\Thelia\Model\CategoryAssociatedContentQuery'); + } + /** * Filter the query by a related \Thelia\Model\CategoryI18n object * diff --git a/core/lib/Thelia/Model/Base/Content.php b/core/lib/Thelia/Model/Base/Content.php index 59745e39c..bd4d29046 100755 --- a/core/lib/Thelia/Model/Base/Content.php +++ b/core/lib/Thelia/Model/Base/Content.php @@ -17,9 +17,9 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; +use Thelia\Model\CategoryAssociatedContent as ChildCategoryAssociatedContent; +use Thelia\Model\CategoryAssociatedContentQuery as ChildCategoryAssociatedContentQuery; use Thelia\Model\Content as ChildContent; -use Thelia\Model\ContentAssoc as ChildContentAssoc; -use Thelia\Model\ContentAssocQuery as ChildContentAssocQuery; use Thelia\Model\ContentDocument as ChildContentDocument; use Thelia\Model\ContentDocumentQuery as ChildContentDocumentQuery; use Thelia\Model\ContentFolder as ChildContentFolder; @@ -33,6 +33,8 @@ use Thelia\Model\ContentVersion as ChildContentVersion; use Thelia\Model\ContentVersionQuery as ChildContentVersionQuery; use Thelia\Model\Folder as ChildFolder; use Thelia\Model\FolderQuery as ChildFolderQuery; +use Thelia\Model\ProductAssociatedContent as ChildProductAssociatedContent; +use Thelia\Model\ProductAssociatedContentQuery as ChildProductAssociatedContentQuery; use Thelia\Model\Rewriting as ChildRewriting; use Thelia\Model\RewritingQuery as ChildRewritingQuery; use Thelia\Model\Map\ContentTableMap; @@ -121,12 +123,6 @@ abstract class Content implements ActiveRecordInterface */ protected $version_created_by; - /** - * @var ObjectCollection|ChildContentAssoc[] Collection to store aggregation of ChildContentAssoc objects. - */ - protected $collContentAssocs; - protected $collContentAssocsPartial; - /** * @var ObjectCollection|ChildRewriting[] Collection to store aggregation of ChildRewriting objects. */ @@ -151,6 +147,18 @@ abstract class Content implements ActiveRecordInterface protected $collContentDocuments; protected $collContentDocumentsPartial; + /** + * @var ObjectCollection|ChildProductAssociatedContent[] Collection to store aggregation of ChildProductAssociatedContent objects. + */ + protected $collProductAssociatedContents; + protected $collProductAssociatedContentsPartial; + + /** + * @var ObjectCollection|ChildCategoryAssociatedContent[] Collection to store aggregation of ChildCategoryAssociatedContent objects. + */ + protected $collCategoryAssociatedContents; + protected $collCategoryAssociatedContentsPartial; + /** * @var ObjectCollection|ChildContentI18n[] Collection to store aggregation of ChildContentI18n objects. */ @@ -204,12 +212,6 @@ abstract class Content implements ActiveRecordInterface */ protected $foldersScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $contentAssocsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -234,6 +236,18 @@ abstract class Content implements ActiveRecordInterface */ protected $contentDocumentsScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $productAssociatedContentsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $categoryAssociatedContentsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -938,8 +952,6 @@ abstract class Content implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->collContentAssocs = null; - $this->collRewritings = null; $this->collContentFolders = null; @@ -948,6 +960,10 @@ abstract class Content implements ActiveRecordInterface $this->collContentDocuments = null; + $this->collProductAssociatedContents = null; + + $this->collCategoryAssociatedContents = null; + $this->collContentI18ns = null; $this->collContentVersions = null; @@ -1125,23 +1141,6 @@ abstract class Content implements ActiveRecordInterface } } - if ($this->contentAssocsScheduledForDeletion !== null) { - if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - \Thelia\Model\ContentAssocQuery::create() - ->filterByPrimaryKeys($this->contentAssocsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->contentAssocsScheduledForDeletion = null; - } - } - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->rewritingsScheduledForDeletion !== null) { if (!$this->rewritingsScheduledForDeletion->isEmpty()) { \Thelia\Model\RewritingQuery::create() @@ -1210,6 +1209,40 @@ abstract class Content implements ActiveRecordInterface } } + if ($this->productAssociatedContentsScheduledForDeletion !== null) { + if (!$this->productAssociatedContentsScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProductAssociatedContentQuery::create() + ->filterByPrimaryKeys($this->productAssociatedContentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->productAssociatedContentsScheduledForDeletion = null; + } + } + + if ($this->collProductAssociatedContents !== null) { + foreach ($this->collProductAssociatedContents as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->categoryAssociatedContentsScheduledForDeletion !== null) { + if (!$this->categoryAssociatedContentsScheduledForDeletion->isEmpty()) { + \Thelia\Model\CategoryAssociatedContentQuery::create() + ->filterByPrimaryKeys($this->categoryAssociatedContentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->categoryAssociatedContentsScheduledForDeletion = null; + } + } + + if ($this->collCategoryAssociatedContents !== null) { + foreach ($this->collCategoryAssociatedContents as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->contentI18nsScheduledForDeletion !== null) { if (!$this->contentI18nsScheduledForDeletion->isEmpty()) { \Thelia\Model\ContentI18nQuery::create() @@ -1460,9 +1493,6 @@ abstract class Content implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->collContentAssocs) { - $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collRewritings) { $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1475,6 +1505,12 @@ abstract class Content implements ActiveRecordInterface if (null !== $this->collContentDocuments) { $result['ContentDocuments'] = $this->collContentDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collProductAssociatedContents) { + $result['ProductAssociatedContents'] = $this->collProductAssociatedContents->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCategoryAssociatedContents) { + $result['CategoryAssociatedContents'] = $this->collCategoryAssociatedContents->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collContentI18ns) { $result['ContentI18ns'] = $this->collContentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1666,12 +1702,6 @@ abstract class Content implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getContentAssocs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentAssoc($relObj->copy($deepCopy)); - } - } - foreach ($this->getRewritings() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addRewriting($relObj->copy($deepCopy)); @@ -1696,6 +1726,18 @@ abstract class Content implements ActiveRecordInterface } } + foreach ($this->getProductAssociatedContents() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addProductAssociatedContent($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCategoryAssociatedContents() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCategoryAssociatedContent($relObj->copy($deepCopy)); + } + } + foreach ($this->getContentI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addContentI18n($relObj->copy($deepCopy)); @@ -1749,9 +1791,6 @@ abstract class Content implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('ContentAssoc' == $relationName) { - return $this->initContentAssocs(); - } if ('Rewriting' == $relationName) { return $this->initRewritings(); } @@ -1764,6 +1803,12 @@ abstract class Content implements ActiveRecordInterface if ('ContentDocument' == $relationName) { return $this->initContentDocuments(); } + if ('ProductAssociatedContent' == $relationName) { + return $this->initProductAssociatedContents(); + } + if ('CategoryAssociatedContent' == $relationName) { + return $this->initCategoryAssociatedContents(); + } if ('ContentI18n' == $relationName) { return $this->initContentI18ns(); } @@ -1772,274 +1817,6 @@ abstract class Content implements ActiveRecordInterface } } - /** - * Clears out the collContentAssocs collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addContentAssocs() - */ - public function clearContentAssocs() - { - $this->collContentAssocs = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collContentAssocs collection loaded partially. - */ - public function resetPartialContentAssocs($v = true) - { - $this->collContentAssocsPartial = $v; - } - - /** - * Initializes the collContentAssocs collection. - * - * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentAssocs($overrideExisting = true) - { - if (null !== $this->collContentAssocs && !$overrideExisting) { - return; - } - $this->collContentAssocs = new ObjectCollection(); - $this->collContentAssocs->setModel('\Thelia\Model\ContentAssoc'); - } - - /** - * Gets an array of ChildContentAssoc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildContent is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - * @throws PropelException - */ - public function getContentAssocs($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - // return empty collection - $this->initContentAssocs(); - } else { - $collContentAssocs = ChildContentAssocQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { - $this->initContentAssocs(false); - - foreach ($collContentAssocs as $obj) { - if (false == $this->collContentAssocs->contains($obj)) { - $this->collContentAssocs->append($obj); - } - } - - $this->collContentAssocsPartial = true; - } - - $collContentAssocs->getInternalIterator()->rewind(); - - return $collContentAssocs; - } - - if ($partial && $this->collContentAssocs) { - foreach ($this->collContentAssocs as $obj) { - if ($obj->isNew()) { - $collContentAssocs[] = $obj; - } - } - } - - $this->collContentAssocs = $collContentAssocs; - $this->collContentAssocsPartial = false; - } - } - - return $this->collContentAssocs; - } - - /** - * Sets a collection of ContentAssoc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $contentAssocs A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildContent The current object (for fluent API support) - */ - public function setContentAssocs(Collection $contentAssocs, ConnectionInterface $con = null) - { - $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - - - $this->contentAssocsScheduledForDeletion = $contentAssocsToDelete; - - foreach ($contentAssocsToDelete as $contentAssocRemoved) { - $contentAssocRemoved->setContent(null); - } - - $this->collContentAssocs = null; - foreach ($contentAssocs as $contentAssoc) { - $this->addContentAssoc($contentAssoc); - } - - $this->collContentAssocs = $contentAssocs; - $this->collContentAssocsPartial = false; - - return $this; - } - - /** - * Returns the number of related ContentAssoc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related ContentAssoc objects. - * @throws PropelException - */ - public function countContentAssocs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getContentAssocs()); - } - - $query = ChildContentAssocQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - - return count($this->collContentAssocs); - } - - /** - * Method called to associate a ChildContentAssoc object to this object - * through the ChildContentAssoc foreign key attribute. - * - * @param ChildContentAssoc $l ChildContentAssoc - * @return \Thelia\Model\Content The current object (for fluent API support) - */ - public function addContentAssoc(ChildContentAssoc $l) - { - if ($this->collContentAssocs === null) { - $this->initContentAssocs(); - $this->collContentAssocsPartial = true; - } - - if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddContentAssoc($l); - } - - return $this; - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to add. - */ - protected function doAddContentAssoc($contentAssoc) - { - $this->collContentAssocs[]= $contentAssoc; - $contentAssoc->setContent($this); - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to remove. - * @return ChildContent The current object (for fluent API support) - */ - public function removeContentAssoc($contentAssoc) - { - if ($this->getContentAssocs()->contains($contentAssoc)) { - $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc)); - if (null === $this->contentAssocsScheduledForDeletion) { - $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs; - $this->contentAssocsScheduledForDeletion->clear(); - } - $this->contentAssocsScheduledForDeletion[]= $contentAssoc; - $contentAssoc->setContent(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - */ - public function getContentAssocsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildContentAssocQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); - - return $this->getContentAssocs($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - */ - public function getContentAssocsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildContentAssocQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getContentAssocs($query, $con); - } - /** * Clears out the collRewritings collection * @@ -3015,6 +2792,492 @@ abstract class Content implements ActiveRecordInterface return $this; } + /** + * Clears out the collProductAssociatedContents collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addProductAssociatedContents() + */ + public function clearProductAssociatedContents() + { + $this->collProductAssociatedContents = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collProductAssociatedContents collection loaded partially. + */ + public function resetPartialProductAssociatedContents($v = true) + { + $this->collProductAssociatedContentsPartial = $v; + } + + /** + * Initializes the collProductAssociatedContents collection. + * + * By default this just sets the collProductAssociatedContents collection to an empty array (like clearcollProductAssociatedContents()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initProductAssociatedContents($overrideExisting = true) + { + if (null !== $this->collProductAssociatedContents && !$overrideExisting) { + return; + } + $this->collProductAssociatedContents = new ObjectCollection(); + $this->collProductAssociatedContents->setModel('\Thelia\Model\ProductAssociatedContent'); + } + + /** + * Gets an array of ChildProductAssociatedContent objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildContent is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProductAssociatedContent[] List of ChildProductAssociatedContent objects + * @throws PropelException + */ + public function getProductAssociatedContents($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collProductAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collProductAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductAssociatedContents) { + // return empty collection + $this->initProductAssociatedContents(); + } else { + $collProductAssociatedContents = ChildProductAssociatedContentQuery::create(null, $criteria) + ->filterByContent($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collProductAssociatedContentsPartial && count($collProductAssociatedContents)) { + $this->initProductAssociatedContents(false); + + foreach ($collProductAssociatedContents as $obj) { + if (false == $this->collProductAssociatedContents->contains($obj)) { + $this->collProductAssociatedContents->append($obj); + } + } + + $this->collProductAssociatedContentsPartial = true; + } + + $collProductAssociatedContents->getInternalIterator()->rewind(); + + return $collProductAssociatedContents; + } + + if ($partial && $this->collProductAssociatedContents) { + foreach ($this->collProductAssociatedContents as $obj) { + if ($obj->isNew()) { + $collProductAssociatedContents[] = $obj; + } + } + } + + $this->collProductAssociatedContents = $collProductAssociatedContents; + $this->collProductAssociatedContentsPartial = false; + } + } + + return $this->collProductAssociatedContents; + } + + /** + * Sets a collection of ProductAssociatedContent objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $productAssociatedContents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) + */ + public function setProductAssociatedContents(Collection $productAssociatedContents, ConnectionInterface $con = null) + { + $productAssociatedContentsToDelete = $this->getProductAssociatedContents(new Criteria(), $con)->diff($productAssociatedContents); + + + $this->productAssociatedContentsScheduledForDeletion = $productAssociatedContentsToDelete; + + foreach ($productAssociatedContentsToDelete as $productAssociatedContentRemoved) { + $productAssociatedContentRemoved->setContent(null); + } + + $this->collProductAssociatedContents = null; + foreach ($productAssociatedContents as $productAssociatedContent) { + $this->addProductAssociatedContent($productAssociatedContent); + } + + $this->collProductAssociatedContents = $productAssociatedContents; + $this->collProductAssociatedContentsPartial = false; + + return $this; + } + + /** + * Returns the number of related ProductAssociatedContent objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related ProductAssociatedContent objects. + * @throws PropelException + */ + public function countProductAssociatedContents(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collProductAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collProductAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductAssociatedContents) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getProductAssociatedContents()); + } + + $query = ChildProductAssociatedContentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); + } + + return count($this->collProductAssociatedContents); + } + + /** + * Method called to associate a ChildProductAssociatedContent object to this object + * through the ChildProductAssociatedContent foreign key attribute. + * + * @param ChildProductAssociatedContent $l ChildProductAssociatedContent + * @return \Thelia\Model\Content The current object (for fluent API support) + */ + public function addProductAssociatedContent(ChildProductAssociatedContent $l) + { + if ($this->collProductAssociatedContents === null) { + $this->initProductAssociatedContents(); + $this->collProductAssociatedContentsPartial = true; + } + + if (!in_array($l, $this->collProductAssociatedContents->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProductAssociatedContent($l); + } + + return $this; + } + + /** + * @param ProductAssociatedContent $productAssociatedContent The productAssociatedContent object to add. + */ + protected function doAddProductAssociatedContent($productAssociatedContent) + { + $this->collProductAssociatedContents[]= $productAssociatedContent; + $productAssociatedContent->setContent($this); + } + + /** + * @param ProductAssociatedContent $productAssociatedContent The productAssociatedContent object to remove. + * @return ChildContent The current object (for fluent API support) + */ + public function removeProductAssociatedContent($productAssociatedContent) + { + if ($this->getProductAssociatedContents()->contains($productAssociatedContent)) { + $this->collProductAssociatedContents->remove($this->collProductAssociatedContents->search($productAssociatedContent)); + if (null === $this->productAssociatedContentsScheduledForDeletion) { + $this->productAssociatedContentsScheduledForDeletion = clone $this->collProductAssociatedContents; + $this->productAssociatedContentsScheduledForDeletion->clear(); + } + $this->productAssociatedContentsScheduledForDeletion[]= clone $productAssociatedContent; + $productAssociatedContent->setContent(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Content is new, it will return + * an empty collection; or if this Content has previously + * been saved, it will retrieve related ProductAssociatedContents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Content. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildProductAssociatedContent[] List of ChildProductAssociatedContent objects + */ + public function getProductAssociatedContentsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildProductAssociatedContentQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); + + return $this->getProductAssociatedContents($query, $con); + } + + /** + * Clears out the collCategoryAssociatedContents collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCategoryAssociatedContents() + */ + public function clearCategoryAssociatedContents() + { + $this->collCategoryAssociatedContents = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCategoryAssociatedContents collection loaded partially. + */ + public function resetPartialCategoryAssociatedContents($v = true) + { + $this->collCategoryAssociatedContentsPartial = $v; + } + + /** + * Initializes the collCategoryAssociatedContents collection. + * + * By default this just sets the collCategoryAssociatedContents collection to an empty array (like clearcollCategoryAssociatedContents()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCategoryAssociatedContents($overrideExisting = true) + { + if (null !== $this->collCategoryAssociatedContents && !$overrideExisting) { + return; + } + $this->collCategoryAssociatedContents = new ObjectCollection(); + $this->collCategoryAssociatedContents->setModel('\Thelia\Model\CategoryAssociatedContent'); + } + + /** + * Gets an array of ChildCategoryAssociatedContent objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildContent is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCategoryAssociatedContent[] List of ChildCategoryAssociatedContent objects + * @throws PropelException + */ + public function getCategoryAssociatedContents($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCategoryAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collCategoryAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryAssociatedContents) { + // return empty collection + $this->initCategoryAssociatedContents(); + } else { + $collCategoryAssociatedContents = ChildCategoryAssociatedContentQuery::create(null, $criteria) + ->filterByContent($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCategoryAssociatedContentsPartial && count($collCategoryAssociatedContents)) { + $this->initCategoryAssociatedContents(false); + + foreach ($collCategoryAssociatedContents as $obj) { + if (false == $this->collCategoryAssociatedContents->contains($obj)) { + $this->collCategoryAssociatedContents->append($obj); + } + } + + $this->collCategoryAssociatedContentsPartial = true; + } + + $collCategoryAssociatedContents->getInternalIterator()->rewind(); + + return $collCategoryAssociatedContents; + } + + if ($partial && $this->collCategoryAssociatedContents) { + foreach ($this->collCategoryAssociatedContents as $obj) { + if ($obj->isNew()) { + $collCategoryAssociatedContents[] = $obj; + } + } + } + + $this->collCategoryAssociatedContents = $collCategoryAssociatedContents; + $this->collCategoryAssociatedContentsPartial = false; + } + } + + return $this->collCategoryAssociatedContents; + } + + /** + * Sets a collection of CategoryAssociatedContent objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $categoryAssociatedContents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) + */ + public function setCategoryAssociatedContents(Collection $categoryAssociatedContents, ConnectionInterface $con = null) + { + $categoryAssociatedContentsToDelete = $this->getCategoryAssociatedContents(new Criteria(), $con)->diff($categoryAssociatedContents); + + + $this->categoryAssociatedContentsScheduledForDeletion = $categoryAssociatedContentsToDelete; + + foreach ($categoryAssociatedContentsToDelete as $categoryAssociatedContentRemoved) { + $categoryAssociatedContentRemoved->setContent(null); + } + + $this->collCategoryAssociatedContents = null; + foreach ($categoryAssociatedContents as $categoryAssociatedContent) { + $this->addCategoryAssociatedContent($categoryAssociatedContent); + } + + $this->collCategoryAssociatedContents = $categoryAssociatedContents; + $this->collCategoryAssociatedContentsPartial = false; + + return $this; + } + + /** + * Returns the number of related CategoryAssociatedContent objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CategoryAssociatedContent objects. + * @throws PropelException + */ + public function countCategoryAssociatedContents(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCategoryAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collCategoryAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryAssociatedContents) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCategoryAssociatedContents()); + } + + $query = ChildCategoryAssociatedContentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); + } + + return count($this->collCategoryAssociatedContents); + } + + /** + * Method called to associate a ChildCategoryAssociatedContent object to this object + * through the ChildCategoryAssociatedContent foreign key attribute. + * + * @param ChildCategoryAssociatedContent $l ChildCategoryAssociatedContent + * @return \Thelia\Model\Content The current object (for fluent API support) + */ + public function addCategoryAssociatedContent(ChildCategoryAssociatedContent $l) + { + if ($this->collCategoryAssociatedContents === null) { + $this->initCategoryAssociatedContents(); + $this->collCategoryAssociatedContentsPartial = true; + } + + if (!in_array($l, $this->collCategoryAssociatedContents->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCategoryAssociatedContent($l); + } + + return $this; + } + + /** + * @param CategoryAssociatedContent $categoryAssociatedContent The categoryAssociatedContent object to add. + */ + protected function doAddCategoryAssociatedContent($categoryAssociatedContent) + { + $this->collCategoryAssociatedContents[]= $categoryAssociatedContent; + $categoryAssociatedContent->setContent($this); + } + + /** + * @param CategoryAssociatedContent $categoryAssociatedContent The categoryAssociatedContent object to remove. + * @return ChildContent The current object (for fluent API support) + */ + public function removeCategoryAssociatedContent($categoryAssociatedContent) + { + if ($this->getCategoryAssociatedContents()->contains($categoryAssociatedContent)) { + $this->collCategoryAssociatedContents->remove($this->collCategoryAssociatedContents->search($categoryAssociatedContent)); + if (null === $this->categoryAssociatedContentsScheduledForDeletion) { + $this->categoryAssociatedContentsScheduledForDeletion = clone $this->collCategoryAssociatedContents; + $this->categoryAssociatedContentsScheduledForDeletion->clear(); + } + $this->categoryAssociatedContentsScheduledForDeletion[]= clone $categoryAssociatedContent; + $categoryAssociatedContent->setContent(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Content is new, it will return + * an empty collection; or if this Content has previously + * been saved, it will retrieve related CategoryAssociatedContents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Content. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildCategoryAssociatedContent[] List of ChildCategoryAssociatedContent objects + */ + public function getCategoryAssociatedContentsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildCategoryAssociatedContentQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); + + return $this->getCategoryAssociatedContents($query, $con); + } + /** * Clears out the collContentI18ns collection * @@ -3677,11 +3940,6 @@ abstract class Content implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collContentAssocs) { - foreach ($this->collContentAssocs as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collRewritings) { foreach ($this->collRewritings as $o) { $o->clearAllReferences($deep); @@ -3702,6 +3960,16 @@ abstract class Content implements ActiveRecordInterface $o->clearAllReferences($deep); } } + if ($this->collProductAssociatedContents) { + foreach ($this->collProductAssociatedContents as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCategoryAssociatedContents) { + foreach ($this->collCategoryAssociatedContents as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collContentI18ns) { foreach ($this->collContentI18ns as $o) { $o->clearAllReferences($deep); @@ -3723,10 +3991,6 @@ abstract class Content implements ActiveRecordInterface $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collContentAssocs instanceof Collection) { - $this->collContentAssocs->clearIterator(); - } - $this->collContentAssocs = null; if ($this->collRewritings instanceof Collection) { $this->collRewritings->clearIterator(); } @@ -3743,6 +4007,14 @@ abstract class Content implements ActiveRecordInterface $this->collContentDocuments->clearIterator(); } $this->collContentDocuments = null; + if ($this->collProductAssociatedContents instanceof Collection) { + $this->collProductAssociatedContents->clearIterator(); + } + $this->collProductAssociatedContents = null; + if ($this->collCategoryAssociatedContents instanceof Collection) { + $this->collCategoryAssociatedContents->clearIterator(); + } + $this->collCategoryAssociatedContents = null; if ($this->collContentI18ns instanceof Collection) { $this->collContentI18ns->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/ContentAssoc.php b/core/lib/Thelia/Model/Base/ContentAssoc.php deleted file mode 100755 index eb3645c0b..000000000 --- a/core/lib/Thelia/Model/Base/ContentAssoc.php +++ /dev/null @@ -1,1688 +0,0 @@ -modifiedColumns); - } - - /** - * Has specified column been modified? - * - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID - * @return boolean True if $col has been modified. - */ - public function isColumnModified($col) - { - return in_array($col, $this->modifiedColumns); - } - - /** - * Get the columns that have been modified in this object. - * @return array A unique list of the modified column names for this object. - */ - public function getModifiedColumns() - { - return array_unique($this->modifiedColumns); - } - - /** - * Returns whether the object has ever been saved. This will - * be false, if the object was retrieved from storage or was created - * and then saved. - * - * @return true, if the object has never been persisted. - */ - public function isNew() - { - return $this->new; - } - - /** - * Setter for the isNew attribute. This method will be called - * by Propel-generated children and objects. - * - * @param boolean $b the state of the object. - */ - public function setNew($b) - { - $this->new = (Boolean) $b; - } - - /** - * Whether this object has been deleted. - * @return boolean The deleted state of this object. - */ - public function isDeleted() - { - return $this->deleted; - } - - /** - * Specify whether this object has been deleted. - * @param boolean $b The deleted state of this object. - * @return void - */ - public function setDeleted($b) - { - $this->deleted = (Boolean) $b; - } - - /** - * Sets the modified state for the object to be false. - * @param string $col If supplied, only the specified column is reset. - * @return void - */ - public function resetModified($col = null) - { - if (null !== $col) { - while (false !== ($offset = array_search($col, $this->modifiedColumns))) { - array_splice($this->modifiedColumns, $offset, 1); - } - } else { - $this->modifiedColumns = array(); - } - } - - /** - * Compares this with another ContentAssoc instance. If - * obj is an instance of ContentAssoc, delegates to - * equals(ContentAssoc). Otherwise, returns false. - * - * @param obj The object to compare to. - * @return Whether equal to the object specified. - */ - public function equals($obj) - { - $thisclazz = get_class($this); - if (!is_object($obj) || !($obj instanceof $thisclazz)) { - return false; - } - - if ($this === $obj) { - return true; - } - - if (null === $this->getPrimaryKey() - || null === $obj->getPrimaryKey()) { - return false; - } - - return $this->getPrimaryKey() === $obj->getPrimaryKey(); - } - - /** - * If the primary key is not null, return the hashcode of the - * primary key. Otherwise, return the hash code of the object. - * - * @return int Hashcode - */ - public function hashCode() - { - if (null !== $this->getPrimaryKey()) { - return crc32(serialize($this->getPrimaryKey())); - } - - return crc32(serialize(clone $this)); - } - - /** - * Get the associative array of the virtual columns in this object - * - * @param string $name The virtual column name - * - * @return array - */ - public function getVirtualColumns() - { - return $this->virtualColumns; - } - - /** - * Checks the existence of a virtual column in this object - * - * @return boolean - */ - public function hasVirtualColumn($name) - { - return array_key_exists($name, $this->virtualColumns); - } - - /** - * Get the value of a virtual column in this object - * - * @return mixed - */ - public function getVirtualColumn($name) - { - if (!$this->hasVirtualColumn($name)) { - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); - } - - return $this->virtualColumns[$name]; - } - - /** - * Set the value of a virtual column in this object - * - * @param string $name The virtual column name - * @param mixed $value The value to give to the virtual column - * - * @return ContentAssoc The current object, for fluid interface - */ - public function setVirtualColumn($name, $value) - { - $this->virtualColumns[$name] = $value; - - return $this; - } - - /** - * Logs a message using Propel::log(). - * - * @param string $msg - * @param int $priority One of the Propel::LOG_* logging levels - * @return boolean - */ - protected function log($msg, $priority = Propel::LOG_INFO) - { - return Propel::log(get_class($this) . ': ' . $msg, $priority); - } - - /** - * Populate the current object from a string, using a given parser format - * - * $book = new Book(); - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, - * or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param string $data The source data to import from - * - * @return ContentAssoc The current object, for fluid interface - */ - public function importFrom($parser, $data) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); - } - - /** - * Export the current object properties to a string, using a given parser format - * - * $book = BookQuery::create()->findPk(9012); - * echo $book->exportTo('JSON'); - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. - * @return string The exported data - */ - public function exportTo($parser, $includeLazyLoadColumns = true) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); - } - - /** - * Clean up internal collections prior to serializing - * Avoids recursive loops that turn into segmentation faults when serializing - */ - public function __sleep() - { - $this->clearAllReferences(); - - return array_keys(get_object_vars($this)); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - - return $this->id; - } - - /** - * Get the [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - - return $this->category_id; - } - - /** - * Get the [product_id] column value. - * - * @return int - */ - public function getProductId() - { - - return $this->product_id; - } - - /** - * Get the [content_id] column value. - * - * @return int - */ - public function getContentId() - { - - return $this->content_id; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - - return $this->position; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = NULL) - { - if ($format === null) { - return $this->created_at; - } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; - } - } - - /** - * Get the [optionally formatted] temporal [updated_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getUpdatedAt($format = NULL) - { - if ($format === null) { - return $this->updated_at; - } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; - } - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ContentAssocTableMap::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = ContentAssocTableMap::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - - /** - * Set the value of [product_id] column. - * - * @param int $v new value - * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) - */ - public function setProductId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->product_id !== $v) { - $this->product_id = $v; - $this->modifiedColumns[] = ContentAssocTableMap::PRODUCT_ID; - } - - if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { - $this->aProduct = null; - } - - - return $this; - } // setProductId() - - /** - * Set the value of [content_id] column. - * - * @param int $v new value - * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) - */ - public function setContentId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->content_id !== $v) { - $this->content_id = $v; - $this->modifiedColumns[] = ContentAssocTableMap::CONTENT_ID; - } - - if ($this->aContent !== null && $this->aContent->getId() !== $v) { - $this->aContent = null; - } - - - return $this; - } // setContentId() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = ContentAssocTableMap::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->created_at !== null || $dt !== null) { - if ($dt !== $this->created_at) { - $this->created_at = $dt; - $this->modifiedColumns[] = ContentAssocTableMap::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->updated_at !== null || $dt !== null) { - if ($dt !== $this->updated_at) { - $this->updated_at = $dt; - $this->modifiedColumns[] = ContentAssocTableMap::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return TRUE - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by DataFetcher->fetch(). - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) - { - try { - - - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentAssocTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - $this->id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentAssocTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->category_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentAssocTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->product_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentAssocTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->content_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentAssocTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; - $this->position = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentAssocTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ContentAssocTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 7; // 7 = ContentAssocTableMap::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\ContentAssoc object", 0, $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; - } - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { - $this->aProduct = null; - } - if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { - $this->aContent = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(ContentAssocTableMap::DATABASE_NAME); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $dataFetcher = ChildContentAssocQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); - $row = $dataFetcher->fetch(); - $dataFetcher->close(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aCategory = null; - $this->aProduct = null; - $this->aContent = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param ConnectionInterface $con - * @return void - * @throws PropelException - * @see ContentAssoc::setDeleted() - * @see ContentAssoc::isDeleted() - */ - public function delete(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - try { - $deleteQuery = ChildContentAssocQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see doSave() - */ - public function save(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(ContentAssocTableMap::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(ContentAssocTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ContentAssocTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - ContentAssocTableMap::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(ConnectionInterface $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their corresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - - if ($this->aProduct !== null) { - if ($this->aProduct->isModified() || $this->aProduct->isNew()) { - $affectedRows += $this->aProduct->save($con); - } - $this->setProduct($this->aProduct); - } - - if ($this->aContent !== null) { - if ($this->aContent->isModified() || $this->aContent->isNew()) { - $affectedRows += $this->aContent->save($con); - } - $this->setContent($this->aContent); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param ConnectionInterface $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(ConnectionInterface $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = ContentAssocTableMap::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentAssocTableMap::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ContentAssocTableMap::ID)) { - $modifiedColumns[':p' . $index++] = 'ID'; - } - if ($this->isColumnModified(ContentAssocTableMap::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; - } - if ($this->isColumnModified(ContentAssocTableMap::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; - } - if ($this->isColumnModified(ContentAssocTableMap::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; - } - if ($this->isColumnModified(ContentAssocTableMap::POSITION)) { - $modifiedColumns[':p' . $index++] = 'POSITION'; - } - if ($this->isColumnModified(ContentAssocTableMap::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = 'CREATED_AT'; - } - if ($this->isColumnModified(ContentAssocTableMap::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; - } - - $sql = sprintf( - 'INSERT INTO content_assoc (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case 'ID': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case 'CATEGORY_ID': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); - break; - case 'PRODUCT_ID': - $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); - break; - case 'CONTENT_ID': - $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); - break; - case 'POSITION': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; - case 'CREATED_AT': - $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - case 'UPDATED_AT': - $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', 0, $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param ConnectionInterface $con - * - * @return Integer Number of updated rows - * @see doSave() - */ - protected function doUpdate(ConnectionInterface $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - - return $selectCriteria->doUpdate($valuesCriteria, $con); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return mixed Value of field. - */ - public function getByName($name, $type = TableMap::TYPE_PHPNAME) - { - $pos = ContentAssocTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCategoryId(); - break; - case 2: - return $this->getProductId(); - break; - case 3: - return $this->getContentId(); - break; - case 4: - return $this->getPosition(); - break; - case 5: - return $this->getCreatedAt(); - break; - case 6: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['ContentAssoc'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['ContentAssoc'][$this->getPrimaryKey()] = true; - $keys = ContentAssocTableMap::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCategoryId(), - $keys[2] => $this->getProductId(), - $keys[3] => $this->getContentId(), - $keys[4] => $this->getPosition(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - ); - $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { - $result[$key] = $virtualColumn; - } - - if ($includeForeignObjects) { - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aProduct) { - $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aContent) { - $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return void - */ - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) - { - $pos = ContentAssocTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - - return $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCategoryId($value); - break; - case 2: - $this->setProductId($value); - break; - case 3: - $this->setContentId($value); - break; - case 4: - $this->setPosition($value); - break; - case 5: - $this->setCreatedAt($value); - break; - case 6: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * The default key type is the column's TableMap::TYPE_PHPNAME. - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) - { - $keys = ContentAssocTableMap::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setContentId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ContentAssocTableMap::DATABASE_NAME); - - if ($this->isColumnModified(ContentAssocTableMap::ID)) $criteria->add(ContentAssocTableMap::ID, $this->id); - if ($this->isColumnModified(ContentAssocTableMap::CATEGORY_ID)) $criteria->add(ContentAssocTableMap::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(ContentAssocTableMap::PRODUCT_ID)) $criteria->add(ContentAssocTableMap::PRODUCT_ID, $this->product_id); - if ($this->isColumnModified(ContentAssocTableMap::CONTENT_ID)) $criteria->add(ContentAssocTableMap::CONTENT_ID, $this->content_id); - if ($this->isColumnModified(ContentAssocTableMap::POSITION)) $criteria->add(ContentAssocTableMap::POSITION, $this->position); - if ($this->isColumnModified(ContentAssocTableMap::CREATED_AT)) $criteria->add(ContentAssocTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(ContentAssocTableMap::UPDATED_AT)) $criteria->add(ContentAssocTableMap::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(ContentAssocTableMap::DATABASE_NAME); - $criteria->add(ContentAssocTableMap::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of \Thelia\Model\ContentAssoc (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCategoryId($this->getCategoryId()); - $copyObj->setProductId($this->getProductId()); - $copyObj->setContentId($this->getContentId()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\ContentAssoc Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Declares an association between this object and a ChildCategory object. - * - * @param ChildCategory $v - * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(ChildCategory $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildCategory object, it will not be re-added. - if ($v !== null) { - $v->addContentAssoc($this); - } - - - return $this; - } - - - /** - * Get the associated ChildCategory object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildCategory The associated ChildCategory object. - * @throws PropelException - */ - public function getCategory(ConnectionInterface $con = null) - { - if ($this->aCategory === null && ($this->category_id !== null)) { - $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCategory->addContentAssocs($this); - */ - } - - return $this->aCategory; - } - - /** - * Declares an association between this object and a ChildProduct object. - * - * @param ChildProduct $v - * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) - * @throws PropelException - */ - public function setProduct(ChildProduct $v = null) - { - if ($v === null) { - $this->setProductId(NULL); - } else { - $this->setProductId($v->getId()); - } - - $this->aProduct = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildProduct object, it will not be re-added. - if ($v !== null) { - $v->addContentAssoc($this); - } - - - return $this; - } - - - /** - * Get the associated ChildProduct object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildProduct The associated ChildProduct object. - * @throws PropelException - */ - public function getProduct(ConnectionInterface $con = null) - { - if ($this->aProduct === null && ($this->product_id !== null)) { - $this->aProduct = ChildProductQuery::create()->findPk($this->product_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aProduct->addContentAssocs($this); - */ - } - - return $this->aProduct; - } - - /** - * Declares an association between this object and a ChildContent object. - * - * @param ChildContent $v - * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) - * @throws PropelException - */ - public function setContent(ChildContent $v = null) - { - if ($v === null) { - $this->setContentId(NULL); - } else { - $this->setContentId($v->getId()); - } - - $this->aContent = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildContent object, it will not be re-added. - if ($v !== null) { - $v->addContentAssoc($this); - } - - - return $this; - } - - - /** - * Get the associated ChildContent object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildContent The associated ChildContent object. - * @throws PropelException - */ - public function getContent(ConnectionInterface $con = null) - { - if ($this->aContent === null && ($this->content_id !== null)) { - $this->aContent = ChildContentQuery::create()->findPk($this->content_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aContent->addContentAssocs($this); - */ - } - - return $this->aContent; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->category_id = null; - $this->product_id = null; - $this->content_id = null; - $this->position = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volume/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - } // if ($deep) - - $this->aCategory = null; - $this->aProduct = null; - $this->aContent = null; - } - - /** - * Return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ContentAssocTableMap::DEFAULT_STRING_FORMAT); - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return ChildContentAssoc The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = ContentAssocTableMap::UPDATED_AT; - - return $this; - } - - /** - * Code to be run before persisting the object - * @param ConnectionInterface $con - * @return boolean - */ - public function preSave(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after persisting the object - * @param ConnectionInterface $con - */ - public function postSave(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before inserting to database - * @param ConnectionInterface $con - * @return boolean - */ - public function preInsert(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after inserting to database - * @param ConnectionInterface $con - */ - public function postInsert(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before updating the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preUpdate(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after updating the object in database - * @param ConnectionInterface $con - */ - public function postUpdate(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before deleting the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preDelete(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after deleting the object in database - * @param ConnectionInterface $con - */ - public function postDelete(ConnectionInterface $con = null) - { - - } - - - /** - * Derived method to catches calls to undefined methods. - * - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). - * Allows to define default __call() behavior if you overwrite __call() - * - * @param string $name - * @param mixed $params - * - * @return array|string - */ - public function __call($name, $params) - { - if (0 === strpos($name, 'get')) { - $virtualColumn = substr($name, 3); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - - $virtualColumn = lcfirst($virtualColumn); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - } - - if (0 === strpos($name, 'from')) { - $format = substr($name, 4); - - return $this->importFrom($format, reset($params)); - } - - if (0 === strpos($name, 'to')) { - $format = substr($name, 2); - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; - - return $this->exportTo($format, $includeLazyLoadColumns); - } - - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); - } - -} diff --git a/core/lib/Thelia/Model/Base/ContentAssocQuery.php b/core/lib/Thelia/Model/Base/ContentAssocQuery.php deleted file mode 100755 index 630af8065..000000000 --- a/core/lib/Thelia/Model/Base/ContentAssocQuery.php +++ /dev/null @@ -1,930 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ChildContentAssoc|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ContentAssocTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(ContentAssocTableMap::DATABASE_NAME); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildContentAssoc A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, CATEGORY_ID, PRODUCT_ID, CONTENT_ID, POSITION, CREATED_AT, UPDATED_AT FROM content_assoc WHERE ID = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); - } - $obj = null; - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildContentAssoc(); - $obj->hydrate($row); - ContentAssocTableMap::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildContentAssoc|array|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(ContentAssocTableMap::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(ContentAssocTableMap::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ContentAssocTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ContentAssocTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the category_id column - * - * Example usage: - * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 - * - * - * @see filterByCategory() - * - * @param mixed $categoryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function filterByCategoryId($categoryId = null, $comparison = null) - { - if (is_array($categoryId)) { - $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($categoryId['max'])) { - $this->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $categoryId, $comparison); - } - - /** - * Filter the query on the product_id column - * - * Example usage: - * - * $query->filterByProductId(1234); // WHERE product_id = 1234 - * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 - * - * - * @see filterByProduct() - * - * @param mixed $productId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function filterByProductId($productId = null, $comparison = null) - { - if (is_array($productId)) { - $useMinMax = false; - if (isset($productId['min'])) { - $this->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($productId['max'])) { - $this->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $productId, $comparison); - } - - /** - * Filter the query on the content_id column - * - * Example usage: - * - * $query->filterByContentId(1234); // WHERE content_id = 1234 - * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 - * - * - * @see filterByContent() - * - * @param mixed $contentId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function filterByContentId($contentId = null, $comparison = null) - { - if (is_array($contentId)) { - $useMinMax = false; - if (isset($contentId['min'])) { - $this->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($contentId['max'])) { - $this->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $contentId, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(ContentAssocTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(ContentAssocTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocTableMap::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(ContentAssocTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(ContentAssocTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocTableMap::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(ContentAssocTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(ContentAssocTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\Category object - * - * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof \Thelia\Model\Category) { - return $this - ->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Product object - * - * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function filterByProduct($product, $comparison = null) - { - if ($product instanceof \Thelia\Model\Product) { - return $this - ->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Product relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Product'); - } - - return $this; - } - - /** - * Use the Product relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Content object - * - * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function filterByContent($content, $comparison = null) - { - if ($content instanceof \Thelia\Model\Content) { - return $this - ->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Content relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Content'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Content'); - } - - return $this; - } - - /** - * Use the Content relation Content object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query - */ - public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContent($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); - } - - /** - * Exclude object from result - * - * @param ChildContentAssoc $contentAssoc Object to remove from the list of results - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function prune($contentAssoc = null) - { - if ($contentAssoc) { - $this->addUsingAlias(ContentAssocTableMap::ID, $contentAssoc->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - /** - * Deletes all rows from the content_assoc table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public function doDeleteAll(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += parent::doDeleteAll($con); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - ContentAssocTableMap::clearInstancePool(); - ContentAssocTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildContentAssoc or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildContentAssoc object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public function delete(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(ContentAssocTableMap::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - - ContentAssocTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - ContentAssocTableMap::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(ContentAssocTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(ContentAssocTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(ContentAssocTableMap::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(ContentAssocTableMap::UPDATED_AT); - } - - /** - * Order by create date desc - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(ContentAssocTableMap::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ChildContentAssocQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(ContentAssocTableMap::CREATED_AT); - } - -} // ContentAssocQuery diff --git a/core/lib/Thelia/Model/Base/ContentQuery.php b/core/lib/Thelia/Model/Base/ContentQuery.php index 28d32cbe6..d4749ce46 100755 --- a/core/lib/Thelia/Model/Base/ContentQuery.php +++ b/core/lib/Thelia/Model/Base/ContentQuery.php @@ -44,10 +44,6 @@ use Thelia\Model\Map\ContentTableMap; * @method ChildContentQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildContentQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildContentQuery leftJoinContentAssoc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentAssoc relation - * @method ChildContentQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation - * @method ChildContentQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation - * * @method ChildContentQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation * @method ChildContentQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation * @method ChildContentQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation @@ -64,6 +60,14 @@ use Thelia\Model\Map\ContentTableMap; * @method ChildContentQuery rightJoinContentDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentDocument relation * @method ChildContentQuery innerJoinContentDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentDocument relation * + * @method ChildContentQuery leftJoinProductAssociatedContent($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductAssociatedContent relation + * @method ChildContentQuery rightJoinProductAssociatedContent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductAssociatedContent relation + * @method ChildContentQuery innerJoinProductAssociatedContent($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductAssociatedContent relation + * + * @method ChildContentQuery leftJoinCategoryAssociatedContent($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryAssociatedContent relation + * @method ChildContentQuery rightJoinCategoryAssociatedContent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryAssociatedContent relation + * @method ChildContentQuery innerJoinCategoryAssociatedContent($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryAssociatedContent relation + * * @method ChildContentQuery leftJoinContentI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentI18n relation * @method ChildContentQuery rightJoinContentI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentI18n relation * @method ChildContentQuery innerJoinContentI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentI18n relation @@ -598,79 +602,6 @@ abstract class ContentQuery extends ModelCriteria return $this->addUsingAlias(ContentTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } - /** - * Filter the query by a related \Thelia\Model\ContentAssoc object - * - * @param \Thelia\Model\ContentAssoc|ObjectCollection $contentAssoc the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentQuery The current query, for fluid interface - */ - public function filterByContentAssoc($contentAssoc, $comparison = null) - { - if ($contentAssoc instanceof \Thelia\Model\ContentAssoc) { - return $this - ->addUsingAlias(ContentTableMap::ID, $contentAssoc->getContentId(), $comparison); - } elseif ($contentAssoc instanceof ObjectCollection) { - return $this - ->useContentAssocQuery() - ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type \Thelia\Model\ContentAssoc or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentAssoc relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildContentQuery The current query, for fluid interface - */ - public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentAssoc'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentAssoc'); - } - - return $this; - } - - /** - * Use the ContentAssoc relation ContentAssoc object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query - */ - public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContentAssoc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); - } - /** * Filter the query by a related \Thelia\Model\Rewriting object * @@ -963,6 +894,152 @@ abstract class ContentQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'ContentDocument', '\Thelia\Model\ContentDocumentQuery'); } + /** + * Filter the query by a related \Thelia\Model\ProductAssociatedContent object + * + * @param \Thelia\Model\ProductAssociatedContent|ObjectCollection $productAssociatedContent the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function filterByProductAssociatedContent($productAssociatedContent, $comparison = null) + { + if ($productAssociatedContent instanceof \Thelia\Model\ProductAssociatedContent) { + return $this + ->addUsingAlias(ContentTableMap::ID, $productAssociatedContent->getContentId(), $comparison); + } elseif ($productAssociatedContent instanceof ObjectCollection) { + return $this + ->useProductAssociatedContentQuery() + ->filterByPrimaryKeys($productAssociatedContent->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByProductAssociatedContent() only accepts arguments of type \Thelia\Model\ProductAssociatedContent or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ProductAssociatedContent relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function joinProductAssociatedContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ProductAssociatedContent'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ProductAssociatedContent'); + } + + return $this; + } + + /** + * Use the ProductAssociatedContent relation ProductAssociatedContent object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductAssociatedContentQuery A secondary query class using the current class as primary query + */ + public function useProductAssociatedContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProductAssociatedContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductAssociatedContent', '\Thelia\Model\ProductAssociatedContentQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\CategoryAssociatedContent object + * + * @param \Thelia\Model\CategoryAssociatedContent|ObjectCollection $categoryAssociatedContent the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function filterByCategoryAssociatedContent($categoryAssociatedContent, $comparison = null) + { + if ($categoryAssociatedContent instanceof \Thelia\Model\CategoryAssociatedContent) { + return $this + ->addUsingAlias(ContentTableMap::ID, $categoryAssociatedContent->getContentId(), $comparison); + } elseif ($categoryAssociatedContent instanceof ObjectCollection) { + return $this + ->useCategoryAssociatedContentQuery() + ->filterByPrimaryKeys($categoryAssociatedContent->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCategoryAssociatedContent() only accepts arguments of type \Thelia\Model\CategoryAssociatedContent or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CategoryAssociatedContent relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function joinCategoryAssociatedContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CategoryAssociatedContent'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CategoryAssociatedContent'); + } + + return $this; + } + + /** + * Use the CategoryAssociatedContent relation CategoryAssociatedContent object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryAssociatedContentQuery A secondary query class using the current class as primary query + */ + public function useCategoryAssociatedContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCategoryAssociatedContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CategoryAssociatedContent', '\Thelia\Model\CategoryAssociatedContentQuery'); + } + /** * Filter the query by a related \Thelia\Model\ContentI18n object * diff --git a/core/lib/Thelia/Model/Base/Coupon.php b/core/lib/Thelia/Model/Base/Coupon.php index a339fa835..0a6ee2061 100755 --- a/core/lib/Thelia/Model/Base/Coupon.php +++ b/core/lib/Thelia/Model/Base/Coupon.php @@ -18,10 +18,15 @@ use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Coupon as ChildCoupon; +use Thelia\Model\CouponI18n as ChildCouponI18n; +use Thelia\Model\CouponI18nQuery as ChildCouponI18nQuery; +use Thelia\Model\CouponOrder as ChildCouponOrder; +use Thelia\Model\CouponOrderQuery as ChildCouponOrderQuery; use Thelia\Model\CouponQuery as ChildCouponQuery; -use Thelia\Model\CouponRule as ChildCouponRule; -use Thelia\Model\CouponRuleQuery as ChildCouponRuleQuery; +use Thelia\Model\CouponVersion as ChildCouponVersion; +use Thelia\Model\CouponVersionQuery as ChildCouponVersionQuery; use Thelia\Model\Map\CouponTableMap; +use Thelia\Model\Map\CouponVersionTableMap; abstract class Coupon implements ActiveRecordInterface { @@ -70,10 +75,28 @@ abstract class Coupon implements ActiveRecordInterface protected $code; /** - * The value for the action field. + * The value for the type field. * @var string */ - protected $action; + protected $type; + + /** + * The value for the title field. + * @var string + */ + protected $title; + + /** + * The value for the short_description field. + * @var string + */ + protected $short_description; + + /** + * The value for the description field. + * @var string + */ + protected $description; /** * The value for the value field. @@ -82,28 +105,28 @@ abstract class Coupon implements ActiveRecordInterface protected $value; /** - * The value for the used field. + * The value for the is_used field. * @var int */ - protected $used; + protected $is_used; /** - * The value for the available_since field. - * @var string - */ - protected $available_since; - - /** - * The value for the date_limit field. - * @var string - */ - protected $date_limit; - - /** - * The value for the activate field. + * The value for the is_enabled field. * @var int */ - protected $activate; + protected $is_enabled; + + /** + * The value for the expiration_date field. + * @var string + */ + protected $expiration_date; + + /** + * The value for the serialized_rules field. + * @var string + */ + protected $serialized_rules; /** * The value for the created_at field. @@ -118,10 +141,29 @@ abstract class Coupon implements ActiveRecordInterface protected $updated_at; /** - * @var ObjectCollection|ChildCouponRule[] Collection to store aggregation of ChildCouponRule objects. + * The value for the version field. + * Note: this column has a database default value of: 0 + * @var int */ - protected $collCouponRules; - protected $collCouponRulesPartial; + protected $version; + + /** + * @var ObjectCollection|ChildCouponOrder[] Collection to store aggregation of ChildCouponOrder objects. + */ + protected $collCouponOrders; + protected $collCouponOrdersPartial; + + /** + * @var ObjectCollection|ChildCouponI18n[] Collection to store aggregation of ChildCouponI18n objects. + */ + protected $collCouponI18ns; + protected $collCouponI18nsPartial; + + /** + * @var ObjectCollection|ChildCouponVersion[] Collection to store aggregation of ChildCouponVersion objects. + */ + protected $collCouponVersions; + protected $collCouponVersionsPartial; /** * Flag to prevent endless save loop, if this object is referenced @@ -131,17 +173,64 @@ abstract class Coupon implements ActiveRecordInterface */ protected $alreadyInSave = false; + // i18n behavior + + /** + * Current locale + * @var string + */ + protected $currentLocale = 'en_EN'; + + /** + * Current translation objects + * @var array[ChildCouponI18n] + */ + protected $currentTranslations; + + // versionable behavior + + + /** + * @var bool + */ + protected $enforceVersion = false; + /** * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $couponRulesScheduledForDeletion = null; + protected $couponOrdersScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $couponI18nsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $couponVersionsScheduledForDeletion = null; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->version = 0; + } /** * Initializes internal state of Thelia\Model\Base\Coupon object. + * @see applyDefaults() */ public function __construct() { + $this->applyDefaultValues(); } /** @@ -414,14 +503,47 @@ abstract class Coupon implements ActiveRecordInterface } /** - * Get the [action] column value. + * Get the [type] column value. * * @return string */ - public function getAction() + public function getType() { - return $this->action; + return $this->type; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [short_description] column value. + * + * @return string + */ + public function getShortDescription() + { + + return $this->short_description; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; } /** @@ -436,18 +558,29 @@ abstract class Coupon implements ActiveRecordInterface } /** - * Get the [used] column value. + * Get the [is_used] column value. * * @return int */ - public function getUsed() + public function getIsUsed() { - return $this->used; + return $this->is_used; } /** - * Get the [optionally formatted] temporal [available_since] column value. + * Get the [is_enabled] column value. + * + * @return int + */ + public function getIsEnabled() + { + + return $this->is_enabled; + } + + /** + * Get the [optionally formatted] temporal [expiration_date] column value. * * * @param string $format The date/time format string (either date()-style or strftime()-style). @@ -457,44 +590,24 @@ abstract class Coupon implements ActiveRecordInterface * * @throws PropelException - if unable to parse/validate the date/time value. */ - public function getAvailableSince($format = NULL) + public function getExpirationDate($format = NULL) { if ($format === null) { - return $this->available_since; + return $this->expiration_date; } else { - return $this->available_since !== null ? $this->available_since->format($format) : null; + return $this->expiration_date !== null ? $this->expiration_date->format($format) : null; } } /** - * Get the [optionally formatted] temporal [date_limit] column value. + * Get the [serialized_rules] column value. * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. + * @return string */ - public function getDateLimit($format = NULL) - { - if ($format === null) { - return $this->date_limit; - } else { - return $this->date_limit !== null ? $this->date_limit->format($format) : null; - } - } - - /** - * Get the [activate] column value. - * - * @return int - */ - public function getActivate() + public function getSerializedRules() { - return $this->activate; + return $this->serialized_rules; } /** @@ -537,6 +650,17 @@ abstract class Coupon implements ActiveRecordInterface } } + /** + * Get the [version] column value. + * + * @return int + */ + public function getVersion() + { + + return $this->version; + } + /** * Set the value of [id] column. * @@ -580,25 +704,88 @@ abstract class Coupon implements ActiveRecordInterface } // setCode() /** - * Set the value of [action] column. + * Set the value of [type] column. * * @param string $v new value * @return \Thelia\Model\Coupon The current object (for fluent API support) */ - public function setAction($v) + public function setType($v) { if ($v !== null) { $v = (string) $v; } - if ($this->action !== $v) { - $this->action = $v; - $this->modifiedColumns[] = CouponTableMap::ACTION; + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = CouponTableMap::TYPE; } return $this; - } // setAction() + } // setType() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = CouponTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [short_description] column. + * + * @param string $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setShortDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->short_description !== $v) { + $this->short_description = $v; + $this->modifiedColumns[] = CouponTableMap::SHORT_DESCRIPTION; + } + + + return $this; + } // setShortDescription() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CouponTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() /** * Set the value of [value] column. @@ -622,88 +809,88 @@ abstract class Coupon implements ActiveRecordInterface } // setValue() /** - * Set the value of [used] column. + * Set the value of [is_used] column. * * @param int $v new value * @return \Thelia\Model\Coupon The current object (for fluent API support) */ - public function setUsed($v) + public function setIsUsed($v) { if ($v !== null) { $v = (int) $v; } - if ($this->used !== $v) { - $this->used = $v; - $this->modifiedColumns[] = CouponTableMap::USED; + if ($this->is_used !== $v) { + $this->is_used = $v; + $this->modifiedColumns[] = CouponTableMap::IS_USED; } return $this; - } // setUsed() + } // setIsUsed() /** - * Sets the value of [available_since] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\Coupon The current object (for fluent API support) - */ - public function setAvailableSince($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->available_since !== null || $dt !== null) { - if ($dt !== $this->available_since) { - $this->available_since = $dt; - $this->modifiedColumns[] = CouponTableMap::AVAILABLE_SINCE; - } - } // if either are not null - - - return $this; - } // setAvailableSince() - - /** - * Sets the value of [date_limit] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\Coupon The current object (for fluent API support) - */ - public function setDateLimit($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->date_limit !== null || $dt !== null) { - if ($dt !== $this->date_limit) { - $this->date_limit = $dt; - $this->modifiedColumns[] = CouponTableMap::DATE_LIMIT; - } - } // if either are not null - - - return $this; - } // setDateLimit() - - /** - * Set the value of [activate] column. + * Set the value of [is_enabled] column. * * @param int $v new value * @return \Thelia\Model\Coupon The current object (for fluent API support) */ - public function setActivate($v) + public function setIsEnabled($v) { if ($v !== null) { $v = (int) $v; } - if ($this->activate !== $v) { - $this->activate = $v; - $this->modifiedColumns[] = CouponTableMap::ACTIVATE; + if ($this->is_enabled !== $v) { + $this->is_enabled = $v; + $this->modifiedColumns[] = CouponTableMap::IS_ENABLED; } return $this; - } // setActivate() + } // setIsEnabled() + + /** + * Sets the value of [expiration_date] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setExpirationDate($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->expiration_date !== null || $dt !== null) { + if ($dt !== $this->expiration_date) { + $this->expiration_date = $dt; + $this->modifiedColumns[] = CouponTableMap::EXPIRATION_DATE; + } + } // if either are not null + + + return $this; + } // setExpirationDate() + + /** + * Set the value of [serialized_rules] column. + * + * @param string $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setSerializedRules($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->serialized_rules !== $v) { + $this->serialized_rules = $v; + $this->modifiedColumns[] = CouponTableMap::SERIALIZED_RULES; + } + + + return $this; + } // setSerializedRules() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -747,6 +934,27 @@ abstract class Coupon implements ActiveRecordInterface return $this; } // setUpdatedAt() + /** + * Set the value of [version] column. + * + * @param int $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setVersion($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->version !== $v) { + $this->version = $v; + $this->modifiedColumns[] = CouponTableMap::VERSION; + } + + + return $this; + } // setVersion() + /** * Indicates whether the columns in this object are only set to default values. * @@ -757,6 +965,10 @@ abstract class Coupon implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { + if ($this->version !== 0) { + return false; + } + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -790,41 +1002,50 @@ abstract class Coupon implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CouponTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; $this->code = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponTableMap::translateFieldName('Action', TableMap::TYPE_PHPNAME, $indexType)]; - $this->action = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)]; + $this->type = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponTableMap::translateFieldName('ShortDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->short_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; $this->value = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponTableMap::translateFieldName('Used', TableMap::TYPE_PHPNAME, $indexType)]; - $this->used = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponTableMap::translateFieldName('IsUsed', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_used = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponTableMap::translateFieldName('AvailableSince', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponTableMap::translateFieldName('IsEnabled', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_enabled = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponTableMap::translateFieldName('ExpirationDate', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } - $this->available_since = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->expiration_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponTableMap::translateFieldName('DateLimit', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->date_limit = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponTableMap::translateFieldName('SerializedRules', TableMap::TYPE_PHPNAME, $indexType)]; + $this->serialized_rules = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponTableMap::translateFieldName('Activate', TableMap::TYPE_PHPNAME, $indexType)]; - $this->activate = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; $this->resetModified(); $this->setNew(false); @@ -833,7 +1054,7 @@ abstract class Coupon implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 10; // 10 = CouponTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 14; // 14 = CouponTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Coupon object", 0, $e); @@ -894,7 +1115,11 @@ abstract class Coupon implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->collCouponRules = null; + $this->collCouponOrders = null; + + $this->collCouponI18ns = null; + + $this->collCouponVersions = null; } // if (deep) } @@ -964,6 +1189,11 @@ abstract class Coupon implements ActiveRecordInterface $isInsert = $this->isNew(); try { $ret = $this->preSave($con); + // versionable behavior + if ($this->isVersioningNecessary()) { + $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1); + $createVersion = true; // for postSave hook + } if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior @@ -988,6 +1218,10 @@ abstract class Coupon implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); + // versionable behavior + if (isset($createVersion)) { + $this->addVersion($con); + } CouponTableMap::addInstanceToPool($this); } else { $affectedRows = 0; @@ -1029,17 +1263,51 @@ abstract class Coupon implements ActiveRecordInterface $this->resetModified(); } - if ($this->couponRulesScheduledForDeletion !== null) { - if (!$this->couponRulesScheduledForDeletion->isEmpty()) { - \Thelia\Model\CouponRuleQuery::create() - ->filterByPrimaryKeys($this->couponRulesScheduledForDeletion->getPrimaryKeys(false)) + if ($this->couponOrdersScheduledForDeletion !== null) { + if (!$this->couponOrdersScheduledForDeletion->isEmpty()) { + \Thelia\Model\CouponOrderQuery::create() + ->filterByPrimaryKeys($this->couponOrdersScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->couponRulesScheduledForDeletion = null; + $this->couponOrdersScheduledForDeletion = null; } } - if ($this->collCouponRules !== null) { - foreach ($this->collCouponRules as $referrerFK) { + if ($this->collCouponOrders !== null) { + foreach ($this->collCouponOrders as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->couponI18nsScheduledForDeletion !== null) { + if (!$this->couponI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\CouponI18nQuery::create() + ->filterByPrimaryKeys($this->couponI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->couponI18nsScheduledForDeletion = null; + } + } + + if ($this->collCouponI18ns !== null) { + foreach ($this->collCouponI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->couponVersionsScheduledForDeletion !== null) { + if (!$this->couponVersionsScheduledForDeletion->isEmpty()) { + \Thelia\Model\CouponVersionQuery::create() + ->filterByPrimaryKeys($this->couponVersionsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->couponVersionsScheduledForDeletion = null; + } + } + + if ($this->collCouponVersions !== null) { + foreach ($this->collCouponVersions as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1078,23 +1346,32 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::CODE)) { $modifiedColumns[':p' . $index++] = 'CODE'; } - if ($this->isColumnModified(CouponTableMap::ACTION)) { - $modifiedColumns[':p' . $index++] = 'ACTION'; + if ($this->isColumnModified(CouponTableMap::TYPE)) { + $modifiedColumns[':p' . $index++] = 'TYPE'; + } + if ($this->isColumnModified(CouponTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(CouponTableMap::SHORT_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'SHORT_DESCRIPTION'; + } + if ($this->isColumnModified(CouponTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; } if ($this->isColumnModified(CouponTableMap::VALUE)) { $modifiedColumns[':p' . $index++] = 'VALUE'; } - if ($this->isColumnModified(CouponTableMap::USED)) { - $modifiedColumns[':p' . $index++] = 'USED'; + if ($this->isColumnModified(CouponTableMap::IS_USED)) { + $modifiedColumns[':p' . $index++] = 'IS_USED'; } - if ($this->isColumnModified(CouponTableMap::AVAILABLE_SINCE)) { - $modifiedColumns[':p' . $index++] = 'AVAILABLE_SINCE'; + if ($this->isColumnModified(CouponTableMap::IS_ENABLED)) { + $modifiedColumns[':p' . $index++] = 'IS_ENABLED'; } - if ($this->isColumnModified(CouponTableMap::DATE_LIMIT)) { - $modifiedColumns[':p' . $index++] = 'DATE_LIMIT'; + if ($this->isColumnModified(CouponTableMap::EXPIRATION_DATE)) { + $modifiedColumns[':p' . $index++] = 'EXPIRATION_DATE'; } - if ($this->isColumnModified(CouponTableMap::ACTIVATE)) { - $modifiedColumns[':p' . $index++] = 'ACTIVATE'; + if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES)) { + $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES'; } if ($this->isColumnModified(CouponTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -1102,6 +1379,9 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } + if ($this->isColumnModified(CouponTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; + } $sql = sprintf( 'INSERT INTO coupon (%s) VALUES (%s)', @@ -1119,23 +1399,32 @@ abstract class Coupon implements ActiveRecordInterface case 'CODE': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case 'ACTION': - $stmt->bindValue($identifier, $this->action, PDO::PARAM_STR); + case 'TYPE': + $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'SHORT_DESCRIPTION': + $stmt->bindValue($identifier, $this->short_description, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; case 'VALUE': $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); break; - case 'USED': - $stmt->bindValue($identifier, $this->used, PDO::PARAM_INT); + case 'IS_USED': + $stmt->bindValue($identifier, $this->is_used, PDO::PARAM_INT); break; - case 'AVAILABLE_SINCE': - $stmt->bindValue($identifier, $this->available_since ? $this->available_since->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + case 'IS_ENABLED': + $stmt->bindValue($identifier, $this->is_enabled, PDO::PARAM_INT); break; - case 'DATE_LIMIT': - $stmt->bindValue($identifier, $this->date_limit ? $this->date_limit->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + case 'EXPIRATION_DATE': + $stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case 'ACTIVATE': - $stmt->bindValue($identifier, $this->activate, PDO::PARAM_INT); + case 'SERIALIZED_RULES': + $stmt->bindValue($identifier, $this->serialized_rules, PDO::PARAM_STR); break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); @@ -1143,6 +1432,9 @@ abstract class Coupon implements ActiveRecordInterface case 'UPDATED_AT': $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; + case 'VERSION': + $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); + break; } } $stmt->execute(); @@ -1212,29 +1504,41 @@ abstract class Coupon implements ActiveRecordInterface return $this->getCode(); break; case 2: - return $this->getAction(); + return $this->getType(); break; case 3: - return $this->getValue(); + return $this->getTitle(); break; case 4: - return $this->getUsed(); + return $this->getShortDescription(); break; case 5: - return $this->getAvailableSince(); + return $this->getDescription(); break; case 6: - return $this->getDateLimit(); + return $this->getValue(); break; case 7: - return $this->getActivate(); + return $this->getIsUsed(); break; case 8: - return $this->getCreatedAt(); + return $this->getIsEnabled(); break; case 9: + return $this->getExpirationDate(); + break; + case 10: + return $this->getSerializedRules(); + break; + case 11: + return $this->getCreatedAt(); + break; + case 12: return $this->getUpdatedAt(); break; + case 13: + return $this->getVersion(); + break; default: return null; break; @@ -1266,14 +1570,18 @@ abstract class Coupon implements ActiveRecordInterface $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getCode(), - $keys[2] => $this->getAction(), - $keys[3] => $this->getValue(), - $keys[4] => $this->getUsed(), - $keys[5] => $this->getAvailableSince(), - $keys[6] => $this->getDateLimit(), - $keys[7] => $this->getActivate(), - $keys[8] => $this->getCreatedAt(), - $keys[9] => $this->getUpdatedAt(), + $keys[2] => $this->getType(), + $keys[3] => $this->getTitle(), + $keys[4] => $this->getShortDescription(), + $keys[5] => $this->getDescription(), + $keys[6] => $this->getValue(), + $keys[7] => $this->getIsUsed(), + $keys[8] => $this->getIsEnabled(), + $keys[9] => $this->getExpirationDate(), + $keys[10] => $this->getSerializedRules(), + $keys[11] => $this->getCreatedAt(), + $keys[12] => $this->getUpdatedAt(), + $keys[13] => $this->getVersion(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1282,8 +1590,14 @@ abstract class Coupon implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->collCouponRules) { - $result['CouponRules'] = $this->collCouponRules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collCouponOrders) { + $result['CouponOrders'] = $this->collCouponOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCouponI18ns) { + $result['CouponI18ns'] = $this->collCouponI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCouponVersions) { + $result['CouponVersions'] = $this->collCouponVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1326,29 +1640,41 @@ abstract class Coupon implements ActiveRecordInterface $this->setCode($value); break; case 2: - $this->setAction($value); + $this->setType($value); break; case 3: - $this->setValue($value); + $this->setTitle($value); break; case 4: - $this->setUsed($value); + $this->setShortDescription($value); break; case 5: - $this->setAvailableSince($value); + $this->setDescription($value); break; case 6: - $this->setDateLimit($value); + $this->setValue($value); break; case 7: - $this->setActivate($value); + $this->setIsUsed($value); break; case 8: - $this->setCreatedAt($value); + $this->setIsEnabled($value); break; case 9: + $this->setExpirationDate($value); + break; + case 10: + $this->setSerializedRules($value); + break; + case 11: + $this->setCreatedAt($value); + break; + case 12: $this->setUpdatedAt($value); break; + case 13: + $this->setVersion($value); + break; } // switch() } @@ -1375,14 +1701,18 @@ abstract class Coupon implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setAction($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setValue($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUsed($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setAvailableSince($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDateLimit($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setActivate($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]); + if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setShortDescription($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDescription($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setValue($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setIsUsed($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setIsEnabled($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setExpirationDate($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setSerializedRules($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setCreatedAt($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setUpdatedAt($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setVersion($arr[$keys[13]]); } /** @@ -1396,14 +1726,18 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::ID)) $criteria->add(CouponTableMap::ID, $this->id); if ($this->isColumnModified(CouponTableMap::CODE)) $criteria->add(CouponTableMap::CODE, $this->code); - if ($this->isColumnModified(CouponTableMap::ACTION)) $criteria->add(CouponTableMap::ACTION, $this->action); + if ($this->isColumnModified(CouponTableMap::TYPE)) $criteria->add(CouponTableMap::TYPE, $this->type); + if ($this->isColumnModified(CouponTableMap::TITLE)) $criteria->add(CouponTableMap::TITLE, $this->title); + if ($this->isColumnModified(CouponTableMap::SHORT_DESCRIPTION)) $criteria->add(CouponTableMap::SHORT_DESCRIPTION, $this->short_description); + if ($this->isColumnModified(CouponTableMap::DESCRIPTION)) $criteria->add(CouponTableMap::DESCRIPTION, $this->description); if ($this->isColumnModified(CouponTableMap::VALUE)) $criteria->add(CouponTableMap::VALUE, $this->value); - if ($this->isColumnModified(CouponTableMap::USED)) $criteria->add(CouponTableMap::USED, $this->used); - if ($this->isColumnModified(CouponTableMap::AVAILABLE_SINCE)) $criteria->add(CouponTableMap::AVAILABLE_SINCE, $this->available_since); - if ($this->isColumnModified(CouponTableMap::DATE_LIMIT)) $criteria->add(CouponTableMap::DATE_LIMIT, $this->date_limit); - if ($this->isColumnModified(CouponTableMap::ACTIVATE)) $criteria->add(CouponTableMap::ACTIVATE, $this->activate); + if ($this->isColumnModified(CouponTableMap::IS_USED)) $criteria->add(CouponTableMap::IS_USED, $this->is_used); + if ($this->isColumnModified(CouponTableMap::IS_ENABLED)) $criteria->add(CouponTableMap::IS_ENABLED, $this->is_enabled); + if ($this->isColumnModified(CouponTableMap::EXPIRATION_DATE)) $criteria->add(CouponTableMap::EXPIRATION_DATE, $this->expiration_date); + if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES)) $criteria->add(CouponTableMap::SERIALIZED_RULES, $this->serialized_rules); if ($this->isColumnModified(CouponTableMap::CREATED_AT)) $criteria->add(CouponTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) $criteria->add(CouponTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(CouponTableMap::VERSION)) $criteria->add(CouponTableMap::VERSION, $this->version); return $criteria; } @@ -1468,23 +1802,39 @@ abstract class Coupon implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setCode($this->getCode()); - $copyObj->setAction($this->getAction()); + $copyObj->setType($this->getType()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setShortDescription($this->getShortDescription()); + $copyObj->setDescription($this->getDescription()); $copyObj->setValue($this->getValue()); - $copyObj->setUsed($this->getUsed()); - $copyObj->setAvailableSince($this->getAvailableSince()); - $copyObj->setDateLimit($this->getDateLimit()); - $copyObj->setActivate($this->getActivate()); + $copyObj->setIsUsed($this->getIsUsed()); + $copyObj->setIsEnabled($this->getIsEnabled()); + $copyObj->setExpirationDate($this->getExpirationDate()); + $copyObj->setSerializedRules($this->getSerializedRules()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); + $copyObj->setVersion($this->getVersion()); if ($deepCopy) { // important: temporarily setNew(false) because this affects the behavior of // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getCouponRules() as $relObj) { + foreach ($this->getCouponOrders() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCouponRule($relObj->copy($deepCopy)); + $copyObj->addCouponOrder($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCouponI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCouponI18n($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCouponVersions() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCouponVersion($relObj->copy($deepCopy)); } } @@ -1529,37 +1879,43 @@ abstract class Coupon implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('CouponRule' == $relationName) { - return $this->initCouponRules(); + if ('CouponOrder' == $relationName) { + return $this->initCouponOrders(); + } + if ('CouponI18n' == $relationName) { + return $this->initCouponI18ns(); + } + if ('CouponVersion' == $relationName) { + return $this->initCouponVersions(); } } /** - * Clears out the collCouponRules collection + * Clears out the collCouponOrders collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addCouponRules() + * @see addCouponOrders() */ - public function clearCouponRules() + public function clearCouponOrders() { - $this->collCouponRules = null; // important to set this to NULL since that means it is uninitialized + $this->collCouponOrders = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collCouponRules collection loaded partially. + * Reset is the collCouponOrders collection loaded partially. */ - public function resetPartialCouponRules($v = true) + public function resetPartialCouponOrders($v = true) { - $this->collCouponRulesPartial = $v; + $this->collCouponOrdersPartial = $v; } /** - * Initializes the collCouponRules collection. + * Initializes the collCouponOrders collection. * - * By default this just sets the collCouponRules collection to an empty array (like clearcollCouponRules()); + * By default this just sets the collCouponOrders collection to an empty array (like clearcollCouponOrders()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1568,17 +1924,17 @@ abstract class Coupon implements ActiveRecordInterface * * @return void */ - public function initCouponRules($overrideExisting = true) + public function initCouponOrders($overrideExisting = true) { - if (null !== $this->collCouponRules && !$overrideExisting) { + if (null !== $this->collCouponOrders && !$overrideExisting) { return; } - $this->collCouponRules = new ObjectCollection(); - $this->collCouponRules->setModel('\Thelia\Model\CouponRule'); + $this->collCouponOrders = new ObjectCollection(); + $this->collCouponOrders->setModel('\Thelia\Model\CouponOrder'); } /** - * Gets an array of ChildCouponRule objects which contain a foreign key that references this object. + * Gets an array of ChildCouponOrder objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1588,109 +1944,109 @@ abstract class Coupon implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildCouponRule[] List of ChildCouponRule objects + * @return Collection|ChildCouponOrder[] List of ChildCouponOrder objects * @throws PropelException */ - public function getCouponRules($criteria = null, ConnectionInterface $con = null) + public function getCouponOrders($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collCouponRulesPartial && !$this->isNew(); - if (null === $this->collCouponRules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCouponRules) { + $partial = $this->collCouponOrdersPartial && !$this->isNew(); + if (null === $this->collCouponOrders || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponOrders) { // return empty collection - $this->initCouponRules(); + $this->initCouponOrders(); } else { - $collCouponRules = ChildCouponRuleQuery::create(null, $criteria) + $collCouponOrders = ChildCouponOrderQuery::create(null, $criteria) ->filterByCoupon($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collCouponRulesPartial && count($collCouponRules)) { - $this->initCouponRules(false); + if (false !== $this->collCouponOrdersPartial && count($collCouponOrders)) { + $this->initCouponOrders(false); - foreach ($collCouponRules as $obj) { - if (false == $this->collCouponRules->contains($obj)) { - $this->collCouponRules->append($obj); + foreach ($collCouponOrders as $obj) { + if (false == $this->collCouponOrders->contains($obj)) { + $this->collCouponOrders->append($obj); } } - $this->collCouponRulesPartial = true; + $this->collCouponOrdersPartial = true; } - $collCouponRules->getInternalIterator()->rewind(); + $collCouponOrders->getInternalIterator()->rewind(); - return $collCouponRules; + return $collCouponOrders; } - if ($partial && $this->collCouponRules) { - foreach ($this->collCouponRules as $obj) { + if ($partial && $this->collCouponOrders) { + foreach ($this->collCouponOrders as $obj) { if ($obj->isNew()) { - $collCouponRules[] = $obj; + $collCouponOrders[] = $obj; } } } - $this->collCouponRules = $collCouponRules; - $this->collCouponRulesPartial = false; + $this->collCouponOrders = $collCouponOrders; + $this->collCouponOrdersPartial = false; } } - return $this->collCouponRules; + return $this->collCouponOrders; } /** - * Sets a collection of CouponRule objects related by a one-to-many relationship + * Sets a collection of CouponOrder objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $couponRules A Propel collection. + * @param Collection $couponOrders A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildCoupon The current object (for fluent API support) */ - public function setCouponRules(Collection $couponRules, ConnectionInterface $con = null) + public function setCouponOrders(Collection $couponOrders, ConnectionInterface $con = null) { - $couponRulesToDelete = $this->getCouponRules(new Criteria(), $con)->diff($couponRules); + $couponOrdersToDelete = $this->getCouponOrders(new Criteria(), $con)->diff($couponOrders); - $this->couponRulesScheduledForDeletion = $couponRulesToDelete; + $this->couponOrdersScheduledForDeletion = $couponOrdersToDelete; - foreach ($couponRulesToDelete as $couponRuleRemoved) { - $couponRuleRemoved->setCoupon(null); + foreach ($couponOrdersToDelete as $couponOrderRemoved) { + $couponOrderRemoved->setCoupon(null); } - $this->collCouponRules = null; - foreach ($couponRules as $couponRule) { - $this->addCouponRule($couponRule); + $this->collCouponOrders = null; + foreach ($couponOrders as $couponOrder) { + $this->addCouponOrder($couponOrder); } - $this->collCouponRules = $couponRules; - $this->collCouponRulesPartial = false; + $this->collCouponOrders = $couponOrders; + $this->collCouponOrdersPartial = false; return $this; } /** - * Returns the number of related CouponRule objects. + * Returns the number of related CouponOrder objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related CouponRule objects. + * @return int Count of related CouponOrder objects. * @throws PropelException */ - public function countCouponRules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countCouponOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collCouponRulesPartial && !$this->isNew(); - if (null === $this->collCouponRules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCouponRules) { + $partial = $this->collCouponOrdersPartial && !$this->isNew(); + if (null === $this->collCouponOrders || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponOrders) { return 0; } if ($partial && !$criteria) { - return count($this->getCouponRules()); + return count($this->getCouponOrders()); } - $query = ChildCouponRuleQuery::create(null, $criteria); + $query = ChildCouponOrderQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1700,53 +2056,524 @@ abstract class Coupon implements ActiveRecordInterface ->count($con); } - return count($this->collCouponRules); + return count($this->collCouponOrders); } /** - * Method called to associate a ChildCouponRule object to this object - * through the ChildCouponRule foreign key attribute. + * Method called to associate a ChildCouponOrder object to this object + * through the ChildCouponOrder foreign key attribute. * - * @param ChildCouponRule $l ChildCouponRule + * @param ChildCouponOrder $l ChildCouponOrder * @return \Thelia\Model\Coupon The current object (for fluent API support) */ - public function addCouponRule(ChildCouponRule $l) + public function addCouponOrder(ChildCouponOrder $l) { - if ($this->collCouponRules === null) { - $this->initCouponRules(); - $this->collCouponRulesPartial = true; + if ($this->collCouponOrders === null) { + $this->initCouponOrders(); + $this->collCouponOrdersPartial = true; } - if (!in_array($l, $this->collCouponRules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddCouponRule($l); + if (!in_array($l, $this->collCouponOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCouponOrder($l); } return $this; } /** - * @param CouponRule $couponRule The couponRule object to add. + * @param CouponOrder $couponOrder The couponOrder object to add. */ - protected function doAddCouponRule($couponRule) + protected function doAddCouponOrder($couponOrder) { - $this->collCouponRules[]= $couponRule; - $couponRule->setCoupon($this); + $this->collCouponOrders[]= $couponOrder; + $couponOrder->setCoupon($this); } /** - * @param CouponRule $couponRule The couponRule object to remove. + * @param CouponOrder $couponOrder The couponOrder object to remove. * @return ChildCoupon The current object (for fluent API support) */ - public function removeCouponRule($couponRule) + public function removeCouponOrder($couponOrder) { - if ($this->getCouponRules()->contains($couponRule)) { - $this->collCouponRules->remove($this->collCouponRules->search($couponRule)); - if (null === $this->couponRulesScheduledForDeletion) { - $this->couponRulesScheduledForDeletion = clone $this->collCouponRules; - $this->couponRulesScheduledForDeletion->clear(); + if ($this->getCouponOrders()->contains($couponOrder)) { + $this->collCouponOrders->remove($this->collCouponOrders->search($couponOrder)); + if (null === $this->couponOrdersScheduledForDeletion) { + $this->couponOrdersScheduledForDeletion = clone $this->collCouponOrders; + $this->couponOrdersScheduledForDeletion->clear(); } - $this->couponRulesScheduledForDeletion[]= clone $couponRule; - $couponRule->setCoupon(null); + $this->couponOrdersScheduledForDeletion[]= clone $couponOrder; + $couponOrder->setCoupon(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Coupon is new, it will return + * an empty collection; or if this Coupon has previously + * been saved, it will retrieve related CouponOrders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Coupon. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildCouponOrder[] List of ChildCouponOrder objects + */ + public function getCouponOrdersJoinOrder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildCouponOrderQuery::create(null, $criteria); + $query->joinWith('Order', $joinBehavior); + + return $this->getCouponOrders($query, $con); + } + + /** + * Clears out the collCouponI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCouponI18ns() + */ + public function clearCouponI18ns() + { + $this->collCouponI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCouponI18ns collection loaded partially. + */ + public function resetPartialCouponI18ns($v = true) + { + $this->collCouponI18nsPartial = $v; + } + + /** + * Initializes the collCouponI18ns collection. + * + * By default this just sets the collCouponI18ns collection to an empty array (like clearcollCouponI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCouponI18ns($overrideExisting = true) + { + if (null !== $this->collCouponI18ns && !$overrideExisting) { + return; + } + $this->collCouponI18ns = new ObjectCollection(); + $this->collCouponI18ns->setModel('\Thelia\Model\CouponI18n'); + } + + /** + * Gets an array of ChildCouponI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildCoupon is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCouponI18n[] List of ChildCouponI18n objects + * @throws PropelException + */ + public function getCouponI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCouponI18nsPartial && !$this->isNew(); + if (null === $this->collCouponI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponI18ns) { + // return empty collection + $this->initCouponI18ns(); + } else { + $collCouponI18ns = ChildCouponI18nQuery::create(null, $criteria) + ->filterByCoupon($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCouponI18nsPartial && count($collCouponI18ns)) { + $this->initCouponI18ns(false); + + foreach ($collCouponI18ns as $obj) { + if (false == $this->collCouponI18ns->contains($obj)) { + $this->collCouponI18ns->append($obj); + } + } + + $this->collCouponI18nsPartial = true; + } + + $collCouponI18ns->getInternalIterator()->rewind(); + + return $collCouponI18ns; + } + + if ($partial && $this->collCouponI18ns) { + foreach ($this->collCouponI18ns as $obj) { + if ($obj->isNew()) { + $collCouponI18ns[] = $obj; + } + } + } + + $this->collCouponI18ns = $collCouponI18ns; + $this->collCouponI18nsPartial = false; + } + } + + return $this->collCouponI18ns; + } + + /** + * Sets a collection of CouponI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $couponI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCoupon The current object (for fluent API support) + */ + public function setCouponI18ns(Collection $couponI18ns, ConnectionInterface $con = null) + { + $couponI18nsToDelete = $this->getCouponI18ns(new Criteria(), $con)->diff($couponI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->couponI18nsScheduledForDeletion = clone $couponI18nsToDelete; + + foreach ($couponI18nsToDelete as $couponI18nRemoved) { + $couponI18nRemoved->setCoupon(null); + } + + $this->collCouponI18ns = null; + foreach ($couponI18ns as $couponI18n) { + $this->addCouponI18n($couponI18n); + } + + $this->collCouponI18ns = $couponI18ns; + $this->collCouponI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related CouponI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CouponI18n objects. + * @throws PropelException + */ + public function countCouponI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCouponI18nsPartial && !$this->isNew(); + if (null === $this->collCouponI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCouponI18ns()); + } + + $query = ChildCouponI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCoupon($this) + ->count($con); + } + + return count($this->collCouponI18ns); + } + + /** + * Method called to associate a ChildCouponI18n object to this object + * through the ChildCouponI18n foreign key attribute. + * + * @param ChildCouponI18n $l ChildCouponI18n + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function addCouponI18n(ChildCouponI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collCouponI18ns === null) { + $this->initCouponI18ns(); + $this->collCouponI18nsPartial = true; + } + + if (!in_array($l, $this->collCouponI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCouponI18n($l); + } + + return $this; + } + + /** + * @param CouponI18n $couponI18n The couponI18n object to add. + */ + protected function doAddCouponI18n($couponI18n) + { + $this->collCouponI18ns[]= $couponI18n; + $couponI18n->setCoupon($this); + } + + /** + * @param CouponI18n $couponI18n The couponI18n object to remove. + * @return ChildCoupon The current object (for fluent API support) + */ + public function removeCouponI18n($couponI18n) + { + if ($this->getCouponI18ns()->contains($couponI18n)) { + $this->collCouponI18ns->remove($this->collCouponI18ns->search($couponI18n)); + if (null === $this->couponI18nsScheduledForDeletion) { + $this->couponI18nsScheduledForDeletion = clone $this->collCouponI18ns; + $this->couponI18nsScheduledForDeletion->clear(); + } + $this->couponI18nsScheduledForDeletion[]= clone $couponI18n; + $couponI18n->setCoupon(null); + } + + return $this; + } + + /** + * Clears out the collCouponVersions collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCouponVersions() + */ + public function clearCouponVersions() + { + $this->collCouponVersions = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCouponVersions collection loaded partially. + */ + public function resetPartialCouponVersions($v = true) + { + $this->collCouponVersionsPartial = $v; + } + + /** + * Initializes the collCouponVersions collection. + * + * By default this just sets the collCouponVersions collection to an empty array (like clearcollCouponVersions()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCouponVersions($overrideExisting = true) + { + if (null !== $this->collCouponVersions && !$overrideExisting) { + return; + } + $this->collCouponVersions = new ObjectCollection(); + $this->collCouponVersions->setModel('\Thelia\Model\CouponVersion'); + } + + /** + * Gets an array of ChildCouponVersion objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildCoupon is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCouponVersion[] List of ChildCouponVersion objects + * @throws PropelException + */ + public function getCouponVersions($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCouponVersionsPartial && !$this->isNew(); + if (null === $this->collCouponVersions || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponVersions) { + // return empty collection + $this->initCouponVersions(); + } else { + $collCouponVersions = ChildCouponVersionQuery::create(null, $criteria) + ->filterByCoupon($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCouponVersionsPartial && count($collCouponVersions)) { + $this->initCouponVersions(false); + + foreach ($collCouponVersions as $obj) { + if (false == $this->collCouponVersions->contains($obj)) { + $this->collCouponVersions->append($obj); + } + } + + $this->collCouponVersionsPartial = true; + } + + $collCouponVersions->getInternalIterator()->rewind(); + + return $collCouponVersions; + } + + if ($partial && $this->collCouponVersions) { + foreach ($this->collCouponVersions as $obj) { + if ($obj->isNew()) { + $collCouponVersions[] = $obj; + } + } + } + + $this->collCouponVersions = $collCouponVersions; + $this->collCouponVersionsPartial = false; + } + } + + return $this->collCouponVersions; + } + + /** + * Sets a collection of CouponVersion objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $couponVersions A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCoupon The current object (for fluent API support) + */ + public function setCouponVersions(Collection $couponVersions, ConnectionInterface $con = null) + { + $couponVersionsToDelete = $this->getCouponVersions(new Criteria(), $con)->diff($couponVersions); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->couponVersionsScheduledForDeletion = clone $couponVersionsToDelete; + + foreach ($couponVersionsToDelete as $couponVersionRemoved) { + $couponVersionRemoved->setCoupon(null); + } + + $this->collCouponVersions = null; + foreach ($couponVersions as $couponVersion) { + $this->addCouponVersion($couponVersion); + } + + $this->collCouponVersions = $couponVersions; + $this->collCouponVersionsPartial = false; + + return $this; + } + + /** + * Returns the number of related CouponVersion objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CouponVersion objects. + * @throws PropelException + */ + public function countCouponVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCouponVersionsPartial && !$this->isNew(); + if (null === $this->collCouponVersions || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponVersions) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCouponVersions()); + } + + $query = ChildCouponVersionQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCoupon($this) + ->count($con); + } + + return count($this->collCouponVersions); + } + + /** + * Method called to associate a ChildCouponVersion object to this object + * through the ChildCouponVersion foreign key attribute. + * + * @param ChildCouponVersion $l ChildCouponVersion + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function addCouponVersion(ChildCouponVersion $l) + { + if ($this->collCouponVersions === null) { + $this->initCouponVersions(); + $this->collCouponVersionsPartial = true; + } + + if (!in_array($l, $this->collCouponVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCouponVersion($l); + } + + return $this; + } + + /** + * @param CouponVersion $couponVersion The couponVersion object to add. + */ + protected function doAddCouponVersion($couponVersion) + { + $this->collCouponVersions[]= $couponVersion; + $couponVersion->setCoupon($this); + } + + /** + * @param CouponVersion $couponVersion The couponVersion object to remove. + * @return ChildCoupon The current object (for fluent API support) + */ + public function removeCouponVersion($couponVersion) + { + if ($this->getCouponVersions()->contains($couponVersion)) { + $this->collCouponVersions->remove($this->collCouponVersions->search($couponVersion)); + if (null === $this->couponVersionsScheduledForDeletion) { + $this->couponVersionsScheduledForDeletion = clone $this->collCouponVersions; + $this->couponVersionsScheduledForDeletion->clear(); + } + $this->couponVersionsScheduledForDeletion[]= clone $couponVersion; + $couponVersion->setCoupon(null); } return $this; @@ -1759,16 +2586,21 @@ abstract class Coupon implements ActiveRecordInterface { $this->id = null; $this->code = null; - $this->action = null; + $this->type = null; + $this->title = null; + $this->short_description = null; + $this->description = null; $this->value = null; - $this->used = null; - $this->available_since = null; - $this->date_limit = null; - $this->activate = null; + $this->is_used = null; + $this->is_enabled = null; + $this->expiration_date = null; + $this->serialized_rules = null; $this->created_at = null; $this->updated_at = null; + $this->version = null; $this->alreadyInSave = false; $this->clearAllReferences(); + $this->applyDefaultValues(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); @@ -1786,17 +2618,39 @@ abstract class Coupon implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collCouponRules) { - foreach ($this->collCouponRules as $o) { + if ($this->collCouponOrders) { + foreach ($this->collCouponOrders as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCouponI18ns) { + foreach ($this->collCouponI18ns as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCouponVersions) { + foreach ($this->collCouponVersions as $o) { $o->clearAllReferences($deep); } } } // if ($deep) - if ($this->collCouponRules instanceof Collection) { - $this->collCouponRules->clearIterator(); + // i18n behavior + $this->currentLocale = 'en_EN'; + $this->currentTranslations = null; + + if ($this->collCouponOrders instanceof Collection) { + $this->collCouponOrders->clearIterator(); } - $this->collCouponRules = null; + $this->collCouponOrders = null; + if ($this->collCouponI18ns instanceof Collection) { + $this->collCouponI18ns->clearIterator(); + } + $this->collCouponI18ns = null; + if ($this->collCouponVersions instanceof Collection) { + $this->collCouponVersions->clearIterator(); + } + $this->collCouponVersions = null; } /** @@ -1823,6 +2677,397 @@ abstract class Coupon implements ActiveRecordInterface return $this; } + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildCoupon The current object (for fluent API support) + */ + public function setLocale($locale = 'en_EN') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCouponI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collCouponI18ns) { + foreach ($this->collCouponI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildCouponI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildCouponI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addCouponI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCoupon The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildCouponI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collCouponI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collCouponI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCouponI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + // versionable behavior + + /** + * Enforce a new Version of this object upon next save. + * + * @return \Thelia\Model\Coupon + */ + public function enforceVersioning() + { + $this->enforceVersion = true; + + return $this; + } + + /** + * Checks whether the current state must be recorded as a version + * + * @return boolean + */ + public function isVersioningNecessary($con = null) + { + if ($this->alreadyInSave) { + return false; + } + + if ($this->enforceVersion) { + return true; + } + + if (ChildCouponQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) { + return true; + } + + return false; + } + + /** + * Creates a version of the current object and saves it. + * + * @param ConnectionInterface $con the connection to use + * + * @return ChildCouponVersion A version object + */ + public function addVersion($con = null) + { + $this->enforceVersion = false; + + $version = new ChildCouponVersion(); + $version->setId($this->getId()); + $version->setCode($this->getCode()); + $version->setType($this->getType()); + $version->setTitle($this->getTitle()); + $version->setShortDescription($this->getShortDescription()); + $version->setDescription($this->getDescription()); + $version->setValue($this->getValue()); + $version->setIsUsed($this->getIsUsed()); + $version->setIsEnabled($this->getIsEnabled()); + $version->setExpirationDate($this->getExpirationDate()); + $version->setSerializedRules($this->getSerializedRules()); + $version->setCreatedAt($this->getCreatedAt()); + $version->setUpdatedAt($this->getUpdatedAt()); + $version->setVersion($this->getVersion()); + $version->setCoupon($this); + $version->save($con); + + return $version; + } + + /** + * Sets the properties of the current object to the value they had at a specific version + * + * @param integer $versionNumber The version number to read + * @param ConnectionInterface $con The connection to use + * + * @return ChildCoupon The current object (for fluent API support) + */ + public function toVersion($versionNumber, $con = null) + { + $version = $this->getOneVersion($versionNumber, $con); + if (!$version) { + throw new PropelException(sprintf('No ChildCoupon object found with version %d', $version)); + } + $this->populateFromVersion($version, $con); + + return $this; + } + + /** + * Sets the properties of the current object to the value they had at a specific version + * + * @param ChildCouponVersion $version The version object to use + * @param ConnectionInterface $con the connection to use + * @param array $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects. + * + * @return ChildCoupon The current object (for fluent API support) + */ + public function populateFromVersion($version, $con = null, &$loadedObjects = array()) + { + $loadedObjects['ChildCoupon'][$version->getId()][$version->getVersion()] = $this; + $this->setId($version->getId()); + $this->setCode($version->getCode()); + $this->setType($version->getType()); + $this->setTitle($version->getTitle()); + $this->setShortDescription($version->getShortDescription()); + $this->setDescription($version->getDescription()); + $this->setValue($version->getValue()); + $this->setIsUsed($version->getIsUsed()); + $this->setIsEnabled($version->getIsEnabled()); + $this->setExpirationDate($version->getExpirationDate()); + $this->setSerializedRules($version->getSerializedRules()); + $this->setCreatedAt($version->getCreatedAt()); + $this->setUpdatedAt($version->getUpdatedAt()); + $this->setVersion($version->getVersion()); + + return $this; + } + + /** + * Gets the latest persisted version number for the current object + * + * @param ConnectionInterface $con the connection to use + * + * @return integer + */ + public function getLastVersionNumber($con = null) + { + $v = ChildCouponVersionQuery::create() + ->filterByCoupon($this) + ->orderByVersion('desc') + ->findOne($con); + if (!$v) { + return 0; + } + + return $v->getVersion(); + } + + /** + * Checks whether the current object is the latest one + * + * @param ConnectionInterface $con the connection to use + * + * @return Boolean + */ + public function isLastVersion($con = null) + { + return $this->getLastVersionNumber($con) == $this->getVersion(); + } + + /** + * Retrieves a version object for this entity and a version number + * + * @param integer $versionNumber The version number to read + * @param ConnectionInterface $con the connection to use + * + * @return ChildCouponVersion A version object + */ + public function getOneVersion($versionNumber, $con = null) + { + return ChildCouponVersionQuery::create() + ->filterByCoupon($this) + ->filterByVersion($versionNumber) + ->findOne($con); + } + + /** + * Gets all the versions of this object, in incremental order + * + * @param ConnectionInterface $con the connection to use + * + * @return ObjectCollection A list of ChildCouponVersion objects + */ + public function getAllVersions($con = null) + { + $criteria = new Criteria(); + $criteria->addAscendingOrderByColumn(CouponVersionTableMap::VERSION); + + return $this->getCouponVersions($criteria, $con); + } + + /** + * Compares the current object with another of its version. + * + * print_r($book->compareVersion(1)); + * => array( + * '1' => array('Title' => 'Book title at version 1'), + * '2' => array('Title' => 'Book title at version 2') + * ); + * + * + * @param integer $versionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. + * + * @return array A list of differences + */ + public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array()) + { + $fromVersion = $this->toArray(); + $toVersion = $this->getOneVersion($versionNumber, $con)->toArray(); + + return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns); + } + + /** + * Compares two versions of the current object. + * + * print_r($book->compareVersions(1, 2)); + * => array( + * '1' => array('Title' => 'Book title at version 1'), + * '2' => array('Title' => 'Book title at version 2') + * ); + * + * + * @param integer $fromVersionNumber + * @param integer $toVersionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. + * + * @return array A list of differences + */ + public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array()) + { + $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray(); + $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray(); + + return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns); + } + + /** + * Computes the diff between two versions. + * + * print_r($book->computeDiff(1, 2)); + * => array( + * '1' => array('Title' => 'Book title at version 1'), + * '2' => array('Title' => 'Book title at version 2') + * ); + * + * + * @param array $fromVersion An array representing the original version. + * @param array $toVersion An array representing the destination version. + * @param string $keys Main key used for the result diff (versions|columns). + * @param array $ignoredColumns The columns to exclude from the diff. + * + * @return array A list of differences + */ + protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array()) + { + $fromVersionNumber = $fromVersion['Version']; + $toVersionNumber = $toVersion['Version']; + $ignoredColumns = array_merge(array( + 'Version', + ), $ignoredColumns); + $diff = array(); + foreach ($fromVersion as $key => $value) { + if (in_array($key, $ignoredColumns)) { + continue; + } + if ($toVersion[$key] != $value) { + switch ($keys) { + case 'versions': + $diff[$fromVersionNumber][$key] = $value; + $diff[$toVersionNumber][$key] = $toVersion[$key]; + break; + default: + $diff[$key] = array( + $fromVersionNumber => $value, + $toVersionNumber => $toVersion[$key], + ); + break; + } + } + } + + return $diff; + } + /** + * retrieve the last $number versions. + * + * @param Integer $number the number of record to return. + * @return PropelCollection|array \Thelia\Model\CouponVersion[] List of \Thelia\Model\CouponVersion objects + */ + public function getLastVersions($number = 10, $criteria = null, $con = null) + { + $criteria = ChildCouponVersionQuery::create(null, $criteria); + $criteria->addDescendingOrderByColumn(CouponVersionTableMap::VERSION); + $criteria->limit($number); + + return $this->getCouponVersions($criteria, $con); + } /** * Code to be run before persisting the object * @param ConnectionInterface $con diff --git a/core/lib/Thelia/Model/Base/CouponOrder.php b/core/lib/Thelia/Model/Base/CouponOrder.php index 71a71f673..a183f262e 100755 --- a/core/lib/Thelia/Model/Base/CouponOrder.php +++ b/core/lib/Thelia/Model/Base/CouponOrder.php @@ -16,8 +16,10 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; +use Thelia\Model\Coupon as ChildCoupon; use Thelia\Model\CouponOrder as ChildCouponOrder; use Thelia\Model\CouponOrderQuery as ChildCouponOrderQuery; +use Thelia\Model\CouponQuery as ChildCouponQuery; use Thelia\Model\Order as ChildOrder; use Thelia\Model\OrderQuery as ChildOrderQuery; use Thelia\Model\Map\CouponOrderTableMap; @@ -97,6 +99,11 @@ abstract class CouponOrder implements ActiveRecordInterface */ protected $aOrder; + /** + * @var Coupon + */ + protected $aCoupon; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -506,6 +513,10 @@ abstract class CouponOrder implements ActiveRecordInterface $this->modifiedColumns[] = CouponOrderTableMap::CODE; } + if ($this->aCoupon !== null && $this->aCoupon->getCode() !== $v) { + $this->aCoupon = null; + } + return $this; } // setCode() @@ -666,6 +677,9 @@ abstract class CouponOrder implements ActiveRecordInterface if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) { $this->aOrder = null; } + if ($this->aCoupon !== null && $this->code !== $this->aCoupon->getCode()) { + $this->aCoupon = null; + } } // ensureConsistency /** @@ -706,6 +720,7 @@ abstract class CouponOrder implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? $this->aOrder = null; + $this->aCoupon = null; } // if (deep) } @@ -840,6 +855,13 @@ abstract class CouponOrder implements ActiveRecordInterface $this->setOrder($this->aOrder); } + if ($this->aCoupon !== null) { + if ($this->aCoupon->isModified() || $this->aCoupon->isNew()) { + $affectedRows += $this->aCoupon->save($con); + } + $this->setCoupon($this->aCoupon); + } + if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -1050,6 +1072,9 @@ abstract class CouponOrder implements ActiveRecordInterface if (null !== $this->aOrder) { $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } + if (null !== $this->aCoupon) { + $result['Coupon'] = $this->aCoupon->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } } return $result; @@ -1296,6 +1321,59 @@ abstract class CouponOrder implements ActiveRecordInterface return $this->aOrder; } + /** + * Declares an association between this object and a ChildCoupon object. + * + * @param ChildCoupon $v + * @return \Thelia\Model\CouponOrder The current object (for fluent API support) + * @throws PropelException + */ + public function setCoupon(ChildCoupon $v = null) + { + if ($v === null) { + $this->setCode(NULL); + } else { + $this->setCode($v->getCode()); + } + + $this->aCoupon = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCoupon object, it will not be re-added. + if ($v !== null) { + $v->addCouponOrder($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCoupon object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCoupon The associated ChildCoupon object. + * @throws PropelException + */ + public function getCoupon(ConnectionInterface $con = null) + { + if ($this->aCoupon === null && (($this->code !== "" && $this->code !== null))) { + $this->aCoupon = ChildCouponQuery::create() + ->filterByCouponOrder($this) // here + ->findOne($con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCoupon->addCouponOrders($this); + */ + } + + return $this->aCoupon; + } + /** * Clears the current object and sets all attributes to their default values */ @@ -1329,6 +1407,7 @@ abstract class CouponOrder implements ActiveRecordInterface } // if ($deep) $this->aOrder = null; + $this->aCoupon = null; } /** diff --git a/core/lib/Thelia/Model/Base/CouponOrderQuery.php b/core/lib/Thelia/Model/Base/CouponOrderQuery.php index 6897f56dd..e3a95ea1a 100755 --- a/core/lib/Thelia/Model/Base/CouponOrderQuery.php +++ b/core/lib/Thelia/Model/Base/CouponOrderQuery.php @@ -43,6 +43,10 @@ use Thelia\Model\Map\CouponOrderTableMap; * @method ChildCouponOrderQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation * @method ChildCouponOrderQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation * + * @method ChildCouponOrderQuery leftJoinCoupon($relationAlias = null) Adds a LEFT JOIN clause to the query using the Coupon relation + * @method ChildCouponOrderQuery rightJoinCoupon($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Coupon relation + * @method ChildCouponOrderQuery innerJoinCoupon($relationAlias = null) Adds a INNER JOIN clause to the query using the Coupon relation + * * @method ChildCouponOrder findOne(ConnectionInterface $con = null) Return the first ChildCouponOrder matching the query * @method ChildCouponOrder findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCouponOrder matching the query, or a new ChildCouponOrder object populated from the query conditions when no match is found * @@ -551,6 +555,81 @@ abstract class CouponOrderQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery'); } + /** + * Filter the query by a related \Thelia\Model\Coupon object + * + * @param \Thelia\Model\Coupon|ObjectCollection $coupon The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function filterByCoupon($coupon, $comparison = null) + { + if ($coupon instanceof \Thelia\Model\Coupon) { + return $this + ->addUsingAlias(CouponOrderTableMap::CODE, $coupon->getCode(), $comparison); + } elseif ($coupon instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CouponOrderTableMap::CODE, $coupon->toKeyValue('PrimaryKey', 'Code'), $comparison); + } else { + throw new PropelException('filterByCoupon() only accepts arguments of type \Thelia\Model\Coupon or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Coupon relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function joinCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Coupon'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Coupon'); + } + + return $this; + } + + /** + * Use the Coupon relation Coupon object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CouponQuery A secondary query class using the current class as primary query + */ + public function useCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCoupon($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery'); + } + /** * Exclude object from result * diff --git a/core/lib/Thelia/Model/Base/CouponQuery.php b/core/lib/Thelia/Model/Base/CouponQuery.php index 23fdd2e4c..fa5700786 100755 --- a/core/lib/Thelia/Model/Base/CouponQuery.php +++ b/core/lib/Thelia/Model/Base/CouponQuery.php @@ -13,6 +13,7 @@ use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; use Thelia\Model\Coupon as ChildCoupon; +use Thelia\Model\CouponI18nQuery as ChildCouponI18nQuery; use Thelia\Model\CouponQuery as ChildCouponQuery; use Thelia\Model\Map\CouponTableMap; @@ -23,63 +24,94 @@ use Thelia\Model\Map\CouponTableMap; * * @method ChildCouponQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildCouponQuery orderByCode($order = Criteria::ASC) Order by the code column - * @method ChildCouponQuery orderByAction($order = Criteria::ASC) Order by the action column + * @method ChildCouponQuery orderByType($order = Criteria::ASC) Order by the type column + * @method ChildCouponQuery orderByTitle($order = Criteria::ASC) Order by the title column + * @method ChildCouponQuery orderByShortDescription($order = Criteria::ASC) Order by the short_description column + * @method ChildCouponQuery orderByDescription($order = Criteria::ASC) Order by the description column * @method ChildCouponQuery orderByValue($order = Criteria::ASC) Order by the value column - * @method ChildCouponQuery orderByUsed($order = Criteria::ASC) Order by the used column - * @method ChildCouponQuery orderByAvailableSince($order = Criteria::ASC) Order by the available_since column - * @method ChildCouponQuery orderByDateLimit($order = Criteria::ASC) Order by the date_limit column - * @method ChildCouponQuery orderByActivate($order = Criteria::ASC) Order by the activate column + * @method ChildCouponQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column + * @method ChildCouponQuery orderByIsEnabled($order = Criteria::ASC) Order by the is_enabled column + * @method ChildCouponQuery orderByExpirationDate($order = Criteria::ASC) Order by the expiration_date column + * @method ChildCouponQuery orderBySerializedRules($order = Criteria::ASC) Order by the serialized_rules column * @method ChildCouponQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCouponQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column + * @method ChildCouponQuery orderByVersion($order = Criteria::ASC) Order by the version column * * @method ChildCouponQuery groupById() Group by the id column * @method ChildCouponQuery groupByCode() Group by the code column - * @method ChildCouponQuery groupByAction() Group by the action column + * @method ChildCouponQuery groupByType() Group by the type column + * @method ChildCouponQuery groupByTitle() Group by the title column + * @method ChildCouponQuery groupByShortDescription() Group by the short_description column + * @method ChildCouponQuery groupByDescription() Group by the description column * @method ChildCouponQuery groupByValue() Group by the value column - * @method ChildCouponQuery groupByUsed() Group by the used column - * @method ChildCouponQuery groupByAvailableSince() Group by the available_since column - * @method ChildCouponQuery groupByDateLimit() Group by the date_limit column - * @method ChildCouponQuery groupByActivate() Group by the activate column + * @method ChildCouponQuery groupByIsUsed() Group by the is_used column + * @method ChildCouponQuery groupByIsEnabled() Group by the is_enabled column + * @method ChildCouponQuery groupByExpirationDate() Group by the expiration_date column + * @method ChildCouponQuery groupBySerializedRules() Group by the serialized_rules column * @method ChildCouponQuery groupByCreatedAt() Group by the created_at column * @method ChildCouponQuery groupByUpdatedAt() Group by the updated_at column + * @method ChildCouponQuery groupByVersion() Group by the version column * * @method ChildCouponQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method ChildCouponQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildCouponQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildCouponQuery leftJoinCouponRule($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponRule relation - * @method ChildCouponQuery rightJoinCouponRule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponRule relation - * @method ChildCouponQuery innerJoinCouponRule($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponRule relation + * @method ChildCouponQuery leftJoinCouponOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponOrder relation + * @method ChildCouponQuery rightJoinCouponOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponOrder relation + * @method ChildCouponQuery innerJoinCouponOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponOrder relation + * + * @method ChildCouponQuery leftJoinCouponI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponI18n relation + * @method ChildCouponQuery rightJoinCouponI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponI18n relation + * @method ChildCouponQuery innerJoinCouponI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponI18n relation + * + * @method ChildCouponQuery leftJoinCouponVersion($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponVersion relation + * @method ChildCouponQuery rightJoinCouponVersion($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponVersion relation + * @method ChildCouponQuery innerJoinCouponVersion($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponVersion relation * * @method ChildCoupon findOne(ConnectionInterface $con = null) Return the first ChildCoupon matching the query * @method ChildCoupon findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCoupon matching the query, or a new ChildCoupon object populated from the query conditions when no match is found * * @method ChildCoupon findOneById(int $id) Return the first ChildCoupon filtered by the id column * @method ChildCoupon findOneByCode(string $code) Return the first ChildCoupon filtered by the code column - * @method ChildCoupon findOneByAction(string $action) Return the first ChildCoupon filtered by the action column + * @method ChildCoupon findOneByType(string $type) Return the first ChildCoupon filtered by the type column + * @method ChildCoupon findOneByTitle(string $title) Return the first ChildCoupon filtered by the title column + * @method ChildCoupon findOneByShortDescription(string $short_description) Return the first ChildCoupon filtered by the short_description column + * @method ChildCoupon findOneByDescription(string $description) Return the first ChildCoupon filtered by the description column * @method ChildCoupon findOneByValue(double $value) Return the first ChildCoupon filtered by the value column - * @method ChildCoupon findOneByUsed(int $used) Return the first ChildCoupon filtered by the used column - * @method ChildCoupon findOneByAvailableSince(string $available_since) Return the first ChildCoupon filtered by the available_since column - * @method ChildCoupon findOneByDateLimit(string $date_limit) Return the first ChildCoupon filtered by the date_limit column - * @method ChildCoupon findOneByActivate(int $activate) Return the first ChildCoupon filtered by the activate column + * @method ChildCoupon findOneByIsUsed(int $is_used) Return the first ChildCoupon filtered by the is_used column + * @method ChildCoupon findOneByIsEnabled(int $is_enabled) Return the first ChildCoupon filtered by the is_enabled column + * @method ChildCoupon findOneByExpirationDate(string $expiration_date) Return the first ChildCoupon filtered by the expiration_date column + * @method ChildCoupon findOneBySerializedRules(string $serialized_rules) Return the first ChildCoupon filtered by the serialized_rules column * @method ChildCoupon findOneByCreatedAt(string $created_at) Return the first ChildCoupon filtered by the created_at column * @method ChildCoupon findOneByUpdatedAt(string $updated_at) Return the first ChildCoupon filtered by the updated_at column + * @method ChildCoupon findOneByVersion(int $version) Return the first ChildCoupon filtered by the version column * * @method array findById(int $id) Return ChildCoupon objects filtered by the id column * @method array findByCode(string $code) Return ChildCoupon objects filtered by the code column - * @method array findByAction(string $action) Return ChildCoupon objects filtered by the action column + * @method array findByType(string $type) Return ChildCoupon objects filtered by the type column + * @method array findByTitle(string $title) Return ChildCoupon objects filtered by the title column + * @method array findByShortDescription(string $short_description) Return ChildCoupon objects filtered by the short_description column + * @method array findByDescription(string $description) Return ChildCoupon objects filtered by the description column * @method array findByValue(double $value) Return ChildCoupon objects filtered by the value column - * @method array findByUsed(int $used) Return ChildCoupon objects filtered by the used column - * @method array findByAvailableSince(string $available_since) Return ChildCoupon objects filtered by the available_since column - * @method array findByDateLimit(string $date_limit) Return ChildCoupon objects filtered by the date_limit column - * @method array findByActivate(int $activate) Return ChildCoupon objects filtered by the activate column + * @method array findByIsUsed(int $is_used) Return ChildCoupon objects filtered by the is_used column + * @method array findByIsEnabled(int $is_enabled) Return ChildCoupon objects filtered by the is_enabled column + * @method array findByExpirationDate(string $expiration_date) Return ChildCoupon objects filtered by the expiration_date column + * @method array findBySerializedRules(string $serialized_rules) Return ChildCoupon objects filtered by the serialized_rules column * @method array findByCreatedAt(string $created_at) Return ChildCoupon objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCoupon objects filtered by the updated_at column + * @method array findByVersion(int $version) Return ChildCoupon objects filtered by the version column * */ abstract class CouponQuery extends ModelCriteria { + // versionable behavior + + /** + * Whether the versioning is enabled + */ + static $isVersioningEnabled = true; + /** * Initializes internal state of \Thelia\Model\Base\CouponQuery object. * @@ -163,7 +195,7 @@ abstract class CouponQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CODE, ACTION, VALUE, USED, AVAILABLE_SINCE, DATE_LIMIT, ACTIVATE, CREATED_AT, UPDATED_AT FROM coupon WHERE ID = :p0'; + $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, VALUE, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES, CREATED_AT, UPDATED_AT, VERSION FROM coupon WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -323,32 +355,119 @@ abstract class CouponQuery extends ModelCriteria } /** - * Filter the query on the action column + * Filter the query on the type column * * Example usage: * - * $query->filterByAction('fooValue'); // WHERE action = 'fooValue' - * $query->filterByAction('%fooValue%'); // WHERE action LIKE '%fooValue%' + * $query->filterByType('fooValue'); // WHERE type = 'fooValue' + * $query->filterByType('%fooValue%'); // WHERE type LIKE '%fooValue%' * * - * @param string $action The value to use as filter. + * @param string $type The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterByAction($action = null, $comparison = null) + public function filterByType($type = null, $comparison = null) { if (null === $comparison) { - if (is_array($action)) { + if (is_array($type)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $action)) { - $action = str_replace('*', '%', $action); + } elseif (preg_match('/[\%\*]/', $type)) { + $type = str_replace('*', '%', $type); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(CouponTableMap::ACTION, $action, $comparison); + return $this->addUsingAlias(CouponTableMap::TYPE, $type, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the short_description column + * + * Example usage: + * + * $query->filterByShortDescription('fooValue'); // WHERE short_description = 'fooValue' + * $query->filterByShortDescription('%fooValue%'); // WHERE short_description LIKE '%fooValue%' + * + * + * @param string $shortDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByShortDescription($shortDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($shortDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $shortDescription)) { + $shortDescription = str_replace('*', '%', $shortDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponTableMap::SHORT_DESCRIPTION, $shortDescription, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponTableMap::DESCRIPTION, $description, $comparison); } /** @@ -393,16 +512,16 @@ abstract class CouponQuery extends ModelCriteria } /** - * Filter the query on the used column + * Filter the query on the is_used column * * Example usage: * - * $query->filterByUsed(1234); // WHERE used = 1234 - * $query->filterByUsed(array(12, 34)); // WHERE used IN (12, 34) - * $query->filterByUsed(array('min' => 12)); // WHERE used > 12 + * $query->filterByIsUsed(1234); // WHERE is_used = 1234 + * $query->filterByIsUsed(array(12, 34)); // WHERE is_used IN (12, 34) + * $query->filterByIsUsed(array('min' => 12)); // WHERE is_used > 12 * * - * @param mixed $used The value to use as filter. + * @param mixed $isUsed The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -410,16 +529,16 @@ abstract class CouponQuery extends ModelCriteria * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterByUsed($used = null, $comparison = null) + public function filterByIsUsed($isUsed = null, $comparison = null) { - if (is_array($used)) { + if (is_array($isUsed)) { $useMinMax = false; - if (isset($used['min'])) { - $this->addUsingAlias(CouponTableMap::USED, $used['min'], Criteria::GREATER_EQUAL); + if (isset($isUsed['min'])) { + $this->addUsingAlias(CouponTableMap::IS_USED, $isUsed['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($used['max'])) { - $this->addUsingAlias(CouponTableMap::USED, $used['max'], Criteria::LESS_EQUAL); + if (isset($isUsed['max'])) { + $this->addUsingAlias(CouponTableMap::IS_USED, $isUsed['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -430,20 +549,61 @@ abstract class CouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponTableMap::USED, $used, $comparison); + return $this->addUsingAlias(CouponTableMap::IS_USED, $isUsed, $comparison); } /** - * Filter the query on the available_since column + * Filter the query on the is_enabled column * * Example usage: * - * $query->filterByAvailableSince('2011-03-14'); // WHERE available_since = '2011-03-14' - * $query->filterByAvailableSince('now'); // WHERE available_since = '2011-03-14' - * $query->filterByAvailableSince(array('max' => 'yesterday')); // WHERE available_since > '2011-03-13' + * $query->filterByIsEnabled(1234); // WHERE is_enabled = 1234 + * $query->filterByIsEnabled(array(12, 34)); // WHERE is_enabled IN (12, 34) + * $query->filterByIsEnabled(array('min' => 12)); // WHERE is_enabled > 12 * * - * @param mixed $availableSince The value to use as filter. + * @param mixed $isEnabled The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByIsEnabled($isEnabled = null, $comparison = null) + { + if (is_array($isEnabled)) { + $useMinMax = false; + if (isset($isEnabled['min'])) { + $this->addUsingAlias(CouponTableMap::IS_ENABLED, $isEnabled['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isEnabled['max'])) { + $this->addUsingAlias(CouponTableMap::IS_ENABLED, $isEnabled['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponTableMap::IS_ENABLED, $isEnabled, $comparison); + } + + /** + * Filter the query on the expiration_date column + * + * Example usage: + * + * $query->filterByExpirationDate('2011-03-14'); // WHERE expiration_date = '2011-03-14' + * $query->filterByExpirationDate('now'); // WHERE expiration_date = '2011-03-14' + * $query->filterByExpirationDate(array('max' => 'yesterday')); // WHERE expiration_date > '2011-03-13' + * + * + * @param mixed $expirationDate The value to use as filter. * Values can be integers (unix timestamps), DateTime objects, or strings. * Empty strings are treated as NULL. * Use scalar values for equality. @@ -453,16 +613,16 @@ abstract class CouponQuery extends ModelCriteria * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterByAvailableSince($availableSince = null, $comparison = null) + public function filterByExpirationDate($expirationDate = null, $comparison = null) { - if (is_array($availableSince)) { + if (is_array($expirationDate)) { $useMinMax = false; - if (isset($availableSince['min'])) { - $this->addUsingAlias(CouponTableMap::AVAILABLE_SINCE, $availableSince['min'], Criteria::GREATER_EQUAL); + if (isset($expirationDate['min'])) { + $this->addUsingAlias(CouponTableMap::EXPIRATION_DATE, $expirationDate['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($availableSince['max'])) { - $this->addUsingAlias(CouponTableMap::AVAILABLE_SINCE, $availableSince['max'], Criteria::LESS_EQUAL); + if (isset($expirationDate['max'])) { + $this->addUsingAlias(CouponTableMap::EXPIRATION_DATE, $expirationDate['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -473,91 +633,36 @@ abstract class CouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponTableMap::AVAILABLE_SINCE, $availableSince, $comparison); + return $this->addUsingAlias(CouponTableMap::EXPIRATION_DATE, $expirationDate, $comparison); } /** - * Filter the query on the date_limit column + * Filter the query on the serialized_rules column * * Example usage: * - * $query->filterByDateLimit('2011-03-14'); // WHERE date_limit = '2011-03-14' - * $query->filterByDateLimit('now'); // WHERE date_limit = '2011-03-14' - * $query->filterByDateLimit(array('max' => 'yesterday')); // WHERE date_limit > '2011-03-13' + * $query->filterBySerializedRules('fooValue'); // WHERE serialized_rules = 'fooValue' + * $query->filterBySerializedRules('%fooValue%'); // WHERE serialized_rules LIKE '%fooValue%' * * - * @param mixed $dateLimit The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $serializedRules The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterByDateLimit($dateLimit = null, $comparison = null) + public function filterBySerializedRules($serializedRules = null, $comparison = null) { - if (is_array($dateLimit)) { - $useMinMax = false; - if (isset($dateLimit['min'])) { - $this->addUsingAlias(CouponTableMap::DATE_LIMIT, $dateLimit['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dateLimit['max'])) { - $this->addUsingAlias(CouponTableMap::DATE_LIMIT, $dateLimit['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { + if (null === $comparison) { + if (is_array($serializedRules)) { $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $serializedRules)) { + $serializedRules = str_replace('*', '%', $serializedRules); + $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(CouponTableMap::DATE_LIMIT, $dateLimit, $comparison); - } - - /** - * Filter the query on the activate column - * - * Example usage: - * - * $query->filterByActivate(1234); // WHERE activate = 1234 - * $query->filterByActivate(array(12, 34)); // WHERE activate IN (12, 34) - * $query->filterByActivate(array('min' => 12)); // WHERE activate > 12 - * - * - * @param mixed $activate The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCouponQuery The current query, for fluid interface - */ - public function filterByActivate($activate = null, $comparison = null) - { - if (is_array($activate)) { - $useMinMax = false; - if (isset($activate['min'])) { - $this->addUsingAlias(CouponTableMap::ACTIVATE, $activate['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($activate['max'])) { - $this->addUsingAlias(CouponTableMap::ACTIVATE, $activate['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponTableMap::ACTIVATE, $activate, $comparison); + return $this->addUsingAlias(CouponTableMap::SERIALIZED_RULES, $serializedRules, $comparison); } /** @@ -647,40 +752,81 @@ abstract class CouponQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\CouponRule object + * Filter the query on the version column * - * @param \Thelia\Model\CouponRule|ObjectCollection $couponRule the related object to use as filter + * Example usage: + * + * $query->filterByVersion(1234); // WHERE version = 1234 + * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * + * + * @param mixed $version The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByVersion($version = null, $comparison = null) + { + if (is_array($version)) { + $useMinMax = false; + if (isset($version['min'])) { + $this->addUsingAlias(CouponTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($version['max'])) { + $this->addUsingAlias(CouponTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponTableMap::VERSION, $version, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\CouponOrder object + * + * @param \Thelia\Model\CouponOrder|ObjectCollection $couponOrder the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterByCouponRule($couponRule, $comparison = null) + public function filterByCouponOrder($couponOrder, $comparison = null) { - if ($couponRule instanceof \Thelia\Model\CouponRule) { + if ($couponOrder instanceof \Thelia\Model\CouponOrder) { return $this - ->addUsingAlias(CouponTableMap::ID, $couponRule->getCouponId(), $comparison); - } elseif ($couponRule instanceof ObjectCollection) { + ->addUsingAlias(CouponTableMap::CODE, $couponOrder->getCode(), $comparison); + } elseif ($couponOrder instanceof ObjectCollection) { return $this - ->useCouponRuleQuery() - ->filterByPrimaryKeys($couponRule->getPrimaryKeys()) + ->useCouponOrderQuery() + ->filterByPrimaryKeys($couponOrder->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByCouponRule() only accepts arguments of type \Thelia\Model\CouponRule or Collection'); + throw new PropelException('filterByCouponOrder() only accepts arguments of type \Thelia\Model\CouponOrder or Collection'); } } /** - * Adds a JOIN clause to the query using the CouponRule relation + * Adds a JOIN clause to the query using the CouponOrder relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildCouponQuery The current query, for fluid interface */ - public function joinCouponRule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinCouponOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CouponRule'); + $relationMap = $tableMap->getRelation('CouponOrder'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -695,14 +841,14 @@ abstract class CouponQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'CouponRule'); + $this->addJoinObject($join, 'CouponOrder'); } return $this; } /** - * Use the CouponRule relation CouponRule object + * Use the CouponOrder relation CouponOrder object * * @see useQuery() * @@ -710,13 +856,159 @@ abstract class CouponQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\CouponRuleQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\CouponOrderQuery A secondary query class using the current class as primary query */ - public function useCouponRuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useCouponOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinCouponRule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CouponRule', '\Thelia\Model\CouponRuleQuery'); + ->joinCouponOrder($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CouponOrder', '\Thelia\Model\CouponOrderQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\CouponI18n object + * + * @param \Thelia\Model\CouponI18n|ObjectCollection $couponI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByCouponI18n($couponI18n, $comparison = null) + { + if ($couponI18n instanceof \Thelia\Model\CouponI18n) { + return $this + ->addUsingAlias(CouponTableMap::ID, $couponI18n->getId(), $comparison); + } elseif ($couponI18n instanceof ObjectCollection) { + return $this + ->useCouponI18nQuery() + ->filterByPrimaryKeys($couponI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCouponI18n() only accepts arguments of type \Thelia\Model\CouponI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CouponI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function joinCouponI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CouponI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CouponI18n'); + } + + return $this; + } + + /** + * Use the CouponI18n relation CouponI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CouponI18nQuery A secondary query class using the current class as primary query + */ + public function useCouponI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinCouponI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CouponI18n', '\Thelia\Model\CouponI18nQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\CouponVersion object + * + * @param \Thelia\Model\CouponVersion|ObjectCollection $couponVersion the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByCouponVersion($couponVersion, $comparison = null) + { + if ($couponVersion instanceof \Thelia\Model\CouponVersion) { + return $this + ->addUsingAlias(CouponTableMap::ID, $couponVersion->getId(), $comparison); + } elseif ($couponVersion instanceof ObjectCollection) { + return $this + ->useCouponVersionQuery() + ->filterByPrimaryKeys($couponVersion->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCouponVersion() only accepts arguments of type \Thelia\Model\CouponVersion or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CouponVersion relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function joinCouponVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CouponVersion'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CouponVersion'); + } + + return $this; + } + + /** + * Use the CouponVersion relation CouponVersion object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CouponVersionQuery A secondary query class using the current class as primary query + */ + public function useCouponVersionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCouponVersion($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CouponVersion', '\Thelia\Model\CouponVersionQuery'); } /** @@ -876,4 +1168,89 @@ abstract class CouponQuery extends ModelCriteria return $this->addAscendingOrderByColumn(CouponTableMap::CREATED_AT); } + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'CouponI18n'; + + return $this + ->joinCouponI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('CouponI18n'); + $this->with['CouponI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCouponI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CouponI18n', '\Thelia\Model\CouponI18nQuery'); + } + + // versionable behavior + + /** + * Checks whether versioning is enabled + * + * @return boolean + */ + static public function isVersioningEnabled() + { + return self::$isVersioningEnabled; + } + + /** + * Enables versioning + */ + static public function enableVersioning() + { + self::$isVersioningEnabled = true; + } + + /** + * Disables versioning + */ + static public function disableVersioning() + { + self::$isVersioningEnabled = false; + } + } // CouponQuery diff --git a/core/lib/Thelia/Model/Base/Order.php b/core/lib/Thelia/Model/Base/Order.php index 6932ec6c4..3c47ce415 100755 --- a/core/lib/Thelia/Model/Base/Order.php +++ b/core/lib/Thelia/Model/Base/Order.php @@ -2842,6 +2842,31 @@ abstract class Order implements ActiveRecordInterface return $this; } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Order is new, it will return + * an empty collection; or if this Order has previously + * been saved, it will retrieve related CouponOrders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Order. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildCouponOrder[] List of ChildCouponOrder objects + */ + public function getCouponOrdersJoinCoupon($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildCouponOrderQuery::create(null, $criteria); + $query->joinWith('Coupon', $joinBehavior); + + return $this->getCouponOrders($query, $con); + } + /** * Clears the current object and sets all attributes to their default values */ diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php index 867f7dd50..e66c2fe17 100755 --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -23,11 +23,11 @@ use Thelia\Model\CartItem as ChildCartItem; use Thelia\Model\CartItemQuery as ChildCartItemQuery; use Thelia\Model\Category as ChildCategory; use Thelia\Model\CategoryQuery as ChildCategoryQuery; -use Thelia\Model\ContentAssoc as ChildContentAssoc; -use Thelia\Model\ContentAssocQuery as ChildContentAssocQuery; use Thelia\Model\FeatureProduct as ChildFeatureProduct; use Thelia\Model\FeatureProductQuery as ChildFeatureProductQuery; use Thelia\Model\Product as ChildProduct; +use Thelia\Model\ProductAssociatedContent as ChildProductAssociatedContent; +use Thelia\Model\ProductAssociatedContentQuery as ChildProductAssociatedContentQuery; use Thelia\Model\ProductCategory as ChildProductCategory; use Thelia\Model\ProductCategoryQuery as ChildProductCategoryQuery; use Thelia\Model\ProductDocument as ChildProductDocument; @@ -167,12 +167,6 @@ abstract class Product implements ActiveRecordInterface protected $collProductSaleElementss; protected $collProductSaleElementssPartial; - /** - * @var ObjectCollection|ChildContentAssoc[] Collection to store aggregation of ChildContentAssoc objects. - */ - protected $collContentAssocs; - protected $collContentAssocsPartial; - /** * @var ObjectCollection|ChildProductImage[] Collection to store aggregation of ChildProductImage objects. */ @@ -209,6 +203,12 @@ abstract class Product implements ActiveRecordInterface protected $collCartItems; protected $collCartItemsPartial; + /** + * @var ObjectCollection|ChildProductAssociatedContent[] Collection to store aggregation of ChildProductAssociatedContent objects. + */ + protected $collProductAssociatedContents; + protected $collProductAssociatedContentsPartial; + /** * @var ObjectCollection|ChildProductI18n[] Collection to store aggregation of ChildProductI18n objects. */ @@ -302,12 +302,6 @@ abstract class Product implements ActiveRecordInterface */ protected $productSaleElementssScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $contentAssocsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -344,6 +338,12 @@ abstract class Product implements ActiveRecordInterface */ protected $cartItemsScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $productAssociatedContentsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -1137,8 +1137,6 @@ abstract class Product implements ActiveRecordInterface $this->collProductSaleElementss = null; - $this->collContentAssocs = null; - $this->collProductImages = null; $this->collProductDocuments = null; @@ -1151,6 +1149,8 @@ abstract class Product implements ActiveRecordInterface $this->collCartItems = null; + $this->collProductAssociatedContents = null; + $this->collProductI18ns = null; $this->collProductVersions = null; @@ -1447,23 +1447,6 @@ abstract class Product implements ActiveRecordInterface } } - if ($this->contentAssocsScheduledForDeletion !== null) { - if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - \Thelia\Model\ContentAssocQuery::create() - ->filterByPrimaryKeys($this->contentAssocsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->contentAssocsScheduledForDeletion = null; - } - } - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->productImagesScheduledForDeletion !== null) { if (!$this->productImagesScheduledForDeletion->isEmpty()) { \Thelia\Model\ProductImageQuery::create() @@ -1566,6 +1549,23 @@ abstract class Product implements ActiveRecordInterface } } + if ($this->productAssociatedContentsScheduledForDeletion !== null) { + if (!$this->productAssociatedContentsScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProductAssociatedContentQuery::create() + ->filterByPrimaryKeys($this->productAssociatedContentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->productAssociatedContentsScheduledForDeletion = null; + } + } + + if ($this->collProductAssociatedContents !== null) { + foreach ($this->collProductAssociatedContents as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->productI18nsScheduledForDeletion !== null) { if (!$this->productI18nsScheduledForDeletion->isEmpty()) { \Thelia\Model\ProductI18nQuery::create() @@ -1848,9 +1848,6 @@ abstract class Product implements ActiveRecordInterface if (null !== $this->collProductSaleElementss) { $result['ProductSaleElementss'] = $this->collProductSaleElementss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collContentAssocs) { - $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collProductImages) { $result['ProductImages'] = $this->collProductImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1869,6 +1866,9 @@ abstract class Product implements ActiveRecordInterface if (null !== $this->collCartItems) { $result['CartItems'] = $this->collCartItems->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collProductAssociatedContents) { + $result['ProductAssociatedContents'] = $this->collProductAssociatedContents->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collProductI18ns) { $result['ProductI18ns'] = $this->collProductI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -2090,12 +2090,6 @@ abstract class Product implements ActiveRecordInterface } } - foreach ($this->getContentAssocs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentAssoc($relObj->copy($deepCopy)); - } - } - foreach ($this->getProductImages() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addProductImage($relObj->copy($deepCopy)); @@ -2132,6 +2126,12 @@ abstract class Product implements ActiveRecordInterface } } + foreach ($this->getProductAssociatedContents() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addProductAssociatedContent($relObj->copy($deepCopy)); + } + } + foreach ($this->getProductI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addProductI18n($relObj->copy($deepCopy)); @@ -2245,9 +2245,6 @@ abstract class Product implements ActiveRecordInterface if ('ProductSaleElements' == $relationName) { return $this->initProductSaleElementss(); } - if ('ContentAssoc' == $relationName) { - return $this->initContentAssocs(); - } if ('ProductImage' == $relationName) { return $this->initProductImages(); } @@ -2266,6 +2263,9 @@ abstract class Product implements ActiveRecordInterface if ('CartItem' == $relationName) { return $this->initCartItems(); } + if ('ProductAssociatedContent' == $relationName) { + return $this->initProductAssociatedContents(); + } if ('ProductI18n' == $relationName) { return $this->initProductI18ns(); } @@ -3006,274 +3006,6 @@ abstract class Product implements ActiveRecordInterface return $this; } - /** - * Clears out the collContentAssocs collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addContentAssocs() - */ - public function clearContentAssocs() - { - $this->collContentAssocs = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collContentAssocs collection loaded partially. - */ - public function resetPartialContentAssocs($v = true) - { - $this->collContentAssocsPartial = $v; - } - - /** - * Initializes the collContentAssocs collection. - * - * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentAssocs($overrideExisting = true) - { - if (null !== $this->collContentAssocs && !$overrideExisting) { - return; - } - $this->collContentAssocs = new ObjectCollection(); - $this->collContentAssocs->setModel('\Thelia\Model\ContentAssoc'); - } - - /** - * Gets an array of ChildContentAssoc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildProduct is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - * @throws PropelException - */ - public function getContentAssocs($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - // return empty collection - $this->initContentAssocs(); - } else { - $collContentAssocs = ChildContentAssocQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { - $this->initContentAssocs(false); - - foreach ($collContentAssocs as $obj) { - if (false == $this->collContentAssocs->contains($obj)) { - $this->collContentAssocs->append($obj); - } - } - - $this->collContentAssocsPartial = true; - } - - $collContentAssocs->getInternalIterator()->rewind(); - - return $collContentAssocs; - } - - if ($partial && $this->collContentAssocs) { - foreach ($this->collContentAssocs as $obj) { - if ($obj->isNew()) { - $collContentAssocs[] = $obj; - } - } - } - - $this->collContentAssocs = $collContentAssocs; - $this->collContentAssocsPartial = false; - } - } - - return $this->collContentAssocs; - } - - /** - * Sets a collection of ContentAssoc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $contentAssocs A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildProduct The current object (for fluent API support) - */ - public function setContentAssocs(Collection $contentAssocs, ConnectionInterface $con = null) - { - $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - - - $this->contentAssocsScheduledForDeletion = $contentAssocsToDelete; - - foreach ($contentAssocsToDelete as $contentAssocRemoved) { - $contentAssocRemoved->setProduct(null); - } - - $this->collContentAssocs = null; - foreach ($contentAssocs as $contentAssoc) { - $this->addContentAssoc($contentAssoc); - } - - $this->collContentAssocs = $contentAssocs; - $this->collContentAssocsPartial = false; - - return $this; - } - - /** - * Returns the number of related ContentAssoc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related ContentAssoc objects. - * @throws PropelException - */ - public function countContentAssocs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getContentAssocs()); - } - - $query = ChildContentAssocQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - - return count($this->collContentAssocs); - } - - /** - * Method called to associate a ChildContentAssoc object to this object - * through the ChildContentAssoc foreign key attribute. - * - * @param ChildContentAssoc $l ChildContentAssoc - * @return \Thelia\Model\Product The current object (for fluent API support) - */ - public function addContentAssoc(ChildContentAssoc $l) - { - if ($this->collContentAssocs === null) { - $this->initContentAssocs(); - $this->collContentAssocsPartial = true; - } - - if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddContentAssoc($l); - } - - return $this; - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to add. - */ - protected function doAddContentAssoc($contentAssoc) - { - $this->collContentAssocs[]= $contentAssoc; - $contentAssoc->setProduct($this); - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to remove. - * @return ChildProduct The current object (for fluent API support) - */ - public function removeContentAssoc($contentAssoc) - { - if ($this->getContentAssocs()->contains($contentAssoc)) { - $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc)); - if (null === $this->contentAssocsScheduledForDeletion) { - $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs; - $this->contentAssocsScheduledForDeletion->clear(); - } - $this->contentAssocsScheduledForDeletion[]= $contentAssoc; - $contentAssoc->setProduct(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - */ - public function getContentAssocsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildContentAssocQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); - - return $this->getContentAssocs($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - */ - public function getContentAssocsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildContentAssocQuery::create(null, $criteria); - $query->joinWith('Content', $joinBehavior); - - return $this->getContentAssocs($query, $con); - } - /** * Clears out the collProductImages collection * @@ -4707,6 +4439,249 @@ abstract class Product implements ActiveRecordInterface return $this->getCartItems($query, $con); } + /** + * Clears out the collProductAssociatedContents collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addProductAssociatedContents() + */ + public function clearProductAssociatedContents() + { + $this->collProductAssociatedContents = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collProductAssociatedContents collection loaded partially. + */ + public function resetPartialProductAssociatedContents($v = true) + { + $this->collProductAssociatedContentsPartial = $v; + } + + /** + * Initializes the collProductAssociatedContents collection. + * + * By default this just sets the collProductAssociatedContents collection to an empty array (like clearcollProductAssociatedContents()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initProductAssociatedContents($overrideExisting = true) + { + if (null !== $this->collProductAssociatedContents && !$overrideExisting) { + return; + } + $this->collProductAssociatedContents = new ObjectCollection(); + $this->collProductAssociatedContents->setModel('\Thelia\Model\ProductAssociatedContent'); + } + + /** + * Gets an array of ChildProductAssociatedContent objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildProduct is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProductAssociatedContent[] List of ChildProductAssociatedContent objects + * @throws PropelException + */ + public function getProductAssociatedContents($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collProductAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collProductAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductAssociatedContents) { + // return empty collection + $this->initProductAssociatedContents(); + } else { + $collProductAssociatedContents = ChildProductAssociatedContentQuery::create(null, $criteria) + ->filterByProduct($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collProductAssociatedContentsPartial && count($collProductAssociatedContents)) { + $this->initProductAssociatedContents(false); + + foreach ($collProductAssociatedContents as $obj) { + if (false == $this->collProductAssociatedContents->contains($obj)) { + $this->collProductAssociatedContents->append($obj); + } + } + + $this->collProductAssociatedContentsPartial = true; + } + + $collProductAssociatedContents->getInternalIterator()->rewind(); + + return $collProductAssociatedContents; + } + + if ($partial && $this->collProductAssociatedContents) { + foreach ($this->collProductAssociatedContents as $obj) { + if ($obj->isNew()) { + $collProductAssociatedContents[] = $obj; + } + } + } + + $this->collProductAssociatedContents = $collProductAssociatedContents; + $this->collProductAssociatedContentsPartial = false; + } + } + + return $this->collProductAssociatedContents; + } + + /** + * Sets a collection of ProductAssociatedContent objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $productAssociatedContents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) + */ + public function setProductAssociatedContents(Collection $productAssociatedContents, ConnectionInterface $con = null) + { + $productAssociatedContentsToDelete = $this->getProductAssociatedContents(new Criteria(), $con)->diff($productAssociatedContents); + + + $this->productAssociatedContentsScheduledForDeletion = $productAssociatedContentsToDelete; + + foreach ($productAssociatedContentsToDelete as $productAssociatedContentRemoved) { + $productAssociatedContentRemoved->setProduct(null); + } + + $this->collProductAssociatedContents = null; + foreach ($productAssociatedContents as $productAssociatedContent) { + $this->addProductAssociatedContent($productAssociatedContent); + } + + $this->collProductAssociatedContents = $productAssociatedContents; + $this->collProductAssociatedContentsPartial = false; + + return $this; + } + + /** + * Returns the number of related ProductAssociatedContent objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related ProductAssociatedContent objects. + * @throws PropelException + */ + public function countProductAssociatedContents(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collProductAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collProductAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductAssociatedContents) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getProductAssociatedContents()); + } + + $query = ChildProductAssociatedContentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProduct($this) + ->count($con); + } + + return count($this->collProductAssociatedContents); + } + + /** + * Method called to associate a ChildProductAssociatedContent object to this object + * through the ChildProductAssociatedContent foreign key attribute. + * + * @param ChildProductAssociatedContent $l ChildProductAssociatedContent + * @return \Thelia\Model\Product The current object (for fluent API support) + */ + public function addProductAssociatedContent(ChildProductAssociatedContent $l) + { + if ($this->collProductAssociatedContents === null) { + $this->initProductAssociatedContents(); + $this->collProductAssociatedContentsPartial = true; + } + + if (!in_array($l, $this->collProductAssociatedContents->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProductAssociatedContent($l); + } + + return $this; + } + + /** + * @param ProductAssociatedContent $productAssociatedContent The productAssociatedContent object to add. + */ + protected function doAddProductAssociatedContent($productAssociatedContent) + { + $this->collProductAssociatedContents[]= $productAssociatedContent; + $productAssociatedContent->setProduct($this); + } + + /** + * @param ProductAssociatedContent $productAssociatedContent The productAssociatedContent object to remove. + * @return ChildProduct The current object (for fluent API support) + */ + public function removeProductAssociatedContent($productAssociatedContent) + { + if ($this->getProductAssociatedContents()->contains($productAssociatedContent)) { + $this->collProductAssociatedContents->remove($this->collProductAssociatedContents->search($productAssociatedContent)); + if (null === $this->productAssociatedContentsScheduledForDeletion) { + $this->productAssociatedContentsScheduledForDeletion = clone $this->collProductAssociatedContents; + $this->productAssociatedContentsScheduledForDeletion->clear(); + } + $this->productAssociatedContentsScheduledForDeletion[]= clone $productAssociatedContent; + $productAssociatedContent->setProduct(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related ProductAssociatedContents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildProductAssociatedContent[] List of ChildProductAssociatedContent objects + */ + public function getProductAssociatedContentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildProductAssociatedContentQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); + + return $this->getProductAssociatedContents($query, $con); + } + /** * Clears out the collProductI18ns collection * @@ -5752,11 +5727,6 @@ abstract class Product implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collContentAssocs) { - foreach ($this->collContentAssocs as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collProductImages) { foreach ($this->collProductImages as $o) { $o->clearAllReferences($deep); @@ -5787,6 +5757,11 @@ abstract class Product implements ActiveRecordInterface $o->clearAllReferences($deep); } } + if ($this->collProductAssociatedContents) { + foreach ($this->collProductAssociatedContents as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collProductI18ns) { foreach ($this->collProductI18ns as $o) { $o->clearAllReferences($deep); @@ -5830,10 +5805,6 @@ abstract class Product implements ActiveRecordInterface $this->collProductSaleElementss->clearIterator(); } $this->collProductSaleElementss = null; - if ($this->collContentAssocs instanceof Collection) { - $this->collContentAssocs->clearIterator(); - } - $this->collContentAssocs = null; if ($this->collProductImages instanceof Collection) { $this->collProductImages->clearIterator(); } @@ -5858,6 +5829,10 @@ abstract class Product implements ActiveRecordInterface $this->collCartItems->clearIterator(); } $this->collCartItems = null; + if ($this->collProductAssociatedContents instanceof Collection) { + $this->collProductAssociatedContents->clearIterator(); + } + $this->collProductAssociatedContents = null; if ($this->collProductI18ns instanceof Collection) { $this->collProductI18ns->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/ProductQuery.php b/core/lib/Thelia/Model/Base/ProductQuery.php index 9d4685f38..8a4d4ed18 100755 --- a/core/lib/Thelia/Model/Base/ProductQuery.php +++ b/core/lib/Thelia/Model/Base/ProductQuery.php @@ -64,10 +64,6 @@ use Thelia\Model\Map\ProductTableMap; * @method ChildProductQuery rightJoinProductSaleElements($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductSaleElements relation * @method ChildProductQuery innerJoinProductSaleElements($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductSaleElements relation * - * @method ChildProductQuery leftJoinContentAssoc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentAssoc relation - * @method ChildProductQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation - * @method ChildProductQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation - * * @method ChildProductQuery leftJoinProductImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductImage relation * @method ChildProductQuery rightJoinProductImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductImage relation * @method ChildProductQuery innerJoinProductImage($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductImage relation @@ -92,6 +88,10 @@ use Thelia\Model\Map\ProductTableMap; * @method ChildProductQuery rightJoinCartItem($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CartItem relation * @method ChildProductQuery innerJoinCartItem($relationAlias = null) Adds a INNER JOIN clause to the query using the CartItem relation * + * @method ChildProductQuery leftJoinProductAssociatedContent($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductAssociatedContent relation + * @method ChildProductQuery rightJoinProductAssociatedContent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductAssociatedContent relation + * @method ChildProductQuery innerJoinProductAssociatedContent($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductAssociatedContent relation + * * @method ChildProductQuery leftJoinProductI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductI18n relation * @method ChildProductQuery rightJoinProductI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductI18n relation * @method ChildProductQuery innerJoinProductI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductI18n relation @@ -996,79 +996,6 @@ abstract class ProductQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'ProductSaleElements', '\Thelia\Model\ProductSaleElementsQuery'); } - /** - * Filter the query by a related \Thelia\Model\ContentAssoc object - * - * @param \Thelia\Model\ContentAssoc|ObjectCollection $contentAssoc the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildProductQuery The current query, for fluid interface - */ - public function filterByContentAssoc($contentAssoc, $comparison = null) - { - if ($contentAssoc instanceof \Thelia\Model\ContentAssoc) { - return $this - ->addUsingAlias(ProductTableMap::ID, $contentAssoc->getProductId(), $comparison); - } elseif ($contentAssoc instanceof ObjectCollection) { - return $this - ->useContentAssocQuery() - ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type \Thelia\Model\ContentAssoc or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentAssoc relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildProductQuery The current query, for fluid interface - */ - public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentAssoc'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentAssoc'); - } - - return $this; - } - - /** - * Use the ContentAssoc relation ContentAssoc object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query - */ - public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContentAssoc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); - } - /** * Filter the query by a related \Thelia\Model\ProductImage object * @@ -1507,6 +1434,79 @@ abstract class ProductQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'CartItem', '\Thelia\Model\CartItemQuery'); } + /** + * Filter the query by a related \Thelia\Model\ProductAssociatedContent object + * + * @param \Thelia\Model\ProductAssociatedContent|ObjectCollection $productAssociatedContent the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductQuery The current query, for fluid interface + */ + public function filterByProductAssociatedContent($productAssociatedContent, $comparison = null) + { + if ($productAssociatedContent instanceof \Thelia\Model\ProductAssociatedContent) { + return $this + ->addUsingAlias(ProductTableMap::ID, $productAssociatedContent->getProductId(), $comparison); + } elseif ($productAssociatedContent instanceof ObjectCollection) { + return $this + ->useProductAssociatedContentQuery() + ->filterByPrimaryKeys($productAssociatedContent->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByProductAssociatedContent() only accepts arguments of type \Thelia\Model\ProductAssociatedContent or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ProductAssociatedContent relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProductQuery The current query, for fluid interface + */ + public function joinProductAssociatedContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ProductAssociatedContent'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ProductAssociatedContent'); + } + + return $this; + } + + /** + * Use the ProductAssociatedContent relation ProductAssociatedContent object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductAssociatedContentQuery A secondary query class using the current class as primary query + */ + public function useProductAssociatedContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProductAssociatedContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductAssociatedContent', '\Thelia\Model\ProductAssociatedContentQuery'); + } + /** * Filter the query by a related \Thelia\Model\ProductI18n object * diff --git a/core/lib/Thelia/Model/ContentAssoc.php b/core/lib/Thelia/Model/ContentAssoc.php deleted file mode 100755 index 0723ef537..000000000 --- a/core/lib/Thelia/Model/ContentAssoc.php +++ /dev/null @@ -1,9 +0,0 @@ -addRelation('ProductCategory', '\\Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'ProductCategories'); $this->addRelation('FeatureCategory', '\\Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'FeatureCategories'); $this->addRelation('AttributeCategory', '\\Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'AttributeCategories'); - $this->addRelation('ContentAssoc', '\\Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); $this->addRelation('CategoryImage', '\\Thelia\\Model\\CategoryImage', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryImages'); $this->addRelation('CategoryDocument', '\\Thelia\\Model\\CategoryDocument', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryDocuments'); + $this->addRelation('CategoryAssociatedContent', '\\Thelia\\Model\\CategoryAssociatedContent', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryAssociatedContents'); $this->addRelation('CategoryI18n', '\\Thelia\\Model\\CategoryI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryI18ns'); $this->addRelation('CategoryVersion', '\\Thelia\\Model\\CategoryVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryVersions'); $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Products'); @@ -228,10 +228,10 @@ class CategoryTableMap extends TableMap ProductCategoryTableMap::clearInstancePool(); FeatureCategoryTableMap::clearInstancePool(); AttributeCategoryTableMap::clearInstancePool(); - ContentAssocTableMap::clearInstancePool(); RewritingTableMap::clearInstancePool(); CategoryImageTableMap::clearInstancePool(); CategoryDocumentTableMap::clearInstancePool(); + CategoryAssociatedContentTableMap::clearInstancePool(); CategoryI18nTableMap::clearInstancePool(); CategoryVersionTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/ContentAssocTableMap.php b/core/lib/Thelia/Model/Map/ContentAssocTableMap.php deleted file mode 100755 index b080bea83..000000000 --- a/core/lib/Thelia/Model/Map/ContentAssocTableMap.php +++ /dev/null @@ -1,465 +0,0 @@ - array('Id', 'CategoryId', 'ProductId', 'ContentId', 'Position', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'categoryId', 'productId', 'contentId', 'position', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ContentAssocTableMap::ID, ContentAssocTableMap::CATEGORY_ID, ContentAssocTableMap::PRODUCT_ID, ContentAssocTableMap::CONTENT_ID, ContentAssocTableMap::POSITION, ContentAssocTableMap::CREATED_AT, ContentAssocTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CATEGORY_ID', 'PRODUCT_ID', 'CONTENT_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'category_id', 'product_id', 'content_id', 'position', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'CategoryId' => 1, 'ProductId' => 2, 'ContentId' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'categoryId' => 1, 'productId' => 2, 'contentId' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - self::TYPE_COLNAME => array(ContentAssocTableMap::ID => 0, ContentAssocTableMap::CATEGORY_ID => 1, ContentAssocTableMap::PRODUCT_ID => 2, ContentAssocTableMap::CONTENT_ID => 3, ContentAssocTableMap::POSITION => 4, ContentAssocTableMap::CREATED_AT => 5, ContentAssocTableMap::UPDATED_AT => 6, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CATEGORY_ID' => 1, 'PRODUCT_ID' => 2, 'CONTENT_ID' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - self::TYPE_FIELDNAME => array('id' => 0, 'category_id' => 1, 'product_id' => 2, 'content_id' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * Initialize the table attributes and columns - * Relations are not initialized by this method since they are lazy loaded - * - * @return void - * @throws PropelException - */ - public function initialize() - { - // attributes - $this->setName('content_assoc'); - $this->setPhpName('ContentAssoc'); - $this->setClassName('\\Thelia\\Model\\ContentAssoc'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null); - $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null); - $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), - ); - } // getBehaviors() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - */ - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - // If the PK cannot be derived from the row, return NULL. - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { - return null; - } - - return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - * - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - - return (int) $row[ - $indexType == TableMap::TYPE_NUM - ? 0 + $offset - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) - ]; - } - - /** - * The class that the tableMap will make instances of. - * - * If $withPrefix is true, the returned path - * uses a dot-path notation which is translated into a path - * relative to a location on the PHP include_path. - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') - * - * @param boolean $withPrefix Whether or not to return the path with the class name - * @return string path.to.ClassName - */ - public static function getOMClass($withPrefix = true) - { - return $withPrefix ? ContentAssocTableMap::CLASS_DEFAULT : ContentAssocTableMap::OM_CLASS; - } - - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row row returned by DataFetcher->fetch(). - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (ContentAssoc object, last column rank) - */ - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - $key = ContentAssocTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = ContentAssocTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + ContentAssocTableMap::NUM_HYDRATE_COLUMNS; - } else { - $cls = ContentAssocTableMap::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $offset, false, $indexType); - ContentAssocTableMap::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @param DataFetcherInterface $dataFetcher - * @return array - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(DataFetcherInterface $dataFetcher) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = static::getOMClass(false); - // populate the object(s) - while ($row = $dataFetcher->fetch()) { - $key = ContentAssocTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = ContentAssocTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - ContentAssocTableMap::addInstanceToPool($obj, $key); - } // if key exists - } - - return $results; - } - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(ContentAssocTableMap::ID); - $criteria->addSelectColumn(ContentAssocTableMap::CATEGORY_ID); - $criteria->addSelectColumn(ContentAssocTableMap::PRODUCT_ID); - $criteria->addSelectColumn(ContentAssocTableMap::CONTENT_ID); - $criteria->addSelectColumn(ContentAssocTableMap::POSITION); - $criteria->addSelectColumn(ContentAssocTableMap::CREATED_AT); - $criteria->addSelectColumn(ContentAssocTableMap::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); - $criteria->addSelectColumn($alias . '.PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.CONTENT_ID'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - } - } - - /** - * Returns the TableMap related to this object. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getServiceContainer()->getDatabaseMap(ContentAssocTableMap::DATABASE_NAME)->getTable(ContentAssocTableMap::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this tableMap class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentAssocTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(ContentAssocTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new ContentAssocTableMap()); - } - } - - /** - * Performs a DELETE on the database, given a ContentAssoc or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ContentAssoc object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - // rename for clarity - $criteria = $values; - } elseif ($values instanceof \Thelia\Model\ContentAssoc) { // it's a model object - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(ContentAssocTableMap::DATABASE_NAME); - $criteria->add(ContentAssocTableMap::ID, (array) $values, Criteria::IN); - } - - $query = ContentAssocQuery::create()->mergeWith($criteria); - - if ($values instanceof Criteria) { ContentAssocTableMap::clearInstancePool(); - } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { ContentAssocTableMap::removeInstanceFromPool($singleval); - } - } - - return $query->delete($con); - } - - /** - * Deletes all rows from the content_assoc table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public static function doDeleteAll(ConnectionInterface $con = null) - { - return ContentAssocQuery::create()->doDeleteAll($con); - } - - /** - * Performs an INSERT on the database, given a ContentAssoc or Criteria object. - * - * @param mixed $criteria Criteria or ContentAssoc object containing data that is used to create the INSERT statement. - * @param ConnectionInterface $con the ConnectionInterface connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($criteria, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME); - } - - if ($criteria instanceof Criteria) { - $criteria = clone $criteria; // rename for clarity - } else { - $criteria = $criteria->buildCriteria(); // build Criteria from ContentAssoc object - } - - if ($criteria->containsKey(ContentAssocTableMap::ID) && $criteria->keyContainsValue(ContentAssocTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ContentAssocTableMap::ID.')'); - } - - - // Set the correct dbName - $query = ContentAssocQuery::create()->mergeWith($criteria); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = $query->doInsert($con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - -} // ContentAssocTableMap -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -ContentAssocTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ContentTableMap.php b/core/lib/Thelia/Model/Map/ContentTableMap.php index 724c839a1..5b6787a28 100755 --- a/core/lib/Thelia/Model/Map/ContentTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentTableMap.php @@ -184,11 +184,12 @@ class ContentTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('ContentAssoc', '\\Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); $this->addRelation('ContentFolder', '\\Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders'); $this->addRelation('ContentImage', '\\Thelia\\Model\\ContentImage', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentImages'); $this->addRelation('ContentDocument', '\\Thelia\\Model\\ContentDocument', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentDocuments'); + $this->addRelation('ProductAssociatedContent', '\\Thelia\\Model\\ProductAssociatedContent', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ProductAssociatedContents'); + $this->addRelation('CategoryAssociatedContent', '\\Thelia\\Model\\CategoryAssociatedContent', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'CategoryAssociatedContents'); $this->addRelation('ContentI18n', '\\Thelia\\Model\\ContentI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ContentI18ns'); $this->addRelation('ContentVersion', '\\Thelia\\Model\\ContentVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ContentVersions'); $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Folders'); @@ -215,11 +216,12 @@ class ContentTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ContentAssocTableMap::clearInstancePool(); RewritingTableMap::clearInstancePool(); ContentFolderTableMap::clearInstancePool(); ContentImageTableMap::clearInstancePool(); ContentDocumentTableMap::clearInstancePool(); + ProductAssociatedContentTableMap::clearInstancePool(); + CategoryAssociatedContentTableMap::clearInstancePool(); ContentI18nTableMap::clearInstancePool(); ContentVersionTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/CouponOrderTableMap.php b/core/lib/Thelia/Model/Map/CouponOrderTableMap.php index 9d91ef068..1826bcb70 100755 --- a/core/lib/Thelia/Model/Map/CouponOrderTableMap.php +++ b/core/lib/Thelia/Model/Map/CouponOrderTableMap.php @@ -152,7 +152,7 @@ class CouponOrderTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); + $this->addForeignKey('CODE', 'Code', 'VARCHAR', 'coupon', 'CODE', true, 45, null); $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); @@ -164,6 +164,7 @@ class CouponOrderTableMap extends TableMap public function buildRelations() { $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Coupon', '\\Thelia\\Model\\Coupon', RelationMap::MANY_TO_ONE, array('code' => 'code', ), null, null); } // buildRelations() /** diff --git a/core/lib/Thelia/Model/Map/CouponTableMap.php b/core/lib/Thelia/Model/Map/CouponTableMap.php index d1ff79ac0..7e576a585 100755 --- a/core/lib/Thelia/Model/Map/CouponTableMap.php +++ b/core/lib/Thelia/Model/Map/CouponTableMap.php @@ -57,7 +57,7 @@ class CouponTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 10; + const NUM_COLUMNS = 14; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CouponTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 10; + const NUM_HYDRATE_COLUMNS = 14; /** * the column name for the ID field @@ -80,9 +80,24 @@ class CouponTableMap extends TableMap const CODE = 'coupon.CODE'; /** - * the column name for the ACTION field + * the column name for the TYPE field */ - const ACTION = 'coupon.ACTION'; + const TYPE = 'coupon.TYPE'; + + /** + * the column name for the TITLE field + */ + const TITLE = 'coupon.TITLE'; + + /** + * the column name for the SHORT_DESCRIPTION field + */ + const SHORT_DESCRIPTION = 'coupon.SHORT_DESCRIPTION'; + + /** + * the column name for the DESCRIPTION field + */ + const DESCRIPTION = 'coupon.DESCRIPTION'; /** * the column name for the VALUE field @@ -90,24 +105,24 @@ class CouponTableMap extends TableMap const VALUE = 'coupon.VALUE'; /** - * the column name for the USED field + * the column name for the IS_USED field */ - const USED = 'coupon.USED'; + const IS_USED = 'coupon.IS_USED'; /** - * the column name for the AVAILABLE_SINCE field + * the column name for the IS_ENABLED field */ - const AVAILABLE_SINCE = 'coupon.AVAILABLE_SINCE'; + const IS_ENABLED = 'coupon.IS_ENABLED'; /** - * the column name for the DATE_LIMIT field + * the column name for the EXPIRATION_DATE field */ - const DATE_LIMIT = 'coupon.DATE_LIMIT'; + const EXPIRATION_DATE = 'coupon.EXPIRATION_DATE'; /** - * the column name for the ACTIVATE field + * the column name for the SERIALIZED_RULES field */ - const ACTIVATE = 'coupon.ACTIVATE'; + const SERIALIZED_RULES = 'coupon.SERIALIZED_RULES'; /** * the column name for the CREATED_AT field @@ -119,11 +134,25 @@ class CouponTableMap extends TableMap */ const UPDATED_AT = 'coupon.UPDATED_AT'; + /** + * the column name for the VERSION field + */ + const VERSION = 'coupon.VERSION'; + /** * The default string format for model objects of the related table */ const DEFAULT_STRING_FORMAT = 'YAML'; + // i18n behavior + + /** + * The default locale to use for translations. + * + * @var string + */ + const DEFAULT_LOCALE = 'en_EN'; + /** * holds an array of fieldnames * @@ -131,12 +160,12 @@ class CouponTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Code', 'Action', 'Value', 'Used', 'AvailableSince', 'DateLimit', 'Activate', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'code', 'action', 'value', 'used', 'availableSince', 'dateLimit', 'activate', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::ACTION, CouponTableMap::VALUE, CouponTableMap::USED, CouponTableMap::AVAILABLE_SINCE, CouponTableMap::DATE_LIMIT, CouponTableMap::ACTIVATE, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'ACTION', 'VALUE', 'USED', 'AVAILABLE_SINCE', 'DATE_LIMIT', 'ACTIVATE', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'code', 'action', 'value', 'used', 'available_since', 'date_limit', 'activate', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Value', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'CreatedAt', 'UpdatedAt', 'Version', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'value', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'createdAt', 'updatedAt', 'version', ), + self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::TITLE, CouponTableMap::SHORT_DESCRIPTION, CouponTableMap::DESCRIPTION, CouponTableMap::VALUE, CouponTableMap::IS_USED, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::SERIALIZED_RULES, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'VALUE', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), + self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'value', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'created_at', 'updated_at', 'version', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) ); /** @@ -146,12 +175,12 @@ class CouponTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Action' => 2, 'Value' => 3, 'Used' => 4, 'AvailableSince' => 5, 'DateLimit' => 6, 'Activate' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'action' => 2, 'value' => 3, 'used' => 4, 'availableSince' => 5, 'dateLimit' => 6, 'activate' => 7, 'createdAt' => 8, 'updatedAt' => 9, ), - self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::ACTION => 2, CouponTableMap::VALUE => 3, CouponTableMap::USED => 4, CouponTableMap::AVAILABLE_SINCE => 5, CouponTableMap::DATE_LIMIT => 6, CouponTableMap::ACTIVATE => 7, CouponTableMap::CREATED_AT => 8, CouponTableMap::UPDATED_AT => 9, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'ACTION' => 2, 'VALUE' => 3, 'USED' => 4, 'AVAILABLE_SINCE' => 5, 'DATE_LIMIT' => 6, 'ACTIVATE' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ), - self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'action' => 2, 'value' => 3, 'used' => 4, 'available_since' => 5, 'date_limit' => 6, 'activate' => 7, 'created_at' => 8, 'updated_at' => 9, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Value' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRules' => 10, 'CreatedAt' => 11, 'UpdatedAt' => 12, 'Version' => 13, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'value' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRules' => 10, 'createdAt' => 11, 'updatedAt' => 12, 'version' => 13, ), + self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::TITLE => 3, CouponTableMap::SHORT_DESCRIPTION => 4, CouponTableMap::DESCRIPTION => 5, CouponTableMap::VALUE => 6, CouponTableMap::IS_USED => 7, CouponTableMap::IS_ENABLED => 8, CouponTableMap::EXPIRATION_DATE => 9, CouponTableMap::SERIALIZED_RULES => 10, CouponTableMap::CREATED_AT => 11, CouponTableMap::UPDATED_AT => 12, CouponTableMap::VERSION => 13, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'VALUE' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES' => 10, 'CREATED_AT' => 11, 'UPDATED_AT' => 12, 'VERSION' => 13, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'value' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules' => 10, 'created_at' => 11, 'updated_at' => 12, 'version' => 13, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) ); /** @@ -172,14 +201,18 @@ class CouponTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); - $this->addColumn('ACTION', 'Action', 'VARCHAR', true, 255, null); + $this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null); + $this->addColumn('TITLE', 'Title', 'VARCHAR', true, 255, null); + $this->addColumn('SHORT_DESCRIPTION', 'ShortDescription', 'LONGVARCHAR', true, null, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', true, null, null); $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null); - $this->addColumn('USED', 'Used', 'TINYINT', false, null, null); - $this->addColumn('AVAILABLE_SINCE', 'AvailableSince', 'TIMESTAMP', false, null, null); - $this->addColumn('DATE_LIMIT', 'DateLimit', 'TIMESTAMP', false, null, null); - $this->addColumn('ACTIVATE', 'Activate', 'TINYINT', false, null, null); + $this->addColumn('IS_USED', 'IsUsed', 'TINYINT', true, null, null); + $this->addColumn('IS_ENABLED', 'IsEnabled', 'TINYINT', true, null, null); + $this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null); + $this->addColumn('SERIALIZED_RULES', 'SerializedRules', 'LONGVARCHAR', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0); } // initialize() /** @@ -187,7 +220,9 @@ class CouponTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('CouponRule', '\\Thelia\\Model\\CouponRule', RelationMap::ONE_TO_MANY, array('id' => 'coupon_id', ), 'CASCADE', 'RESTRICT', 'CouponRules'); + $this->addRelation('CouponOrder', '\\Thelia\\Model\\CouponOrder', RelationMap::ONE_TO_MANY, array('code' => 'code', ), null, null, 'CouponOrders'); + $this->addRelation('CouponI18n', '\\Thelia\\Model\\CouponI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CouponI18ns'); + $this->addRelation('CouponVersion', '\\Thelia\\Model\\CouponVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CouponVersions'); } // buildRelations() /** @@ -200,6 +235,8 @@ class CouponTableMap extends TableMap { return array( 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => '', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'false', 'log_created_by' => 'false', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), ); } // getBehaviors() /** @@ -209,7 +246,8 @@ class CouponTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CouponRuleTableMap::clearInstancePool(); + CouponI18nTableMap::clearInstancePool(); + CouponVersionTableMap::clearInstancePool(); } /** @@ -352,25 +390,33 @@ class CouponTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(CouponTableMap::ID); $criteria->addSelectColumn(CouponTableMap::CODE); - $criteria->addSelectColumn(CouponTableMap::ACTION); + $criteria->addSelectColumn(CouponTableMap::TYPE); + $criteria->addSelectColumn(CouponTableMap::TITLE); + $criteria->addSelectColumn(CouponTableMap::SHORT_DESCRIPTION); + $criteria->addSelectColumn(CouponTableMap::DESCRIPTION); $criteria->addSelectColumn(CouponTableMap::VALUE); - $criteria->addSelectColumn(CouponTableMap::USED); - $criteria->addSelectColumn(CouponTableMap::AVAILABLE_SINCE); - $criteria->addSelectColumn(CouponTableMap::DATE_LIMIT); - $criteria->addSelectColumn(CouponTableMap::ACTIVATE); + $criteria->addSelectColumn(CouponTableMap::IS_USED); + $criteria->addSelectColumn(CouponTableMap::IS_ENABLED); + $criteria->addSelectColumn(CouponTableMap::EXPIRATION_DATE); + $criteria->addSelectColumn(CouponTableMap::SERIALIZED_RULES); $criteria->addSelectColumn(CouponTableMap::CREATED_AT); $criteria->addSelectColumn(CouponTableMap::UPDATED_AT); + $criteria->addSelectColumn(CouponTableMap::VERSION); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.ACTION'); + $criteria->addSelectColumn($alias . '.TYPE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.SHORT_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.VALUE'); - $criteria->addSelectColumn($alias . '.USED'); - $criteria->addSelectColumn($alias . '.AVAILABLE_SINCE'); - $criteria->addSelectColumn($alias . '.DATE_LIMIT'); - $criteria->addSelectColumn($alias . '.ACTIVATE'); + $criteria->addSelectColumn($alias . '.IS_USED'); + $criteria->addSelectColumn($alias . '.IS_ENABLED'); + $criteria->addSelectColumn($alias . '.EXPIRATION_DATE'); + $criteria->addSelectColumn($alias . '.SERIALIZED_RULES'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.VERSION'); } } diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php index ef2cc7ca0..81badfba0 100755 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -200,13 +200,13 @@ class ProductTableMap extends TableMap $this->addRelation('ProductCategory', '\\Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductCategories'); $this->addRelation('FeatureProduct', '\\Thelia\\Model\\FeatureProduct', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'FeatureProducts'); $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductSaleElementss'); - $this->addRelation('ContentAssoc', '\\Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); $this->addRelation('ProductImage', '\\Thelia\\Model\\ProductImage', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductImages'); $this->addRelation('ProductDocument', '\\Thelia\\Model\\ProductDocument', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductDocuments'); $this->addRelation('AccessoryRelatedByProductId', '\\Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'AccessoriesRelatedByProductId'); $this->addRelation('AccessoryRelatedByAccessory', '\\Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'accessory', ), 'CASCADE', 'RESTRICT', 'AccessoriesRelatedByAccessory'); $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); $this->addRelation('CartItem', '\\Thelia\\Model\\CartItem', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), null, null, 'CartItems'); + $this->addRelation('ProductAssociatedContent', '\\Thelia\\Model\\ProductAssociatedContent', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductAssociatedContents'); $this->addRelation('ProductI18n', '\\Thelia\\Model\\ProductI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProductI18ns'); $this->addRelation('ProductVersion', '\\Thelia\\Model\\ProductVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProductVersions'); $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Categories'); @@ -238,11 +238,11 @@ class ProductTableMap extends TableMap ProductCategoryTableMap::clearInstancePool(); FeatureProductTableMap::clearInstancePool(); ProductSaleElementsTableMap::clearInstancePool(); - ContentAssocTableMap::clearInstancePool(); ProductImageTableMap::clearInstancePool(); ProductDocumentTableMap::clearInstancePool(); AccessoryTableMap::clearInstancePool(); RewritingTableMap::clearInstancePool(); + ProductAssociatedContentTableMap::clearInstancePool(); ProductI18nTableMap::clearInstancePool(); ProductVersionTableMap::clearInstancePool(); } diff --git a/install/thelia.sql b/install/thelia.sql index 3d9806696..031b00f5b 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -567,42 +567,6 @@ CREATE TABLE `content` PRIMARY KEY (`id`) ) ENGINE=InnoDB; --- --------------------------------------------------------------------- --- content_assoc --- --------------------------------------------------------------------- - -DROP TABLE IF EXISTS `content_assoc`; - -CREATE TABLE `content_assoc` -( - `id` INTEGER NOT NULL AUTO_INCREMENT, - `category_id` INTEGER, - `product_id` INTEGER, - `content_id` INTEGER, - `position` INTEGER, - `created_at` DATETIME, - `updated_at` DATETIME, - PRIMARY KEY (`id`), - INDEX `idx_content_assoc_category_id` (`category_id`), - INDEX `idx_content_assoc_product_id` (`product_id`), - INDEX `idx_content_assoc_content_id` (`content_id`), - CONSTRAINT `fk_content_assoc_category_id` - FOREIGN KEY (`category_id`) - REFERENCES `category` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE, - CONSTRAINT `fk_content_assoc_product_id` - FOREIGN KEY (`product_id`) - REFERENCES `product` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE, - CONSTRAINT `fk_content_assoc_content_id` - FOREIGN KEY (`content_id`) - REFERENCES `content` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE -) ENGINE=InnoDB; - -- --------------------------------------------------------------------- -- product_image -- --------------------------------------------------------------------- @@ -1117,42 +1081,22 @@ CREATE TABLE `coupon` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `code` VARCHAR(45) NOT NULL, - `action` VARCHAR(255) NOT NULL, + `type` VARCHAR(255) NOT NULL, + `title` VARCHAR(255) NOT NULL, + `short_description` TEXT NOT NULL, + `description` LONGTEXT NOT NULL, `value` FLOAT NOT NULL, - `used` TINYINT, - `available_since` DATETIME, - `date_limit` DATETIME, - `activate` TINYINT, + `is_used` TINYINT NOT NULL, + `is_enabled` TINYINT NOT NULL, + `expiration_date` DATETIME NOT NULL, + `serialized_rules` TEXT NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, + `version` INTEGER DEFAULT 0, PRIMARY KEY (`id`), UNIQUE INDEX `code_UNIQUE` (`code`) ) ENGINE=InnoDB; --- --------------------------------------------------------------------- --- coupon_rule --- --------------------------------------------------------------------- - -DROP TABLE IF EXISTS `coupon_rule`; - -CREATE TABLE `coupon_rule` -( - `id` INTEGER NOT NULL AUTO_INCREMENT, - `coupon_id` INTEGER NOT NULL, - `controller` VARCHAR(255), - `operation` VARCHAR(255), - `value` FLOAT, - `created_at` DATETIME, - `updated_at` DATETIME, - PRIMARY KEY (`id`), - INDEX `idx_coupon_rule_coupon_id` (`coupon_id`), - CONSTRAINT `fk_coupon_rule_coupon_id` - FOREIGN KEY (`coupon_id`) - REFERENCES `coupon` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE -) ENGINE=InnoDB; - -- --------------------------------------------------------------------- -- coupon_order -- --------------------------------------------------------------------- @@ -1169,11 +1113,15 @@ CREATE TABLE `coupon_order` `updated_at` DATETIME, PRIMARY KEY (`id`), INDEX `idx_coupon_order_order_id` (`order_id`), + INDEX `fk_coupon_order_coupon_idx` (`code`), CONSTRAINT `fk_coupon_order_order_id` FOREIGN KEY (`order_id`) REFERENCES `order` (`id`) ON UPDATE RESTRICT - ON DELETE CASCADE + ON DELETE CASCADE, + CONSTRAINT `fk_coupon_order_coupon` + FOREIGN KEY (`code`) + REFERENCES `coupon` (`code`) ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -1457,6 +1405,64 @@ CREATE TABLE `folder_document` ON DELETE CASCADE ) ENGINE=InnoDB; +-- --------------------------------------------------------------------- +-- product_associated_content +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `product_associated_content`; + +CREATE TABLE `product_associated_content` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `product_id` INTEGER NOT NULL, + `content_id` INTEGER NOT NULL, + `position` INTEGER NOT NULL, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `idx_product_associated_content_product_id` (`product_id`), + INDEX `idx_product_associated_content_content_id` (`content_id`), + CONSTRAINT `fk_product_associated_content_product_id` + FOREIGN KEY (`product_id`) + REFERENCES `product` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE, + CONSTRAINT `fk_product_associated_content_content_id` + FOREIGN KEY (`content_id`) + REFERENCES `content` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- category_associated_content +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `category_associated_content`; + +CREATE TABLE `category_associated_content` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `category_id` INTEGER NOT NULL, + `content_id` INTEGER NOT NULL, + `position` INTEGER NOT NULL, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `idx_category_associated_content_category_id` (`category_id`), + INDEX `idx_category_associated_content_content_id` (`content_id`), + CONSTRAINT `fk_category_associated_content_category_id` + FOREIGN KEY (`category_id`) + REFERENCES `category` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE, + CONSTRAINT `fk_category_associated_content_content_id` + FOREIGN KEY (`content_id`) + REFERENCES `content` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + -- --------------------------------------------------------------------- -- category_i18n -- --------------------------------------------------------------------- @@ -1466,7 +1472,7 @@ DROP TABLE IF EXISTS `category_i18n`; CREATE TABLE `category_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1487,7 +1493,7 @@ DROP TABLE IF EXISTS `product_i18n`; CREATE TABLE `product_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1508,7 +1514,7 @@ DROP TABLE IF EXISTS `country_i18n`; CREATE TABLE `country_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1529,7 +1535,7 @@ DROP TABLE IF EXISTS `tax_i18n`; CREATE TABLE `tax_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` TEXT, PRIMARY KEY (`id`,`locale`), @@ -1548,7 +1554,7 @@ DROP TABLE IF EXISTS `tax_rule_i18n`; CREATE TABLE `tax_rule_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, PRIMARY KEY (`id`,`locale`), CONSTRAINT `tax_rule_i18n_FK_1` FOREIGN KEY (`id`) @@ -1565,7 +1571,7 @@ DROP TABLE IF EXISTS `feature_i18n`; CREATE TABLE `feature_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1586,7 +1592,7 @@ DROP TABLE IF EXISTS `feature_av_i18n`; CREATE TABLE `feature_av_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1607,7 +1613,7 @@ DROP TABLE IF EXISTS `attribute_i18n`; CREATE TABLE `attribute_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1628,7 +1634,7 @@ DROP TABLE IF EXISTS `attribute_av_i18n`; CREATE TABLE `attribute_av_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1649,7 +1655,7 @@ DROP TABLE IF EXISTS `config_i18n`; CREATE TABLE `config_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1670,7 +1676,7 @@ DROP TABLE IF EXISTS `customer_title_i18n`; CREATE TABLE `customer_title_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `short` VARCHAR(10), `long` VARCHAR(45), PRIMARY KEY (`id`,`locale`), @@ -1689,7 +1695,7 @@ DROP TABLE IF EXISTS `folder_i18n`; CREATE TABLE `folder_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1710,7 +1716,7 @@ DROP TABLE IF EXISTS `content_i18n`; CREATE TABLE `content_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1731,7 +1737,7 @@ DROP TABLE IF EXISTS `product_image_i18n`; CREATE TABLE `product_image_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1752,7 +1758,7 @@ DROP TABLE IF EXISTS `product_document_i18n`; CREATE TABLE `product_document_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1773,7 +1779,7 @@ DROP TABLE IF EXISTS `currency_i18n`; CREATE TABLE `currency_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `name` VARCHAR(45), PRIMARY KEY (`id`,`locale`), CONSTRAINT `currency_i18n_FK_1` @@ -1791,7 +1797,7 @@ DROP TABLE IF EXISTS `order_status_i18n`; CREATE TABLE `order_status_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1812,7 +1818,7 @@ DROP TABLE IF EXISTS `module_i18n`; CREATE TABLE `module_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1833,7 +1839,7 @@ DROP TABLE IF EXISTS `group_i18n`; CREATE TABLE `group_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1854,7 +1860,7 @@ DROP TABLE IF EXISTS `resource_i18n`; CREATE TABLE `resource_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1875,7 +1881,7 @@ DROP TABLE IF EXISTS `message_i18n`; CREATE TABLE `message_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` TEXT, `description` LONGTEXT, `description_html` LONGTEXT, @@ -1886,6 +1892,23 @@ CREATE TABLE `message_i18n` ON DELETE CASCADE ) ENGINE=InnoDB; +-- --------------------------------------------------------------------- +-- coupon_i18n +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `coupon_i18n`; + +CREATE TABLE `coupon_i18n` +( + `id` INTEGER NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, + PRIMARY KEY (`id`,`locale`), + CONSTRAINT `coupon_i18n_FK_1` + FOREIGN KEY (`id`) + REFERENCES `coupon` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + -- --------------------------------------------------------------------- -- category_image_i18n -- --------------------------------------------------------------------- @@ -1895,7 +1918,7 @@ DROP TABLE IF EXISTS `category_image_i18n`; CREATE TABLE `category_image_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1916,7 +1939,7 @@ DROP TABLE IF EXISTS `folder_image_i18n`; CREATE TABLE `folder_image_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1937,7 +1960,7 @@ DROP TABLE IF EXISTS `content_image_i18n`; CREATE TABLE `content_image_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1958,7 +1981,7 @@ DROP TABLE IF EXISTS `category_document_i18n`; CREATE TABLE `category_document_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -1979,7 +2002,7 @@ DROP TABLE IF EXISTS `content_document_i18n`; CREATE TABLE `content_document_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -2000,7 +2023,7 @@ DROP TABLE IF EXISTS `folder_document_i18n`; CREATE TABLE `folder_document_i18n` ( `id` INTEGER NOT NULL, - `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_EN' NOT NULL, `title` VARCHAR(255), `description` LONGTEXT, `chapo` TEXT, @@ -2132,5 +2155,34 @@ CREATE TABLE `message_version` ON DELETE CASCADE ) ENGINE=InnoDB; +-- --------------------------------------------------------------------- +-- coupon_version +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `coupon_version`; + +CREATE TABLE `coupon_version` +( + `id` INTEGER NOT NULL, + `code` VARCHAR(45) NOT NULL, + `type` VARCHAR(255) NOT NULL, + `title` VARCHAR(255) NOT NULL, + `short_description` TEXT NOT NULL, + `description` LONGTEXT NOT NULL, + `value` FLOAT NOT NULL, + `is_used` TINYINT NOT NULL, + `is_enabled` TINYINT NOT NULL, + `expiration_date` DATETIME NOT NULL, + `serialized_rules` TEXT NOT NULL, + `created_at` DATETIME, + `updated_at` DATETIME, + `version` INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (`id`,`version`), + CONSTRAINT `coupon_version_FK_1` + FOREIGN KEY (`id`) + REFERENCES `coupon` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + # This restores the fkey checks, after having unset them earlier SET FOREIGN_KEY_CHECKS = 1; diff --git a/local/config/schema.xml b/local/config/schema.xml index 238f66277..839e89079 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -425,32 +425,6 @@
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    @@ -817,30 +791,21 @@
    - + + + + - - - - + + + + -
    - - - - - - - - - - - - - + +
    @@ -850,9 +815,15 @@ + + + + + +
    @@ -1086,4 +1057,42 @@
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    From 73677b7c1a2d78cf11219096c72f1121f95403d4 Mon Sep 17 00:00:00 2001 From: gmorel Date: Thu, 22 Aug 2013 20:02:03 +0200 Subject: [PATCH 024/268] WIP Coupon Update Coupon Model + SQL Implementattion Fixtures for Coupon and CouponFactory --- core/lib/Thelia/Coupon/CouponFactory.php | 64 +- .../lib/Thelia/Coupon/Parameter/DateParam.php | 13 +- .../Thelia/Coupon/Parameter/IntegerParam.php | 12 +- .../Thelia/Coupon/Parameter/IntervalParam.php | 12 +- .../Thelia/Coupon/Parameter/PriceParam.php | 11 +- .../Thelia/Coupon/Parameter/QuantityParam.php | 2 +- .../Coupon/Parameter/RepeatedDateParam.php | 10 + .../Parameter/RepeatedIntervalParam.php | 10 + .../Thelia/Coupon/Parameter/RepeatedParam.php | 14 +- .../Parameter/RuleParameterInterface.php | 45 + .../Thelia/Coupon/Parameter/RuleValidator.php | 77 + .../Coupon/Rule/AvailableForTotalAmount.php | 48 +- .../Thelia/Coupon/Rule/CouponRuleAbstract.php | 54 +- .../Thelia/Coupon/Type/CouponInterface.php | 11 + core/lib/Thelia/Model/Base/Accessory.php | 13 +- core/lib/Thelia/Model/Base/Category.php | 619 +++-- .../Model/Base/CategoryAssociatedContent.php | 1553 ++++++++++++ .../Base/CategoryAssociatedContentQuery.php | 804 +++++++ core/lib/Thelia/Model/Base/CategoryQuery.php | 154 +- core/lib/Thelia/Model/Base/Content.php | 916 ++++--- core/lib/Thelia/Model/Base/ContentQuery.php | 231 +- core/lib/Thelia/Model/Base/Coupon.php | 312 ++- core/lib/Thelia/Model/Base/CouponI18n.php | 1207 ++++++++++ .../lib/Thelia/Model/Base/CouponI18nQuery.php | 475 ++++ core/lib/Thelia/Model/Base/CouponQuery.php | 183 +- core/lib/Thelia/Model/Base/CouponVersion.php | 2115 +++++++++++++++++ .../Thelia/Model/Base/CouponVersionQuery.php | 1084 +++++++++ core/lib/Thelia/Model/Base/Product.php | 619 +++-- .../Model/Base/ProductAssociatedContent.php | 1553 ++++++++++++ .../Base/ProductAssociatedContentQuery.php | 804 +++++++ core/lib/Thelia/Model/Base/ProductQuery.php | 154 +- .../Model/CategoryAssociatedContent.php | 9 + .../Model/CategoryAssociatedContentQuery.php | 20 + core/lib/Thelia/Model/CouponI18n.php | 9 + core/lib/Thelia/Model/CouponI18nQuery.php | 20 + core/lib/Thelia/Model/CouponVersion.php | 9 + core/lib/Thelia/Model/CouponVersionQuery.php | 20 + .../Thelia/Model/Map/AccessoryTableMap.php | 6 +- .../Map/CategoryAssociatedContentTableMap.php | 456 ++++ .../lib/Thelia/Model/Map/CategoryTableMap.php | 4 +- core/lib/Thelia/Model/Map/ContentTableMap.php | 6 +- .../Thelia/Model/Map/CouponI18nTableMap.php | 465 ++++ core/lib/Thelia/Model/Map/CouponTableMap.php | 72 +- .../Model/Map/CouponVersionTableMap.php | 585 +++++ .../Map/ProductAssociatedContentTableMap.php | 456 ++++ core/lib/Thelia/Model/Map/ProductTableMap.php | 4 +- .../Thelia/Model/ProductAssociatedContent.php | 9 + .../Model/ProductAssociatedContentQuery.php | 20 + .../Rule/AvailableForTotalAmountTest.php | 144 +- install/faker.php | 75 +- install/thelia.sql | 119 +- local/config/schema.xml | 94 +- 52 files changed, 14325 insertions(+), 1456 deletions(-) create mode 100644 core/lib/Thelia/Coupon/Parameter/RuleParameterInterface.php create mode 100644 core/lib/Thelia/Coupon/Parameter/RuleValidator.php create mode 100644 core/lib/Thelia/Model/Base/CategoryAssociatedContent.php create mode 100644 core/lib/Thelia/Model/Base/CategoryAssociatedContentQuery.php create mode 100644 core/lib/Thelia/Model/Base/CouponI18n.php create mode 100644 core/lib/Thelia/Model/Base/CouponI18nQuery.php create mode 100644 core/lib/Thelia/Model/Base/CouponVersion.php create mode 100644 core/lib/Thelia/Model/Base/CouponVersionQuery.php create mode 100644 core/lib/Thelia/Model/Base/ProductAssociatedContent.php create mode 100644 core/lib/Thelia/Model/Base/ProductAssociatedContentQuery.php create mode 100644 core/lib/Thelia/Model/CategoryAssociatedContent.php create mode 100644 core/lib/Thelia/Model/CategoryAssociatedContentQuery.php create mode 100644 core/lib/Thelia/Model/CouponI18n.php create mode 100644 core/lib/Thelia/Model/CouponI18nQuery.php create mode 100644 core/lib/Thelia/Model/CouponVersion.php create mode 100644 core/lib/Thelia/Model/CouponVersionQuery.php create mode 100644 core/lib/Thelia/Model/Map/CategoryAssociatedContentTableMap.php create mode 100644 core/lib/Thelia/Model/Map/CouponI18nTableMap.php create mode 100644 core/lib/Thelia/Model/Map/CouponVersionTableMap.php create mode 100644 core/lib/Thelia/Model/Map/ProductAssociatedContentTableMap.php create mode 100644 core/lib/Thelia/Model/ProductAssociatedContent.php create mode 100644 core/lib/Thelia/Model/ProductAssociatedContentQuery.php diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php index 7f74c7f21..f81e95b97 100644 --- a/core/lib/Thelia/Coupon/CouponFactory.php +++ b/core/lib/Thelia/Coupon/CouponFactory.php @@ -24,6 +24,12 @@ namespace Thelia\Coupon; use Thelia\Coupon\Type\CouponInterface; +use Thelia\Coupon\Type\RemoveXAmount; +use Thelia\Model\Base\CouponQuery; +use Thelia\Model\Coupon; +use Symfony\Component\Serializer\Serializer; +use Symfony\Component\Serializer\Encoder\JsonEncoder; +use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer; /** * Created by JetBrains PhpStorm. @@ -41,11 +47,67 @@ class CouponFactory /** * Build a CouponInterface from its database data * - * @param int $couponCode CouponInterface id + * @param string $couponCode Coupon code ex: XMAS * * @return CouponInterface ready to be processed */ public function buildCouponFromCode($couponCode) { + + $couponQuery = CouponQuery::create(); + $couponModel = $couponQuery->findByCode($couponCode); + + return $this->buildCouponInterfacFromModel($couponModel); + } + + /** + * Build a CouponInterface from its Model data contained in the DataBase + * + * @param Coupon $model Database data + * + * @return CouponInterface ready to use CouponInterface object instance + */ + protected function buildCouponInterfacFromModel(Coupon $model) + { + $isCumulative = ($model->getIsCumulative() == 1 ? true : false); + $isRemovingPostage = ($model->getIsRemovingPostage() == 1 ? true : false); + $couponClass = $model->getType(); + + /** @var CouponInterface $coupon*/ + $coupon = new $$couponClass( + $model->getCode(), + $model->getTitle(), + $model->getShortDescription(), + $model->getDescription(), + $model->getAmount(), + $isCumulative, + $isRemovingPostage + ); + + $normalizer = new GetSetMethodNormalizer(); + $encoder = new JsonEncoder(); + + $serializer = new Serializer(array($normalizer), array($encoder)); + + $o = new \ArrayObject(); + $unserializedRuleTypes = $o->unserialize( + $model->getSerializedRulesType() + ); + $unserializedRuleContents = $o->unserialize( + $model->getSerializedRulesContent() + ); + + $rules = array(); + foreach ($unserializedRuleTypes as $key => $unserializedRuleType) { + $rules[] = $serializer->deserialize( + $unserializedRuleContents[$key], + $unserializedRuleType, + 'json' + ); + } + + $coupon->setRules($rules); + + return $coupon; } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/DateParam.php b/core/lib/Thelia/Coupon/Parameter/DateParam.php index fa4ea7d97..989477210 100644 --- a/core/lib/Thelia/Coupon/Parameter/DateParam.php +++ b/core/lib/Thelia/Coupon/Parameter/DateParam.php @@ -36,7 +36,7 @@ use Thelia\Coupon\Parameter\ComparableInterface; * @author Guillaume MOREL * */ -class DateParam implements ComparableInterface +class DateParam implements ComparableInterface, RuleParameterInterface { /** @var \DateTime Date */ protected $dateTime = null; @@ -93,4 +93,15 @@ class DateParam implements ComparableInterface return $ret; } + /** + * Get Parameter value to test against + * + * @return \Datetime + */ + public function getValue() + { + return clone $this->dateTime; + } + + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/IntegerParam.php b/core/lib/Thelia/Coupon/Parameter/IntegerParam.php index c4d6ca5e7..14d63417b 100644 --- a/core/lib/Thelia/Coupon/Parameter/IntegerParam.php +++ b/core/lib/Thelia/Coupon/Parameter/IntegerParam.php @@ -36,7 +36,7 @@ use Thelia\Coupon\Parameter\ComparableInterface; * @author Guillaume MOREL * */ -class IntegerParam implements ComparableInterface +class IntegerParam implements ComparableInterface, RuleParameterInterface { /** @var int Integer to compare with */ protected $integer = 0; @@ -94,4 +94,14 @@ class IntegerParam implements ComparableInterface return $ret; } + /** + * Get Parameter value to test against + * + * @return int + */ + public function getValue() + { + return $this->integer; + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/IntervalParam.php b/core/lib/Thelia/Coupon/Parameter/IntervalParam.php index 88444fe36..3e29d24be 100644 --- a/core/lib/Thelia/Coupon/Parameter/IntervalParam.php +++ b/core/lib/Thelia/Coupon/Parameter/IntervalParam.php @@ -34,7 +34,7 @@ namespace Thelia\Coupon\Parameter; * @author Guillaume MOREL * */ -class IntervalParam implements ComparableInterface +class IntervalParam implements ComparableInterface, RuleParameterInterface { /** @var \DatePeriod Date period */ protected $datePeriod = null; @@ -105,4 +105,14 @@ class IntervalParam implements ComparableInterface return $ret; } + + /** + * Get Parameter value to test against + * + * @return \DatePeriod + */ + public function getValue() + { + return clone $this->datePeriod; + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/PriceParam.php b/core/lib/Thelia/Coupon/Parameter/PriceParam.php index 7d74101a0..2f3834777 100644 --- a/core/lib/Thelia/Coupon/Parameter/PriceParam.php +++ b/core/lib/Thelia/Coupon/Parameter/PriceParam.php @@ -37,7 +37,7 @@ use Thelia\Coupon\Parameter\ComparableInterface; * @author Guillaume MOREL * */ -class PriceParam implements ComparableInterface +class PriceParam implements ComparableInterface, RuleParameterInterface { /** @var float Positive Float to compare with */ protected $price = null; @@ -113,4 +113,13 @@ class PriceParam implements ComparableInterface return $ret; } + /** + * Get Parameter value to test against + * + * @return float + */ + public function getValue() + { + return $this->price; + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/QuantityParam.php b/core/lib/Thelia/Coupon/Parameter/QuantityParam.php index e4dffb221..526aa4152 100644 --- a/core/lib/Thelia/Coupon/Parameter/QuantityParam.php +++ b/core/lib/Thelia/Coupon/Parameter/QuantityParam.php @@ -75,4 +75,4 @@ class QuantityParam extends IntegerParam return parent::compareTo($other); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php b/core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php index dc99a0d26..2e99391e6 100644 --- a/core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php +++ b/core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php @@ -87,4 +87,14 @@ class RepeatedDateParam extends RepeatedParam return $ret; } + + /** + * Get Parameter value to test against + * + * @return \DatePeriod + */ + public function getValue() + { + return clone $this->datePeriod; + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php b/core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php index 4d857716f..3c4de7348 100644 --- a/core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php +++ b/core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php @@ -121,4 +121,14 @@ class RepeatedIntervalParam extends RepeatedParam return $ret; } + + /** + * Get Parameter value to test against + * + * @return \DatePeriod + */ + public function getValue() + { + return clone $this->datePeriod; + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/RepeatedParam.php b/core/lib/Thelia/Coupon/Parameter/RepeatedParam.php index 1d9dd4905..dba3de0af 100644 --- a/core/lib/Thelia/Coupon/Parameter/RepeatedParam.php +++ b/core/lib/Thelia/Coupon/Parameter/RepeatedParam.php @@ -38,7 +38,7 @@ use DateTime; * @author Guillaume MOREL * */ -abstract class RepeatedParam implements ComparableInterface +abstract class RepeatedParam implements ComparableInterface, RuleParameterInterface { /** @var DateTime The start date of the period. */ protected $from = null; @@ -232,10 +232,20 @@ abstract class RepeatedParam implements ComparableInterface /** * Get date DatePeriod * - * @return DatePeriod + * @return \DatePeriod */ public function getDatePeriod() { return clone $this->datePeriod; } + + /** + * Get Parameter value to test against + * + * @return \DatePeriod + */ + public function getValue() + { + return clone $this->datePeriod; + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/RuleParameterInterface.php b/core/lib/Thelia/Coupon/Parameter/RuleParameterInterface.php new file mode 100644 index 000000000..4583bd799 --- /dev/null +++ b/core/lib/Thelia/Coupon/Parameter/RuleParameterInterface.php @@ -0,0 +1,45 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon\Parameter; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Get a Param value + * + * @package Coupon + * @author Guillaume MOREL + * + */ +interface RuleParameterInterface +{ + /** + * Get Parameter value to test against + * + * @return mixed + */ + public function getValue(); +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/RuleValidator.php b/core/lib/Thelia/Coupon/Parameter/RuleValidator.php new file mode 100644 index 000000000..f6ffc3b13 --- /dev/null +++ b/core/lib/Thelia/Coupon/Parameter/RuleValidator.php @@ -0,0 +1,77 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon\Parameter; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Allow to validate parameters + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class RuleValidator +{ + /** @var string Operator ex: Operators::INFERIOR */ + protected $operator = null; + + /** @var ComparableInterface Validator */ + protected $param = null; + + /** + * Constructor + * + * @param string $operator Operator ex: Operators::INFERIOR + * @param ComparableInterface $param Validator ex: PriceParam + */ + function __construct($operator, ComparableInterface $param) + { + $this->operator = $operator; + $this->param = $param; + } + + /** + * Get Validator Operator + * + * @return string + */ + public function getOperator() + { + return $this->operator; + } + + /** + * Get Validator Param + * + * @return ComparableInterface + */ + public function getParam() + { + return $this->param; + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php index 2f1de57ba..2e109f9ec 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php @@ -26,6 +26,8 @@ namespace Thelia\Coupon\Rule; use Symfony\Component\Intl\Exception\NotImplementedException; use Thelia\Coupon\CouponAdapterInterface; use Thelia\Coupon\Parameter\PriceParam; +use Thelia\Coupon\Parameter\RuleValidator; +use Thelia\Exception\InvalidRuleException; use Thelia\Exception\InvalidRuleOperatorException; use Thelia\Exception\InvalidRuleValueException; @@ -53,20 +55,30 @@ class AvailableForTotalAmount extends CouponRuleAbstract Operators::SUPERIOR, ); - /** @var PriceParam Price Validator */ + /** @var RuleValidator Price Validator */ protected $priceValidator = null; /** * Constructor * - * @param array $validators Parameters validating $paramsToValidate against + * @param array $validators Array of RuleValidator + * validating $paramsToValidate against * @param array $validated Parameters to be paramsToValidate + * + * @throws \Thelia\Exception\InvalidRuleException */ public function __construct(array $validators, array $validated = null) { parent::__construct($validators, $validated); - $this->priceValidator = $validators[self::PARAM1_PRICE][self::VALUE]; + if (isset($validators[self::PARAM1_PRICE]) + && $validators[self::PARAM1_PRICE] instanceof RuleValidator + ) { + $this->priceValidator = $validators[self::PARAM1_PRICE]; + } else { + throw new InvalidRuleException(get_class()); + } + } @@ -82,16 +94,23 @@ class AvailableForTotalAmount extends CouponRuleAbstract if (!isset($this->validators) || empty($this->validators) ||!isset($this->validators[self::PARAM1_PRICE]) - ||!isset($this->validators[self::PARAM1_PRICE][self::VALUE]) - ||!$this->validators[self::PARAM1_PRICE][self::VALUE] instanceof PriceParam + ||!isset($this->validators[self::PARAM1_PRICE]) ) { throw new InvalidRuleValueException(get_class(), self::PARAM1_PRICE); } + /** @var RuleValidator $ruleValidator */ + $ruleValidator = $this->validators[self::PARAM1_PRICE]; + /** @var PriceParam $price */ + $price = $ruleValidator->getParam(); + + if (!$price instanceof PriceParam) { + throw new InvalidRuleValueException(get_class(), self::PARAM1_PRICE); + } + $this->checkBackOfficeInputsOperators(); - /** @var PriceParam $price */ - $price = $this->validators[self::PARAM1_PRICE][self::VALUE]; + return $this->isPriceValid($price->getPrice()); } @@ -128,7 +147,7 @@ class AvailableForTotalAmount extends CouponRuleAbstract { $priceValidator = $this->priceValidator; try { - $priceValidator->compareTo($price); + $priceValidator->getParam()->compareTo($price); } catch(\InvalidArgumentException $e) { throw new InvalidRuleValueException(get_class(), self::PARAM1_PRICE); } @@ -145,7 +164,7 @@ class AvailableForTotalAmount extends CouponRuleAbstract * @throws \Symfony\Component\Intl\Exception\NotImplementedException * @return $this */ - protected function setValidators(CouponAdapterInterface $adapter) + protected function setValidatorsFromAdapter(CouponAdapterInterface $adapter) { $adapter->getRule($this); } @@ -167,5 +186,16 @@ class AvailableForTotalAmount extends CouponRuleAbstract return $this; } + /** + * Return all validators + * Serialization purpose + * + * @return array + */ + public function getValidators() + { + return $this->validators; + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php b/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php index a8a51cd00..4bdd0d57d 100644 --- a/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php +++ b/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php @@ -26,6 +26,8 @@ namespace Thelia\Coupon\Rule; use Symfony\Component\Intl\Exception\NotImplementedException; use Thelia\Coupon\CouponAdapterInterface; use Thelia\Coupon\Parameter\ComparableInterface; +use Thelia\Coupon\Parameter\RuleValidator; +use Thelia\Exception\InvalidRuleException; use Thelia\Exception\InvalidRuleOperatorException; /** @@ -59,21 +61,48 @@ abstract class CouponRuleAbstract implements CouponRuleInterface * Constructor * Ex: * Param 1 : - * $validators['price']['operator'] = Operators::INFERIOR - * ['value'] = new IntegerParam(10) + * $priceValidator = new RuleValidator( + * Operators::INFERIOR, + * new IntegerParam(10) + * ) + * $validators[AvailableForTotalAmount::PARAM1_PRICE] = $priceValidator * * Param 2 : - * $paramsToValidate['price'] = 9 + * $paramsToValidate[AvailableForTotalAmount::PARAM1_PRICE] = 9 * - * @param array $validators Parameters validating $paramsToValidate against + * @param array $validators Array of RuleValidator + * validating $paramsToValidate against * @param array $validated Parameters to be paramsToValidate + * + * @throws InvalidRuleException */ public function __construct(array $validators, array $validated = null) { - $this->validators = $validators; + $this->setValidators($validators); $this->paramsToValidate = $validated; } + /** + * Check validator relevancy and store them + * + * @param array $validators Array of RuleValidator + * validating $paramsToValidate against + * + * @return $this + * @throws InvalidRuleException + */ + protected function setValidators(array $validators) + { + foreach ($validators as $validator) { + if (!$validator instanceof RuleValidator) { + throw new InvalidRuleException(get_class()); + } + } + $this->validators = $validators; + + return $this; + } + /** * Check if the current Checkout matches this condition * @@ -85,11 +114,12 @@ abstract class CouponRuleAbstract implements CouponRuleInterface $this->checkCheckoutInput(); $isMatching = true; + /** @var $validator RuleValidator*/ foreach ($this->validators as $param => $validator) { $a = $this->paramsToValidate[$param]; - $operator = $validator[self::OPERATOR]; - /** @var ComparableInterface $b */ - $b = $validator[self::VALUE]; + $operator = $validator->getOperator(); + /** @var ComparableInterface, RuleParameterInterface $b */ + $b = $validator->getParam(); if (!Operators::isValidAccordingToOperator($a, $operator, $b)) { $isMatching = false; @@ -118,9 +148,11 @@ abstract class CouponRuleAbstract implements CouponRuleInterface */ protected function checkBackOfficeInputsOperators() { + /** @var RuleValidator $param */ foreach ($this->validators as $key => $param) { - if (!isset($param[self::OPERATOR]) - ||!in_array($param[self::OPERATOR], $this->availableOperators) + $operator = $param->getOperator(); + if (!isset($operator) + ||!in_array($operator, $this->availableOperators) ) { throw new InvalidRuleOperatorException(get_class(), $key); } @@ -137,7 +169,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface * @throws \Symfony\Component\Intl\Exception\NotImplementedException * @return $this */ - protected function setValidators(CouponAdapterInterface $adapter) + protected function setValidatorsFromAdapter(CouponAdapterInterface $adapter) { throw new NotImplementedException( 'CouponRuleInterface::setValidators needs to be implemented' diff --git a/core/lib/Thelia/Coupon/Type/CouponInterface.php b/core/lib/Thelia/Coupon/Type/CouponInterface.php index e2f49e3bb..8c51126ea 100644 --- a/core/lib/Thelia/Coupon/Type/CouponInterface.php +++ b/core/lib/Thelia/Coupon/Type/CouponInterface.php @@ -109,4 +109,15 @@ interface CouponInterface * @return bool */ public function isMatching(); + + /** + * Replace the existing Rules by those given in parameter + * If one Rule is badly implemented, no Rule will be added + * + * @param array $rules CouponRuleInterface to add + * + * @return $this + * @throws \Thelia\Exception\InvalidRuleException + */ + public function setRules(array $rules); } diff --git a/core/lib/Thelia/Model/Base/Accessory.php b/core/lib/Thelia/Model/Base/Accessory.php index f5acd9977..f4110b19e 100644 --- a/core/lib/Thelia/Model/Base/Accessory.php +++ b/core/lib/Thelia/Model/Base/Accessory.php @@ -891,6 +891,10 @@ abstract class Accessory implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; + $this->modifiedColumns[] = AccessoryTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AccessoryTableMap::ID . ')'); + } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AccessoryTableMap::ID)) { @@ -948,6 +952,13 @@ abstract class Accessory implements ActiveRecordInterface throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + $this->setNew(false); } @@ -1224,7 +1235,6 @@ abstract class Accessory implements ActiveRecordInterface */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { - $copyObj->setId($this->getId()); $copyObj->setProductId($this->getProductId()); $copyObj->setAccessory($this->getAccessory()); $copyObj->setPosition($this->getPosition()); @@ -1232,6 +1242,7 @@ abstract class Accessory implements ActiveRecordInterface $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value } } diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php index 2f05de899..810283e44 100644 --- a/core/lib/Thelia/Model/Base/Category.php +++ b/core/lib/Thelia/Model/Base/Category.php @@ -22,6 +22,8 @@ use Thelia\Model\AttributeCategory as ChildAttributeCategory; use Thelia\Model\AttributeCategoryQuery as ChildAttributeCategoryQuery; use Thelia\Model\AttributeQuery as ChildAttributeQuery; use Thelia\Model\Category as ChildCategory; +use Thelia\Model\CategoryAssociatedContent as ChildCategoryAssociatedContent; +use Thelia\Model\CategoryAssociatedContentQuery as ChildCategoryAssociatedContentQuery; use Thelia\Model\CategoryDocument as ChildCategoryDocument; use Thelia\Model\CategoryDocumentQuery as ChildCategoryDocumentQuery; use Thelia\Model\CategoryI18n as ChildCategoryI18n; @@ -31,8 +33,6 @@ use Thelia\Model\CategoryImageQuery as ChildCategoryImageQuery; use Thelia\Model\CategoryQuery as ChildCategoryQuery; use Thelia\Model\CategoryVersion as ChildCategoryVersion; use Thelia\Model\CategoryVersionQuery as ChildCategoryVersionQuery; -use Thelia\Model\ContentAssoc as ChildContentAssoc; -use Thelia\Model\ContentAssocQuery as ChildContentAssocQuery; use Thelia\Model\Feature as ChildFeature; use Thelia\Model\FeatureCategory as ChildFeatureCategory; use Thelia\Model\FeatureCategoryQuery as ChildFeatureCategoryQuery; @@ -153,12 +153,6 @@ abstract class Category implements ActiveRecordInterface protected $collAttributeCategories; protected $collAttributeCategoriesPartial; - /** - * @var ObjectCollection|ChildContentAssoc[] Collection to store aggregation of ChildContentAssoc objects. - */ - protected $collContentAssocs; - protected $collContentAssocsPartial; - /** * @var ObjectCollection|ChildRewriting[] Collection to store aggregation of ChildRewriting objects. */ @@ -177,6 +171,12 @@ abstract class Category implements ActiveRecordInterface protected $collCategoryDocuments; protected $collCategoryDocumentsPartial; + /** + * @var ObjectCollection|ChildCategoryAssociatedContent[] Collection to store aggregation of ChildCategoryAssociatedContent objects. + */ + protected $collCategoryAssociatedContents; + protected $collCategoryAssociatedContentsPartial; + /** * @var ObjectCollection|ChildCategoryI18n[] Collection to store aggregation of ChildCategoryI18n objects. */ @@ -270,12 +270,6 @@ abstract class Category implements ActiveRecordInterface */ protected $attributeCategoriesScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $contentAssocsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -294,6 +288,12 @@ abstract class Category implements ActiveRecordInterface */ protected $categoryDocumentsScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $categoryAssociatedContentsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -1039,14 +1039,14 @@ abstract class Category implements ActiveRecordInterface $this->collAttributeCategories = null; - $this->collContentAssocs = null; - $this->collRewritings = null; $this->collCategoryImages = null; $this->collCategoryDocuments = null; + $this->collCategoryAssociatedContents = null; + $this->collCategoryI18ns = null; $this->collCategoryVersions = null; @@ -1331,23 +1331,6 @@ abstract class Category implements ActiveRecordInterface } } - if ($this->contentAssocsScheduledForDeletion !== null) { - if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - \Thelia\Model\ContentAssocQuery::create() - ->filterByPrimaryKeys($this->contentAssocsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->contentAssocsScheduledForDeletion = null; - } - } - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->rewritingsScheduledForDeletion !== null) { if (!$this->rewritingsScheduledForDeletion->isEmpty()) { \Thelia\Model\RewritingQuery::create() @@ -1399,6 +1382,23 @@ abstract class Category implements ActiveRecordInterface } } + if ($this->categoryAssociatedContentsScheduledForDeletion !== null) { + if (!$this->categoryAssociatedContentsScheduledForDeletion->isEmpty()) { + \Thelia\Model\CategoryAssociatedContentQuery::create() + ->filterByPrimaryKeys($this->categoryAssociatedContentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->categoryAssociatedContentsScheduledForDeletion = null; + } + } + + if ($this->collCategoryAssociatedContents !== null) { + foreach ($this->collCategoryAssociatedContents as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->categoryI18nsScheduledForDeletion !== null) { if (!$this->categoryI18nsScheduledForDeletion->isEmpty()) { \Thelia\Model\CategoryI18nQuery::create() @@ -1668,9 +1668,6 @@ abstract class Category implements ActiveRecordInterface if (null !== $this->collAttributeCategories) { $result['AttributeCategories'] = $this->collAttributeCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collContentAssocs) { - $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collRewritings) { $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1680,6 +1677,9 @@ abstract class Category implements ActiveRecordInterface if (null !== $this->collCategoryDocuments) { $result['CategoryDocuments'] = $this->collCategoryDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collCategoryAssociatedContents) { + $result['CategoryAssociatedContents'] = $this->collCategoryAssociatedContents->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collCategoryI18ns) { $result['CategoryI18ns'] = $this->collCategoryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1895,12 +1895,6 @@ abstract class Category implements ActiveRecordInterface } } - foreach ($this->getContentAssocs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentAssoc($relObj->copy($deepCopy)); - } - } - foreach ($this->getRewritings() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addRewriting($relObj->copy($deepCopy)); @@ -1919,6 +1913,12 @@ abstract class Category implements ActiveRecordInterface } } + foreach ($this->getCategoryAssociatedContents() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCategoryAssociatedContent($relObj->copy($deepCopy)); + } + } + foreach ($this->getCategoryI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCategoryI18n($relObj->copy($deepCopy)); @@ -1981,9 +1981,6 @@ abstract class Category implements ActiveRecordInterface if ('AttributeCategory' == $relationName) { return $this->initAttributeCategories(); } - if ('ContentAssoc' == $relationName) { - return $this->initContentAssocs(); - } if ('Rewriting' == $relationName) { return $this->initRewritings(); } @@ -1993,6 +1990,9 @@ abstract class Category implements ActiveRecordInterface if ('CategoryDocument' == $relationName) { return $this->initCategoryDocuments(); } + if ('CategoryAssociatedContent' == $relationName) { + return $this->initCategoryAssociatedContents(); + } if ('CategoryI18n' == $relationName) { return $this->initCategoryI18ns(); } @@ -2733,274 +2733,6 @@ abstract class Category implements ActiveRecordInterface return $this->getAttributeCategories($query, $con); } - /** - * Clears out the collContentAssocs collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addContentAssocs() - */ - public function clearContentAssocs() - { - $this->collContentAssocs = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collContentAssocs collection loaded partially. - */ - public function resetPartialContentAssocs($v = true) - { - $this->collContentAssocsPartial = $v; - } - - /** - * Initializes the collContentAssocs collection. - * - * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentAssocs($overrideExisting = true) - { - if (null !== $this->collContentAssocs && !$overrideExisting) { - return; - } - $this->collContentAssocs = new ObjectCollection(); - $this->collContentAssocs->setModel('\Thelia\Model\ContentAssoc'); - } - - /** - * Gets an array of ChildContentAssoc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildCategory is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - * @throws PropelException - */ - public function getContentAssocs($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - // return empty collection - $this->initContentAssocs(); - } else { - $collContentAssocs = ChildContentAssocQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { - $this->initContentAssocs(false); - - foreach ($collContentAssocs as $obj) { - if (false == $this->collContentAssocs->contains($obj)) { - $this->collContentAssocs->append($obj); - } - } - - $this->collContentAssocsPartial = true; - } - - $collContentAssocs->getInternalIterator()->rewind(); - - return $collContentAssocs; - } - - if ($partial && $this->collContentAssocs) { - foreach ($this->collContentAssocs as $obj) { - if ($obj->isNew()) { - $collContentAssocs[] = $obj; - } - } - } - - $this->collContentAssocs = $collContentAssocs; - $this->collContentAssocsPartial = false; - } - } - - return $this->collContentAssocs; - } - - /** - * Sets a collection of ContentAssoc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $contentAssocs A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildCategory The current object (for fluent API support) - */ - public function setContentAssocs(Collection $contentAssocs, ConnectionInterface $con = null) - { - $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - - - $this->contentAssocsScheduledForDeletion = $contentAssocsToDelete; - - foreach ($contentAssocsToDelete as $contentAssocRemoved) { - $contentAssocRemoved->setCategory(null); - } - - $this->collContentAssocs = null; - foreach ($contentAssocs as $contentAssoc) { - $this->addContentAssoc($contentAssoc); - } - - $this->collContentAssocs = $contentAssocs; - $this->collContentAssocsPartial = false; - - return $this; - } - - /** - * Returns the number of related ContentAssoc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related ContentAssoc objects. - * @throws PropelException - */ - public function countContentAssocs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getContentAssocs()); - } - - $query = ChildContentAssocQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collContentAssocs); - } - - /** - * Method called to associate a ChildContentAssoc object to this object - * through the ChildContentAssoc foreign key attribute. - * - * @param ChildContentAssoc $l ChildContentAssoc - * @return \Thelia\Model\Category The current object (for fluent API support) - */ - public function addContentAssoc(ChildContentAssoc $l) - { - if ($this->collContentAssocs === null) { - $this->initContentAssocs(); - $this->collContentAssocsPartial = true; - } - - if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddContentAssoc($l); - } - - return $this; - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to add. - */ - protected function doAddContentAssoc($contentAssoc) - { - $this->collContentAssocs[]= $contentAssoc; - $contentAssoc->setCategory($this); - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to remove. - * @return ChildCategory The current object (for fluent API support) - */ - public function removeContentAssoc($contentAssoc) - { - if ($this->getContentAssocs()->contains($contentAssoc)) { - $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc)); - if (null === $this->contentAssocsScheduledForDeletion) { - $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs; - $this->contentAssocsScheduledForDeletion->clear(); - } - $this->contentAssocsScheduledForDeletion[]= $contentAssoc; - $contentAssoc->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - */ - public function getContentAssocsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildContentAssocQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getContentAssocs($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - */ - public function getContentAssocsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildContentAssocQuery::create(null, $criteria); - $query->joinWith('Content', $joinBehavior); - - return $this->getContentAssocs($query, $con); - } - /** * Clears out the collRewritings collection * @@ -3730,6 +3462,249 @@ abstract class Category implements ActiveRecordInterface return $this; } + /** + * Clears out the collCategoryAssociatedContents collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCategoryAssociatedContents() + */ + public function clearCategoryAssociatedContents() + { + $this->collCategoryAssociatedContents = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCategoryAssociatedContents collection loaded partially. + */ + public function resetPartialCategoryAssociatedContents($v = true) + { + $this->collCategoryAssociatedContentsPartial = $v; + } + + /** + * Initializes the collCategoryAssociatedContents collection. + * + * By default this just sets the collCategoryAssociatedContents collection to an empty array (like clearcollCategoryAssociatedContents()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCategoryAssociatedContents($overrideExisting = true) + { + if (null !== $this->collCategoryAssociatedContents && !$overrideExisting) { + return; + } + $this->collCategoryAssociatedContents = new ObjectCollection(); + $this->collCategoryAssociatedContents->setModel('\Thelia\Model\CategoryAssociatedContent'); + } + + /** + * Gets an array of ChildCategoryAssociatedContent objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildCategory is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCategoryAssociatedContent[] List of ChildCategoryAssociatedContent objects + * @throws PropelException + */ + public function getCategoryAssociatedContents($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCategoryAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collCategoryAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryAssociatedContents) { + // return empty collection + $this->initCategoryAssociatedContents(); + } else { + $collCategoryAssociatedContents = ChildCategoryAssociatedContentQuery::create(null, $criteria) + ->filterByCategory($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCategoryAssociatedContentsPartial && count($collCategoryAssociatedContents)) { + $this->initCategoryAssociatedContents(false); + + foreach ($collCategoryAssociatedContents as $obj) { + if (false == $this->collCategoryAssociatedContents->contains($obj)) { + $this->collCategoryAssociatedContents->append($obj); + } + } + + $this->collCategoryAssociatedContentsPartial = true; + } + + $collCategoryAssociatedContents->getInternalIterator()->rewind(); + + return $collCategoryAssociatedContents; + } + + if ($partial && $this->collCategoryAssociatedContents) { + foreach ($this->collCategoryAssociatedContents as $obj) { + if ($obj->isNew()) { + $collCategoryAssociatedContents[] = $obj; + } + } + } + + $this->collCategoryAssociatedContents = $collCategoryAssociatedContents; + $this->collCategoryAssociatedContentsPartial = false; + } + } + + return $this->collCategoryAssociatedContents; + } + + /** + * Sets a collection of CategoryAssociatedContent objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $categoryAssociatedContents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) + */ + public function setCategoryAssociatedContents(Collection $categoryAssociatedContents, ConnectionInterface $con = null) + { + $categoryAssociatedContentsToDelete = $this->getCategoryAssociatedContents(new Criteria(), $con)->diff($categoryAssociatedContents); + + + $this->categoryAssociatedContentsScheduledForDeletion = $categoryAssociatedContentsToDelete; + + foreach ($categoryAssociatedContentsToDelete as $categoryAssociatedContentRemoved) { + $categoryAssociatedContentRemoved->setCategory(null); + } + + $this->collCategoryAssociatedContents = null; + foreach ($categoryAssociatedContents as $categoryAssociatedContent) { + $this->addCategoryAssociatedContent($categoryAssociatedContent); + } + + $this->collCategoryAssociatedContents = $categoryAssociatedContents; + $this->collCategoryAssociatedContentsPartial = false; + + return $this; + } + + /** + * Returns the number of related CategoryAssociatedContent objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CategoryAssociatedContent objects. + * @throws PropelException + */ + public function countCategoryAssociatedContents(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCategoryAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collCategoryAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryAssociatedContents) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCategoryAssociatedContents()); + } + + $query = ChildCategoryAssociatedContentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); + } + + return count($this->collCategoryAssociatedContents); + } + + /** + * Method called to associate a ChildCategoryAssociatedContent object to this object + * through the ChildCategoryAssociatedContent foreign key attribute. + * + * @param ChildCategoryAssociatedContent $l ChildCategoryAssociatedContent + * @return \Thelia\Model\Category The current object (for fluent API support) + */ + public function addCategoryAssociatedContent(ChildCategoryAssociatedContent $l) + { + if ($this->collCategoryAssociatedContents === null) { + $this->initCategoryAssociatedContents(); + $this->collCategoryAssociatedContentsPartial = true; + } + + if (!in_array($l, $this->collCategoryAssociatedContents->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCategoryAssociatedContent($l); + } + + return $this; + } + + /** + * @param CategoryAssociatedContent $categoryAssociatedContent The categoryAssociatedContent object to add. + */ + protected function doAddCategoryAssociatedContent($categoryAssociatedContent) + { + $this->collCategoryAssociatedContents[]= $categoryAssociatedContent; + $categoryAssociatedContent->setCategory($this); + } + + /** + * @param CategoryAssociatedContent $categoryAssociatedContent The categoryAssociatedContent object to remove. + * @return ChildCategory The current object (for fluent API support) + */ + public function removeCategoryAssociatedContent($categoryAssociatedContent) + { + if ($this->getCategoryAssociatedContents()->contains($categoryAssociatedContent)) { + $this->collCategoryAssociatedContents->remove($this->collCategoryAssociatedContents->search($categoryAssociatedContent)); + if (null === $this->categoryAssociatedContentsScheduledForDeletion) { + $this->categoryAssociatedContentsScheduledForDeletion = clone $this->collCategoryAssociatedContents; + $this->categoryAssociatedContentsScheduledForDeletion->clear(); + } + $this->categoryAssociatedContentsScheduledForDeletion[]= clone $categoryAssociatedContent; + $categoryAssociatedContent->setCategory(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Category is new, it will return + * an empty collection; or if this Category has previously + * been saved, it will retrieve related CategoryAssociatedContents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Category. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildCategoryAssociatedContent[] List of ChildCategoryAssociatedContent objects + */ + public function getCategoryAssociatedContentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildCategoryAssociatedContentQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); + + return $this->getCategoryAssociatedContents($query, $con); + } + /** * Clears out the collCategoryI18ns collection * @@ -4774,11 +4749,6 @@ abstract class Category implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collContentAssocs) { - foreach ($this->collContentAssocs as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collRewritings) { foreach ($this->collRewritings as $o) { $o->clearAllReferences($deep); @@ -4794,6 +4764,11 @@ abstract class Category implements ActiveRecordInterface $o->clearAllReferences($deep); } } + if ($this->collCategoryAssociatedContents) { + foreach ($this->collCategoryAssociatedContents as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collCategoryI18ns) { foreach ($this->collCategoryI18ns as $o) { $o->clearAllReferences($deep); @@ -4837,10 +4812,6 @@ abstract class Category implements ActiveRecordInterface $this->collAttributeCategories->clearIterator(); } $this->collAttributeCategories = null; - if ($this->collContentAssocs instanceof Collection) { - $this->collContentAssocs->clearIterator(); - } - $this->collContentAssocs = null; if ($this->collRewritings instanceof Collection) { $this->collRewritings->clearIterator(); } @@ -4853,6 +4824,10 @@ abstract class Category implements ActiveRecordInterface $this->collCategoryDocuments->clearIterator(); } $this->collCategoryDocuments = null; + if ($this->collCategoryAssociatedContents instanceof Collection) { + $this->collCategoryAssociatedContents->clearIterator(); + } + $this->collCategoryAssociatedContents = null; if ($this->collCategoryI18ns instanceof Collection) { $this->collCategoryI18ns->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php b/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php new file mode 100644 index 000000000..a731ec971 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php @@ -0,0 +1,1553 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CategoryAssociatedContent instance. If + * obj is an instance of CategoryAssociatedContent, delegates to + * equals(CategoryAssociatedContent). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CategoryAssociatedContent The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CategoryAssociatedContent The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [category_id] column value. + * + * @return int + */ + public function getCategoryId() + { + + return $this->category_id; + } + + /** + * Get the [content_id] column value. + * + * @return int + */ + public function getContentId() + { + + return $this->content_id; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [category_id] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + */ + public function setCategoryId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->category_id !== $v) { + $this->category_id = $v; + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::CATEGORY_ID; + } + + if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { + $this->aCategory = null; + } + + + return $this; + } // setCategoryId() + + /** + * Set the value of [content_id] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + */ + public function setContentId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->content_id !== $v) { + $this->content_id = $v; + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::CONTENT_ID; + } + + if ($this->aContent !== null && $this->aContent->getId() !== $v) { + $this->aContent = null; + } + + + return $this; + } // setContentId() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::POSITION; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CategoryAssociatedContentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryAssociatedContentTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->category_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryAssociatedContentTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->content_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryAssociatedContentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryAssociatedContentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryAssociatedContentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = CategoryAssociatedContentTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CategoryAssociatedContent object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { + $this->aCategory = null; + } + if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { + $this->aContent = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCategoryAssociatedContentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCategory = null; + $this->aContent = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CategoryAssociatedContent::setDeleted() + * @see CategoryAssociatedContent::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCategoryAssociatedContentQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CategoryAssociatedContentTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CategoryAssociatedContentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CategoryAssociatedContentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CategoryAssociatedContentTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCategory !== null) { + if ($this->aCategory->isModified() || $this->aCategory->isNew()) { + $affectedRows += $this->aCategory->save($con); + } + $this->setCategory($this->aCategory); + } + + if ($this->aContent !== null) { + if ($this->aContent->isModified() || $this->aContent->isNew()) { + $affectedRows += $this->aContent->save($con); + } + $this->setContent($this->aContent); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryAssociatedContentTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CategoryAssociatedContentTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CategoryAssociatedContentTableMap::CATEGORY_ID)) { + $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; + } + if ($this->isColumnModified(CategoryAssociatedContentTableMap::CONTENT_ID)) { + $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; + } + if ($this->isColumnModified(CategoryAssociatedContentTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(CategoryAssociatedContentTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(CategoryAssociatedContentTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO category_associated_content (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'CATEGORY_ID': + $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); + break; + case 'CONTENT_ID': + $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryAssociatedContentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getCategoryId(); + break; + case 2: + return $this->getContentId(); + break; + case 3: + return $this->getPosition(); + break; + case 4: + return $this->getCreatedAt(); + break; + case 5: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CategoryAssociatedContent'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CategoryAssociatedContent'][$this->getPrimaryKey()] = true; + $keys = CategoryAssociatedContentTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getCategoryId(), + $keys[2] => $this->getContentId(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCategory) { + $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aContent) { + $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryAssociatedContentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setCategoryId($value); + break; + case 2: + $this->setContentId($value); + break; + case 3: + $this->setPosition($value); + break; + case 4: + $this->setCreatedAt($value); + break; + case 5: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = CategoryAssociatedContentTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setContentId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(CategoryAssociatedContentTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CategoryAssociatedContentTableMap::ID)) $criteria->add(CategoryAssociatedContentTableMap::ID, $this->id); + if ($this->isColumnModified(CategoryAssociatedContentTableMap::CATEGORY_ID)) $criteria->add(CategoryAssociatedContentTableMap::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(CategoryAssociatedContentTableMap::CONTENT_ID)) $criteria->add(CategoryAssociatedContentTableMap::CONTENT_ID, $this->content_id); + if ($this->isColumnModified(CategoryAssociatedContentTableMap::POSITION)) $criteria->add(CategoryAssociatedContentTableMap::POSITION, $this->position); + if ($this->isColumnModified(CategoryAssociatedContentTableMap::CREATED_AT)) $criteria->add(CategoryAssociatedContentTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CategoryAssociatedContentTableMap::UPDATED_AT)) $criteria->add(CategoryAssociatedContentTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CategoryAssociatedContentTableMap::DATABASE_NAME); + $criteria->add(CategoryAssociatedContentTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\CategoryAssociatedContent (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setCategoryId($this->getCategoryId()); + $copyObj->setContentId($this->getContentId()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\CategoryAssociatedContent Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildCategory object. + * + * @param ChildCategory $v + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + * @throws PropelException + */ + public function setCategory(ChildCategory $v = null) + { + if ($v === null) { + $this->setCategoryId(NULL); + } else { + $this->setCategoryId($v->getId()); + } + + $this->aCategory = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCategory object, it will not be re-added. + if ($v !== null) { + $v->addCategoryAssociatedContent($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCategory object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategory The associated ChildCategory object. + * @throws PropelException + */ + public function getCategory(ConnectionInterface $con = null) + { + if ($this->aCategory === null && ($this->category_id !== null)) { + $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCategory->addCategoryAssociatedContents($this); + */ + } + + return $this->aCategory; + } + + /** + * Declares an association between this object and a ChildContent object. + * + * @param ChildContent $v + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + * @throws PropelException + */ + public function setContent(ChildContent $v = null) + { + if ($v === null) { + $this->setContentId(NULL); + } else { + $this->setContentId($v->getId()); + } + + $this->aContent = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildContent object, it will not be re-added. + if ($v !== null) { + $v->addCategoryAssociatedContent($this); + } + + + return $this; + } + + + /** + * Get the associated ChildContent object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContent The associated ChildContent object. + * @throws PropelException + */ + public function getContent(ConnectionInterface $con = null) + { + if ($this->aContent === null && ($this->content_id !== null)) { + $this->aContent = ChildContentQuery::create()->findPk($this->content_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aContent->addCategoryAssociatedContents($this); + */ + } + + return $this->aContent; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->category_id = null; + $this->content_id = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCategory = null; + $this->aContent = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CategoryAssociatedContentTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildCategoryAssociatedContent The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/CategoryAssociatedContentQuery.php b/core/lib/Thelia/Model/Base/CategoryAssociatedContentQuery.php new file mode 100644 index 000000000..bb03306f4 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryAssociatedContentQuery.php @@ -0,0 +1,804 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCategoryAssociatedContent|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CategoryAssociatedContentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCategoryAssociatedContent A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, CATEGORY_ID, CONTENT_ID, POSITION, CREATED_AT, UPDATED_AT FROM category_associated_content WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCategoryAssociatedContent(); + $obj->hydrate($row); + CategoryAssociatedContentTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCategoryAssociatedContent|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the category_id column + * + * Example usage: + * + * $query->filterByCategoryId(1234); // WHERE category_id = 1234 + * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 + * + * + * @see filterByCategory() + * + * @param mixed $categoryId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByCategoryId($categoryId = null, $comparison = null) + { + if (is_array($categoryId)) { + $useMinMax = false; + if (isset($categoryId['min'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($categoryId['max'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::CATEGORY_ID, $categoryId, $comparison); + } + + /** + * Filter the query on the content_id column + * + * Example usage: + * + * $query->filterByContentId(1234); // WHERE content_id = 1234 + * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) + * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 + * + * + * @see filterByContent() + * + * @param mixed $contentId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByContentId($contentId = null, $comparison = null) + { + if (is_array($contentId)) { + $useMinMax = false; + if (isset($contentId['min'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($contentId['max'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::CONTENT_ID, $contentId, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Category object + * + * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByCategory($category, $comparison = null) + { + if ($category instanceof \Thelia\Model\Category) { + return $this + ->addUsingAlias(CategoryAssociatedContentTableMap::CATEGORY_ID, $category->getId(), $comparison); + } elseif ($category instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CategoryAssociatedContentTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Category relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Category'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Category'); + } + + return $this; + } + + /** + * Use the Category relation Category object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query + */ + public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCategory($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Content object + * + * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByContent($content, $comparison = null) + { + if ($content instanceof \Thelia\Model\Content) { + return $this + ->addUsingAlias(CategoryAssociatedContentTableMap::CONTENT_ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CategoryAssociatedContentTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Content relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Content'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Content'); + } + + return $this; + } + + /** + * Use the Content relation Content object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query + */ + public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); + } + + /** + * Exclude object from result + * + * @param ChildCategoryAssociatedContent $categoryAssociatedContent Object to remove from the list of results + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function prune($categoryAssociatedContent = null) + { + if ($categoryAssociatedContent) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::ID, $categoryAssociatedContent->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the category_associated_content table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CategoryAssociatedContentTableMap::clearInstancePool(); + CategoryAssociatedContentTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCategoryAssociatedContent or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCategoryAssociatedContent object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CategoryAssociatedContentTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + CategoryAssociatedContentTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CategoryAssociatedContentTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CategoryAssociatedContentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CategoryAssociatedContentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CategoryAssociatedContentTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CategoryAssociatedContentTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CategoryAssociatedContentTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CategoryAssociatedContentTableMap::CREATED_AT); + } + +} // CategoryAssociatedContentQuery diff --git a/core/lib/Thelia/Model/Base/CategoryQuery.php b/core/lib/Thelia/Model/Base/CategoryQuery.php index 5a9c1165f..4c823a223 100644 --- a/core/lib/Thelia/Model/Base/CategoryQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryQuery.php @@ -58,10 +58,6 @@ use Thelia\Model\Map\CategoryTableMap; * @method ChildCategoryQuery rightJoinAttributeCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCategory relation * @method ChildCategoryQuery innerJoinAttributeCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCategory relation * - * @method ChildCategoryQuery leftJoinContentAssoc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentAssoc relation - * @method ChildCategoryQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation - * @method ChildCategoryQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation - * * @method ChildCategoryQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation * @method ChildCategoryQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation * @method ChildCategoryQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation @@ -74,6 +70,10 @@ use Thelia\Model\Map\CategoryTableMap; * @method ChildCategoryQuery rightJoinCategoryDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryDocument relation * @method ChildCategoryQuery innerJoinCategoryDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryDocument relation * + * @method ChildCategoryQuery leftJoinCategoryAssociatedContent($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryAssociatedContent relation + * @method ChildCategoryQuery rightJoinCategoryAssociatedContent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryAssociatedContent relation + * @method ChildCategoryQuery innerJoinCategoryAssociatedContent($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryAssociatedContent relation + * * @method ChildCategoryQuery leftJoinCategoryI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryI18n relation * @method ChildCategoryQuery rightJoinCategoryI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryI18n relation * @method ChildCategoryQuery innerJoinCategoryI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryI18n relation @@ -870,79 +870,6 @@ abstract class CategoryQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery'); } - /** - * Filter the query by a related \Thelia\Model\ContentAssoc object - * - * @param \Thelia\Model\ContentAssoc|ObjectCollection $contentAssoc the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function filterByContentAssoc($contentAssoc, $comparison = null) - { - if ($contentAssoc instanceof \Thelia\Model\ContentAssoc) { - return $this - ->addUsingAlias(CategoryTableMap::ID, $contentAssoc->getCategoryId(), $comparison); - } elseif ($contentAssoc instanceof ObjectCollection) { - return $this - ->useContentAssocQuery() - ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type \Thelia\Model\ContentAssoc or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentAssoc relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentAssoc'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentAssoc'); - } - - return $this; - } - - /** - * Use the ContentAssoc relation ContentAssoc object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query - */ - public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContentAssoc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); - } - /** * Filter the query by a related \Thelia\Model\Rewriting object * @@ -1162,6 +1089,79 @@ abstract class CategoryQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'CategoryDocument', '\Thelia\Model\CategoryDocumentQuery'); } + /** + * Filter the query by a related \Thelia\Model\CategoryAssociatedContent object + * + * @param \Thelia\Model\CategoryAssociatedContent|ObjectCollection $categoryAssociatedContent the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryQuery The current query, for fluid interface + */ + public function filterByCategoryAssociatedContent($categoryAssociatedContent, $comparison = null) + { + if ($categoryAssociatedContent instanceof \Thelia\Model\CategoryAssociatedContent) { + return $this + ->addUsingAlias(CategoryTableMap::ID, $categoryAssociatedContent->getCategoryId(), $comparison); + } elseif ($categoryAssociatedContent instanceof ObjectCollection) { + return $this + ->useCategoryAssociatedContentQuery() + ->filterByPrimaryKeys($categoryAssociatedContent->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCategoryAssociatedContent() only accepts arguments of type \Thelia\Model\CategoryAssociatedContent or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CategoryAssociatedContent relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryQuery The current query, for fluid interface + */ + public function joinCategoryAssociatedContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CategoryAssociatedContent'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CategoryAssociatedContent'); + } + + return $this; + } + + /** + * Use the CategoryAssociatedContent relation CategoryAssociatedContent object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryAssociatedContentQuery A secondary query class using the current class as primary query + */ + public function useCategoryAssociatedContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCategoryAssociatedContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CategoryAssociatedContent', '\Thelia\Model\CategoryAssociatedContentQuery'); + } + /** * Filter the query by a related \Thelia\Model\CategoryI18n object * diff --git a/core/lib/Thelia/Model/Base/Content.php b/core/lib/Thelia/Model/Base/Content.php index e8514fc08..e46d82ac4 100644 --- a/core/lib/Thelia/Model/Base/Content.php +++ b/core/lib/Thelia/Model/Base/Content.php @@ -17,9 +17,9 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; +use Thelia\Model\CategoryAssociatedContent as ChildCategoryAssociatedContent; +use Thelia\Model\CategoryAssociatedContentQuery as ChildCategoryAssociatedContentQuery; use Thelia\Model\Content as ChildContent; -use Thelia\Model\ContentAssoc as ChildContentAssoc; -use Thelia\Model\ContentAssocQuery as ChildContentAssocQuery; use Thelia\Model\ContentDocument as ChildContentDocument; use Thelia\Model\ContentDocumentQuery as ChildContentDocumentQuery; use Thelia\Model\ContentFolder as ChildContentFolder; @@ -33,6 +33,8 @@ use Thelia\Model\ContentVersion as ChildContentVersion; use Thelia\Model\ContentVersionQuery as ChildContentVersionQuery; use Thelia\Model\Folder as ChildFolder; use Thelia\Model\FolderQuery as ChildFolderQuery; +use Thelia\Model\ProductAssociatedContent as ChildProductAssociatedContent; +use Thelia\Model\ProductAssociatedContentQuery as ChildProductAssociatedContentQuery; use Thelia\Model\Rewriting as ChildRewriting; use Thelia\Model\RewritingQuery as ChildRewritingQuery; use Thelia\Model\Map\ContentTableMap; @@ -121,12 +123,6 @@ abstract class Content implements ActiveRecordInterface */ protected $version_created_by; - /** - * @var ObjectCollection|ChildContentAssoc[] Collection to store aggregation of ChildContentAssoc objects. - */ - protected $collContentAssocs; - protected $collContentAssocsPartial; - /** * @var ObjectCollection|ChildRewriting[] Collection to store aggregation of ChildRewriting objects. */ @@ -151,6 +147,18 @@ abstract class Content implements ActiveRecordInterface protected $collContentDocuments; protected $collContentDocumentsPartial; + /** + * @var ObjectCollection|ChildProductAssociatedContent[] Collection to store aggregation of ChildProductAssociatedContent objects. + */ + protected $collProductAssociatedContents; + protected $collProductAssociatedContentsPartial; + + /** + * @var ObjectCollection|ChildCategoryAssociatedContent[] Collection to store aggregation of ChildCategoryAssociatedContent objects. + */ + protected $collCategoryAssociatedContents; + protected $collCategoryAssociatedContentsPartial; + /** * @var ObjectCollection|ChildContentI18n[] Collection to store aggregation of ChildContentI18n objects. */ @@ -204,12 +212,6 @@ abstract class Content implements ActiveRecordInterface */ protected $foldersScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $contentAssocsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -234,6 +236,18 @@ abstract class Content implements ActiveRecordInterface */ protected $contentDocumentsScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $productAssociatedContentsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $categoryAssociatedContentsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -938,8 +952,6 @@ abstract class Content implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->collContentAssocs = null; - $this->collRewritings = null; $this->collContentFolders = null; @@ -948,6 +960,10 @@ abstract class Content implements ActiveRecordInterface $this->collContentDocuments = null; + $this->collProductAssociatedContents = null; + + $this->collCategoryAssociatedContents = null; + $this->collContentI18ns = null; $this->collContentVersions = null; @@ -1125,23 +1141,6 @@ abstract class Content implements ActiveRecordInterface } } - if ($this->contentAssocsScheduledForDeletion !== null) { - if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - \Thelia\Model\ContentAssocQuery::create() - ->filterByPrimaryKeys($this->contentAssocsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->contentAssocsScheduledForDeletion = null; - } - } - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->rewritingsScheduledForDeletion !== null) { if (!$this->rewritingsScheduledForDeletion->isEmpty()) { \Thelia\Model\RewritingQuery::create() @@ -1210,6 +1209,40 @@ abstract class Content implements ActiveRecordInterface } } + if ($this->productAssociatedContentsScheduledForDeletion !== null) { + if (!$this->productAssociatedContentsScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProductAssociatedContentQuery::create() + ->filterByPrimaryKeys($this->productAssociatedContentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->productAssociatedContentsScheduledForDeletion = null; + } + } + + if ($this->collProductAssociatedContents !== null) { + foreach ($this->collProductAssociatedContents as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->categoryAssociatedContentsScheduledForDeletion !== null) { + if (!$this->categoryAssociatedContentsScheduledForDeletion->isEmpty()) { + \Thelia\Model\CategoryAssociatedContentQuery::create() + ->filterByPrimaryKeys($this->categoryAssociatedContentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->categoryAssociatedContentsScheduledForDeletion = null; + } + } + + if ($this->collCategoryAssociatedContents !== null) { + foreach ($this->collCategoryAssociatedContents as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->contentI18nsScheduledForDeletion !== null) { if (!$this->contentI18nsScheduledForDeletion->isEmpty()) { \Thelia\Model\ContentI18nQuery::create() @@ -1460,9 +1493,6 @@ abstract class Content implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->collContentAssocs) { - $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collRewritings) { $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1475,6 +1505,12 @@ abstract class Content implements ActiveRecordInterface if (null !== $this->collContentDocuments) { $result['ContentDocuments'] = $this->collContentDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collProductAssociatedContents) { + $result['ProductAssociatedContents'] = $this->collProductAssociatedContents->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCategoryAssociatedContents) { + $result['CategoryAssociatedContents'] = $this->collCategoryAssociatedContents->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collContentI18ns) { $result['ContentI18ns'] = $this->collContentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1666,12 +1702,6 @@ abstract class Content implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getContentAssocs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentAssoc($relObj->copy($deepCopy)); - } - } - foreach ($this->getRewritings() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addRewriting($relObj->copy($deepCopy)); @@ -1696,6 +1726,18 @@ abstract class Content implements ActiveRecordInterface } } + foreach ($this->getProductAssociatedContents() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addProductAssociatedContent($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCategoryAssociatedContents() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCategoryAssociatedContent($relObj->copy($deepCopy)); + } + } + foreach ($this->getContentI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addContentI18n($relObj->copy($deepCopy)); @@ -1749,9 +1791,6 @@ abstract class Content implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('ContentAssoc' == $relationName) { - return $this->initContentAssocs(); - } if ('Rewriting' == $relationName) { return $this->initRewritings(); } @@ -1764,6 +1803,12 @@ abstract class Content implements ActiveRecordInterface if ('ContentDocument' == $relationName) { return $this->initContentDocuments(); } + if ('ProductAssociatedContent' == $relationName) { + return $this->initProductAssociatedContents(); + } + if ('CategoryAssociatedContent' == $relationName) { + return $this->initCategoryAssociatedContents(); + } if ('ContentI18n' == $relationName) { return $this->initContentI18ns(); } @@ -1772,274 +1817,6 @@ abstract class Content implements ActiveRecordInterface } } - /** - * Clears out the collContentAssocs collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addContentAssocs() - */ - public function clearContentAssocs() - { - $this->collContentAssocs = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collContentAssocs collection loaded partially. - */ - public function resetPartialContentAssocs($v = true) - { - $this->collContentAssocsPartial = $v; - } - - /** - * Initializes the collContentAssocs collection. - * - * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentAssocs($overrideExisting = true) - { - if (null !== $this->collContentAssocs && !$overrideExisting) { - return; - } - $this->collContentAssocs = new ObjectCollection(); - $this->collContentAssocs->setModel('\Thelia\Model\ContentAssoc'); - } - - /** - * Gets an array of ChildContentAssoc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildContent is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - * @throws PropelException - */ - public function getContentAssocs($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - // return empty collection - $this->initContentAssocs(); - } else { - $collContentAssocs = ChildContentAssocQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { - $this->initContentAssocs(false); - - foreach ($collContentAssocs as $obj) { - if (false == $this->collContentAssocs->contains($obj)) { - $this->collContentAssocs->append($obj); - } - } - - $this->collContentAssocsPartial = true; - } - - $collContentAssocs->getInternalIterator()->rewind(); - - return $collContentAssocs; - } - - if ($partial && $this->collContentAssocs) { - foreach ($this->collContentAssocs as $obj) { - if ($obj->isNew()) { - $collContentAssocs[] = $obj; - } - } - } - - $this->collContentAssocs = $collContentAssocs; - $this->collContentAssocsPartial = false; - } - } - - return $this->collContentAssocs; - } - - /** - * Sets a collection of ContentAssoc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $contentAssocs A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildContent The current object (for fluent API support) - */ - public function setContentAssocs(Collection $contentAssocs, ConnectionInterface $con = null) - { - $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - - - $this->contentAssocsScheduledForDeletion = $contentAssocsToDelete; - - foreach ($contentAssocsToDelete as $contentAssocRemoved) { - $contentAssocRemoved->setContent(null); - } - - $this->collContentAssocs = null; - foreach ($contentAssocs as $contentAssoc) { - $this->addContentAssoc($contentAssoc); - } - - $this->collContentAssocs = $contentAssocs; - $this->collContentAssocsPartial = false; - - return $this; - } - - /** - * Returns the number of related ContentAssoc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related ContentAssoc objects. - * @throws PropelException - */ - public function countContentAssocs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getContentAssocs()); - } - - $query = ChildContentAssocQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - - return count($this->collContentAssocs); - } - - /** - * Method called to associate a ChildContentAssoc object to this object - * through the ChildContentAssoc foreign key attribute. - * - * @param ChildContentAssoc $l ChildContentAssoc - * @return \Thelia\Model\Content The current object (for fluent API support) - */ - public function addContentAssoc(ChildContentAssoc $l) - { - if ($this->collContentAssocs === null) { - $this->initContentAssocs(); - $this->collContentAssocsPartial = true; - } - - if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddContentAssoc($l); - } - - return $this; - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to add. - */ - protected function doAddContentAssoc($contentAssoc) - { - $this->collContentAssocs[]= $contentAssoc; - $contentAssoc->setContent($this); - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to remove. - * @return ChildContent The current object (for fluent API support) - */ - public function removeContentAssoc($contentAssoc) - { - if ($this->getContentAssocs()->contains($contentAssoc)) { - $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc)); - if (null === $this->contentAssocsScheduledForDeletion) { - $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs; - $this->contentAssocsScheduledForDeletion->clear(); - } - $this->contentAssocsScheduledForDeletion[]= $contentAssoc; - $contentAssoc->setContent(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - */ - public function getContentAssocsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildContentAssocQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); - - return $this->getContentAssocs($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - */ - public function getContentAssocsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildContentAssocQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getContentAssocs($query, $con); - } - /** * Clears out the collRewritings collection * @@ -3015,6 +2792,492 @@ abstract class Content implements ActiveRecordInterface return $this; } + /** + * Clears out the collProductAssociatedContents collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addProductAssociatedContents() + */ + public function clearProductAssociatedContents() + { + $this->collProductAssociatedContents = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collProductAssociatedContents collection loaded partially. + */ + public function resetPartialProductAssociatedContents($v = true) + { + $this->collProductAssociatedContentsPartial = $v; + } + + /** + * Initializes the collProductAssociatedContents collection. + * + * By default this just sets the collProductAssociatedContents collection to an empty array (like clearcollProductAssociatedContents()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initProductAssociatedContents($overrideExisting = true) + { + if (null !== $this->collProductAssociatedContents && !$overrideExisting) { + return; + } + $this->collProductAssociatedContents = new ObjectCollection(); + $this->collProductAssociatedContents->setModel('\Thelia\Model\ProductAssociatedContent'); + } + + /** + * Gets an array of ChildProductAssociatedContent objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildContent is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProductAssociatedContent[] List of ChildProductAssociatedContent objects + * @throws PropelException + */ + public function getProductAssociatedContents($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collProductAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collProductAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductAssociatedContents) { + // return empty collection + $this->initProductAssociatedContents(); + } else { + $collProductAssociatedContents = ChildProductAssociatedContentQuery::create(null, $criteria) + ->filterByContent($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collProductAssociatedContentsPartial && count($collProductAssociatedContents)) { + $this->initProductAssociatedContents(false); + + foreach ($collProductAssociatedContents as $obj) { + if (false == $this->collProductAssociatedContents->contains($obj)) { + $this->collProductAssociatedContents->append($obj); + } + } + + $this->collProductAssociatedContentsPartial = true; + } + + $collProductAssociatedContents->getInternalIterator()->rewind(); + + return $collProductAssociatedContents; + } + + if ($partial && $this->collProductAssociatedContents) { + foreach ($this->collProductAssociatedContents as $obj) { + if ($obj->isNew()) { + $collProductAssociatedContents[] = $obj; + } + } + } + + $this->collProductAssociatedContents = $collProductAssociatedContents; + $this->collProductAssociatedContentsPartial = false; + } + } + + return $this->collProductAssociatedContents; + } + + /** + * Sets a collection of ProductAssociatedContent objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $productAssociatedContents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) + */ + public function setProductAssociatedContents(Collection $productAssociatedContents, ConnectionInterface $con = null) + { + $productAssociatedContentsToDelete = $this->getProductAssociatedContents(new Criteria(), $con)->diff($productAssociatedContents); + + + $this->productAssociatedContentsScheduledForDeletion = $productAssociatedContentsToDelete; + + foreach ($productAssociatedContentsToDelete as $productAssociatedContentRemoved) { + $productAssociatedContentRemoved->setContent(null); + } + + $this->collProductAssociatedContents = null; + foreach ($productAssociatedContents as $productAssociatedContent) { + $this->addProductAssociatedContent($productAssociatedContent); + } + + $this->collProductAssociatedContents = $productAssociatedContents; + $this->collProductAssociatedContentsPartial = false; + + return $this; + } + + /** + * Returns the number of related ProductAssociatedContent objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related ProductAssociatedContent objects. + * @throws PropelException + */ + public function countProductAssociatedContents(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collProductAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collProductAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductAssociatedContents) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getProductAssociatedContents()); + } + + $query = ChildProductAssociatedContentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); + } + + return count($this->collProductAssociatedContents); + } + + /** + * Method called to associate a ChildProductAssociatedContent object to this object + * through the ChildProductAssociatedContent foreign key attribute. + * + * @param ChildProductAssociatedContent $l ChildProductAssociatedContent + * @return \Thelia\Model\Content The current object (for fluent API support) + */ + public function addProductAssociatedContent(ChildProductAssociatedContent $l) + { + if ($this->collProductAssociatedContents === null) { + $this->initProductAssociatedContents(); + $this->collProductAssociatedContentsPartial = true; + } + + if (!in_array($l, $this->collProductAssociatedContents->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProductAssociatedContent($l); + } + + return $this; + } + + /** + * @param ProductAssociatedContent $productAssociatedContent The productAssociatedContent object to add. + */ + protected function doAddProductAssociatedContent($productAssociatedContent) + { + $this->collProductAssociatedContents[]= $productAssociatedContent; + $productAssociatedContent->setContent($this); + } + + /** + * @param ProductAssociatedContent $productAssociatedContent The productAssociatedContent object to remove. + * @return ChildContent The current object (for fluent API support) + */ + public function removeProductAssociatedContent($productAssociatedContent) + { + if ($this->getProductAssociatedContents()->contains($productAssociatedContent)) { + $this->collProductAssociatedContents->remove($this->collProductAssociatedContents->search($productAssociatedContent)); + if (null === $this->productAssociatedContentsScheduledForDeletion) { + $this->productAssociatedContentsScheduledForDeletion = clone $this->collProductAssociatedContents; + $this->productAssociatedContentsScheduledForDeletion->clear(); + } + $this->productAssociatedContentsScheduledForDeletion[]= clone $productAssociatedContent; + $productAssociatedContent->setContent(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Content is new, it will return + * an empty collection; or if this Content has previously + * been saved, it will retrieve related ProductAssociatedContents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Content. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildProductAssociatedContent[] List of ChildProductAssociatedContent objects + */ + public function getProductAssociatedContentsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildProductAssociatedContentQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); + + return $this->getProductAssociatedContents($query, $con); + } + + /** + * Clears out the collCategoryAssociatedContents collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCategoryAssociatedContents() + */ + public function clearCategoryAssociatedContents() + { + $this->collCategoryAssociatedContents = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCategoryAssociatedContents collection loaded partially. + */ + public function resetPartialCategoryAssociatedContents($v = true) + { + $this->collCategoryAssociatedContentsPartial = $v; + } + + /** + * Initializes the collCategoryAssociatedContents collection. + * + * By default this just sets the collCategoryAssociatedContents collection to an empty array (like clearcollCategoryAssociatedContents()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCategoryAssociatedContents($overrideExisting = true) + { + if (null !== $this->collCategoryAssociatedContents && !$overrideExisting) { + return; + } + $this->collCategoryAssociatedContents = new ObjectCollection(); + $this->collCategoryAssociatedContents->setModel('\Thelia\Model\CategoryAssociatedContent'); + } + + /** + * Gets an array of ChildCategoryAssociatedContent objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildContent is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCategoryAssociatedContent[] List of ChildCategoryAssociatedContent objects + * @throws PropelException + */ + public function getCategoryAssociatedContents($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCategoryAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collCategoryAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryAssociatedContents) { + // return empty collection + $this->initCategoryAssociatedContents(); + } else { + $collCategoryAssociatedContents = ChildCategoryAssociatedContentQuery::create(null, $criteria) + ->filterByContent($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCategoryAssociatedContentsPartial && count($collCategoryAssociatedContents)) { + $this->initCategoryAssociatedContents(false); + + foreach ($collCategoryAssociatedContents as $obj) { + if (false == $this->collCategoryAssociatedContents->contains($obj)) { + $this->collCategoryAssociatedContents->append($obj); + } + } + + $this->collCategoryAssociatedContentsPartial = true; + } + + $collCategoryAssociatedContents->getInternalIterator()->rewind(); + + return $collCategoryAssociatedContents; + } + + if ($partial && $this->collCategoryAssociatedContents) { + foreach ($this->collCategoryAssociatedContents as $obj) { + if ($obj->isNew()) { + $collCategoryAssociatedContents[] = $obj; + } + } + } + + $this->collCategoryAssociatedContents = $collCategoryAssociatedContents; + $this->collCategoryAssociatedContentsPartial = false; + } + } + + return $this->collCategoryAssociatedContents; + } + + /** + * Sets a collection of CategoryAssociatedContent objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $categoryAssociatedContents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) + */ + public function setCategoryAssociatedContents(Collection $categoryAssociatedContents, ConnectionInterface $con = null) + { + $categoryAssociatedContentsToDelete = $this->getCategoryAssociatedContents(new Criteria(), $con)->diff($categoryAssociatedContents); + + + $this->categoryAssociatedContentsScheduledForDeletion = $categoryAssociatedContentsToDelete; + + foreach ($categoryAssociatedContentsToDelete as $categoryAssociatedContentRemoved) { + $categoryAssociatedContentRemoved->setContent(null); + } + + $this->collCategoryAssociatedContents = null; + foreach ($categoryAssociatedContents as $categoryAssociatedContent) { + $this->addCategoryAssociatedContent($categoryAssociatedContent); + } + + $this->collCategoryAssociatedContents = $categoryAssociatedContents; + $this->collCategoryAssociatedContentsPartial = false; + + return $this; + } + + /** + * Returns the number of related CategoryAssociatedContent objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CategoryAssociatedContent objects. + * @throws PropelException + */ + public function countCategoryAssociatedContents(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCategoryAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collCategoryAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryAssociatedContents) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCategoryAssociatedContents()); + } + + $query = ChildCategoryAssociatedContentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); + } + + return count($this->collCategoryAssociatedContents); + } + + /** + * Method called to associate a ChildCategoryAssociatedContent object to this object + * through the ChildCategoryAssociatedContent foreign key attribute. + * + * @param ChildCategoryAssociatedContent $l ChildCategoryAssociatedContent + * @return \Thelia\Model\Content The current object (for fluent API support) + */ + public function addCategoryAssociatedContent(ChildCategoryAssociatedContent $l) + { + if ($this->collCategoryAssociatedContents === null) { + $this->initCategoryAssociatedContents(); + $this->collCategoryAssociatedContentsPartial = true; + } + + if (!in_array($l, $this->collCategoryAssociatedContents->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCategoryAssociatedContent($l); + } + + return $this; + } + + /** + * @param CategoryAssociatedContent $categoryAssociatedContent The categoryAssociatedContent object to add. + */ + protected function doAddCategoryAssociatedContent($categoryAssociatedContent) + { + $this->collCategoryAssociatedContents[]= $categoryAssociatedContent; + $categoryAssociatedContent->setContent($this); + } + + /** + * @param CategoryAssociatedContent $categoryAssociatedContent The categoryAssociatedContent object to remove. + * @return ChildContent The current object (for fluent API support) + */ + public function removeCategoryAssociatedContent($categoryAssociatedContent) + { + if ($this->getCategoryAssociatedContents()->contains($categoryAssociatedContent)) { + $this->collCategoryAssociatedContents->remove($this->collCategoryAssociatedContents->search($categoryAssociatedContent)); + if (null === $this->categoryAssociatedContentsScheduledForDeletion) { + $this->categoryAssociatedContentsScheduledForDeletion = clone $this->collCategoryAssociatedContents; + $this->categoryAssociatedContentsScheduledForDeletion->clear(); + } + $this->categoryAssociatedContentsScheduledForDeletion[]= clone $categoryAssociatedContent; + $categoryAssociatedContent->setContent(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Content is new, it will return + * an empty collection; or if this Content has previously + * been saved, it will retrieve related CategoryAssociatedContents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Content. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildCategoryAssociatedContent[] List of ChildCategoryAssociatedContent objects + */ + public function getCategoryAssociatedContentsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildCategoryAssociatedContentQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); + + return $this->getCategoryAssociatedContents($query, $con); + } + /** * Clears out the collContentI18ns collection * @@ -3677,11 +3940,6 @@ abstract class Content implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collContentAssocs) { - foreach ($this->collContentAssocs as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collRewritings) { foreach ($this->collRewritings as $o) { $o->clearAllReferences($deep); @@ -3702,6 +3960,16 @@ abstract class Content implements ActiveRecordInterface $o->clearAllReferences($deep); } } + if ($this->collProductAssociatedContents) { + foreach ($this->collProductAssociatedContents as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCategoryAssociatedContents) { + foreach ($this->collCategoryAssociatedContents as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collContentI18ns) { foreach ($this->collContentI18ns as $o) { $o->clearAllReferences($deep); @@ -3723,10 +3991,6 @@ abstract class Content implements ActiveRecordInterface $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collContentAssocs instanceof Collection) { - $this->collContentAssocs->clearIterator(); - } - $this->collContentAssocs = null; if ($this->collRewritings instanceof Collection) { $this->collRewritings->clearIterator(); } @@ -3743,6 +4007,14 @@ abstract class Content implements ActiveRecordInterface $this->collContentDocuments->clearIterator(); } $this->collContentDocuments = null; + if ($this->collProductAssociatedContents instanceof Collection) { + $this->collProductAssociatedContents->clearIterator(); + } + $this->collProductAssociatedContents = null; + if ($this->collCategoryAssociatedContents instanceof Collection) { + $this->collCategoryAssociatedContents->clearIterator(); + } + $this->collCategoryAssociatedContents = null; if ($this->collContentI18ns instanceof Collection) { $this->collContentI18ns->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/ContentQuery.php b/core/lib/Thelia/Model/Base/ContentQuery.php index 28d32cbe6..d4749ce46 100644 --- a/core/lib/Thelia/Model/Base/ContentQuery.php +++ b/core/lib/Thelia/Model/Base/ContentQuery.php @@ -44,10 +44,6 @@ use Thelia\Model\Map\ContentTableMap; * @method ChildContentQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildContentQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildContentQuery leftJoinContentAssoc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentAssoc relation - * @method ChildContentQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation - * @method ChildContentQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation - * * @method ChildContentQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation * @method ChildContentQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation * @method ChildContentQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation @@ -64,6 +60,14 @@ use Thelia\Model\Map\ContentTableMap; * @method ChildContentQuery rightJoinContentDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentDocument relation * @method ChildContentQuery innerJoinContentDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentDocument relation * + * @method ChildContentQuery leftJoinProductAssociatedContent($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductAssociatedContent relation + * @method ChildContentQuery rightJoinProductAssociatedContent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductAssociatedContent relation + * @method ChildContentQuery innerJoinProductAssociatedContent($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductAssociatedContent relation + * + * @method ChildContentQuery leftJoinCategoryAssociatedContent($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryAssociatedContent relation + * @method ChildContentQuery rightJoinCategoryAssociatedContent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryAssociatedContent relation + * @method ChildContentQuery innerJoinCategoryAssociatedContent($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryAssociatedContent relation + * * @method ChildContentQuery leftJoinContentI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentI18n relation * @method ChildContentQuery rightJoinContentI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentI18n relation * @method ChildContentQuery innerJoinContentI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentI18n relation @@ -598,79 +602,6 @@ abstract class ContentQuery extends ModelCriteria return $this->addUsingAlias(ContentTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } - /** - * Filter the query by a related \Thelia\Model\ContentAssoc object - * - * @param \Thelia\Model\ContentAssoc|ObjectCollection $contentAssoc the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentQuery The current query, for fluid interface - */ - public function filterByContentAssoc($contentAssoc, $comparison = null) - { - if ($contentAssoc instanceof \Thelia\Model\ContentAssoc) { - return $this - ->addUsingAlias(ContentTableMap::ID, $contentAssoc->getContentId(), $comparison); - } elseif ($contentAssoc instanceof ObjectCollection) { - return $this - ->useContentAssocQuery() - ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type \Thelia\Model\ContentAssoc or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentAssoc relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildContentQuery The current query, for fluid interface - */ - public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentAssoc'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentAssoc'); - } - - return $this; - } - - /** - * Use the ContentAssoc relation ContentAssoc object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query - */ - public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContentAssoc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); - } - /** * Filter the query by a related \Thelia\Model\Rewriting object * @@ -963,6 +894,152 @@ abstract class ContentQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'ContentDocument', '\Thelia\Model\ContentDocumentQuery'); } + /** + * Filter the query by a related \Thelia\Model\ProductAssociatedContent object + * + * @param \Thelia\Model\ProductAssociatedContent|ObjectCollection $productAssociatedContent the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function filterByProductAssociatedContent($productAssociatedContent, $comparison = null) + { + if ($productAssociatedContent instanceof \Thelia\Model\ProductAssociatedContent) { + return $this + ->addUsingAlias(ContentTableMap::ID, $productAssociatedContent->getContentId(), $comparison); + } elseif ($productAssociatedContent instanceof ObjectCollection) { + return $this + ->useProductAssociatedContentQuery() + ->filterByPrimaryKeys($productAssociatedContent->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByProductAssociatedContent() only accepts arguments of type \Thelia\Model\ProductAssociatedContent or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ProductAssociatedContent relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function joinProductAssociatedContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ProductAssociatedContent'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ProductAssociatedContent'); + } + + return $this; + } + + /** + * Use the ProductAssociatedContent relation ProductAssociatedContent object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductAssociatedContentQuery A secondary query class using the current class as primary query + */ + public function useProductAssociatedContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProductAssociatedContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductAssociatedContent', '\Thelia\Model\ProductAssociatedContentQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\CategoryAssociatedContent object + * + * @param \Thelia\Model\CategoryAssociatedContent|ObjectCollection $categoryAssociatedContent the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function filterByCategoryAssociatedContent($categoryAssociatedContent, $comparison = null) + { + if ($categoryAssociatedContent instanceof \Thelia\Model\CategoryAssociatedContent) { + return $this + ->addUsingAlias(ContentTableMap::ID, $categoryAssociatedContent->getContentId(), $comparison); + } elseif ($categoryAssociatedContent instanceof ObjectCollection) { + return $this + ->useCategoryAssociatedContentQuery() + ->filterByPrimaryKeys($categoryAssociatedContent->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCategoryAssociatedContent() only accepts arguments of type \Thelia\Model\CategoryAssociatedContent or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CategoryAssociatedContent relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function joinCategoryAssociatedContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CategoryAssociatedContent'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CategoryAssociatedContent'); + } + + return $this; + } + + /** + * Use the CategoryAssociatedContent relation CategoryAssociatedContent object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryAssociatedContentQuery A secondary query class using the current class as primary query + */ + public function useCategoryAssociatedContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCategoryAssociatedContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CategoryAssociatedContent', '\Thelia\Model\CategoryAssociatedContentQuery'); + } + /** * Filter the query by a related \Thelia\Model\ContentI18n object * diff --git a/core/lib/Thelia/Model/Base/Coupon.php b/core/lib/Thelia/Model/Base/Coupon.php index 89a4dc9e2..643b438b6 100644 --- a/core/lib/Thelia/Model/Base/Coupon.php +++ b/core/lib/Thelia/Model/Base/Coupon.php @@ -99,10 +99,10 @@ abstract class Coupon implements ActiveRecordInterface protected $description; /** - * The value for the value field. + * The value for the amount field. * @var double */ - protected $value; + protected $amount; /** * The value for the is_used field. @@ -123,10 +123,28 @@ abstract class Coupon implements ActiveRecordInterface protected $expiration_date; /** - * The value for the serialized_rules field. + * The value for the serialized_rules_type field. * @var string */ - protected $serialized_rules; + protected $serialized_rules_type; + + /** + * The value for the serialized_rules_content field. + * @var string + */ + protected $serialized_rules_content; + + /** + * The value for the is_cumulative field. + * @var int + */ + protected $is_cumulative; + + /** + * The value for the is_removing_postage field. + * @var int + */ + protected $is_removing_postage; /** * The value for the created_at field. @@ -547,14 +565,14 @@ abstract class Coupon implements ActiveRecordInterface } /** - * Get the [value] column value. + * Get the [amount] column value. * * @return double */ - public function getValue() + public function getAmount() { - return $this->value; + return $this->amount; } /** @@ -600,14 +618,47 @@ abstract class Coupon implements ActiveRecordInterface } /** - * Get the [serialized_rules] column value. + * Get the [serialized_rules_type] column value. * * @return string */ - public function getSerializedRules() + public function getSerializedRulesType() { - return $this->serialized_rules; + return $this->serialized_rules_type; + } + + /** + * Get the [serialized_rules_content] column value. + * + * @return string + */ + public function getSerializedRulesContent() + { + + return $this->serialized_rules_content; + } + + /** + * Get the [is_cumulative] column value. + * + * @return int + */ + public function getIsCumulative() + { + + return $this->is_cumulative; + } + + /** + * Get the [is_removing_postage] column value. + * + * @return int + */ + public function getIsRemovingPostage() + { + + return $this->is_removing_postage; } /** @@ -788,25 +839,25 @@ abstract class Coupon implements ActiveRecordInterface } // setDescription() /** - * Set the value of [value] column. + * Set the value of [amount] column. * * @param double $v new value * @return \Thelia\Model\Coupon The current object (for fluent API support) */ - public function setValue($v) + public function setAmount($v) { if ($v !== null) { $v = (double) $v; } - if ($this->value !== $v) { - $this->value = $v; - $this->modifiedColumns[] = CouponTableMap::VALUE; + if ($this->amount !== $v) { + $this->amount = $v; + $this->modifiedColumns[] = CouponTableMap::AMOUNT; } return $this; - } // setValue() + } // setAmount() /** * Set the value of [is_used] column. @@ -872,25 +923,88 @@ abstract class Coupon implements ActiveRecordInterface } // setExpirationDate() /** - * Set the value of [serialized_rules] column. + * Set the value of [serialized_rules_type] column. * * @param string $v new value * @return \Thelia\Model\Coupon The current object (for fluent API support) */ - public function setSerializedRules($v) + public function setSerializedRulesType($v) { if ($v !== null) { $v = (string) $v; } - if ($this->serialized_rules !== $v) { - $this->serialized_rules = $v; - $this->modifiedColumns[] = CouponTableMap::SERIALIZED_RULES; + if ($this->serialized_rules_type !== $v) { + $this->serialized_rules_type = $v; + $this->modifiedColumns[] = CouponTableMap::SERIALIZED_RULES_TYPE; } return $this; - } // setSerializedRules() + } // setSerializedRulesType() + + /** + * Set the value of [serialized_rules_content] column. + * + * @param string $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setSerializedRulesContent($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->serialized_rules_content !== $v) { + $this->serialized_rules_content = $v; + $this->modifiedColumns[] = CouponTableMap::SERIALIZED_RULES_CONTENT; + } + + + return $this; + } // setSerializedRulesContent() + + /** + * Set the value of [is_cumulative] column. + * + * @param int $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setIsCumulative($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_cumulative !== $v) { + $this->is_cumulative = $v; + $this->modifiedColumns[] = CouponTableMap::IS_CUMULATIVE; + } + + + return $this; + } // setIsCumulative() + + /** + * Set the value of [is_removing_postage] column. + * + * @param int $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setIsRemovingPostage($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_removing_postage !== $v) { + $this->is_removing_postage = $v; + $this->modifiedColumns[] = CouponTableMap::IS_REMOVING_POSTAGE; + } + + + return $this; + } // setIsRemovingPostage() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -1014,8 +1128,8 @@ abstract class Coupon implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; $this->description = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; - $this->value = (null !== $col) ? (double) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponTableMap::translateFieldName('Amount', TableMap::TYPE_PHPNAME, $indexType)]; + $this->amount = (null !== $col) ? (double) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponTableMap::translateFieldName('IsUsed', TableMap::TYPE_PHPNAME, $indexType)]; $this->is_used = (null !== $col) ? (int) $col : null; @@ -1029,22 +1143,31 @@ abstract class Coupon implements ActiveRecordInterface } $this->expiration_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponTableMap::translateFieldName('SerializedRules', TableMap::TYPE_PHPNAME, $indexType)]; - $this->serialized_rules = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponTableMap::translateFieldName('SerializedRulesType', TableMap::TYPE_PHPNAME, $indexType)]; + $this->serialized_rules_type = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponTableMap::translateFieldName('SerializedRulesContent', TableMap::TYPE_PHPNAME, $indexType)]; + $this->serialized_rules_content = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_cumulative = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_removing_postage = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CouponTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; $this->version = (null !== $col) ? (int) $col : null; $this->resetModified(); @@ -1054,7 +1177,7 @@ abstract class Coupon implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 14; // 14 = CouponTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 17; // 17 = CouponTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Coupon object", 0, $e); @@ -1358,8 +1481,8 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::DESCRIPTION)) { $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; } - if ($this->isColumnModified(CouponTableMap::VALUE)) { - $modifiedColumns[':p' . $index++] = 'VALUE'; + if ($this->isColumnModified(CouponTableMap::AMOUNT)) { + $modifiedColumns[':p' . $index++] = 'AMOUNT'; } if ($this->isColumnModified(CouponTableMap::IS_USED)) { $modifiedColumns[':p' . $index++] = 'IS_USED'; @@ -1370,8 +1493,17 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::EXPIRATION_DATE)) { $modifiedColumns[':p' . $index++] = 'EXPIRATION_DATE'; } - if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES)) { - $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES'; + if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES_TYPE)) { + $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES_TYPE'; + } + if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES_CONTENT)) { + $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES_CONTENT'; + } + if ($this->isColumnModified(CouponTableMap::IS_CUMULATIVE)) { + $modifiedColumns[':p' . $index++] = 'IS_CUMULATIVE'; + } + if ($this->isColumnModified(CouponTableMap::IS_REMOVING_POSTAGE)) { + $modifiedColumns[':p' . $index++] = 'IS_REMOVING_POSTAGE'; } if ($this->isColumnModified(CouponTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -1411,8 +1543,8 @@ abstract class Coupon implements ActiveRecordInterface case 'DESCRIPTION': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case 'VALUE': - $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); + case 'AMOUNT': + $stmt->bindValue($identifier, $this->amount, PDO::PARAM_STR); break; case 'IS_USED': $stmt->bindValue($identifier, $this->is_used, PDO::PARAM_INT); @@ -1423,8 +1555,17 @@ abstract class Coupon implements ActiveRecordInterface case 'EXPIRATION_DATE': $stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case 'SERIALIZED_RULES': - $stmt->bindValue($identifier, $this->serialized_rules, PDO::PARAM_STR); + case 'SERIALIZED_RULES_TYPE': + $stmt->bindValue($identifier, $this->serialized_rules_type, PDO::PARAM_STR); + break; + case 'SERIALIZED_RULES_CONTENT': + $stmt->bindValue($identifier, $this->serialized_rules_content, PDO::PARAM_STR); + break; + case 'IS_CUMULATIVE': + $stmt->bindValue($identifier, $this->is_cumulative, PDO::PARAM_INT); + break; + case 'IS_REMOVING_POSTAGE': + $stmt->bindValue($identifier, $this->is_removing_postage, PDO::PARAM_INT); break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); @@ -1516,7 +1657,7 @@ abstract class Coupon implements ActiveRecordInterface return $this->getDescription(); break; case 6: - return $this->getValue(); + return $this->getAmount(); break; case 7: return $this->getIsUsed(); @@ -1528,15 +1669,24 @@ abstract class Coupon implements ActiveRecordInterface return $this->getExpirationDate(); break; case 10: - return $this->getSerializedRules(); + return $this->getSerializedRulesType(); break; case 11: - return $this->getCreatedAt(); + return $this->getSerializedRulesContent(); break; case 12: - return $this->getUpdatedAt(); + return $this->getIsCumulative(); break; case 13: + return $this->getIsRemovingPostage(); + break; + case 14: + return $this->getCreatedAt(); + break; + case 15: + return $this->getUpdatedAt(); + break; + case 16: return $this->getVersion(); break; default: @@ -1574,14 +1724,17 @@ abstract class Coupon implements ActiveRecordInterface $keys[3] => $this->getTitle(), $keys[4] => $this->getShortDescription(), $keys[5] => $this->getDescription(), - $keys[6] => $this->getValue(), + $keys[6] => $this->getAmount(), $keys[7] => $this->getIsUsed(), $keys[8] => $this->getIsEnabled(), $keys[9] => $this->getExpirationDate(), - $keys[10] => $this->getSerializedRules(), - $keys[11] => $this->getCreatedAt(), - $keys[12] => $this->getUpdatedAt(), - $keys[13] => $this->getVersion(), + $keys[10] => $this->getSerializedRulesType(), + $keys[11] => $this->getSerializedRulesContent(), + $keys[12] => $this->getIsCumulative(), + $keys[13] => $this->getIsRemovingPostage(), + $keys[14] => $this->getCreatedAt(), + $keys[15] => $this->getUpdatedAt(), + $keys[16] => $this->getVersion(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1652,7 +1805,7 @@ abstract class Coupon implements ActiveRecordInterface $this->setDescription($value); break; case 6: - $this->setValue($value); + $this->setAmount($value); break; case 7: $this->setIsUsed($value); @@ -1664,15 +1817,24 @@ abstract class Coupon implements ActiveRecordInterface $this->setExpirationDate($value); break; case 10: - $this->setSerializedRules($value); + $this->setSerializedRulesType($value); break; case 11: - $this->setCreatedAt($value); + $this->setSerializedRulesContent($value); break; case 12: - $this->setUpdatedAt($value); + $this->setIsCumulative($value); break; case 13: + $this->setIsRemovingPostage($value); + break; + case 14: + $this->setCreatedAt($value); + break; + case 15: + $this->setUpdatedAt($value); + break; + case 16: $this->setVersion($value); break; } // switch() @@ -1705,14 +1867,17 @@ abstract class Coupon implements ActiveRecordInterface if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setShortDescription($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setDescription($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setValue($arr[$keys[6]]); + if (array_key_exists($keys[6], $arr)) $this->setAmount($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setIsUsed($arr[$keys[7]]); if (array_key_exists($keys[8], $arr)) $this->setIsEnabled($arr[$keys[8]]); if (array_key_exists($keys[9], $arr)) $this->setExpirationDate($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setSerializedRules($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setCreatedAt($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setUpdatedAt($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setVersion($arr[$keys[13]]); + if (array_key_exists($keys[10], $arr)) $this->setSerializedRulesType($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setSerializedRulesContent($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setIsCumulative($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setIsRemovingPostage($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setCreatedAt($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setUpdatedAt($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setVersion($arr[$keys[16]]); } /** @@ -1730,11 +1895,14 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::TITLE)) $criteria->add(CouponTableMap::TITLE, $this->title); if ($this->isColumnModified(CouponTableMap::SHORT_DESCRIPTION)) $criteria->add(CouponTableMap::SHORT_DESCRIPTION, $this->short_description); if ($this->isColumnModified(CouponTableMap::DESCRIPTION)) $criteria->add(CouponTableMap::DESCRIPTION, $this->description); - if ($this->isColumnModified(CouponTableMap::VALUE)) $criteria->add(CouponTableMap::VALUE, $this->value); + if ($this->isColumnModified(CouponTableMap::AMOUNT)) $criteria->add(CouponTableMap::AMOUNT, $this->amount); if ($this->isColumnModified(CouponTableMap::IS_USED)) $criteria->add(CouponTableMap::IS_USED, $this->is_used); if ($this->isColumnModified(CouponTableMap::IS_ENABLED)) $criteria->add(CouponTableMap::IS_ENABLED, $this->is_enabled); if ($this->isColumnModified(CouponTableMap::EXPIRATION_DATE)) $criteria->add(CouponTableMap::EXPIRATION_DATE, $this->expiration_date); - if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES)) $criteria->add(CouponTableMap::SERIALIZED_RULES, $this->serialized_rules); + if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES_TYPE)) $criteria->add(CouponTableMap::SERIALIZED_RULES_TYPE, $this->serialized_rules_type); + if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES_CONTENT)) $criteria->add(CouponTableMap::SERIALIZED_RULES_CONTENT, $this->serialized_rules_content); + if ($this->isColumnModified(CouponTableMap::IS_CUMULATIVE)) $criteria->add(CouponTableMap::IS_CUMULATIVE, $this->is_cumulative); + if ($this->isColumnModified(CouponTableMap::IS_REMOVING_POSTAGE)) $criteria->add(CouponTableMap::IS_REMOVING_POSTAGE, $this->is_removing_postage); if ($this->isColumnModified(CouponTableMap::CREATED_AT)) $criteria->add(CouponTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) $criteria->add(CouponTableMap::UPDATED_AT, $this->updated_at); if ($this->isColumnModified(CouponTableMap::VERSION)) $criteria->add(CouponTableMap::VERSION, $this->version); @@ -1806,11 +1974,14 @@ abstract class Coupon implements ActiveRecordInterface $copyObj->setTitle($this->getTitle()); $copyObj->setShortDescription($this->getShortDescription()); $copyObj->setDescription($this->getDescription()); - $copyObj->setValue($this->getValue()); + $copyObj->setAmount($this->getAmount()); $copyObj->setIsUsed($this->getIsUsed()); $copyObj->setIsEnabled($this->getIsEnabled()); $copyObj->setExpirationDate($this->getExpirationDate()); - $copyObj->setSerializedRules($this->getSerializedRules()); + $copyObj->setSerializedRulesType($this->getSerializedRulesType()); + $copyObj->setSerializedRulesContent($this->getSerializedRulesContent()); + $copyObj->setIsCumulative($this->getIsCumulative()); + $copyObj->setIsRemovingPostage($this->getIsRemovingPostage()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); $copyObj->setVersion($this->getVersion()); @@ -2590,11 +2761,14 @@ abstract class Coupon implements ActiveRecordInterface $this->title = null; $this->short_description = null; $this->description = null; - $this->value = null; + $this->amount = null; $this->is_used = null; $this->is_enabled = null; $this->expiration_date = null; - $this->serialized_rules = null; + $this->serialized_rules_type = null; + $this->serialized_rules_content = null; + $this->is_cumulative = null; + $this->is_removing_postage = null; $this->created_at = null; $this->updated_at = null; $this->version = null; @@ -2830,11 +3004,14 @@ abstract class Coupon implements ActiveRecordInterface $version->setTitle($this->getTitle()); $version->setShortDescription($this->getShortDescription()); $version->setDescription($this->getDescription()); - $version->setValue($this->getValue()); + $version->setAmount($this->getAmount()); $version->setIsUsed($this->getIsUsed()); $version->setIsEnabled($this->getIsEnabled()); $version->setExpirationDate($this->getExpirationDate()); - $version->setSerializedRules($this->getSerializedRules()); + $version->setSerializedRulesType($this->getSerializedRulesType()); + $version->setSerializedRulesContent($this->getSerializedRulesContent()); + $version->setIsCumulative($this->getIsCumulative()); + $version->setIsRemovingPostage($this->getIsRemovingPostage()); $version->setCreatedAt($this->getCreatedAt()); $version->setUpdatedAt($this->getUpdatedAt()); $version->setVersion($this->getVersion()); @@ -2881,11 +3058,14 @@ abstract class Coupon implements ActiveRecordInterface $this->setTitle($version->getTitle()); $this->setShortDescription($version->getShortDescription()); $this->setDescription($version->getDescription()); - $this->setValue($version->getValue()); + $this->setAmount($version->getAmount()); $this->setIsUsed($version->getIsUsed()); $this->setIsEnabled($version->getIsEnabled()); $this->setExpirationDate($version->getExpirationDate()); - $this->setSerializedRules($version->getSerializedRules()); + $this->setSerializedRulesType($version->getSerializedRulesType()); + $this->setSerializedRulesContent($version->getSerializedRulesContent()); + $this->setIsCumulative($version->getIsCumulative()); + $this->setIsRemovingPostage($version->getIsRemovingPostage()); $this->setCreatedAt($version->getCreatedAt()); $this->setUpdatedAt($version->getUpdatedAt()); $this->setVersion($version->getVersion()); diff --git a/core/lib/Thelia/Model/Base/CouponI18n.php b/core/lib/Thelia/Model/Base/CouponI18n.php new file mode 100644 index 000000000..bc7cc8cdc --- /dev/null +++ b/core/lib/Thelia/Model/Base/CouponI18n.php @@ -0,0 +1,1207 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\CouponI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CouponI18n instance. If + * obj is an instance of CouponI18n, delegates to + * equals(CouponI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CouponI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CouponI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CouponI18nTableMap::ID; + } + + if ($this->aCoupon !== null && $this->aCoupon->getId() !== $v) { + $this->aCoupon = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = CouponI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_EN') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CouponI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CouponI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 2; // 2 = CouponI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CouponI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aCoupon !== null && $this->id !== $this->aCoupon->getId()) { + $this->aCoupon = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CouponI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCouponI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCoupon = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CouponI18n::setDeleted() + * @see CouponI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCouponI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CouponI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCoupon !== null) { + if ($this->aCoupon->isModified() || $this->aCoupon->isNew()) { + $affectedRows += $this->aCoupon->save($con); + } + $this->setCoupon($this->aCoupon); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CouponI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CouponI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + + $sql = sprintf( + 'INSERT INTO coupon_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CouponI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CouponI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CouponI18n'][serialize($this->getPrimaryKey())] = true; + $keys = CouponI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCoupon) { + $result['Coupon'] = $this->aCoupon->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CouponI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = CouponI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(CouponI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CouponI18nTableMap::ID)) $criteria->add(CouponI18nTableMap::ID, $this->id); + if ($this->isColumnModified(CouponI18nTableMap::LOCALE)) $criteria->add(CouponI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CouponI18nTableMap::DATABASE_NAME); + $criteria->add(CouponI18nTableMap::ID, $this->id); + $criteria->add(CouponI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\CouponI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\CouponI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildCoupon object. + * + * @param ChildCoupon $v + * @return \Thelia\Model\CouponI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setCoupon(ChildCoupon $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aCoupon = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCoupon object, it will not be re-added. + if ($v !== null) { + $v->addCouponI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCoupon object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCoupon The associated ChildCoupon object. + * @throws PropelException + */ + public function getCoupon(ConnectionInterface $con = null) + { + if ($this->aCoupon === null && ($this->id !== null)) { + $this->aCoupon = ChildCouponQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCoupon->addCouponI18ns($this); + */ + } + + return $this->aCoupon; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCoupon = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CouponI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/CouponI18nQuery.php b/core/lib/Thelia/Model/Base/CouponI18nQuery.php new file mode 100644 index 000000000..9468f787f --- /dev/null +++ b/core/lib/Thelia/Model/Base/CouponI18nQuery.php @@ -0,0 +1,475 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCouponI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CouponI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CouponI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCouponI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE FROM coupon_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCouponI18n(); + $obj->hydrate($row); + CouponI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCouponI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(CouponI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(CouponI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(CouponI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(CouponI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByCoupon() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CouponI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CouponI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Coupon object + * + * @param \Thelia\Model\Coupon|ObjectCollection $coupon The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function filterByCoupon($coupon, $comparison = null) + { + if ($coupon instanceof \Thelia\Model\Coupon) { + return $this + ->addUsingAlias(CouponI18nTableMap::ID, $coupon->getId(), $comparison); + } elseif ($coupon instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CouponI18nTableMap::ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCoupon() only accepts arguments of type \Thelia\Model\Coupon or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Coupon relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function joinCoupon($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Coupon'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Coupon'); + } + + return $this; + } + + /** + * Use the Coupon relation Coupon object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CouponQuery A secondary query class using the current class as primary query + */ + public function useCouponQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinCoupon($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery'); + } + + /** + * Exclude object from result + * + * @param ChildCouponI18n $couponI18n Object to remove from the list of results + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function prune($couponI18n = null) + { + if ($couponI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(CouponI18nTableMap::ID), $couponI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(CouponI18nTableMap::LOCALE), $couponI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the coupon_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CouponI18nTableMap::clearInstancePool(); + CouponI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCouponI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCouponI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CouponI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + CouponI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CouponI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // CouponI18nQuery diff --git a/core/lib/Thelia/Model/Base/CouponQuery.php b/core/lib/Thelia/Model/Base/CouponQuery.php index fa5700786..196dbbdaa 100644 --- a/core/lib/Thelia/Model/Base/CouponQuery.php +++ b/core/lib/Thelia/Model/Base/CouponQuery.php @@ -28,11 +28,14 @@ use Thelia\Model\Map\CouponTableMap; * @method ChildCouponQuery orderByTitle($order = Criteria::ASC) Order by the title column * @method ChildCouponQuery orderByShortDescription($order = Criteria::ASC) Order by the short_description column * @method ChildCouponQuery orderByDescription($order = Criteria::ASC) Order by the description column - * @method ChildCouponQuery orderByValue($order = Criteria::ASC) Order by the value column + * @method ChildCouponQuery orderByAmount($order = Criteria::ASC) Order by the amount column * @method ChildCouponQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column * @method ChildCouponQuery orderByIsEnabled($order = Criteria::ASC) Order by the is_enabled column * @method ChildCouponQuery orderByExpirationDate($order = Criteria::ASC) Order by the expiration_date column - * @method ChildCouponQuery orderBySerializedRules($order = Criteria::ASC) Order by the serialized_rules column + * @method ChildCouponQuery orderBySerializedRulesType($order = Criteria::ASC) Order by the serialized_rules_type column + * @method ChildCouponQuery orderBySerializedRulesContent($order = Criteria::ASC) Order by the serialized_rules_content column + * @method ChildCouponQuery orderByIsCumulative($order = Criteria::ASC) Order by the is_cumulative column + * @method ChildCouponQuery orderByIsRemovingPostage($order = Criteria::ASC) Order by the is_removing_postage column * @method ChildCouponQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCouponQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @method ChildCouponQuery orderByVersion($order = Criteria::ASC) Order by the version column @@ -43,11 +46,14 @@ use Thelia\Model\Map\CouponTableMap; * @method ChildCouponQuery groupByTitle() Group by the title column * @method ChildCouponQuery groupByShortDescription() Group by the short_description column * @method ChildCouponQuery groupByDescription() Group by the description column - * @method ChildCouponQuery groupByValue() Group by the value column + * @method ChildCouponQuery groupByAmount() Group by the amount column * @method ChildCouponQuery groupByIsUsed() Group by the is_used column * @method ChildCouponQuery groupByIsEnabled() Group by the is_enabled column * @method ChildCouponQuery groupByExpirationDate() Group by the expiration_date column - * @method ChildCouponQuery groupBySerializedRules() Group by the serialized_rules column + * @method ChildCouponQuery groupBySerializedRulesType() Group by the serialized_rules_type column + * @method ChildCouponQuery groupBySerializedRulesContent() Group by the serialized_rules_content column + * @method ChildCouponQuery groupByIsCumulative() Group by the is_cumulative column + * @method ChildCouponQuery groupByIsRemovingPostage() Group by the is_removing_postage column * @method ChildCouponQuery groupByCreatedAt() Group by the created_at column * @method ChildCouponQuery groupByUpdatedAt() Group by the updated_at column * @method ChildCouponQuery groupByVersion() Group by the version column @@ -77,11 +83,14 @@ use Thelia\Model\Map\CouponTableMap; * @method ChildCoupon findOneByTitle(string $title) Return the first ChildCoupon filtered by the title column * @method ChildCoupon findOneByShortDescription(string $short_description) Return the first ChildCoupon filtered by the short_description column * @method ChildCoupon findOneByDescription(string $description) Return the first ChildCoupon filtered by the description column - * @method ChildCoupon findOneByValue(double $value) Return the first ChildCoupon filtered by the value column + * @method ChildCoupon findOneByAmount(double $amount) Return the first ChildCoupon filtered by the amount column * @method ChildCoupon findOneByIsUsed(int $is_used) Return the first ChildCoupon filtered by the is_used column * @method ChildCoupon findOneByIsEnabled(int $is_enabled) Return the first ChildCoupon filtered by the is_enabled column * @method ChildCoupon findOneByExpirationDate(string $expiration_date) Return the first ChildCoupon filtered by the expiration_date column - * @method ChildCoupon findOneBySerializedRules(string $serialized_rules) Return the first ChildCoupon filtered by the serialized_rules column + * @method ChildCoupon findOneBySerializedRulesType(string $serialized_rules_type) Return the first ChildCoupon filtered by the serialized_rules_type column + * @method ChildCoupon findOneBySerializedRulesContent(string $serialized_rules_content) Return the first ChildCoupon filtered by the serialized_rules_content column + * @method ChildCoupon findOneByIsCumulative(int $is_cumulative) Return the first ChildCoupon filtered by the is_cumulative column + * @method ChildCoupon findOneByIsRemovingPostage(int $is_removing_postage) Return the first ChildCoupon filtered by the is_removing_postage column * @method ChildCoupon findOneByCreatedAt(string $created_at) Return the first ChildCoupon filtered by the created_at column * @method ChildCoupon findOneByUpdatedAt(string $updated_at) Return the first ChildCoupon filtered by the updated_at column * @method ChildCoupon findOneByVersion(int $version) Return the first ChildCoupon filtered by the version column @@ -92,11 +101,14 @@ use Thelia\Model\Map\CouponTableMap; * @method array findByTitle(string $title) Return ChildCoupon objects filtered by the title column * @method array findByShortDescription(string $short_description) Return ChildCoupon objects filtered by the short_description column * @method array findByDescription(string $description) Return ChildCoupon objects filtered by the description column - * @method array findByValue(double $value) Return ChildCoupon objects filtered by the value column + * @method array findByAmount(double $amount) Return ChildCoupon objects filtered by the amount column * @method array findByIsUsed(int $is_used) Return ChildCoupon objects filtered by the is_used column * @method array findByIsEnabled(int $is_enabled) Return ChildCoupon objects filtered by the is_enabled column * @method array findByExpirationDate(string $expiration_date) Return ChildCoupon objects filtered by the expiration_date column - * @method array findBySerializedRules(string $serialized_rules) Return ChildCoupon objects filtered by the serialized_rules column + * @method array findBySerializedRulesType(string $serialized_rules_type) Return ChildCoupon objects filtered by the serialized_rules_type column + * @method array findBySerializedRulesContent(string $serialized_rules_content) Return ChildCoupon objects filtered by the serialized_rules_content column + * @method array findByIsCumulative(int $is_cumulative) Return ChildCoupon objects filtered by the is_cumulative column + * @method array findByIsRemovingPostage(int $is_removing_postage) Return ChildCoupon objects filtered by the is_removing_postage column * @method array findByCreatedAt(string $created_at) Return ChildCoupon objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCoupon objects filtered by the updated_at column * @method array findByVersion(int $version) Return ChildCoupon objects filtered by the version column @@ -195,7 +207,7 @@ abstract class CouponQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, VALUE, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES, CREATED_AT, UPDATED_AT, VERSION FROM coupon WHERE ID = :p0'; + $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, AMOUNT, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES_TYPE, SERIALIZED_RULES_CONTENT, IS_CUMULATIVE, IS_REMOVING_POSTAGE, CREATED_AT, UPDATED_AT, VERSION FROM coupon WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -471,16 +483,16 @@ abstract class CouponQuery extends ModelCriteria } /** - * Filter the query on the value column + * Filter the query on the amount column * * Example usage: * - * $query->filterByValue(1234); // WHERE value = 1234 - * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34) - * $query->filterByValue(array('min' => 12)); // WHERE value > 12 + * $query->filterByAmount(1234); // WHERE amount = 1234 + * $query->filterByAmount(array(12, 34)); // WHERE amount IN (12, 34) + * $query->filterByAmount(array('min' => 12)); // WHERE amount > 12 * * - * @param mixed $value The value to use as filter. + * @param mixed $amount The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -488,16 +500,16 @@ abstract class CouponQuery extends ModelCriteria * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterByValue($value = null, $comparison = null) + public function filterByAmount($amount = null, $comparison = null) { - if (is_array($value)) { + if (is_array($amount)) { $useMinMax = false; - if (isset($value['min'])) { - $this->addUsingAlias(CouponTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL); + if (isset($amount['min'])) { + $this->addUsingAlias(CouponTableMap::AMOUNT, $amount['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($value['max'])) { - $this->addUsingAlias(CouponTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL); + if (isset($amount['max'])) { + $this->addUsingAlias(CouponTableMap::AMOUNT, $amount['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -508,7 +520,7 @@ abstract class CouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponTableMap::VALUE, $value, $comparison); + return $this->addUsingAlias(CouponTableMap::AMOUNT, $amount, $comparison); } /** @@ -637,32 +649,143 @@ abstract class CouponQuery extends ModelCriteria } /** - * Filter the query on the serialized_rules column + * Filter the query on the serialized_rules_type column * * Example usage: * - * $query->filterBySerializedRules('fooValue'); // WHERE serialized_rules = 'fooValue' - * $query->filterBySerializedRules('%fooValue%'); // WHERE serialized_rules LIKE '%fooValue%' + * $query->filterBySerializedRulesType('fooValue'); // WHERE serialized_rules_type = 'fooValue' + * $query->filterBySerializedRulesType('%fooValue%'); // WHERE serialized_rules_type LIKE '%fooValue%' * * - * @param string $serializedRules The value to use as filter. + * @param string $serializedRulesType The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterBySerializedRules($serializedRules = null, $comparison = null) + public function filterBySerializedRulesType($serializedRulesType = null, $comparison = null) { if (null === $comparison) { - if (is_array($serializedRules)) { + if (is_array($serializedRulesType)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $serializedRules)) { - $serializedRules = str_replace('*', '%', $serializedRules); + } elseif (preg_match('/[\%\*]/', $serializedRulesType)) { + $serializedRulesType = str_replace('*', '%', $serializedRulesType); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(CouponTableMap::SERIALIZED_RULES, $serializedRules, $comparison); + return $this->addUsingAlias(CouponTableMap::SERIALIZED_RULES_TYPE, $serializedRulesType, $comparison); + } + + /** + * Filter the query on the serialized_rules_content column + * + * Example usage: + * + * $query->filterBySerializedRulesContent('fooValue'); // WHERE serialized_rules_content = 'fooValue' + * $query->filterBySerializedRulesContent('%fooValue%'); // WHERE serialized_rules_content LIKE '%fooValue%' + * + * + * @param string $serializedRulesContent The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterBySerializedRulesContent($serializedRulesContent = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($serializedRulesContent)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $serializedRulesContent)) { + $serializedRulesContent = str_replace('*', '%', $serializedRulesContent); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponTableMap::SERIALIZED_RULES_CONTENT, $serializedRulesContent, $comparison); + } + + /** + * Filter the query on the is_cumulative column + * + * Example usage: + * + * $query->filterByIsCumulative(1234); // WHERE is_cumulative = 1234 + * $query->filterByIsCumulative(array(12, 34)); // WHERE is_cumulative IN (12, 34) + * $query->filterByIsCumulative(array('min' => 12)); // WHERE is_cumulative > 12 + * + * + * @param mixed $isCumulative The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByIsCumulative($isCumulative = null, $comparison = null) + { + if (is_array($isCumulative)) { + $useMinMax = false; + if (isset($isCumulative['min'])) { + $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isCumulative['max'])) { + $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative, $comparison); + } + + /** + * Filter the query on the is_removing_postage column + * + * Example usage: + * + * $query->filterByIsRemovingPostage(1234); // WHERE is_removing_postage = 1234 + * $query->filterByIsRemovingPostage(array(12, 34)); // WHERE is_removing_postage IN (12, 34) + * $query->filterByIsRemovingPostage(array('min' => 12)); // WHERE is_removing_postage > 12 + * + * + * @param mixed $isRemovingPostage The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByIsRemovingPostage($isRemovingPostage = null, $comparison = null) + { + if (is_array($isRemovingPostage)) { + $useMinMax = false; + if (isset($isRemovingPostage['min'])) { + $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isRemovingPostage['max'])) { + $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison); } /** diff --git a/core/lib/Thelia/Model/Base/CouponVersion.php b/core/lib/Thelia/Model/Base/CouponVersion.php new file mode 100644 index 000000000..5fcf14d45 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CouponVersion.php @@ -0,0 +1,2115 @@ +version = 0; + } + + /** + * Initializes internal state of Thelia\Model\Base\CouponVersion object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CouponVersion instance. If + * obj is an instance of CouponVersion, delegates to + * equals(CouponVersion). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CouponVersion The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CouponVersion The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [code] column value. + * + * @return string + */ + public function getCode() + { + + return $this->code; + } + + /** + * Get the [type] column value. + * + * @return string + */ + public function getType() + { + + return $this->type; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [short_description] column value. + * + * @return string + */ + public function getShortDescription() + { + + return $this->short_description; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [amount] column value. + * + * @return double + */ + public function getAmount() + { + + return $this->amount; + } + + /** + * Get the [is_used] column value. + * + * @return int + */ + public function getIsUsed() + { + + return $this->is_used; + } + + /** + * Get the [is_enabled] column value. + * + * @return int + */ + public function getIsEnabled() + { + + return $this->is_enabled; + } + + /** + * Get the [optionally formatted] temporal [expiration_date] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getExpirationDate($format = NULL) + { + if ($format === null) { + return $this->expiration_date; + } else { + return $this->expiration_date !== null ? $this->expiration_date->format($format) : null; + } + } + + /** + * Get the [serialized_rules_type] column value. + * + * @return string + */ + public function getSerializedRulesType() + { + + return $this->serialized_rules_type; + } + + /** + * Get the [serialized_rules_content] column value. + * + * @return string + */ + public function getSerializedRulesContent() + { + + return $this->serialized_rules_content; + } + + /** + * Get the [is_cumulative] column value. + * + * @return int + */ + public function getIsCumulative() + { + + return $this->is_cumulative; + } + + /** + * Get the [is_removing_postage] column value. + * + * @return int + */ + public function getIsRemovingPostage() + { + + return $this->is_removing_postage; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Get the [version] column value. + * + * @return int + */ + public function getVersion() + { + + return $this->version; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CouponVersionTableMap::ID; + } + + if ($this->aCoupon !== null && $this->aCoupon->getId() !== $v) { + $this->aCoupon = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [code] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setCode($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->code !== $v) { + $this->code = $v; + $this->modifiedColumns[] = CouponVersionTableMap::CODE; + } + + + return $this; + } // setCode() + + /** + * Set the value of [type] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setType($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = CouponVersionTableMap::TYPE; + } + + + return $this; + } // setType() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = CouponVersionTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [short_description] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setShortDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->short_description !== $v) { + $this->short_description = $v; + $this->modifiedColumns[] = CouponVersionTableMap::SHORT_DESCRIPTION; + } + + + return $this; + } // setShortDescription() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CouponVersionTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [amount] column. + * + * @param double $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setAmount($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->amount !== $v) { + $this->amount = $v; + $this->modifiedColumns[] = CouponVersionTableMap::AMOUNT; + } + + + return $this; + } // setAmount() + + /** + * Set the value of [is_used] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setIsUsed($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_used !== $v) { + $this->is_used = $v; + $this->modifiedColumns[] = CouponVersionTableMap::IS_USED; + } + + + return $this; + } // setIsUsed() + + /** + * Set the value of [is_enabled] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setIsEnabled($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_enabled !== $v) { + $this->is_enabled = $v; + $this->modifiedColumns[] = CouponVersionTableMap::IS_ENABLED; + } + + + return $this; + } // setIsEnabled() + + /** + * Sets the value of [expiration_date] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setExpirationDate($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->expiration_date !== null || $dt !== null) { + if ($dt !== $this->expiration_date) { + $this->expiration_date = $dt; + $this->modifiedColumns[] = CouponVersionTableMap::EXPIRATION_DATE; + } + } // if either are not null + + + return $this; + } // setExpirationDate() + + /** + * Set the value of [serialized_rules_type] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setSerializedRulesType($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->serialized_rules_type !== $v) { + $this->serialized_rules_type = $v; + $this->modifiedColumns[] = CouponVersionTableMap::SERIALIZED_RULES_TYPE; + } + + + return $this; + } // setSerializedRulesType() + + /** + * Set the value of [serialized_rules_content] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setSerializedRulesContent($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->serialized_rules_content !== $v) { + $this->serialized_rules_content = $v; + $this->modifiedColumns[] = CouponVersionTableMap::SERIALIZED_RULES_CONTENT; + } + + + return $this; + } // setSerializedRulesContent() + + /** + * Set the value of [is_cumulative] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setIsCumulative($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_cumulative !== $v) { + $this->is_cumulative = $v; + $this->modifiedColumns[] = CouponVersionTableMap::IS_CUMULATIVE; + } + + + return $this; + } // setIsCumulative() + + /** + * Set the value of [is_removing_postage] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setIsRemovingPostage($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_removing_postage !== $v) { + $this->is_removing_postage = $v; + $this->modifiedColumns[] = CouponVersionTableMap::IS_REMOVING_POSTAGE; + } + + + return $this; + } // setIsRemovingPostage() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CouponVersionTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CouponVersionTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Set the value of [version] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setVersion($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->version !== $v) { + $this->version = $v; + $this->modifiedColumns[] = CouponVersionTableMap::VERSION; + } + + + return $this; + } // setVersion() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->version !== 0) { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CouponVersionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CouponVersionTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponVersionTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)]; + $this->type = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponVersionTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponVersionTableMap::translateFieldName('ShortDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->short_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponVersionTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponVersionTableMap::translateFieldName('Amount', TableMap::TYPE_PHPNAME, $indexType)]; + $this->amount = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponVersionTableMap::translateFieldName('IsUsed', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_used = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponVersionTableMap::translateFieldName('IsEnabled', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_enabled = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponVersionTableMap::translateFieldName('ExpirationDate', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->expiration_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponVersionTableMap::translateFieldName('SerializedRulesType', TableMap::TYPE_PHPNAME, $indexType)]; + $this->serialized_rules_type = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponVersionTableMap::translateFieldName('SerializedRulesContent', TableMap::TYPE_PHPNAME, $indexType)]; + $this->serialized_rules_content = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponVersionTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_cumulative = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponVersionTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_removing_postage = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CouponVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CouponVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CouponVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 17; // 17 = CouponVersionTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CouponVersion object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aCoupon !== null && $this->id !== $this->aCoupon->getId()) { + $this->aCoupon = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CouponVersionTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCouponVersionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCoupon = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CouponVersion::setDeleted() + * @see CouponVersion::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponVersionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCouponVersionQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponVersionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CouponVersionTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCoupon !== null) { + if ($this->aCoupon->isModified() || $this->aCoupon->isNew()) { + $affectedRows += $this->aCoupon->save($con); + } + $this->setCoupon($this->aCoupon); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CouponVersionTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CouponVersionTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; + } + if ($this->isColumnModified(CouponVersionTableMap::TYPE)) { + $modifiedColumns[':p' . $index++] = 'TYPE'; + } + if ($this->isColumnModified(CouponVersionTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(CouponVersionTableMap::SHORT_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'SHORT_DESCRIPTION'; + } + if ($this->isColumnModified(CouponVersionTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(CouponVersionTableMap::AMOUNT)) { + $modifiedColumns[':p' . $index++] = 'AMOUNT'; + } + if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) { + $modifiedColumns[':p' . $index++] = 'IS_USED'; + } + if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) { + $modifiedColumns[':p' . $index++] = 'IS_ENABLED'; + } + if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) { + $modifiedColumns[':p' . $index++] = 'EXPIRATION_DATE'; + } + if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES_TYPE)) { + $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES_TYPE'; + } + if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES_CONTENT)) { + $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES_CONTENT'; + } + if ($this->isColumnModified(CouponVersionTableMap::IS_CUMULATIVE)) { + $modifiedColumns[':p' . $index++] = 'IS_CUMULATIVE'; + } + if ($this->isColumnModified(CouponVersionTableMap::IS_REMOVING_POSTAGE)) { + $modifiedColumns[':p' . $index++] = 'IS_REMOVING_POSTAGE'; + } + if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(CouponVersionTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + if ($this->isColumnModified(CouponVersionTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; + } + + $sql = sprintf( + 'INSERT INTO coupon_version (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'CODE': + $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); + break; + case 'TYPE': + $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'SHORT_DESCRIPTION': + $stmt->bindValue($identifier, $this->short_description, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'AMOUNT': + $stmt->bindValue($identifier, $this->amount, PDO::PARAM_STR); + break; + case 'IS_USED': + $stmt->bindValue($identifier, $this->is_used, PDO::PARAM_INT); + break; + case 'IS_ENABLED': + $stmt->bindValue($identifier, $this->is_enabled, PDO::PARAM_INT); + break; + case 'EXPIRATION_DATE': + $stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'SERIALIZED_RULES_TYPE': + $stmt->bindValue($identifier, $this->serialized_rules_type, PDO::PARAM_STR); + break; + case 'SERIALIZED_RULES_CONTENT': + $stmt->bindValue($identifier, $this->serialized_rules_content, PDO::PARAM_STR); + break; + case 'IS_CUMULATIVE': + $stmt->bindValue($identifier, $this->is_cumulative, PDO::PARAM_INT); + break; + case 'IS_REMOVING_POSTAGE': + $stmt->bindValue($identifier, $this->is_removing_postage, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'VERSION': + $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CouponVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getCode(); + break; + case 2: + return $this->getType(); + break; + case 3: + return $this->getTitle(); + break; + case 4: + return $this->getShortDescription(); + break; + case 5: + return $this->getDescription(); + break; + case 6: + return $this->getAmount(); + break; + case 7: + return $this->getIsUsed(); + break; + case 8: + return $this->getIsEnabled(); + break; + case 9: + return $this->getExpirationDate(); + break; + case 10: + return $this->getSerializedRulesType(); + break; + case 11: + return $this->getSerializedRulesContent(); + break; + case 12: + return $this->getIsCumulative(); + break; + case 13: + return $this->getIsRemovingPostage(); + break; + case 14: + return $this->getCreatedAt(); + break; + case 15: + return $this->getUpdatedAt(); + break; + case 16: + return $this->getVersion(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CouponVersion'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CouponVersion'][serialize($this->getPrimaryKey())] = true; + $keys = CouponVersionTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getCode(), + $keys[2] => $this->getType(), + $keys[3] => $this->getTitle(), + $keys[4] => $this->getShortDescription(), + $keys[5] => $this->getDescription(), + $keys[6] => $this->getAmount(), + $keys[7] => $this->getIsUsed(), + $keys[8] => $this->getIsEnabled(), + $keys[9] => $this->getExpirationDate(), + $keys[10] => $this->getSerializedRulesType(), + $keys[11] => $this->getSerializedRulesContent(), + $keys[12] => $this->getIsCumulative(), + $keys[13] => $this->getIsRemovingPostage(), + $keys[14] => $this->getCreatedAt(), + $keys[15] => $this->getUpdatedAt(), + $keys[16] => $this->getVersion(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCoupon) { + $result['Coupon'] = $this->aCoupon->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CouponVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setCode($value); + break; + case 2: + $this->setType($value); + break; + case 3: + $this->setTitle($value); + break; + case 4: + $this->setShortDescription($value); + break; + case 5: + $this->setDescription($value); + break; + case 6: + $this->setAmount($value); + break; + case 7: + $this->setIsUsed($value); + break; + case 8: + $this->setIsEnabled($value); + break; + case 9: + $this->setExpirationDate($value); + break; + case 10: + $this->setSerializedRulesType($value); + break; + case 11: + $this->setSerializedRulesContent($value); + break; + case 12: + $this->setIsCumulative($value); + break; + case 13: + $this->setIsRemovingPostage($value); + break; + case 14: + $this->setCreatedAt($value); + break; + case 15: + $this->setUpdatedAt($value); + break; + case 16: + $this->setVersion($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = CouponVersionTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setShortDescription($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDescription($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setAmount($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setIsUsed($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setIsEnabled($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setExpirationDate($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setSerializedRulesType($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setSerializedRulesContent($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setIsCumulative($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setIsRemovingPostage($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setCreatedAt($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setUpdatedAt($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setVersion($arr[$keys[16]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(CouponVersionTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CouponVersionTableMap::ID)) $criteria->add(CouponVersionTableMap::ID, $this->id); + if ($this->isColumnModified(CouponVersionTableMap::CODE)) $criteria->add(CouponVersionTableMap::CODE, $this->code); + if ($this->isColumnModified(CouponVersionTableMap::TYPE)) $criteria->add(CouponVersionTableMap::TYPE, $this->type); + if ($this->isColumnModified(CouponVersionTableMap::TITLE)) $criteria->add(CouponVersionTableMap::TITLE, $this->title); + if ($this->isColumnModified(CouponVersionTableMap::SHORT_DESCRIPTION)) $criteria->add(CouponVersionTableMap::SHORT_DESCRIPTION, $this->short_description); + if ($this->isColumnModified(CouponVersionTableMap::DESCRIPTION)) $criteria->add(CouponVersionTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(CouponVersionTableMap::AMOUNT)) $criteria->add(CouponVersionTableMap::AMOUNT, $this->amount); + if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) $criteria->add(CouponVersionTableMap::IS_USED, $this->is_used); + if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) $criteria->add(CouponVersionTableMap::IS_ENABLED, $this->is_enabled); + if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) $criteria->add(CouponVersionTableMap::EXPIRATION_DATE, $this->expiration_date); + if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES_TYPE)) $criteria->add(CouponVersionTableMap::SERIALIZED_RULES_TYPE, $this->serialized_rules_type); + if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES_CONTENT)) $criteria->add(CouponVersionTableMap::SERIALIZED_RULES_CONTENT, $this->serialized_rules_content); + if ($this->isColumnModified(CouponVersionTableMap::IS_CUMULATIVE)) $criteria->add(CouponVersionTableMap::IS_CUMULATIVE, $this->is_cumulative); + if ($this->isColumnModified(CouponVersionTableMap::IS_REMOVING_POSTAGE)) $criteria->add(CouponVersionTableMap::IS_REMOVING_POSTAGE, $this->is_removing_postage); + if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) $criteria->add(CouponVersionTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CouponVersionTableMap::UPDATED_AT)) $criteria->add(CouponVersionTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(CouponVersionTableMap::VERSION)) $criteria->add(CouponVersionTableMap::VERSION, $this->version); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CouponVersionTableMap::DATABASE_NAME); + $criteria->add(CouponVersionTableMap::ID, $this->id); + $criteria->add(CouponVersionTableMap::VERSION, $this->version); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getVersion(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setVersion($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getVersion()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\CouponVersion (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setCode($this->getCode()); + $copyObj->setType($this->getType()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setShortDescription($this->getShortDescription()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setAmount($this->getAmount()); + $copyObj->setIsUsed($this->getIsUsed()); + $copyObj->setIsEnabled($this->getIsEnabled()); + $copyObj->setExpirationDate($this->getExpirationDate()); + $copyObj->setSerializedRulesType($this->getSerializedRulesType()); + $copyObj->setSerializedRulesContent($this->getSerializedRulesContent()); + $copyObj->setIsCumulative($this->getIsCumulative()); + $copyObj->setIsRemovingPostage($this->getIsRemovingPostage()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + $copyObj->setVersion($this->getVersion()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\CouponVersion Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildCoupon object. + * + * @param ChildCoupon $v + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + * @throws PropelException + */ + public function setCoupon(ChildCoupon $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aCoupon = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCoupon object, it will not be re-added. + if ($v !== null) { + $v->addCouponVersion($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCoupon object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCoupon The associated ChildCoupon object. + * @throws PropelException + */ + public function getCoupon(ConnectionInterface $con = null) + { + if ($this->aCoupon === null && ($this->id !== null)) { + $this->aCoupon = ChildCouponQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCoupon->addCouponVersions($this); + */ + } + + return $this->aCoupon; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->code = null; + $this->type = null; + $this->title = null; + $this->short_description = null; + $this->description = null; + $this->amount = null; + $this->is_used = null; + $this->is_enabled = null; + $this->expiration_date = null; + $this->serialized_rules_type = null; + $this->serialized_rules_content = null; + $this->is_cumulative = null; + $this->is_removing_postage = null; + $this->created_at = null; + $this->updated_at = null; + $this->version = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCoupon = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CouponVersionTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/CouponVersionQuery.php b/core/lib/Thelia/Model/Base/CouponVersionQuery.php new file mode 100644 index 000000000..2ea0e23d7 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CouponVersionQuery.php @@ -0,0 +1,1084 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $version] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCouponVersion|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CouponVersionTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CouponVersionTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCouponVersion A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, AMOUNT, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES_TYPE, SERIALIZED_RULES_CONTENT, IS_CUMULATIVE, IS_REMOVING_POSTAGE, CREATED_AT, UPDATED_AT, VERSION FROM coupon_version WHERE ID = :p0 AND VERSION = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCouponVersion(); + $obj->hydrate($row); + CouponVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCouponVersion|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(CouponVersionTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(CouponVersionTableMap::VERSION, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(CouponVersionTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(CouponVersionTableMap::VERSION, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByCoupon() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CouponVersionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CouponVersionTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the code column + * + * Example usage: + * + * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' + * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' + * + * + * @param string $code The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByCode($code = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($code)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $code)) { + $code = str_replace('*', '%', $code); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::CODE, $code, $comparison); + } + + /** + * Filter the query on the type column + * + * Example usage: + * + * $query->filterByType('fooValue'); // WHERE type = 'fooValue' + * $query->filterByType('%fooValue%'); // WHERE type LIKE '%fooValue%' + * + * + * @param string $type The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByType($type = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($type)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $type)) { + $type = str_replace('*', '%', $type); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::TYPE, $type, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the short_description column + * + * Example usage: + * + * $query->filterByShortDescription('fooValue'); // WHERE short_description = 'fooValue' + * $query->filterByShortDescription('%fooValue%'); // WHERE short_description LIKE '%fooValue%' + * + * + * @param string $shortDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByShortDescription($shortDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($shortDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $shortDescription)) { + $shortDescription = str_replace('*', '%', $shortDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::SHORT_DESCRIPTION, $shortDescription, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the amount column + * + * Example usage: + * + * $query->filterByAmount(1234); // WHERE amount = 1234 + * $query->filterByAmount(array(12, 34)); // WHERE amount IN (12, 34) + * $query->filterByAmount(array('min' => 12)); // WHERE amount > 12 + * + * + * @param mixed $amount The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByAmount($amount = null, $comparison = null) + { + if (is_array($amount)) { + $useMinMax = false; + if (isset($amount['min'])) { + $this->addUsingAlias(CouponVersionTableMap::AMOUNT, $amount['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($amount['max'])) { + $this->addUsingAlias(CouponVersionTableMap::AMOUNT, $amount['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::AMOUNT, $amount, $comparison); + } + + /** + * Filter the query on the is_used column + * + * Example usage: + * + * $query->filterByIsUsed(1234); // WHERE is_used = 1234 + * $query->filterByIsUsed(array(12, 34)); // WHERE is_used IN (12, 34) + * $query->filterByIsUsed(array('min' => 12)); // WHERE is_used > 12 + * + * + * @param mixed $isUsed The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByIsUsed($isUsed = null, $comparison = null) + { + if (is_array($isUsed)) { + $useMinMax = false; + if (isset($isUsed['min'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isUsed['max'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed, $comparison); + } + + /** + * Filter the query on the is_enabled column + * + * Example usage: + * + * $query->filterByIsEnabled(1234); // WHERE is_enabled = 1234 + * $query->filterByIsEnabled(array(12, 34)); // WHERE is_enabled IN (12, 34) + * $query->filterByIsEnabled(array('min' => 12)); // WHERE is_enabled > 12 + * + * + * @param mixed $isEnabled The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByIsEnabled($isEnabled = null, $comparison = null) + { + if (is_array($isEnabled)) { + $useMinMax = false; + if (isset($isEnabled['min'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_ENABLED, $isEnabled['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isEnabled['max'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_ENABLED, $isEnabled['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::IS_ENABLED, $isEnabled, $comparison); + } + + /** + * Filter the query on the expiration_date column + * + * Example usage: + * + * $query->filterByExpirationDate('2011-03-14'); // WHERE expiration_date = '2011-03-14' + * $query->filterByExpirationDate('now'); // WHERE expiration_date = '2011-03-14' + * $query->filterByExpirationDate(array('max' => 'yesterday')); // WHERE expiration_date > '2011-03-13' + * + * + * @param mixed $expirationDate The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByExpirationDate($expirationDate = null, $comparison = null) + { + if (is_array($expirationDate)) { + $useMinMax = false; + if (isset($expirationDate['min'])) { + $this->addUsingAlias(CouponVersionTableMap::EXPIRATION_DATE, $expirationDate['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($expirationDate['max'])) { + $this->addUsingAlias(CouponVersionTableMap::EXPIRATION_DATE, $expirationDate['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::EXPIRATION_DATE, $expirationDate, $comparison); + } + + /** + * Filter the query on the serialized_rules_type column + * + * Example usage: + * + * $query->filterBySerializedRulesType('fooValue'); // WHERE serialized_rules_type = 'fooValue' + * $query->filterBySerializedRulesType('%fooValue%'); // WHERE serialized_rules_type LIKE '%fooValue%' + * + * + * @param string $serializedRulesType The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterBySerializedRulesType($serializedRulesType = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($serializedRulesType)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $serializedRulesType)) { + $serializedRulesType = str_replace('*', '%', $serializedRulesType); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::SERIALIZED_RULES_TYPE, $serializedRulesType, $comparison); + } + + /** + * Filter the query on the serialized_rules_content column + * + * Example usage: + * + * $query->filterBySerializedRulesContent('fooValue'); // WHERE serialized_rules_content = 'fooValue' + * $query->filterBySerializedRulesContent('%fooValue%'); // WHERE serialized_rules_content LIKE '%fooValue%' + * + * + * @param string $serializedRulesContent The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterBySerializedRulesContent($serializedRulesContent = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($serializedRulesContent)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $serializedRulesContent)) { + $serializedRulesContent = str_replace('*', '%', $serializedRulesContent); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::SERIALIZED_RULES_CONTENT, $serializedRulesContent, $comparison); + } + + /** + * Filter the query on the is_cumulative column + * + * Example usage: + * + * $query->filterByIsCumulative(1234); // WHERE is_cumulative = 1234 + * $query->filterByIsCumulative(array(12, 34)); // WHERE is_cumulative IN (12, 34) + * $query->filterByIsCumulative(array('min' => 12)); // WHERE is_cumulative > 12 + * + * + * @param mixed $isCumulative The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByIsCumulative($isCumulative = null, $comparison = null) + { + if (is_array($isCumulative)) { + $useMinMax = false; + if (isset($isCumulative['min'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isCumulative['max'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative, $comparison); + } + + /** + * Filter the query on the is_removing_postage column + * + * Example usage: + * + * $query->filterByIsRemovingPostage(1234); // WHERE is_removing_postage = 1234 + * $query->filterByIsRemovingPostage(array(12, 34)); // WHERE is_removing_postage IN (12, 34) + * $query->filterByIsRemovingPostage(array('min' => 12)); // WHERE is_removing_postage > 12 + * + * + * @param mixed $isRemovingPostage The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByIsRemovingPostage($isRemovingPostage = null, $comparison = null) + { + if (is_array($isRemovingPostage)) { + $useMinMax = false; + if (isset($isRemovingPostage['min'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isRemovingPostage['max'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(CouponVersionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(CouponVersionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(CouponVersionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(CouponVersionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query on the version column + * + * Example usage: + * + * $query->filterByVersion(1234); // WHERE version = 1234 + * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * + * + * @param mixed $version The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByVersion($version = null, $comparison = null) + { + if (is_array($version)) { + $useMinMax = false; + if (isset($version['min'])) { + $this->addUsingAlias(CouponVersionTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($version['max'])) { + $this->addUsingAlias(CouponVersionTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::VERSION, $version, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Coupon object + * + * @param \Thelia\Model\Coupon|ObjectCollection $coupon The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByCoupon($coupon, $comparison = null) + { + if ($coupon instanceof \Thelia\Model\Coupon) { + return $this + ->addUsingAlias(CouponVersionTableMap::ID, $coupon->getId(), $comparison); + } elseif ($coupon instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CouponVersionTableMap::ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCoupon() only accepts arguments of type \Thelia\Model\Coupon or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Coupon relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function joinCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Coupon'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Coupon'); + } + + return $this; + } + + /** + * Use the Coupon relation Coupon object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CouponQuery A secondary query class using the current class as primary query + */ + public function useCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCoupon($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery'); + } + + /** + * Exclude object from result + * + * @param ChildCouponVersion $couponVersion Object to remove from the list of results + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function prune($couponVersion = null) + { + if ($couponVersion) { + $this->addCond('pruneCond0', $this->getAliasedColName(CouponVersionTableMap::ID), $couponVersion->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(CouponVersionTableMap::VERSION), $couponVersion->getVersion(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the coupon_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponVersionTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CouponVersionTableMap::clearInstancePool(); + CouponVersionTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCouponVersion or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCouponVersion object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponVersionTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CouponVersionTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + CouponVersionTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CouponVersionTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // CouponVersionQuery diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php index 905436e1f..707bd0904 100644 --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -23,11 +23,11 @@ use Thelia\Model\CartItem as ChildCartItem; use Thelia\Model\CartItemQuery as ChildCartItemQuery; use Thelia\Model\Category as ChildCategory; use Thelia\Model\CategoryQuery as ChildCategoryQuery; -use Thelia\Model\ContentAssoc as ChildContentAssoc; -use Thelia\Model\ContentAssocQuery as ChildContentAssocQuery; use Thelia\Model\FeatureProduct as ChildFeatureProduct; use Thelia\Model\FeatureProductQuery as ChildFeatureProductQuery; use Thelia\Model\Product as ChildProduct; +use Thelia\Model\ProductAssociatedContent as ChildProductAssociatedContent; +use Thelia\Model\ProductAssociatedContentQuery as ChildProductAssociatedContentQuery; use Thelia\Model\ProductCategory as ChildProductCategory; use Thelia\Model\ProductCategoryQuery as ChildProductCategoryQuery; use Thelia\Model\ProductDocument as ChildProductDocument; @@ -167,12 +167,6 @@ abstract class Product implements ActiveRecordInterface protected $collProductSaleElementss; protected $collProductSaleElementssPartial; - /** - * @var ObjectCollection|ChildContentAssoc[] Collection to store aggregation of ChildContentAssoc objects. - */ - protected $collContentAssocs; - protected $collContentAssocsPartial; - /** * @var ObjectCollection|ChildProductImage[] Collection to store aggregation of ChildProductImage objects. */ @@ -209,6 +203,12 @@ abstract class Product implements ActiveRecordInterface protected $collCartItems; protected $collCartItemsPartial; + /** + * @var ObjectCollection|ChildProductAssociatedContent[] Collection to store aggregation of ChildProductAssociatedContent objects. + */ + protected $collProductAssociatedContents; + protected $collProductAssociatedContentsPartial; + /** * @var ObjectCollection|ChildProductI18n[] Collection to store aggregation of ChildProductI18n objects. */ @@ -302,12 +302,6 @@ abstract class Product implements ActiveRecordInterface */ protected $productSaleElementssScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $contentAssocsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -344,6 +338,12 @@ abstract class Product implements ActiveRecordInterface */ protected $cartItemsScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $productAssociatedContentsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -1137,8 +1137,6 @@ abstract class Product implements ActiveRecordInterface $this->collProductSaleElementss = null; - $this->collContentAssocs = null; - $this->collProductImages = null; $this->collProductDocuments = null; @@ -1151,6 +1149,8 @@ abstract class Product implements ActiveRecordInterface $this->collCartItems = null; + $this->collProductAssociatedContents = null; + $this->collProductI18ns = null; $this->collProductVersions = null; @@ -1447,23 +1447,6 @@ abstract class Product implements ActiveRecordInterface } } - if ($this->contentAssocsScheduledForDeletion !== null) { - if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - \Thelia\Model\ContentAssocQuery::create() - ->filterByPrimaryKeys($this->contentAssocsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->contentAssocsScheduledForDeletion = null; - } - } - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->productImagesScheduledForDeletion !== null) { if (!$this->productImagesScheduledForDeletion->isEmpty()) { \Thelia\Model\ProductImageQuery::create() @@ -1566,6 +1549,23 @@ abstract class Product implements ActiveRecordInterface } } + if ($this->productAssociatedContentsScheduledForDeletion !== null) { + if (!$this->productAssociatedContentsScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProductAssociatedContentQuery::create() + ->filterByPrimaryKeys($this->productAssociatedContentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->productAssociatedContentsScheduledForDeletion = null; + } + } + + if ($this->collProductAssociatedContents !== null) { + foreach ($this->collProductAssociatedContents as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->productI18nsScheduledForDeletion !== null) { if (!$this->productI18nsScheduledForDeletion->isEmpty()) { \Thelia\Model\ProductI18nQuery::create() @@ -1848,9 +1848,6 @@ abstract class Product implements ActiveRecordInterface if (null !== $this->collProductSaleElementss) { $result['ProductSaleElementss'] = $this->collProductSaleElementss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collContentAssocs) { - $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collProductImages) { $result['ProductImages'] = $this->collProductImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1869,6 +1866,9 @@ abstract class Product implements ActiveRecordInterface if (null !== $this->collCartItems) { $result['CartItems'] = $this->collCartItems->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collProductAssociatedContents) { + $result['ProductAssociatedContents'] = $this->collProductAssociatedContents->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collProductI18ns) { $result['ProductI18ns'] = $this->collProductI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -2090,12 +2090,6 @@ abstract class Product implements ActiveRecordInterface } } - foreach ($this->getContentAssocs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentAssoc($relObj->copy($deepCopy)); - } - } - foreach ($this->getProductImages() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addProductImage($relObj->copy($deepCopy)); @@ -2132,6 +2126,12 @@ abstract class Product implements ActiveRecordInterface } } + foreach ($this->getProductAssociatedContents() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addProductAssociatedContent($relObj->copy($deepCopy)); + } + } + foreach ($this->getProductI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addProductI18n($relObj->copy($deepCopy)); @@ -2245,9 +2245,6 @@ abstract class Product implements ActiveRecordInterface if ('ProductSaleElements' == $relationName) { return $this->initProductSaleElementss(); } - if ('ContentAssoc' == $relationName) { - return $this->initContentAssocs(); - } if ('ProductImage' == $relationName) { return $this->initProductImages(); } @@ -2266,6 +2263,9 @@ abstract class Product implements ActiveRecordInterface if ('CartItem' == $relationName) { return $this->initCartItems(); } + if ('ProductAssociatedContent' == $relationName) { + return $this->initProductAssociatedContents(); + } if ('ProductI18n' == $relationName) { return $this->initProductI18ns(); } @@ -3006,274 +3006,6 @@ abstract class Product implements ActiveRecordInterface return $this; } - /** - * Clears out the collContentAssocs collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addContentAssocs() - */ - public function clearContentAssocs() - { - $this->collContentAssocs = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collContentAssocs collection loaded partially. - */ - public function resetPartialContentAssocs($v = true) - { - $this->collContentAssocsPartial = $v; - } - - /** - * Initializes the collContentAssocs collection. - * - * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentAssocs($overrideExisting = true) - { - if (null !== $this->collContentAssocs && !$overrideExisting) { - return; - } - $this->collContentAssocs = new ObjectCollection(); - $this->collContentAssocs->setModel('\Thelia\Model\ContentAssoc'); - } - - /** - * Gets an array of ChildContentAssoc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildProduct is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - * @throws PropelException - */ - public function getContentAssocs($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - // return empty collection - $this->initContentAssocs(); - } else { - $collContentAssocs = ChildContentAssocQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { - $this->initContentAssocs(false); - - foreach ($collContentAssocs as $obj) { - if (false == $this->collContentAssocs->contains($obj)) { - $this->collContentAssocs->append($obj); - } - } - - $this->collContentAssocsPartial = true; - } - - $collContentAssocs->getInternalIterator()->rewind(); - - return $collContentAssocs; - } - - if ($partial && $this->collContentAssocs) { - foreach ($this->collContentAssocs as $obj) { - if ($obj->isNew()) { - $collContentAssocs[] = $obj; - } - } - } - - $this->collContentAssocs = $collContentAssocs; - $this->collContentAssocsPartial = false; - } - } - - return $this->collContentAssocs; - } - - /** - * Sets a collection of ContentAssoc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $contentAssocs A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildProduct The current object (for fluent API support) - */ - public function setContentAssocs(Collection $contentAssocs, ConnectionInterface $con = null) - { - $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - - - $this->contentAssocsScheduledForDeletion = $contentAssocsToDelete; - - foreach ($contentAssocsToDelete as $contentAssocRemoved) { - $contentAssocRemoved->setProduct(null); - } - - $this->collContentAssocs = null; - foreach ($contentAssocs as $contentAssoc) { - $this->addContentAssoc($contentAssoc); - } - - $this->collContentAssocs = $contentAssocs; - $this->collContentAssocsPartial = false; - - return $this; - } - - /** - * Returns the number of related ContentAssoc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related ContentAssoc objects. - * @throws PropelException - */ - public function countContentAssocs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getContentAssocs()); - } - - $query = ChildContentAssocQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - - return count($this->collContentAssocs); - } - - /** - * Method called to associate a ChildContentAssoc object to this object - * through the ChildContentAssoc foreign key attribute. - * - * @param ChildContentAssoc $l ChildContentAssoc - * @return \Thelia\Model\Product The current object (for fluent API support) - */ - public function addContentAssoc(ChildContentAssoc $l) - { - if ($this->collContentAssocs === null) { - $this->initContentAssocs(); - $this->collContentAssocsPartial = true; - } - - if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddContentAssoc($l); - } - - return $this; - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to add. - */ - protected function doAddContentAssoc($contentAssoc) - { - $this->collContentAssocs[]= $contentAssoc; - $contentAssoc->setProduct($this); - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to remove. - * @return ChildProduct The current object (for fluent API support) - */ - public function removeContentAssoc($contentAssoc) - { - if ($this->getContentAssocs()->contains($contentAssoc)) { - $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc)); - if (null === $this->contentAssocsScheduledForDeletion) { - $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs; - $this->contentAssocsScheduledForDeletion->clear(); - } - $this->contentAssocsScheduledForDeletion[]= $contentAssoc; - $contentAssoc->setProduct(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - */ - public function getContentAssocsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildContentAssocQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); - - return $this->getContentAssocs($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects - */ - public function getContentAssocsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildContentAssocQuery::create(null, $criteria); - $query->joinWith('Content', $joinBehavior); - - return $this->getContentAssocs($query, $con); - } - /** * Clears out the collProductImages collection * @@ -4707,6 +4439,249 @@ abstract class Product implements ActiveRecordInterface return $this->getCartItems($query, $con); } + /** + * Clears out the collProductAssociatedContents collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addProductAssociatedContents() + */ + public function clearProductAssociatedContents() + { + $this->collProductAssociatedContents = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collProductAssociatedContents collection loaded partially. + */ + public function resetPartialProductAssociatedContents($v = true) + { + $this->collProductAssociatedContentsPartial = $v; + } + + /** + * Initializes the collProductAssociatedContents collection. + * + * By default this just sets the collProductAssociatedContents collection to an empty array (like clearcollProductAssociatedContents()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initProductAssociatedContents($overrideExisting = true) + { + if (null !== $this->collProductAssociatedContents && !$overrideExisting) { + return; + } + $this->collProductAssociatedContents = new ObjectCollection(); + $this->collProductAssociatedContents->setModel('\Thelia\Model\ProductAssociatedContent'); + } + + /** + * Gets an array of ChildProductAssociatedContent objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildProduct is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProductAssociatedContent[] List of ChildProductAssociatedContent objects + * @throws PropelException + */ + public function getProductAssociatedContents($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collProductAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collProductAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductAssociatedContents) { + // return empty collection + $this->initProductAssociatedContents(); + } else { + $collProductAssociatedContents = ChildProductAssociatedContentQuery::create(null, $criteria) + ->filterByProduct($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collProductAssociatedContentsPartial && count($collProductAssociatedContents)) { + $this->initProductAssociatedContents(false); + + foreach ($collProductAssociatedContents as $obj) { + if (false == $this->collProductAssociatedContents->contains($obj)) { + $this->collProductAssociatedContents->append($obj); + } + } + + $this->collProductAssociatedContentsPartial = true; + } + + $collProductAssociatedContents->getInternalIterator()->rewind(); + + return $collProductAssociatedContents; + } + + if ($partial && $this->collProductAssociatedContents) { + foreach ($this->collProductAssociatedContents as $obj) { + if ($obj->isNew()) { + $collProductAssociatedContents[] = $obj; + } + } + } + + $this->collProductAssociatedContents = $collProductAssociatedContents; + $this->collProductAssociatedContentsPartial = false; + } + } + + return $this->collProductAssociatedContents; + } + + /** + * Sets a collection of ProductAssociatedContent objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $productAssociatedContents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) + */ + public function setProductAssociatedContents(Collection $productAssociatedContents, ConnectionInterface $con = null) + { + $productAssociatedContentsToDelete = $this->getProductAssociatedContents(new Criteria(), $con)->diff($productAssociatedContents); + + + $this->productAssociatedContentsScheduledForDeletion = $productAssociatedContentsToDelete; + + foreach ($productAssociatedContentsToDelete as $productAssociatedContentRemoved) { + $productAssociatedContentRemoved->setProduct(null); + } + + $this->collProductAssociatedContents = null; + foreach ($productAssociatedContents as $productAssociatedContent) { + $this->addProductAssociatedContent($productAssociatedContent); + } + + $this->collProductAssociatedContents = $productAssociatedContents; + $this->collProductAssociatedContentsPartial = false; + + return $this; + } + + /** + * Returns the number of related ProductAssociatedContent objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related ProductAssociatedContent objects. + * @throws PropelException + */ + public function countProductAssociatedContents(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collProductAssociatedContentsPartial && !$this->isNew(); + if (null === $this->collProductAssociatedContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductAssociatedContents) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getProductAssociatedContents()); + } + + $query = ChildProductAssociatedContentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProduct($this) + ->count($con); + } + + return count($this->collProductAssociatedContents); + } + + /** + * Method called to associate a ChildProductAssociatedContent object to this object + * through the ChildProductAssociatedContent foreign key attribute. + * + * @param ChildProductAssociatedContent $l ChildProductAssociatedContent + * @return \Thelia\Model\Product The current object (for fluent API support) + */ + public function addProductAssociatedContent(ChildProductAssociatedContent $l) + { + if ($this->collProductAssociatedContents === null) { + $this->initProductAssociatedContents(); + $this->collProductAssociatedContentsPartial = true; + } + + if (!in_array($l, $this->collProductAssociatedContents->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProductAssociatedContent($l); + } + + return $this; + } + + /** + * @param ProductAssociatedContent $productAssociatedContent The productAssociatedContent object to add. + */ + protected function doAddProductAssociatedContent($productAssociatedContent) + { + $this->collProductAssociatedContents[]= $productAssociatedContent; + $productAssociatedContent->setProduct($this); + } + + /** + * @param ProductAssociatedContent $productAssociatedContent The productAssociatedContent object to remove. + * @return ChildProduct The current object (for fluent API support) + */ + public function removeProductAssociatedContent($productAssociatedContent) + { + if ($this->getProductAssociatedContents()->contains($productAssociatedContent)) { + $this->collProductAssociatedContents->remove($this->collProductAssociatedContents->search($productAssociatedContent)); + if (null === $this->productAssociatedContentsScheduledForDeletion) { + $this->productAssociatedContentsScheduledForDeletion = clone $this->collProductAssociatedContents; + $this->productAssociatedContentsScheduledForDeletion->clear(); + } + $this->productAssociatedContentsScheduledForDeletion[]= clone $productAssociatedContent; + $productAssociatedContent->setProduct(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related ProductAssociatedContents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildProductAssociatedContent[] List of ChildProductAssociatedContent objects + */ + public function getProductAssociatedContentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildProductAssociatedContentQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); + + return $this->getProductAssociatedContents($query, $con); + } + /** * Clears out the collProductI18ns collection * @@ -5752,11 +5727,6 @@ abstract class Product implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collContentAssocs) { - foreach ($this->collContentAssocs as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collProductImages) { foreach ($this->collProductImages as $o) { $o->clearAllReferences($deep); @@ -5787,6 +5757,11 @@ abstract class Product implements ActiveRecordInterface $o->clearAllReferences($deep); } } + if ($this->collProductAssociatedContents) { + foreach ($this->collProductAssociatedContents as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collProductI18ns) { foreach ($this->collProductI18ns as $o) { $o->clearAllReferences($deep); @@ -5830,10 +5805,6 @@ abstract class Product implements ActiveRecordInterface $this->collProductSaleElementss->clearIterator(); } $this->collProductSaleElementss = null; - if ($this->collContentAssocs instanceof Collection) { - $this->collContentAssocs->clearIterator(); - } - $this->collContentAssocs = null; if ($this->collProductImages instanceof Collection) { $this->collProductImages->clearIterator(); } @@ -5858,6 +5829,10 @@ abstract class Product implements ActiveRecordInterface $this->collCartItems->clearIterator(); } $this->collCartItems = null; + if ($this->collProductAssociatedContents instanceof Collection) { + $this->collProductAssociatedContents->clearIterator(); + } + $this->collProductAssociatedContents = null; if ($this->collProductI18ns instanceof Collection) { $this->collProductI18ns->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/ProductAssociatedContent.php b/core/lib/Thelia/Model/Base/ProductAssociatedContent.php new file mode 100644 index 000000000..6dce2b2c3 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProductAssociatedContent.php @@ -0,0 +1,1553 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ProductAssociatedContent instance. If + * obj is an instance of ProductAssociatedContent, delegates to + * equals(ProductAssociatedContent). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ProductAssociatedContent The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ProductAssociatedContent The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [product_id] column value. + * + * @return int + */ + public function getProductId() + { + + return $this->product_id; + } + + /** + * Get the [content_id] column value. + * + * @return int + */ + public function getContentId() + { + + return $this->content_id; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ProductAssociatedContentTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [product_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + */ + public function setProductId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->product_id !== $v) { + $this->product_id = $v; + $this->modifiedColumns[] = ProductAssociatedContentTableMap::PRODUCT_ID; + } + + if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { + $this->aProduct = null; + } + + + return $this; + } // setProductId() + + /** + * Set the value of [content_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + */ + public function setContentId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->content_id !== $v) { + $this->content_id = $v; + $this->modifiedColumns[] = ProductAssociatedContentTableMap::CONTENT_ID; + } + + if ($this->aContent !== null && $this->aContent->getId() !== $v) { + $this->aContent = null; + } + + + return $this; + } // setContentId() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = ProductAssociatedContentTableMap::POSITION; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ProductAssociatedContentTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ProductAssociatedContentTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductAssociatedContentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductAssociatedContentTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductAssociatedContentTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->content_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductAssociatedContentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductAssociatedContentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductAssociatedContentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ProductAssociatedContentTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ProductAssociatedContent object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { + $this->aProduct = null; + } + if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { + $this->aContent = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildProductAssociatedContentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aProduct = null; + $this->aContent = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ProductAssociatedContent::setDeleted() + * @see ProductAssociatedContent::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildProductAssociatedContentQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ProductAssociatedContentTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ProductAssociatedContentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ProductAssociatedContentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ProductAssociatedContentTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aProduct !== null) { + if ($this->aProduct->isModified() || $this->aProduct->isNew()) { + $affectedRows += $this->aProduct->save($con); + } + $this->setProduct($this->aProduct); + } + + if ($this->aContent !== null) { + if ($this->aContent->isModified() || $this->aContent->isNew()) { + $affectedRows += $this->aContent->save($con); + } + $this->setContent($this->aContent); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = ProductAssociatedContentTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProductAssociatedContentTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ProductAssociatedContentTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ProductAssociatedContentTableMap::PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; + } + if ($this->isColumnModified(ProductAssociatedContentTableMap::CONTENT_ID)) { + $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; + } + if ($this->isColumnModified(ProductAssociatedContentTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(ProductAssociatedContentTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(ProductAssociatedContentTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO product_associated_content (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'PRODUCT_ID': + $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); + break; + case 'CONTENT_ID': + $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProductAssociatedContentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getProductId(); + break; + case 2: + return $this->getContentId(); + break; + case 3: + return $this->getPosition(); + break; + case 4: + return $this->getCreatedAt(); + break; + case 5: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ProductAssociatedContent'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ProductAssociatedContent'][$this->getPrimaryKey()] = true; + $keys = ProductAssociatedContentTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getProductId(), + $keys[2] => $this->getContentId(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aProduct) { + $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aContent) { + $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProductAssociatedContentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setProductId($value); + break; + case 2: + $this->setContentId($value); + break; + case 3: + $this->setPosition($value); + break; + case 4: + $this->setCreatedAt($value); + break; + case 5: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = ProductAssociatedContentTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setContentId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(ProductAssociatedContentTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ProductAssociatedContentTableMap::ID)) $criteria->add(ProductAssociatedContentTableMap::ID, $this->id); + if ($this->isColumnModified(ProductAssociatedContentTableMap::PRODUCT_ID)) $criteria->add(ProductAssociatedContentTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(ProductAssociatedContentTableMap::CONTENT_ID)) $criteria->add(ProductAssociatedContentTableMap::CONTENT_ID, $this->content_id); + if ($this->isColumnModified(ProductAssociatedContentTableMap::POSITION)) $criteria->add(ProductAssociatedContentTableMap::POSITION, $this->position); + if ($this->isColumnModified(ProductAssociatedContentTableMap::CREATED_AT)) $criteria->add(ProductAssociatedContentTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ProductAssociatedContentTableMap::UPDATED_AT)) $criteria->add(ProductAssociatedContentTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(ProductAssociatedContentTableMap::DATABASE_NAME); + $criteria->add(ProductAssociatedContentTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\ProductAssociatedContent (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setProductId($this->getProductId()); + $copyObj->setContentId($this->getContentId()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\ProductAssociatedContent Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildProduct object. + * + * @param ChildProduct $v + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + * @throws PropelException + */ + public function setProduct(ChildProduct $v = null) + { + if ($v === null) { + $this->setProductId(NULL); + } else { + $this->setProductId($v->getId()); + } + + $this->aProduct = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildProduct object, it will not be re-added. + if ($v !== null) { + $v->addProductAssociatedContent($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. + * @throws PropelException + */ + public function getProduct(ConnectionInterface $con = null) + { + if ($this->aProduct === null && ($this->product_id !== null)) { + $this->aProduct = ChildProductQuery::create()->findPk($this->product_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aProduct->addProductAssociatedContents($this); + */ + } + + return $this->aProduct; + } + + /** + * Declares an association between this object and a ChildContent object. + * + * @param ChildContent $v + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + * @throws PropelException + */ + public function setContent(ChildContent $v = null) + { + if ($v === null) { + $this->setContentId(NULL); + } else { + $this->setContentId($v->getId()); + } + + $this->aContent = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildContent object, it will not be re-added. + if ($v !== null) { + $v->addProductAssociatedContent($this); + } + + + return $this; + } + + + /** + * Get the associated ChildContent object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContent The associated ChildContent object. + * @throws PropelException + */ + public function getContent(ConnectionInterface $con = null) + { + if ($this->aContent === null && ($this->content_id !== null)) { + $this->aContent = ChildContentQuery::create()->findPk($this->content_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aContent->addProductAssociatedContents($this); + */ + } + + return $this->aContent; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->product_id = null; + $this->content_id = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aProduct = null; + $this->aContent = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ProductAssociatedContentTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildProductAssociatedContent The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ProductAssociatedContentTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ProductAssociatedContentQuery.php b/core/lib/Thelia/Model/Base/ProductAssociatedContentQuery.php new file mode 100644 index 000000000..d387f40ed --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProductAssociatedContentQuery.php @@ -0,0 +1,804 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProductAssociatedContent|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ProductAssociatedContentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProductAssociatedContent A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, PRODUCT_ID, CONTENT_ID, POSITION, CREATED_AT, UPDATED_AT FROM product_associated_content WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildProductAssociatedContent(); + $obj->hydrate($row); + ProductAssociatedContentTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProductAssociatedContent|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(ProductAssociatedContentTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(ProductAssociatedContentTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductAssociatedContentTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the product_id column + * + * Example usage: + * + * $query->filterByProductId(1234); // WHERE product_id = 1234 + * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) + * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 + * + * + * @see filterByProduct() + * + * @param mixed $productId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByProductId($productId = null, $comparison = null) + { + if (is_array($productId)) { + $useMinMax = false; + if (isset($productId['min'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($productId['max'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductAssociatedContentTableMap::PRODUCT_ID, $productId, $comparison); + } + + /** + * Filter the query on the content_id column + * + * Example usage: + * + * $query->filterByContentId(1234); // WHERE content_id = 1234 + * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) + * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 + * + * + * @see filterByContent() + * + * @param mixed $contentId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByContentId($contentId = null, $comparison = null) + { + if (is_array($contentId)) { + $useMinMax = false; + if (isset($contentId['min'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($contentId['max'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductAssociatedContentTableMap::CONTENT_ID, $contentId, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductAssociatedContentTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductAssociatedContentTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductAssociatedContentTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Product object + * + * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByProduct($product, $comparison = null) + { + if ($product instanceof \Thelia\Model\Product) { + return $this + ->addUsingAlias(ProductAssociatedContentTableMap::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ProductAssociatedContentTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Product relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Product'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Product'); + } + + return $this; + } + + /** + * Use the Product relation Product object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query + */ + public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProduct($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Content object + * + * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByContent($content, $comparison = null) + { + if ($content instanceof \Thelia\Model\Content) { + return $this + ->addUsingAlias(ProductAssociatedContentTableMap::CONTENT_ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ProductAssociatedContentTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Content relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Content'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Content'); + } + + return $this; + } + + /** + * Use the Content relation Content object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query + */ + public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); + } + + /** + * Exclude object from result + * + * @param ChildProductAssociatedContent $productAssociatedContent Object to remove from the list of results + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function prune($productAssociatedContent = null) + { + if ($productAssociatedContent) { + $this->addUsingAlias(ProductAssociatedContentTableMap::ID, $productAssociatedContent->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the product_associated_content table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ProductAssociatedContentTableMap::clearInstancePool(); + ProductAssociatedContentTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildProductAssociatedContent or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildProductAssociatedContent object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ProductAssociatedContentTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ProductAssociatedContentTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ProductAssociatedContentTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ProductAssociatedContentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ProductAssociatedContentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ProductAssociatedContentTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ProductAssociatedContentTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ProductAssociatedContentTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ProductAssociatedContentTableMap::CREATED_AT); + } + +} // ProductAssociatedContentQuery diff --git a/core/lib/Thelia/Model/Base/ProductQuery.php b/core/lib/Thelia/Model/Base/ProductQuery.php index 9d4685f38..8a4d4ed18 100644 --- a/core/lib/Thelia/Model/Base/ProductQuery.php +++ b/core/lib/Thelia/Model/Base/ProductQuery.php @@ -64,10 +64,6 @@ use Thelia\Model\Map\ProductTableMap; * @method ChildProductQuery rightJoinProductSaleElements($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductSaleElements relation * @method ChildProductQuery innerJoinProductSaleElements($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductSaleElements relation * - * @method ChildProductQuery leftJoinContentAssoc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentAssoc relation - * @method ChildProductQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation - * @method ChildProductQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation - * * @method ChildProductQuery leftJoinProductImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductImage relation * @method ChildProductQuery rightJoinProductImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductImage relation * @method ChildProductQuery innerJoinProductImage($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductImage relation @@ -92,6 +88,10 @@ use Thelia\Model\Map\ProductTableMap; * @method ChildProductQuery rightJoinCartItem($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CartItem relation * @method ChildProductQuery innerJoinCartItem($relationAlias = null) Adds a INNER JOIN clause to the query using the CartItem relation * + * @method ChildProductQuery leftJoinProductAssociatedContent($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductAssociatedContent relation + * @method ChildProductQuery rightJoinProductAssociatedContent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductAssociatedContent relation + * @method ChildProductQuery innerJoinProductAssociatedContent($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductAssociatedContent relation + * * @method ChildProductQuery leftJoinProductI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductI18n relation * @method ChildProductQuery rightJoinProductI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductI18n relation * @method ChildProductQuery innerJoinProductI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductI18n relation @@ -996,79 +996,6 @@ abstract class ProductQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'ProductSaleElements', '\Thelia\Model\ProductSaleElementsQuery'); } - /** - * Filter the query by a related \Thelia\Model\ContentAssoc object - * - * @param \Thelia\Model\ContentAssoc|ObjectCollection $contentAssoc the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildProductQuery The current query, for fluid interface - */ - public function filterByContentAssoc($contentAssoc, $comparison = null) - { - if ($contentAssoc instanceof \Thelia\Model\ContentAssoc) { - return $this - ->addUsingAlias(ProductTableMap::ID, $contentAssoc->getProductId(), $comparison); - } elseif ($contentAssoc instanceof ObjectCollection) { - return $this - ->useContentAssocQuery() - ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type \Thelia\Model\ContentAssoc or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentAssoc relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildProductQuery The current query, for fluid interface - */ - public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentAssoc'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentAssoc'); - } - - return $this; - } - - /** - * Use the ContentAssoc relation ContentAssoc object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query - */ - public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContentAssoc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); - } - /** * Filter the query by a related \Thelia\Model\ProductImage object * @@ -1507,6 +1434,79 @@ abstract class ProductQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'CartItem', '\Thelia\Model\CartItemQuery'); } + /** + * Filter the query by a related \Thelia\Model\ProductAssociatedContent object + * + * @param \Thelia\Model\ProductAssociatedContent|ObjectCollection $productAssociatedContent the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductQuery The current query, for fluid interface + */ + public function filterByProductAssociatedContent($productAssociatedContent, $comparison = null) + { + if ($productAssociatedContent instanceof \Thelia\Model\ProductAssociatedContent) { + return $this + ->addUsingAlias(ProductTableMap::ID, $productAssociatedContent->getProductId(), $comparison); + } elseif ($productAssociatedContent instanceof ObjectCollection) { + return $this + ->useProductAssociatedContentQuery() + ->filterByPrimaryKeys($productAssociatedContent->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByProductAssociatedContent() only accepts arguments of type \Thelia\Model\ProductAssociatedContent or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ProductAssociatedContent relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProductQuery The current query, for fluid interface + */ + public function joinProductAssociatedContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ProductAssociatedContent'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ProductAssociatedContent'); + } + + return $this; + } + + /** + * Use the ProductAssociatedContent relation ProductAssociatedContent object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductAssociatedContentQuery A secondary query class using the current class as primary query + */ + public function useProductAssociatedContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProductAssociatedContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductAssociatedContent', '\Thelia\Model\ProductAssociatedContentQuery'); + } + /** * Filter the query by a related \Thelia\Model\ProductI18n object * diff --git a/core/lib/Thelia/Model/CategoryAssociatedContent.php b/core/lib/Thelia/Model/CategoryAssociatedContent.php new file mode 100644 index 000000000..9296e6274 --- /dev/null +++ b/core/lib/Thelia/Model/CategoryAssociatedContent.php @@ -0,0 +1,9 @@ +setPhpName('Accessory'); $this->setClassName('\\Thelia\\Model\\Accessory'); $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); + $this->setUseIdGenerator(true); $this->setIsCrossRef(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); @@ -429,6 +429,10 @@ class AccessoryTableMap extends TableMap $criteria = $criteria->buildCriteria(); // build Criteria from Accessory object } + if ($criteria->containsKey(AccessoryTableMap::ID) && $criteria->keyContainsValue(AccessoryTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AccessoryTableMap::ID.')'); + } + // Set the correct dbName $query = AccessoryQuery::create()->mergeWith($criteria); diff --git a/core/lib/Thelia/Model/Map/CategoryAssociatedContentTableMap.php b/core/lib/Thelia/Model/Map/CategoryAssociatedContentTableMap.php new file mode 100644 index 000000000..c78d59506 --- /dev/null +++ b/core/lib/Thelia/Model/Map/CategoryAssociatedContentTableMap.php @@ -0,0 +1,456 @@ + array('Id', 'CategoryId', 'ContentId', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'categoryId', 'contentId', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CategoryAssociatedContentTableMap::ID, CategoryAssociatedContentTableMap::CATEGORY_ID, CategoryAssociatedContentTableMap::CONTENT_ID, CategoryAssociatedContentTableMap::POSITION, CategoryAssociatedContentTableMap::CREATED_AT, CategoryAssociatedContentTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CATEGORY_ID', 'CONTENT_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'category_id', 'content_id', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'CategoryId' => 1, 'ContentId' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'categoryId' => 1, 'contentId' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(CategoryAssociatedContentTableMap::ID => 0, CategoryAssociatedContentTableMap::CATEGORY_ID => 1, CategoryAssociatedContentTableMap::CONTENT_ID => 2, CategoryAssociatedContentTableMap::POSITION => 3, CategoryAssociatedContentTableMap::CREATED_AT => 4, CategoryAssociatedContentTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CATEGORY_ID' => 1, 'CONTENT_ID' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'category_id' => 1, 'content_id' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('category_associated_content'); + $this->setPhpName('CategoryAssociatedContent'); + $this->setClassName('\\Thelia\\Model\\CategoryAssociatedContent'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null); + $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CategoryAssociatedContentTableMap::CLASS_DEFAULT : CategoryAssociatedContentTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (CategoryAssociatedContent object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CategoryAssociatedContentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CategoryAssociatedContentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CategoryAssociatedContentTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CategoryAssociatedContentTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CategoryAssociatedContentTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CategoryAssociatedContentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CategoryAssociatedContentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + CategoryAssociatedContentTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(CategoryAssociatedContentTableMap::ID); + $criteria->addSelectColumn(CategoryAssociatedContentTableMap::CATEGORY_ID); + $criteria->addSelectColumn(CategoryAssociatedContentTableMap::CONTENT_ID); + $criteria->addSelectColumn(CategoryAssociatedContentTableMap::POSITION); + $criteria->addSelectColumn(CategoryAssociatedContentTableMap::CREATED_AT); + $criteria->addSelectColumn(CategoryAssociatedContentTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.CATEGORY_ID'); + $criteria->addSelectColumn($alias . '.CONTENT_ID'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(CategoryAssociatedContentTableMap::DATABASE_NAME)->getTable(CategoryAssociatedContentTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CategoryAssociatedContentTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CategoryAssociatedContentTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CategoryAssociatedContentTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a CategoryAssociatedContent or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CategoryAssociatedContent object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CategoryAssociatedContent) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CategoryAssociatedContentTableMap::DATABASE_NAME); + $criteria->add(CategoryAssociatedContentTableMap::ID, (array) $values, Criteria::IN); + } + + $query = CategoryAssociatedContentQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CategoryAssociatedContentTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CategoryAssociatedContentTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the category_associated_content table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CategoryAssociatedContentQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CategoryAssociatedContent or Criteria object. + * + * @param mixed $criteria Criteria or CategoryAssociatedContent object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CategoryAssociatedContent object + } + + if ($criteria->containsKey(CategoryAssociatedContentTableMap::ID) && $criteria->keyContainsValue(CategoryAssociatedContentTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CategoryAssociatedContentTableMap::ID.')'); + } + + + // Set the correct dbName + $query = CategoryAssociatedContentQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CategoryAssociatedContentTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CategoryAssociatedContentTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CategoryTableMap.php b/core/lib/Thelia/Model/Map/CategoryTableMap.php index c3526ec5d..f94b14e5f 100644 --- a/core/lib/Thelia/Model/Map/CategoryTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryTableMap.php @@ -193,10 +193,10 @@ class CategoryTableMap extends TableMap $this->addRelation('ProductCategory', '\\Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'ProductCategories'); $this->addRelation('FeatureCategory', '\\Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'FeatureCategories'); $this->addRelation('AttributeCategory', '\\Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'AttributeCategories'); - $this->addRelation('ContentAssoc', '\\Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); $this->addRelation('CategoryImage', '\\Thelia\\Model\\CategoryImage', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryImages'); $this->addRelation('CategoryDocument', '\\Thelia\\Model\\CategoryDocument', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryDocuments'); + $this->addRelation('CategoryAssociatedContent', '\\Thelia\\Model\\CategoryAssociatedContent', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryAssociatedContents'); $this->addRelation('CategoryI18n', '\\Thelia\\Model\\CategoryI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryI18ns'); $this->addRelation('CategoryVersion', '\\Thelia\\Model\\CategoryVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryVersions'); $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Products'); @@ -228,10 +228,10 @@ class CategoryTableMap extends TableMap ProductCategoryTableMap::clearInstancePool(); FeatureCategoryTableMap::clearInstancePool(); AttributeCategoryTableMap::clearInstancePool(); - ContentAssocTableMap::clearInstancePool(); RewritingTableMap::clearInstancePool(); CategoryImageTableMap::clearInstancePool(); CategoryDocumentTableMap::clearInstancePool(); + CategoryAssociatedContentTableMap::clearInstancePool(); CategoryI18nTableMap::clearInstancePool(); CategoryVersionTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/ContentTableMap.php b/core/lib/Thelia/Model/Map/ContentTableMap.php index 724c839a1..5b6787a28 100644 --- a/core/lib/Thelia/Model/Map/ContentTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentTableMap.php @@ -184,11 +184,12 @@ class ContentTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('ContentAssoc', '\\Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); $this->addRelation('ContentFolder', '\\Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders'); $this->addRelation('ContentImage', '\\Thelia\\Model\\ContentImage', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentImages'); $this->addRelation('ContentDocument', '\\Thelia\\Model\\ContentDocument', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentDocuments'); + $this->addRelation('ProductAssociatedContent', '\\Thelia\\Model\\ProductAssociatedContent', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ProductAssociatedContents'); + $this->addRelation('CategoryAssociatedContent', '\\Thelia\\Model\\CategoryAssociatedContent', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'CategoryAssociatedContents'); $this->addRelation('ContentI18n', '\\Thelia\\Model\\ContentI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ContentI18ns'); $this->addRelation('ContentVersion', '\\Thelia\\Model\\ContentVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ContentVersions'); $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Folders'); @@ -215,11 +216,12 @@ class ContentTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ContentAssocTableMap::clearInstancePool(); RewritingTableMap::clearInstancePool(); ContentFolderTableMap::clearInstancePool(); ContentImageTableMap::clearInstancePool(); ContentDocumentTableMap::clearInstancePool(); + ProductAssociatedContentTableMap::clearInstancePool(); + CategoryAssociatedContentTableMap::clearInstancePool(); ContentI18nTableMap::clearInstancePool(); ContentVersionTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/CouponI18nTableMap.php b/core/lib/Thelia/Model/Map/CouponI18nTableMap.php new file mode 100644 index 000000000..99d49216c --- /dev/null +++ b/core/lib/Thelia/Model/Map/CouponI18nTableMap.php @@ -0,0 +1,465 @@ + array('Id', 'Locale', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', ), + self::TYPE_COLNAME => array(CouponI18nTableMap::ID, CouponI18nTableMap::LOCALE, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', ), + self::TYPE_FIELDNAME => array('id', 'locale', ), + self::TYPE_NUM => array(0, 1, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, ), + self::TYPE_COLNAME => array(CouponI18nTableMap::ID => 0, CouponI18nTableMap::LOCALE => 1, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, ), + self::TYPE_NUM => array(0, 1, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('coupon_i18n'); + $this->setPhpName('CouponI18n'); + $this->setClassName('\\Thelia\\Model\\CouponI18n'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'coupon', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Coupon', '\\Thelia\\Model\\Coupon', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\CouponI18n $obj A \Thelia\Model\CouponI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\CouponI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\CouponI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CouponI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CouponI18nTableMap::CLASS_DEFAULT : CouponI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (CouponI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CouponI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CouponI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CouponI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CouponI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CouponI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CouponI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CouponI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + CouponI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(CouponI18nTableMap::ID); + $criteria->addSelectColumn(CouponI18nTableMap::LOCALE); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(CouponI18nTableMap::DATABASE_NAME)->getTable(CouponI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CouponI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CouponI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a CouponI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CouponI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CouponI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CouponI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(CouponI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(CouponI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = CouponI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CouponI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CouponI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the coupon_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CouponI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CouponI18n or Criteria object. + * + * @param mixed $criteria Criteria or CouponI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CouponI18n object + } + + + // Set the correct dbName + $query = CouponI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CouponI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CouponI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CouponTableMap.php b/core/lib/Thelia/Model/Map/CouponTableMap.php index 7e576a585..dfc987b21 100644 --- a/core/lib/Thelia/Model/Map/CouponTableMap.php +++ b/core/lib/Thelia/Model/Map/CouponTableMap.php @@ -57,7 +57,7 @@ class CouponTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 14; + const NUM_COLUMNS = 17; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CouponTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 14; + const NUM_HYDRATE_COLUMNS = 17; /** * the column name for the ID field @@ -100,9 +100,9 @@ class CouponTableMap extends TableMap const DESCRIPTION = 'coupon.DESCRIPTION'; /** - * the column name for the VALUE field + * the column name for the AMOUNT field */ - const VALUE = 'coupon.VALUE'; + const AMOUNT = 'coupon.AMOUNT'; /** * the column name for the IS_USED field @@ -120,9 +120,24 @@ class CouponTableMap extends TableMap const EXPIRATION_DATE = 'coupon.EXPIRATION_DATE'; /** - * the column name for the SERIALIZED_RULES field + * the column name for the SERIALIZED_RULES_TYPE field */ - const SERIALIZED_RULES = 'coupon.SERIALIZED_RULES'; + const SERIALIZED_RULES_TYPE = 'coupon.SERIALIZED_RULES_TYPE'; + + /** + * the column name for the SERIALIZED_RULES_CONTENT field + */ + const SERIALIZED_RULES_CONTENT = 'coupon.SERIALIZED_RULES_CONTENT'; + + /** + * the column name for the IS_CUMULATIVE field + */ + const IS_CUMULATIVE = 'coupon.IS_CUMULATIVE'; + + /** + * the column name for the IS_REMOVING_POSTAGE field + */ + const IS_REMOVING_POSTAGE = 'coupon.IS_REMOVING_POSTAGE'; /** * the column name for the CREATED_AT field @@ -160,12 +175,12 @@ class CouponTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Value', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'CreatedAt', 'UpdatedAt', 'Version', ), - self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'value', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'createdAt', 'updatedAt', 'version', ), - self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::TITLE, CouponTableMap::SHORT_DESCRIPTION, CouponTableMap::DESCRIPTION, CouponTableMap::VALUE, CouponTableMap::IS_USED, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::SERIALIZED_RULES, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ), - self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'VALUE', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), - self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'value', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'created_at', 'updated_at', 'version', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Amount', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRulesType', 'SerializedRulesContent', 'IsCumulative', 'IsRemovingPostage', 'CreatedAt', 'UpdatedAt', 'Version', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'amount', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRulesType', 'serializedRulesContent', 'isCumulative', 'isRemovingPostage', 'createdAt', 'updatedAt', 'version', ), + self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::TITLE, CouponTableMap::SHORT_DESCRIPTION, CouponTableMap::DESCRIPTION, CouponTableMap::AMOUNT, CouponTableMap::IS_USED, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::SERIALIZED_RULES_TYPE, CouponTableMap::SERIALIZED_RULES_CONTENT, CouponTableMap::IS_CUMULATIVE, CouponTableMap::IS_REMOVING_POSTAGE, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'AMOUNT', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES_TYPE', 'SERIALIZED_RULES_CONTENT', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), + self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'amount', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules_type', 'serialized_rules_content', 'is_cumulative', 'is_removing_postage', 'created_at', 'updated_at', 'version', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ) ); /** @@ -175,12 +190,12 @@ class CouponTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Value' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRules' => 10, 'CreatedAt' => 11, 'UpdatedAt' => 12, 'Version' => 13, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'value' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRules' => 10, 'createdAt' => 11, 'updatedAt' => 12, 'version' => 13, ), - self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::TITLE => 3, CouponTableMap::SHORT_DESCRIPTION => 4, CouponTableMap::DESCRIPTION => 5, CouponTableMap::VALUE => 6, CouponTableMap::IS_USED => 7, CouponTableMap::IS_ENABLED => 8, CouponTableMap::EXPIRATION_DATE => 9, CouponTableMap::SERIALIZED_RULES => 10, CouponTableMap::CREATED_AT => 11, CouponTableMap::UPDATED_AT => 12, CouponTableMap::VERSION => 13, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'VALUE' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES' => 10, 'CREATED_AT' => 11, 'UPDATED_AT' => 12, 'VERSION' => 13, ), - self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'value' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules' => 10, 'created_at' => 11, 'updated_at' => 12, 'version' => 13, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Amount' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRulesType' => 10, 'SerializedRulesContent' => 11, 'IsCumulative' => 12, 'IsRemovingPostage' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, 'Version' => 16, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'amount' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRulesType' => 10, 'serializedRulesContent' => 11, 'isCumulative' => 12, 'isRemovingPostage' => 13, 'createdAt' => 14, 'updatedAt' => 15, 'version' => 16, ), + self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::TITLE => 3, CouponTableMap::SHORT_DESCRIPTION => 4, CouponTableMap::DESCRIPTION => 5, CouponTableMap::AMOUNT => 6, CouponTableMap::IS_USED => 7, CouponTableMap::IS_ENABLED => 8, CouponTableMap::EXPIRATION_DATE => 9, CouponTableMap::SERIALIZED_RULES_TYPE => 10, CouponTableMap::SERIALIZED_RULES_CONTENT => 11, CouponTableMap::IS_CUMULATIVE => 12, CouponTableMap::IS_REMOVING_POSTAGE => 13, CouponTableMap::CREATED_AT => 14, CouponTableMap::UPDATED_AT => 15, CouponTableMap::VERSION => 16, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'AMOUNT' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES_TYPE' => 10, 'SERIALIZED_RULES_CONTENT' => 11, 'IS_CUMULATIVE' => 12, 'IS_REMOVING_POSTAGE' => 13, 'CREATED_AT' => 14, 'UPDATED_AT' => 15, 'VERSION' => 16, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'amount' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules_type' => 10, 'serialized_rules_content' => 11, 'is_cumulative' => 12, 'is_removing_postage' => 13, 'created_at' => 14, 'updated_at' => 15, 'version' => 16, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ) ); /** @@ -205,11 +220,14 @@ class CouponTableMap extends TableMap $this->addColumn('TITLE', 'Title', 'VARCHAR', true, 255, null); $this->addColumn('SHORT_DESCRIPTION', 'ShortDescription', 'LONGVARCHAR', true, null, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', true, null, null); - $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null); + $this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null); $this->addColumn('IS_USED', 'IsUsed', 'TINYINT', true, null, null); $this->addColumn('IS_ENABLED', 'IsEnabled', 'TINYINT', true, null, null); $this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null); - $this->addColumn('SERIALIZED_RULES', 'SerializedRules', 'LONGVARCHAR', true, null, null); + $this->addColumn('SERIALIZED_RULES_TYPE', 'SerializedRulesType', 'LONGVARCHAR', true, null, null); + $this->addColumn('SERIALIZED_RULES_CONTENT', 'SerializedRulesContent', 'LONGVARCHAR', true, null, null); + $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'TINYINT', true, null, null); + $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'TINYINT', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0); @@ -394,11 +412,14 @@ class CouponTableMap extends TableMap $criteria->addSelectColumn(CouponTableMap::TITLE); $criteria->addSelectColumn(CouponTableMap::SHORT_DESCRIPTION); $criteria->addSelectColumn(CouponTableMap::DESCRIPTION); - $criteria->addSelectColumn(CouponTableMap::VALUE); + $criteria->addSelectColumn(CouponTableMap::AMOUNT); $criteria->addSelectColumn(CouponTableMap::IS_USED); $criteria->addSelectColumn(CouponTableMap::IS_ENABLED); $criteria->addSelectColumn(CouponTableMap::EXPIRATION_DATE); - $criteria->addSelectColumn(CouponTableMap::SERIALIZED_RULES); + $criteria->addSelectColumn(CouponTableMap::SERIALIZED_RULES_TYPE); + $criteria->addSelectColumn(CouponTableMap::SERIALIZED_RULES_CONTENT); + $criteria->addSelectColumn(CouponTableMap::IS_CUMULATIVE); + $criteria->addSelectColumn(CouponTableMap::IS_REMOVING_POSTAGE); $criteria->addSelectColumn(CouponTableMap::CREATED_AT); $criteria->addSelectColumn(CouponTableMap::UPDATED_AT); $criteria->addSelectColumn(CouponTableMap::VERSION); @@ -409,11 +430,14 @@ class CouponTableMap extends TableMap $criteria->addSelectColumn($alias . '.TITLE'); $criteria->addSelectColumn($alias . '.SHORT_DESCRIPTION'); $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.VALUE'); + $criteria->addSelectColumn($alias . '.AMOUNT'); $criteria->addSelectColumn($alias . '.IS_USED'); $criteria->addSelectColumn($alias . '.IS_ENABLED'); $criteria->addSelectColumn($alias . '.EXPIRATION_DATE'); - $criteria->addSelectColumn($alias . '.SERIALIZED_RULES'); + $criteria->addSelectColumn($alias . '.SERIALIZED_RULES_TYPE'); + $criteria->addSelectColumn($alias . '.SERIALIZED_RULES_CONTENT'); + $criteria->addSelectColumn($alias . '.IS_CUMULATIVE'); + $criteria->addSelectColumn($alias . '.IS_REMOVING_POSTAGE'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); $criteria->addSelectColumn($alias . '.VERSION'); diff --git a/core/lib/Thelia/Model/Map/CouponVersionTableMap.php b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php new file mode 100644 index 000000000..68ece7a0f --- /dev/null +++ b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php @@ -0,0 +1,585 @@ + array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Amount', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRulesType', 'SerializedRulesContent', 'IsCumulative', 'IsRemovingPostage', 'CreatedAt', 'UpdatedAt', 'Version', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'amount', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRulesType', 'serializedRulesContent', 'isCumulative', 'isRemovingPostage', 'createdAt', 'updatedAt', 'version', ), + self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::TITLE, CouponVersionTableMap::SHORT_DESCRIPTION, CouponVersionTableMap::DESCRIPTION, CouponVersionTableMap::AMOUNT, CouponVersionTableMap::IS_USED, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::SERIALIZED_RULES_TYPE, CouponVersionTableMap::SERIALIZED_RULES_CONTENT, CouponVersionTableMap::IS_CUMULATIVE, CouponVersionTableMap::IS_REMOVING_POSTAGE, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'AMOUNT', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES_TYPE', 'SERIALIZED_RULES_CONTENT', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), + self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'amount', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules_type', 'serialized_rules_content', 'is_cumulative', 'is_removing_postage', 'created_at', 'updated_at', 'version', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Amount' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRulesType' => 10, 'SerializedRulesContent' => 11, 'IsCumulative' => 12, 'IsRemovingPostage' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, 'Version' => 16, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'amount' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRulesType' => 10, 'serializedRulesContent' => 11, 'isCumulative' => 12, 'isRemovingPostage' => 13, 'createdAt' => 14, 'updatedAt' => 15, 'version' => 16, ), + self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::TITLE => 3, CouponVersionTableMap::SHORT_DESCRIPTION => 4, CouponVersionTableMap::DESCRIPTION => 5, CouponVersionTableMap::AMOUNT => 6, CouponVersionTableMap::IS_USED => 7, CouponVersionTableMap::IS_ENABLED => 8, CouponVersionTableMap::EXPIRATION_DATE => 9, CouponVersionTableMap::SERIALIZED_RULES_TYPE => 10, CouponVersionTableMap::SERIALIZED_RULES_CONTENT => 11, CouponVersionTableMap::IS_CUMULATIVE => 12, CouponVersionTableMap::IS_REMOVING_POSTAGE => 13, CouponVersionTableMap::CREATED_AT => 14, CouponVersionTableMap::UPDATED_AT => 15, CouponVersionTableMap::VERSION => 16, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'AMOUNT' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES_TYPE' => 10, 'SERIALIZED_RULES_CONTENT' => 11, 'IS_CUMULATIVE' => 12, 'IS_REMOVING_POSTAGE' => 13, 'CREATED_AT' => 14, 'UPDATED_AT' => 15, 'VERSION' => 16, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'amount' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules_type' => 10, 'serialized_rules_content' => 11, 'is_cumulative' => 12, 'is_removing_postage' => 13, 'created_at' => 14, 'updated_at' => 15, 'version' => 16, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('coupon_version'); + $this->setPhpName('CouponVersion'); + $this->setClassName('\\Thelia\\Model\\CouponVersion'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'coupon', 'ID', true, null, null); + $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); + $this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null); + $this->addColumn('TITLE', 'Title', 'VARCHAR', true, 255, null); + $this->addColumn('SHORT_DESCRIPTION', 'ShortDescription', 'LONGVARCHAR', true, null, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', true, null, null); + $this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null); + $this->addColumn('IS_USED', 'IsUsed', 'TINYINT', true, null, null); + $this->addColumn('IS_ENABLED', 'IsEnabled', 'TINYINT', true, null, null); + $this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null); + $this->addColumn('SERIALIZED_RULES_TYPE', 'SerializedRulesType', 'LONGVARCHAR', true, null, null); + $this->addColumn('SERIALIZED_RULES_CONTENT', 'SerializedRulesContent', 'LONGVARCHAR', true, null, null); + $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'TINYINT', true, null, null); + $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'TINYINT', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Coupon', '\\Thelia\\Model\\Coupon', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\CouponVersion $obj A \Thelia\Model\CouponVersion object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\CouponVersion object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\CouponVersion) { + $key = serialize(array((string) $value->getId(), (string) $value->getVersion())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CouponVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 16 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 16 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CouponVersionTableMap::CLASS_DEFAULT : CouponVersionTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (CouponVersion object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CouponVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CouponVersionTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CouponVersionTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CouponVersionTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CouponVersionTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CouponVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CouponVersionTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + CouponVersionTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(CouponVersionTableMap::ID); + $criteria->addSelectColumn(CouponVersionTableMap::CODE); + $criteria->addSelectColumn(CouponVersionTableMap::TYPE); + $criteria->addSelectColumn(CouponVersionTableMap::TITLE); + $criteria->addSelectColumn(CouponVersionTableMap::SHORT_DESCRIPTION); + $criteria->addSelectColumn(CouponVersionTableMap::DESCRIPTION); + $criteria->addSelectColumn(CouponVersionTableMap::AMOUNT); + $criteria->addSelectColumn(CouponVersionTableMap::IS_USED); + $criteria->addSelectColumn(CouponVersionTableMap::IS_ENABLED); + $criteria->addSelectColumn(CouponVersionTableMap::EXPIRATION_DATE); + $criteria->addSelectColumn(CouponVersionTableMap::SERIALIZED_RULES_TYPE); + $criteria->addSelectColumn(CouponVersionTableMap::SERIALIZED_RULES_CONTENT); + $criteria->addSelectColumn(CouponVersionTableMap::IS_CUMULATIVE); + $criteria->addSelectColumn(CouponVersionTableMap::IS_REMOVING_POSTAGE); + $criteria->addSelectColumn(CouponVersionTableMap::CREATED_AT); + $criteria->addSelectColumn(CouponVersionTableMap::UPDATED_AT); + $criteria->addSelectColumn(CouponVersionTableMap::VERSION); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.CODE'); + $criteria->addSelectColumn($alias . '.TYPE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.SHORT_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.AMOUNT'); + $criteria->addSelectColumn($alias . '.IS_USED'); + $criteria->addSelectColumn($alias . '.IS_ENABLED'); + $criteria->addSelectColumn($alias . '.EXPIRATION_DATE'); + $criteria->addSelectColumn($alias . '.SERIALIZED_RULES_TYPE'); + $criteria->addSelectColumn($alias . '.SERIALIZED_RULES_CONTENT'); + $criteria->addSelectColumn($alias . '.IS_CUMULATIVE'); + $criteria->addSelectColumn($alias . '.IS_REMOVING_POSTAGE'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.VERSION'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(CouponVersionTableMap::DATABASE_NAME)->getTable(CouponVersionTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponVersionTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CouponVersionTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CouponVersionTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a CouponVersion or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CouponVersion object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponVersionTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CouponVersion) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CouponVersionTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(CouponVersionTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(CouponVersionTableMap::VERSION, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = CouponVersionQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CouponVersionTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CouponVersionTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the coupon_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CouponVersionQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CouponVersion or Criteria object. + * + * @param mixed $criteria Criteria or CouponVersion object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponVersionTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CouponVersion object + } + + + // Set the correct dbName + $query = CouponVersionQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CouponVersionTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CouponVersionTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProductAssociatedContentTableMap.php b/core/lib/Thelia/Model/Map/ProductAssociatedContentTableMap.php new file mode 100644 index 000000000..d4d1dadb8 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ProductAssociatedContentTableMap.php @@ -0,0 +1,456 @@ + array('Id', 'ProductId', 'ContentId', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'contentId', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProductAssociatedContentTableMap::ID, ProductAssociatedContentTableMap::PRODUCT_ID, ProductAssociatedContentTableMap::CONTENT_ID, ProductAssociatedContentTableMap::POSITION, ProductAssociatedContentTableMap::CREATED_AT, ProductAssociatedContentTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'CONTENT_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'content_id', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'ContentId' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'contentId' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(ProductAssociatedContentTableMap::ID => 0, ProductAssociatedContentTableMap::PRODUCT_ID => 1, ProductAssociatedContentTableMap::CONTENT_ID => 2, ProductAssociatedContentTableMap::POSITION => 3, ProductAssociatedContentTableMap::CREATED_AT => 4, ProductAssociatedContentTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'CONTENT_ID' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'content_id' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('product_associated_content'); + $this->setPhpName('ProductAssociatedContent'); + $this->setClassName('\\Thelia\\Model\\ProductAssociatedContent'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); + $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ProductAssociatedContentTableMap::CLASS_DEFAULT : ProductAssociatedContentTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (ProductAssociatedContent object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ProductAssociatedContentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProductAssociatedContentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ProductAssociatedContentTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ProductAssociatedContentTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ProductAssociatedContentTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ProductAssociatedContentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProductAssociatedContentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + ProductAssociatedContentTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(ProductAssociatedContentTableMap::ID); + $criteria->addSelectColumn(ProductAssociatedContentTableMap::PRODUCT_ID); + $criteria->addSelectColumn(ProductAssociatedContentTableMap::CONTENT_ID); + $criteria->addSelectColumn(ProductAssociatedContentTableMap::POSITION); + $criteria->addSelectColumn(ProductAssociatedContentTableMap::CREATED_AT); + $criteria->addSelectColumn(ProductAssociatedContentTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.PRODUCT_ID'); + $criteria->addSelectColumn($alias . '.CONTENT_ID'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(ProductAssociatedContentTableMap::DATABASE_NAME)->getTable(ProductAssociatedContentTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductAssociatedContentTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProductAssociatedContentTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProductAssociatedContentTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a ProductAssociatedContent or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ProductAssociatedContent object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ProductAssociatedContent) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ProductAssociatedContentTableMap::DATABASE_NAME); + $criteria->add(ProductAssociatedContentTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ProductAssociatedContentQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ProductAssociatedContentTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ProductAssociatedContentTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the product_associated_content table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ProductAssociatedContentQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ProductAssociatedContent or Criteria object. + * + * @param mixed $criteria Criteria or ProductAssociatedContent object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ProductAssociatedContent object + } + + if ($criteria->containsKey(ProductAssociatedContentTableMap::ID) && $criteria->keyContainsValue(ProductAssociatedContentTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProductAssociatedContentTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ProductAssociatedContentQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ProductAssociatedContentTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ProductAssociatedContentTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php index ef2cc7ca0..81badfba0 100644 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -200,13 +200,13 @@ class ProductTableMap extends TableMap $this->addRelation('ProductCategory', '\\Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductCategories'); $this->addRelation('FeatureProduct', '\\Thelia\\Model\\FeatureProduct', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'FeatureProducts'); $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductSaleElementss'); - $this->addRelation('ContentAssoc', '\\Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); $this->addRelation('ProductImage', '\\Thelia\\Model\\ProductImage', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductImages'); $this->addRelation('ProductDocument', '\\Thelia\\Model\\ProductDocument', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductDocuments'); $this->addRelation('AccessoryRelatedByProductId', '\\Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'AccessoriesRelatedByProductId'); $this->addRelation('AccessoryRelatedByAccessory', '\\Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'accessory', ), 'CASCADE', 'RESTRICT', 'AccessoriesRelatedByAccessory'); $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); $this->addRelation('CartItem', '\\Thelia\\Model\\CartItem', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), null, null, 'CartItems'); + $this->addRelation('ProductAssociatedContent', '\\Thelia\\Model\\ProductAssociatedContent', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductAssociatedContents'); $this->addRelation('ProductI18n', '\\Thelia\\Model\\ProductI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProductI18ns'); $this->addRelation('ProductVersion', '\\Thelia\\Model\\ProductVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProductVersions'); $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Categories'); @@ -238,11 +238,11 @@ class ProductTableMap extends TableMap ProductCategoryTableMap::clearInstancePool(); FeatureProductTableMap::clearInstancePool(); ProductSaleElementsTableMap::clearInstancePool(); - ContentAssocTableMap::clearInstancePool(); ProductImageTableMap::clearInstancePool(); ProductDocumentTableMap::clearInstancePool(); AccessoryTableMap::clearInstancePool(); RewritingTableMap::clearInstancePool(); + ProductAssociatedContentTableMap::clearInstancePool(); ProductI18nTableMap::clearInstancePool(); ProductVersionTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/ProductAssociatedContent.php b/core/lib/Thelia/Model/ProductAssociatedContent.php new file mode 100644 index 000000000..9b007baf1 --- /dev/null +++ b/core/lib/Thelia/Model/ProductAssociatedContent.php @@ -0,0 +1,9 @@ +generateValidCouponBaseAdapterMock(); $validators = array( - AvailableForTotalAmount::PARAM1_PRICE => array( - AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, - AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + new PriceParam( + 421.23, + 'EUR' + ) ) ); $validated = array( @@ -104,9 +108,12 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array( - AvailableForTotalAmount::PARAM1_PRICE => array( - AvailableForTotalAmount::OPERATOR => 'X', - AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + 'X', + new PriceParam( + 421.23, + 'EUR' + ) ) ); @@ -123,7 +130,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase /** * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput - * @expectedException \Thelia\Exception\InvalidRuleValueException + * @expectedException ErrorException * */ public function testInValidBackOfficeInputValue() @@ -132,9 +139,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array( - AvailableForTotalAmount::PARAM1_PRICE => array( - AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, - AvailableForTotalAmount::VALUE => 421 + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + 421 ) ); @@ -161,9 +168,12 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array( - AvailableForTotalAmount::PARAM1_PRICE => array( - AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, - AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + new PriceParam( + 421.23, + 'EUR' + ) ) ); @@ -186,9 +196,12 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase public function testInValidCheckoutInputValue() { $validators = array( - AvailableForTotalAmount::PARAM1_PRICE => array( - AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, - AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + new PriceParam( + 421.23, + 'EUR' + ) ) ); @@ -211,9 +224,12 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase public function testInValidCheckoutInputType() { $validators = array( - AvailableForTotalAmount::PARAM1_PRICE => array( - AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, - AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + new PriceParam( + 421.23, + 'EUR' + ) ) ); @@ -227,6 +243,60 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); } + /** + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::isMatching + * + */ + public function testMatchingRuleInferior() + { + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::INFERIOR, + new PriceParam( + 421.23, + 'EUR' + ) + ) + ); + + $validated = array( + AvailableForTotalAmount::PARAM1_PRICE => 421.22 + ); + $rule = new AvailableForTotalAmount($validators, $validated); + + $expected = true; + $actual = $rule->isMatching(); + $this->assertEquals($expected, $actual); + } + + /** + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::isMatching + * + */ + public function testNotMatchingRuleInferior() + { + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::INFERIOR, + new PriceParam( + 421.23, + 'EUR' + ) + ) + ); + + $validated = array( + AvailableForTotalAmount::PARAM1_PRICE => 421.23 + ); + $rule = new AvailableForTotalAmount($validators, $validated); + + $expected = false; + $actual = $rule->isMatching(); + $this->assertEquals($expected, $actual); + } + /** * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::isMatching @@ -238,9 +308,12 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array( - AvailableForTotalAmount::PARAM1_PRICE => array( - AvailableForTotalAmount::OPERATOR => Operators::EQUAL, - AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::EQUAL, + new PriceParam( + 421.23, + 'EUR' + ) ) ); @@ -262,9 +335,12 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase public function testNotMatchingRuleEqual() { $validators = array( - AvailableForTotalAmount::PARAM1_PRICE => array( - AvailableForTotalAmount::OPERATOR => Operators::EQUAL, - AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::EQUAL, + new PriceParam( + 421.23, + 'EUR' + ) ) ); @@ -286,9 +362,12 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase public function testMatchingRuleSuperior() { $validators = array( - AvailableForTotalAmount::PARAM1_PRICE => array( - AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, - AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + new PriceParam( + 421.23, + 'EUR' + ) ) ); @@ -310,9 +389,12 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase public function testNotMatchingRuleSuperior() { $validators = array( - AvailableForTotalAmount::PARAM1_PRICE => array( - AvailableForTotalAmount::OPERATOR => Operators::SUPERIOR, - AvailableForTotalAmount::VALUE => new PriceParam(421.23, 'EUR') + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + new PriceParam( + 421.23, + 'EUR' + ) ) ); diff --git a/install/faker.php b/install/faker.php index b262a8460..7f0159a8d 100755 --- a/install/faker.php +++ b/install/faker.php @@ -6,13 +6,19 @@ use Thelia\Model\FolderImage; use Thelia\Model\ContentImage; use Imagine\Image\Color; use Imagine\Image\Point; +use Symfony\Component\Serializer\Serializer; +use Symfony\Component\Serializer\Encoder\XmlEncoder; +use Symfony\Component\Serializer\Encoder\JsonEncoder; +use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer; require __DIR__ . '/../core/bootstrap.php'; $thelia = new Thelia\Core\Thelia("dev", true); $faker = Faker\Factory::create(); -$con = \Propel\Runtime\Propel::getConnection(Thelia\Model\Map\ProductTableMap::DATABASE_NAME); +$con = \Propel\Runtime\Propel::getConnection( + Thelia\Model\Map\ProductTableMap::DATABASE_NAME +); $con->beginTransaction(); $currency = \Thelia\Model\CurrencyQuery::create()->filterByCode('EUR')->findOne(); @@ -282,6 +288,8 @@ try { } } + generateCouponFixtures(); + $con->commit(); } catch (PropelException $pe) { @@ -294,4 +302,69 @@ catch (Exception $e) { } +/** + * Generate Coupon fixtures + */ +function generateCouponFixtures() +{ + // Coupons + $coupon1 = new Thelia\Model\Coupon(); + $coupon1->setCode('XMAS'); + $coupon1->setType('Thelia\Coupon\Type\RemoveXAmount'); + $coupon1->setTitle('Christmas coupon'); + $coupon1->setShortDescription('Coupon for Christmas removing 10€ if your total checkout is more than 40€'); + $coupon1->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla. +Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla. + +Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros. + +Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non. + +Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'); + $coupon1->setAmount(10.00); + $coupon1->setIsUsed(1); + $coupon1->setIsEnabled(1); + $date = new \DateTime(); + $coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 2 months"))); + + $rule1 = new Thelia\Coupon\Rule\AvailableForTotalAmount( + array( + Thelia\Coupon\Rule\AvailableForTotalAmount::PARAM1_PRICE => new Thelia\Coupon\Parameter\RuleValidator( + Thelia\Coupon\Rule\Operators::SUPERIOR, + new Thelia\Coupon\Parameter\PriceParam( + 40.00, + 'EUR' + ) + ) + ) + ); + $rule2 = new Thelia\Coupon\Rule\AvailableForTotalAmount( + array( + Thelia\Coupon\Rule\AvailableForTotalAmount::PARAM1_PRICE => new Thelia\Coupon\Parameter\RuleValidator( + Thelia\Coupon\Rule\Operators::INFERIOR, + new Thelia\Coupon\Parameter\PriceParam( + 400.00, + 'EUR' + ) + ) + ) + ); + $rules = array($rule1, $rule2); + + $encoders = array(new XmlEncoder(), new JsonEncoder()); + $normalizers = array(new GetSetMethodNormalizer()); + $serializer = new Serializer($normalizers, $encoders); + + $ruleTypes = array(); + /** @var Thelia\Coupon\Rule\CouponRuleInterface $rule */ + foreach ($rules as $rule) { + $ruleTypes[] = get_class($rule); + } + $coupon1->setSerializedRulesType($serializer->serialize($ruleTypes, 'json')); + $coupon1->setSerializedRulesContent($serializer->serialize($rules, 'json')); + + $coupon1->setIsCumulative(1); + $coupon1->setIsRemovingPostage(0); + $coupon1->save(); +} \ No newline at end of file diff --git a/install/thelia.sql b/install/thelia.sql index 502bbd036..83f86248e 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -567,42 +567,6 @@ CREATE TABLE `content` PRIMARY KEY (`id`) ) ENGINE=InnoDB; --- --------------------------------------------------------------------- --- content_assoc --- --------------------------------------------------------------------- - -DROP TABLE IF EXISTS `content_assoc`; - -CREATE TABLE `content_assoc` -( - `id` INTEGER NOT NULL AUTO_INCREMENT, - `category_id` INTEGER, - `product_id` INTEGER, - `content_id` INTEGER, - `position` INTEGER, - `created_at` DATETIME, - `updated_at` DATETIME, - PRIMARY KEY (`id`), - INDEX `idx_content_assoc_category_id` (`category_id`), - INDEX `idx_content_assoc_product_id` (`product_id`), - INDEX `idx_content_assoc_content_id` (`content_id`), - CONSTRAINT `fk_content_assoc_category_id` - FOREIGN KEY (`category_id`) - REFERENCES `category` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE, - CONSTRAINT `fk_content_assoc_product_id` - FOREIGN KEY (`product_id`) - REFERENCES `product` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE, - CONSTRAINT `fk_content_assoc_content_id` - FOREIGN KEY (`content_id`) - REFERENCES `content` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE -) ENGINE=InnoDB; - -- --------------------------------------------------------------------- -- product_image -- --------------------------------------------------------------------- @@ -846,7 +810,7 @@ DROP TABLE IF EXISTS `accessory`; CREATE TABLE `accessory` ( - `id` INTEGER NOT NULL, + `id` INTEGER NOT NULL AUTO_INCREMENT, `product_id` INTEGER NOT NULL, `accessory` INTEGER NOT NULL, `position` INTEGER NOT NULL, @@ -1121,16 +1085,26 @@ CREATE TABLE `coupon` `title` VARCHAR(255) NOT NULL, `short_description` TEXT NOT NULL, `description` LONGTEXT NOT NULL, - `value` FLOAT NOT NULL, + `amount` FLOAT NOT NULL, `is_used` TINYINT NOT NULL, `is_enabled` TINYINT NOT NULL, `expiration_date` DATETIME NOT NULL, - `serialized_rules` TEXT NOT NULL, + `serialized_rules_type` TEXT NOT NULL, + `serialized_rules_content` TEXT NOT NULL, + `is_cumulative` TINYINT NOT NULL, + `is_removing_postage` TINYINT NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, `version` INTEGER DEFAULT 0, PRIMARY KEY (`id`), - UNIQUE INDEX `code_UNIQUE` (`code`) + UNIQUE INDEX `code_UNIQUE` (`code`), + INDEX `idx_is_enabled` (`is_enabled`), + INDEX `idx_is_used` (`is_used`), + INDEX `idx_type` (`type`), + INDEX `idx_amount` (`amount`), + INDEX `idx_expiration_date` (`expiration_date`), + INDEX `idx_is_cumulative` (`is_cumulative`), + INDEX `idx_is_removing_postage` (`is_removing_postage`) ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -1441,6 +1415,64 @@ CREATE TABLE `folder_document` ON DELETE CASCADE ) ENGINE=InnoDB; +-- --------------------------------------------------------------------- +-- product_associated_content +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `product_associated_content`; + +CREATE TABLE `product_associated_content` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `product_id` INTEGER NOT NULL, + `content_id` INTEGER NOT NULL, + `position` INTEGER NOT NULL, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `idx_product_associated_content_product_id` (`product_id`), + INDEX `idx_product_associated_content_content_id` (`content_id`), + CONSTRAINT `fk_product_associated_content_product_id` + FOREIGN KEY (`product_id`) + REFERENCES `product` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE, + CONSTRAINT `fk_product_associated_content_content_id` + FOREIGN KEY (`content_id`) + REFERENCES `content` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- category_associated_content +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `category_associated_content`; + +CREATE TABLE `category_associated_content` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `category_id` INTEGER NOT NULL, + `content_id` INTEGER NOT NULL, + `position` INTEGER NOT NULL, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `idx_category_associated_content_category_id` (`category_id`), + INDEX `idx_category_associated_content_content_id` (`content_id`), + CONSTRAINT `fk_category_associated_content_category_id` + FOREIGN KEY (`category_id`) + REFERENCES `category` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE, + CONSTRAINT `fk_category_associated_content_content_id` + FOREIGN KEY (`content_id`) + REFERENCES `content` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + -- --------------------------------------------------------------------- -- category_i18n -- --------------------------------------------------------------------- @@ -2147,11 +2179,14 @@ CREATE TABLE `coupon_version` `title` VARCHAR(255) NOT NULL, `short_description` TEXT NOT NULL, `description` LONGTEXT NOT NULL, - `value` FLOAT NOT NULL, + `amount` FLOAT NOT NULL, `is_used` TINYINT NOT NULL, `is_enabled` TINYINT NOT NULL, `expiration_date` DATETIME NOT NULL, - `serialized_rules` TEXT NOT NULL, + `serialized_rules_type` TEXT NOT NULL, + `serialized_rules_content` TEXT NOT NULL, + `is_cumulative` TINYINT NOT NULL, + `is_removing_postage` TINYINT NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, `version` INTEGER DEFAULT 0 NOT NULL, diff --git a/local/config/schema.xml b/local/config/schema.xml index 062e778ad..71914d771 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -425,32 +425,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - -
    @@ -631,7 +605,7 @@
    - + @@ -821,14 +795,38 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1083,4 +1081,42 @@
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    \ No newline at end of file From fe4b77f7a8a8fd9dd970005e51591fea8a0c56d8 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 23 Aug 2013 10:55:59 +0200 Subject: [PATCH 025/268] associated content for categories and product tables + loop --- core/lib/Thelia/Config/Resources/config.xml | 1 + .../Core/Template/Loop/AssociatedContent.php | 127 ++ .../Model/Base/CategoryAssociatedContent.php | 1553 +++++++++++++ .../Base/CategoryAssociatedContentQuery.php | 804 +++++++ core/lib/Thelia/Model/Base/CouponI18n.php | 1207 ++++++++++ .../lib/Thelia/Model/Base/CouponI18nQuery.php | 475 ++++ core/lib/Thelia/Model/Base/CouponVersion.php | 1941 +++++++++++++++++ .../Thelia/Model/Base/CouponVersionQuery.php | 961 ++++++++ .../Model/Base/ProductAssociatedContent.php | 1553 +++++++++++++ .../Base/ProductAssociatedContentQuery.php | 804 +++++++ .../Model/CategoryAssociatedContent.php | 9 + .../Model/CategoryAssociatedContentQuery.php | 20 + core/lib/Thelia/Model/CouponI18n.php | 9 + core/lib/Thelia/Model/CouponI18nQuery.php | 20 + core/lib/Thelia/Model/CouponVersion.php | 9 + core/lib/Thelia/Model/CouponVersionQuery.php | 20 + .../Map/CategoryAssociatedContentTableMap.php | 456 ++++ .../Thelia/Model/Map/CouponI18nTableMap.php | 465 ++++ .../Model/Map/CouponVersionTableMap.php | 561 +++++ .../Map/ProductAssociatedContentTableMap.php | 456 ++++ .../Thelia/Model/ProductAssociatedContent.php | 9 + .../Model/ProductAssociatedContentQuery.php | 20 + install/faker.php | 150 +- install/sqldb.map | 2 + templates/default/category.html | 85 +- 25 files changed, 11656 insertions(+), 61 deletions(-) create mode 100755 core/lib/Thelia/Core/Template/Loop/AssociatedContent.php create mode 100644 core/lib/Thelia/Model/Base/CategoryAssociatedContent.php create mode 100644 core/lib/Thelia/Model/Base/CategoryAssociatedContentQuery.php create mode 100644 core/lib/Thelia/Model/Base/CouponI18n.php create mode 100644 core/lib/Thelia/Model/Base/CouponI18nQuery.php create mode 100644 core/lib/Thelia/Model/Base/CouponVersion.php create mode 100644 core/lib/Thelia/Model/Base/CouponVersionQuery.php create mode 100644 core/lib/Thelia/Model/Base/ProductAssociatedContent.php create mode 100644 core/lib/Thelia/Model/Base/ProductAssociatedContentQuery.php create mode 100644 core/lib/Thelia/Model/CategoryAssociatedContent.php create mode 100644 core/lib/Thelia/Model/CategoryAssociatedContentQuery.php create mode 100644 core/lib/Thelia/Model/CouponI18n.php create mode 100644 core/lib/Thelia/Model/CouponI18nQuery.php create mode 100644 core/lib/Thelia/Model/CouponVersion.php create mode 100644 core/lib/Thelia/Model/CouponVersionQuery.php create mode 100644 core/lib/Thelia/Model/Map/CategoryAssociatedContentTableMap.php create mode 100644 core/lib/Thelia/Model/Map/CouponI18nTableMap.php create mode 100644 core/lib/Thelia/Model/Map/CouponVersionTableMap.php create mode 100644 core/lib/Thelia/Model/Map/ProductAssociatedContentTableMap.php create mode 100644 core/lib/Thelia/Model/ProductAssociatedContent.php create mode 100644 core/lib/Thelia/Model/ProductAssociatedContentQuery.php create mode 100644 install/sqldb.map diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index eb07b7b1b..39d8bc905 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -7,6 +7,7 @@ + diff --git a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php new file mode 100755 index 000000000..70d34b01a --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php @@ -0,0 +1,127 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Thelia\Core\Template\Loop\Content; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\LoopResult; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\ProductAssociatedContentQuery; +use Thelia\Model\CategoryAssociatedContentQuery; +use Thelia\Type; + +/** + * + * AssociatedContent loop + * + * + * Class AssociatedContent + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class AssociatedContent extends Content +{ + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + $argumentCollection = parent::getArgDefinitions(); + + $argumentCollection->addArgument(Argument::createIntTypeArgument('product')) + ->addArgument(Argument::createIntTypeArgument('category')); + + $argumentCollection->get('order')->default = "associated_content"; + + $argumentCollection->get('order')->type->getKey(0)->addValue('associated_content'); + $argumentCollection->get('order')->type->getKey(0)->addValue('associated_content_reverse'); + + return $argumentCollection; + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + // + + $product = $this->getProduct(); + $category = $this->getCategory(); + + if($product === null && $category === null) { + throw new \InvalidArgumentException('You have to provide either `product` or `category` argument in associated_content loop'); + } + + if($product !== null) { + $search = ProductAssociatedContentQuery::create(); + + $search->filterByProductId($product, Criteria::EQUAL); + } elseif($category !== null) { + $search = CategoryAssociatedContentQuery::create(); + + $search->filterByCategoryId($category, Criteria::EQUAL); + } + + $order = $this->getOrder(); + $orderByAssociatedContent = array_search('associated_content', $order); + $orderByAssociatedContentReverse = array_search('associated_content_reverse', $order); + + if ($orderByAssociatedContent !== false) { + $search->orderByPosition(Criteria::ASC); + $order[$orderByAssociatedContent] = 'given_id'; + $this->args->get('order')->setValue( implode(',', $order) ); + } + if ($orderByAssociatedContentReverse !== false) { + $search->orderByPosition(Criteria::DESC); + $order[$orderByAssociatedContentReverse] = 'given_id'; + $this->args->get('order')->setValue( implode(',', $order) ); + } + + $associatedContents = $this->search($search); + + $associatedContentIdList = array(0); + foreach ($associatedContents as $associatedContent) { + array_push($associatedContentIdList, $associatedContent->getContentId()); + } + + $receivedIdList = $this->getId(); + + /* if an Id list is receive, loop will only match accessories from this list */ + if ($receivedIdList === null) { + $this->args->get('id')->setValue( implode(',', $associatedContentIdList) ); + } else { + $this->args->get('id')->setValue( implode(',', array_intersect($receivedIdList, $associatedContentIdList)) ); + } + + return parent::exec($pagination); + } + +} diff --git a/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php b/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php new file mode 100644 index 000000000..142ab543f --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php @@ -0,0 +1,1553 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CategoryAssociatedContent instance. If + * obj is an instance of CategoryAssociatedContent, delegates to + * equals(CategoryAssociatedContent). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CategoryAssociatedContent The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CategoryAssociatedContent The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [category_id] column value. + * + * @return int + */ + public function getCategoryId() + { + + return $this->category_id; + } + + /** + * Get the [content_id] column value. + * + * @return int + */ + public function getContentId() + { + + return $this->content_id; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [category_id] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + */ + public function setCategoryId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->category_id !== $v) { + $this->category_id = $v; + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::CATEGORY_ID; + } + + if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { + $this->aCategory = null; + } + + + return $this; + } // setCategoryId() + + /** + * Set the value of [content_id] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + */ + public function setContentId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->content_id !== $v) { + $this->content_id = $v; + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::CONTENT_ID; + } + + if ($this->aContent !== null && $this->aContent->getId() !== $v) { + $this->aContent = null; + } + + + return $this; + } // setContentId() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::POSITION; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CategoryAssociatedContentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryAssociatedContentTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->category_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryAssociatedContentTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->content_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryAssociatedContentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryAssociatedContentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryAssociatedContentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = CategoryAssociatedContentTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CategoryAssociatedContent object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { + $this->aCategory = null; + } + if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { + $this->aContent = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCategoryAssociatedContentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCategory = null; + $this->aContent = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CategoryAssociatedContent::setDeleted() + * @see CategoryAssociatedContent::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCategoryAssociatedContentQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CategoryAssociatedContentTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CategoryAssociatedContentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CategoryAssociatedContentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CategoryAssociatedContentTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCategory !== null) { + if ($this->aCategory->isModified() || $this->aCategory->isNew()) { + $affectedRows += $this->aCategory->save($con); + } + $this->setCategory($this->aCategory); + } + + if ($this->aContent !== null) { + if ($this->aContent->isModified() || $this->aContent->isNew()) { + $affectedRows += $this->aContent->save($con); + } + $this->setContent($this->aContent); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryAssociatedContentTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CategoryAssociatedContentTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CategoryAssociatedContentTableMap::CATEGORY_ID)) { + $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; + } + if ($this->isColumnModified(CategoryAssociatedContentTableMap::CONTENT_ID)) { + $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; + } + if ($this->isColumnModified(CategoryAssociatedContentTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(CategoryAssociatedContentTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(CategoryAssociatedContentTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO category_associated_content (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'CATEGORY_ID': + $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); + break; + case 'CONTENT_ID': + $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryAssociatedContentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getCategoryId(); + break; + case 2: + return $this->getContentId(); + break; + case 3: + return $this->getPosition(); + break; + case 4: + return $this->getCreatedAt(); + break; + case 5: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CategoryAssociatedContent'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CategoryAssociatedContent'][$this->getPrimaryKey()] = true; + $keys = CategoryAssociatedContentTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getCategoryId(), + $keys[2] => $this->getContentId(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCategory) { + $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aContent) { + $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryAssociatedContentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setCategoryId($value); + break; + case 2: + $this->setContentId($value); + break; + case 3: + $this->setPosition($value); + break; + case 4: + $this->setCreatedAt($value); + break; + case 5: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = CategoryAssociatedContentTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setContentId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(CategoryAssociatedContentTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CategoryAssociatedContentTableMap::ID)) $criteria->add(CategoryAssociatedContentTableMap::ID, $this->id); + if ($this->isColumnModified(CategoryAssociatedContentTableMap::CATEGORY_ID)) $criteria->add(CategoryAssociatedContentTableMap::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(CategoryAssociatedContentTableMap::CONTENT_ID)) $criteria->add(CategoryAssociatedContentTableMap::CONTENT_ID, $this->content_id); + if ($this->isColumnModified(CategoryAssociatedContentTableMap::POSITION)) $criteria->add(CategoryAssociatedContentTableMap::POSITION, $this->position); + if ($this->isColumnModified(CategoryAssociatedContentTableMap::CREATED_AT)) $criteria->add(CategoryAssociatedContentTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CategoryAssociatedContentTableMap::UPDATED_AT)) $criteria->add(CategoryAssociatedContentTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CategoryAssociatedContentTableMap::DATABASE_NAME); + $criteria->add(CategoryAssociatedContentTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\CategoryAssociatedContent (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setCategoryId($this->getCategoryId()); + $copyObj->setContentId($this->getContentId()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\CategoryAssociatedContent Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildCategory object. + * + * @param ChildCategory $v + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + * @throws PropelException + */ + public function setCategory(ChildCategory $v = null) + { + if ($v === null) { + $this->setCategoryId(NULL); + } else { + $this->setCategoryId($v->getId()); + } + + $this->aCategory = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCategory object, it will not be re-added. + if ($v !== null) { + $v->addCategoryAssociatedContent($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCategory object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategory The associated ChildCategory object. + * @throws PropelException + */ + public function getCategory(ConnectionInterface $con = null) + { + if ($this->aCategory === null && ($this->category_id !== null)) { + $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCategory->addCategoryAssociatedContents($this); + */ + } + + return $this->aCategory; + } + + /** + * Declares an association between this object and a ChildContent object. + * + * @param ChildContent $v + * @return \Thelia\Model\CategoryAssociatedContent The current object (for fluent API support) + * @throws PropelException + */ + public function setContent(ChildContent $v = null) + { + if ($v === null) { + $this->setContentId(NULL); + } else { + $this->setContentId($v->getId()); + } + + $this->aContent = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildContent object, it will not be re-added. + if ($v !== null) { + $v->addCategoryAssociatedContent($this); + } + + + return $this; + } + + + /** + * Get the associated ChildContent object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContent The associated ChildContent object. + * @throws PropelException + */ + public function getContent(ConnectionInterface $con = null) + { + if ($this->aContent === null && ($this->content_id !== null)) { + $this->aContent = ChildContentQuery::create()->findPk($this->content_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aContent->addCategoryAssociatedContents($this); + */ + } + + return $this->aContent; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->category_id = null; + $this->content_id = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCategory = null; + $this->aContent = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CategoryAssociatedContentTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildCategoryAssociatedContent The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CategoryAssociatedContentTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/CategoryAssociatedContentQuery.php b/core/lib/Thelia/Model/Base/CategoryAssociatedContentQuery.php new file mode 100644 index 000000000..bb03306f4 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryAssociatedContentQuery.php @@ -0,0 +1,804 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCategoryAssociatedContent|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CategoryAssociatedContentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCategoryAssociatedContent A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, CATEGORY_ID, CONTENT_ID, POSITION, CREATED_AT, UPDATED_AT FROM category_associated_content WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCategoryAssociatedContent(); + $obj->hydrate($row); + CategoryAssociatedContentTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCategoryAssociatedContent|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the category_id column + * + * Example usage: + * + * $query->filterByCategoryId(1234); // WHERE category_id = 1234 + * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 + * + * + * @see filterByCategory() + * + * @param mixed $categoryId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByCategoryId($categoryId = null, $comparison = null) + { + if (is_array($categoryId)) { + $useMinMax = false; + if (isset($categoryId['min'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($categoryId['max'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::CATEGORY_ID, $categoryId, $comparison); + } + + /** + * Filter the query on the content_id column + * + * Example usage: + * + * $query->filterByContentId(1234); // WHERE content_id = 1234 + * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) + * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 + * + * + * @see filterByContent() + * + * @param mixed $contentId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByContentId($contentId = null, $comparison = null) + { + if (is_array($contentId)) { + $useMinMax = false; + if (isset($contentId['min'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($contentId['max'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::CONTENT_ID, $contentId, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryAssociatedContentTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Category object + * + * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByCategory($category, $comparison = null) + { + if ($category instanceof \Thelia\Model\Category) { + return $this + ->addUsingAlias(CategoryAssociatedContentTableMap::CATEGORY_ID, $category->getId(), $comparison); + } elseif ($category instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CategoryAssociatedContentTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Category relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Category'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Category'); + } + + return $this; + } + + /** + * Use the Category relation Category object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query + */ + public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCategory($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Content object + * + * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function filterByContent($content, $comparison = null) + { + if ($content instanceof \Thelia\Model\Content) { + return $this + ->addUsingAlias(CategoryAssociatedContentTableMap::CONTENT_ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CategoryAssociatedContentTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Content relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Content'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Content'); + } + + return $this; + } + + /** + * Use the Content relation Content object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query + */ + public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); + } + + /** + * Exclude object from result + * + * @param ChildCategoryAssociatedContent $categoryAssociatedContent Object to remove from the list of results + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function prune($categoryAssociatedContent = null) + { + if ($categoryAssociatedContent) { + $this->addUsingAlias(CategoryAssociatedContentTableMap::ID, $categoryAssociatedContent->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the category_associated_content table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CategoryAssociatedContentTableMap::clearInstancePool(); + CategoryAssociatedContentTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCategoryAssociatedContent or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCategoryAssociatedContent object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CategoryAssociatedContentTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + CategoryAssociatedContentTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CategoryAssociatedContentTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CategoryAssociatedContentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CategoryAssociatedContentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CategoryAssociatedContentTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CategoryAssociatedContentTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CategoryAssociatedContentTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CategoryAssociatedContentTableMap::CREATED_AT); + } + +} // CategoryAssociatedContentQuery diff --git a/core/lib/Thelia/Model/Base/CouponI18n.php b/core/lib/Thelia/Model/Base/CouponI18n.php new file mode 100644 index 000000000..c15ba0309 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CouponI18n.php @@ -0,0 +1,1207 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\CouponI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CouponI18n instance. If + * obj is an instance of CouponI18n, delegates to + * equals(CouponI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CouponI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CouponI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CouponI18nTableMap::ID; + } + + if ($this->aCoupon !== null && $this->aCoupon->getId() !== $v) { + $this->aCoupon = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = CouponI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_EN') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CouponI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CouponI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 2; // 2 = CouponI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CouponI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aCoupon !== null && $this->id !== $this->aCoupon->getId()) { + $this->aCoupon = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CouponI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCouponI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCoupon = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CouponI18n::setDeleted() + * @see CouponI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCouponI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CouponI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCoupon !== null) { + if ($this->aCoupon->isModified() || $this->aCoupon->isNew()) { + $affectedRows += $this->aCoupon->save($con); + } + $this->setCoupon($this->aCoupon); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CouponI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CouponI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + + $sql = sprintf( + 'INSERT INTO coupon_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CouponI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CouponI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CouponI18n'][serialize($this->getPrimaryKey())] = true; + $keys = CouponI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCoupon) { + $result['Coupon'] = $this->aCoupon->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CouponI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = CouponI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(CouponI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CouponI18nTableMap::ID)) $criteria->add(CouponI18nTableMap::ID, $this->id); + if ($this->isColumnModified(CouponI18nTableMap::LOCALE)) $criteria->add(CouponI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CouponI18nTableMap::DATABASE_NAME); + $criteria->add(CouponI18nTableMap::ID, $this->id); + $criteria->add(CouponI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\CouponI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\CouponI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildCoupon object. + * + * @param ChildCoupon $v + * @return \Thelia\Model\CouponI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setCoupon(ChildCoupon $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aCoupon = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCoupon object, it will not be re-added. + if ($v !== null) { + $v->addCouponI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCoupon object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCoupon The associated ChildCoupon object. + * @throws PropelException + */ + public function getCoupon(ConnectionInterface $con = null) + { + if ($this->aCoupon === null && ($this->id !== null)) { + $this->aCoupon = ChildCouponQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCoupon->addCouponI18ns($this); + */ + } + + return $this->aCoupon; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCoupon = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CouponI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/CouponI18nQuery.php b/core/lib/Thelia/Model/Base/CouponI18nQuery.php new file mode 100644 index 000000000..9468f787f --- /dev/null +++ b/core/lib/Thelia/Model/Base/CouponI18nQuery.php @@ -0,0 +1,475 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCouponI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CouponI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CouponI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCouponI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE FROM coupon_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCouponI18n(); + $obj->hydrate($row); + CouponI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCouponI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(CouponI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(CouponI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(CouponI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(CouponI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByCoupon() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CouponI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CouponI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Coupon object + * + * @param \Thelia\Model\Coupon|ObjectCollection $coupon The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function filterByCoupon($coupon, $comparison = null) + { + if ($coupon instanceof \Thelia\Model\Coupon) { + return $this + ->addUsingAlias(CouponI18nTableMap::ID, $coupon->getId(), $comparison); + } elseif ($coupon instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CouponI18nTableMap::ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCoupon() only accepts arguments of type \Thelia\Model\Coupon or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Coupon relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function joinCoupon($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Coupon'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Coupon'); + } + + return $this; + } + + /** + * Use the Coupon relation Coupon object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CouponQuery A secondary query class using the current class as primary query + */ + public function useCouponQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinCoupon($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery'); + } + + /** + * Exclude object from result + * + * @param ChildCouponI18n $couponI18n Object to remove from the list of results + * + * @return ChildCouponI18nQuery The current query, for fluid interface + */ + public function prune($couponI18n = null) + { + if ($couponI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(CouponI18nTableMap::ID), $couponI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(CouponI18nTableMap::LOCALE), $couponI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the coupon_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CouponI18nTableMap::clearInstancePool(); + CouponI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCouponI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCouponI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CouponI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + CouponI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CouponI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // CouponI18nQuery diff --git a/core/lib/Thelia/Model/Base/CouponVersion.php b/core/lib/Thelia/Model/Base/CouponVersion.php new file mode 100644 index 000000000..34d525a7a --- /dev/null +++ b/core/lib/Thelia/Model/Base/CouponVersion.php @@ -0,0 +1,1941 @@ +version = 0; + } + + /** + * Initializes internal state of Thelia\Model\Base\CouponVersion object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CouponVersion instance. If + * obj is an instance of CouponVersion, delegates to + * equals(CouponVersion). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CouponVersion The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CouponVersion The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [code] column value. + * + * @return string + */ + public function getCode() + { + + return $this->code; + } + + /** + * Get the [type] column value. + * + * @return string + */ + public function getType() + { + + return $this->type; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [short_description] column value. + * + * @return string + */ + public function getShortDescription() + { + + return $this->short_description; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [value] column value. + * + * @return double + */ + public function getValue() + { + + return $this->value; + } + + /** + * Get the [is_used] column value. + * + * @return int + */ + public function getIsUsed() + { + + return $this->is_used; + } + + /** + * Get the [is_enabled] column value. + * + * @return int + */ + public function getIsEnabled() + { + + return $this->is_enabled; + } + + /** + * Get the [optionally formatted] temporal [expiration_date] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getExpirationDate($format = NULL) + { + if ($format === null) { + return $this->expiration_date; + } else { + return $this->expiration_date !== null ? $this->expiration_date->format($format) : null; + } + } + + /** + * Get the [serialized_rules] column value. + * + * @return string + */ + public function getSerializedRules() + { + + return $this->serialized_rules; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Get the [version] column value. + * + * @return int + */ + public function getVersion() + { + + return $this->version; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CouponVersionTableMap::ID; + } + + if ($this->aCoupon !== null && $this->aCoupon->getId() !== $v) { + $this->aCoupon = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [code] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setCode($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->code !== $v) { + $this->code = $v; + $this->modifiedColumns[] = CouponVersionTableMap::CODE; + } + + + return $this; + } // setCode() + + /** + * Set the value of [type] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setType($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = CouponVersionTableMap::TYPE; + } + + + return $this; + } // setType() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = CouponVersionTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [short_description] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setShortDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->short_description !== $v) { + $this->short_description = $v; + $this->modifiedColumns[] = CouponVersionTableMap::SHORT_DESCRIPTION; + } + + + return $this; + } // setShortDescription() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CouponVersionTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [value] column. + * + * @param double $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setValue($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->value !== $v) { + $this->value = $v; + $this->modifiedColumns[] = CouponVersionTableMap::VALUE; + } + + + return $this; + } // setValue() + + /** + * Set the value of [is_used] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setIsUsed($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_used !== $v) { + $this->is_used = $v; + $this->modifiedColumns[] = CouponVersionTableMap::IS_USED; + } + + + return $this; + } // setIsUsed() + + /** + * Set the value of [is_enabled] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setIsEnabled($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_enabled !== $v) { + $this->is_enabled = $v; + $this->modifiedColumns[] = CouponVersionTableMap::IS_ENABLED; + } + + + return $this; + } // setIsEnabled() + + /** + * Sets the value of [expiration_date] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setExpirationDate($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->expiration_date !== null || $dt !== null) { + if ($dt !== $this->expiration_date) { + $this->expiration_date = $dt; + $this->modifiedColumns[] = CouponVersionTableMap::EXPIRATION_DATE; + } + } // if either are not null + + + return $this; + } // setExpirationDate() + + /** + * Set the value of [serialized_rules] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setSerializedRules($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->serialized_rules !== $v) { + $this->serialized_rules = $v; + $this->modifiedColumns[] = CouponVersionTableMap::SERIALIZED_RULES; + } + + + return $this; + } // setSerializedRules() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CouponVersionTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CouponVersionTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Set the value of [version] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setVersion($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->version !== $v) { + $this->version = $v; + $this->modifiedColumns[] = CouponVersionTableMap::VERSION; + } + + + return $this; + } // setVersion() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->version !== 0) { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CouponVersionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CouponVersionTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponVersionTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)]; + $this->type = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponVersionTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponVersionTableMap::translateFieldName('ShortDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->short_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponVersionTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponVersionTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; + $this->value = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponVersionTableMap::translateFieldName('IsUsed', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_used = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponVersionTableMap::translateFieldName('IsEnabled', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_enabled = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponVersionTableMap::translateFieldName('ExpirationDate', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->expiration_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponVersionTableMap::translateFieldName('SerializedRules', TableMap::TYPE_PHPNAME, $indexType)]; + $this->serialized_rules = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 14; // 14 = CouponVersionTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CouponVersion object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aCoupon !== null && $this->id !== $this->aCoupon->getId()) { + $this->aCoupon = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CouponVersionTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCouponVersionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCoupon = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CouponVersion::setDeleted() + * @see CouponVersion::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponVersionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCouponVersionQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponVersionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CouponVersionTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCoupon !== null) { + if ($this->aCoupon->isModified() || $this->aCoupon->isNew()) { + $affectedRows += $this->aCoupon->save($con); + } + $this->setCoupon($this->aCoupon); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CouponVersionTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CouponVersionTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; + } + if ($this->isColumnModified(CouponVersionTableMap::TYPE)) { + $modifiedColumns[':p' . $index++] = 'TYPE'; + } + if ($this->isColumnModified(CouponVersionTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(CouponVersionTableMap::SHORT_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'SHORT_DESCRIPTION'; + } + if ($this->isColumnModified(CouponVersionTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(CouponVersionTableMap::VALUE)) { + $modifiedColumns[':p' . $index++] = 'VALUE'; + } + if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) { + $modifiedColumns[':p' . $index++] = 'IS_USED'; + } + if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) { + $modifiedColumns[':p' . $index++] = 'IS_ENABLED'; + } + if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) { + $modifiedColumns[':p' . $index++] = 'EXPIRATION_DATE'; + } + if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES)) { + $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES'; + } + if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(CouponVersionTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + if ($this->isColumnModified(CouponVersionTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; + } + + $sql = sprintf( + 'INSERT INTO coupon_version (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'CODE': + $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); + break; + case 'TYPE': + $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'SHORT_DESCRIPTION': + $stmt->bindValue($identifier, $this->short_description, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'VALUE': + $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); + break; + case 'IS_USED': + $stmt->bindValue($identifier, $this->is_used, PDO::PARAM_INT); + break; + case 'IS_ENABLED': + $stmt->bindValue($identifier, $this->is_enabled, PDO::PARAM_INT); + break; + case 'EXPIRATION_DATE': + $stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'SERIALIZED_RULES': + $stmt->bindValue($identifier, $this->serialized_rules, PDO::PARAM_STR); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'VERSION': + $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CouponVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getCode(); + break; + case 2: + return $this->getType(); + break; + case 3: + return $this->getTitle(); + break; + case 4: + return $this->getShortDescription(); + break; + case 5: + return $this->getDescription(); + break; + case 6: + return $this->getValue(); + break; + case 7: + return $this->getIsUsed(); + break; + case 8: + return $this->getIsEnabled(); + break; + case 9: + return $this->getExpirationDate(); + break; + case 10: + return $this->getSerializedRules(); + break; + case 11: + return $this->getCreatedAt(); + break; + case 12: + return $this->getUpdatedAt(); + break; + case 13: + return $this->getVersion(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CouponVersion'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CouponVersion'][serialize($this->getPrimaryKey())] = true; + $keys = CouponVersionTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getCode(), + $keys[2] => $this->getType(), + $keys[3] => $this->getTitle(), + $keys[4] => $this->getShortDescription(), + $keys[5] => $this->getDescription(), + $keys[6] => $this->getValue(), + $keys[7] => $this->getIsUsed(), + $keys[8] => $this->getIsEnabled(), + $keys[9] => $this->getExpirationDate(), + $keys[10] => $this->getSerializedRules(), + $keys[11] => $this->getCreatedAt(), + $keys[12] => $this->getUpdatedAt(), + $keys[13] => $this->getVersion(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCoupon) { + $result['Coupon'] = $this->aCoupon->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CouponVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setCode($value); + break; + case 2: + $this->setType($value); + break; + case 3: + $this->setTitle($value); + break; + case 4: + $this->setShortDescription($value); + break; + case 5: + $this->setDescription($value); + break; + case 6: + $this->setValue($value); + break; + case 7: + $this->setIsUsed($value); + break; + case 8: + $this->setIsEnabled($value); + break; + case 9: + $this->setExpirationDate($value); + break; + case 10: + $this->setSerializedRules($value); + break; + case 11: + $this->setCreatedAt($value); + break; + case 12: + $this->setUpdatedAt($value); + break; + case 13: + $this->setVersion($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = CouponVersionTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setShortDescription($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDescription($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setValue($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setIsUsed($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setIsEnabled($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setExpirationDate($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setSerializedRules($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setCreatedAt($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setUpdatedAt($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setVersion($arr[$keys[13]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(CouponVersionTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CouponVersionTableMap::ID)) $criteria->add(CouponVersionTableMap::ID, $this->id); + if ($this->isColumnModified(CouponVersionTableMap::CODE)) $criteria->add(CouponVersionTableMap::CODE, $this->code); + if ($this->isColumnModified(CouponVersionTableMap::TYPE)) $criteria->add(CouponVersionTableMap::TYPE, $this->type); + if ($this->isColumnModified(CouponVersionTableMap::TITLE)) $criteria->add(CouponVersionTableMap::TITLE, $this->title); + if ($this->isColumnModified(CouponVersionTableMap::SHORT_DESCRIPTION)) $criteria->add(CouponVersionTableMap::SHORT_DESCRIPTION, $this->short_description); + if ($this->isColumnModified(CouponVersionTableMap::DESCRIPTION)) $criteria->add(CouponVersionTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(CouponVersionTableMap::VALUE)) $criteria->add(CouponVersionTableMap::VALUE, $this->value); + if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) $criteria->add(CouponVersionTableMap::IS_USED, $this->is_used); + if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) $criteria->add(CouponVersionTableMap::IS_ENABLED, $this->is_enabled); + if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) $criteria->add(CouponVersionTableMap::EXPIRATION_DATE, $this->expiration_date); + if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES)) $criteria->add(CouponVersionTableMap::SERIALIZED_RULES, $this->serialized_rules); + if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) $criteria->add(CouponVersionTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CouponVersionTableMap::UPDATED_AT)) $criteria->add(CouponVersionTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(CouponVersionTableMap::VERSION)) $criteria->add(CouponVersionTableMap::VERSION, $this->version); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CouponVersionTableMap::DATABASE_NAME); + $criteria->add(CouponVersionTableMap::ID, $this->id); + $criteria->add(CouponVersionTableMap::VERSION, $this->version); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getVersion(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setVersion($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getVersion()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\CouponVersion (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setCode($this->getCode()); + $copyObj->setType($this->getType()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setShortDescription($this->getShortDescription()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setValue($this->getValue()); + $copyObj->setIsUsed($this->getIsUsed()); + $copyObj->setIsEnabled($this->getIsEnabled()); + $copyObj->setExpirationDate($this->getExpirationDate()); + $copyObj->setSerializedRules($this->getSerializedRules()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + $copyObj->setVersion($this->getVersion()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\CouponVersion Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildCoupon object. + * + * @param ChildCoupon $v + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + * @throws PropelException + */ + public function setCoupon(ChildCoupon $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aCoupon = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCoupon object, it will not be re-added. + if ($v !== null) { + $v->addCouponVersion($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCoupon object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCoupon The associated ChildCoupon object. + * @throws PropelException + */ + public function getCoupon(ConnectionInterface $con = null) + { + if ($this->aCoupon === null && ($this->id !== null)) { + $this->aCoupon = ChildCouponQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCoupon->addCouponVersions($this); + */ + } + + return $this->aCoupon; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->code = null; + $this->type = null; + $this->title = null; + $this->short_description = null; + $this->description = null; + $this->value = null; + $this->is_used = null; + $this->is_enabled = null; + $this->expiration_date = null; + $this->serialized_rules = null; + $this->created_at = null; + $this->updated_at = null; + $this->version = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCoupon = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CouponVersionTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/CouponVersionQuery.php b/core/lib/Thelia/Model/Base/CouponVersionQuery.php new file mode 100644 index 000000000..e1acec354 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CouponVersionQuery.php @@ -0,0 +1,961 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $version] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCouponVersion|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CouponVersionTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CouponVersionTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCouponVersion A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, VALUE, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES, CREATED_AT, UPDATED_AT, VERSION FROM coupon_version WHERE ID = :p0 AND VERSION = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCouponVersion(); + $obj->hydrate($row); + CouponVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCouponVersion|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(CouponVersionTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(CouponVersionTableMap::VERSION, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(CouponVersionTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(CouponVersionTableMap::VERSION, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByCoupon() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CouponVersionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CouponVersionTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the code column + * + * Example usage: + * + * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' + * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' + * + * + * @param string $code The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByCode($code = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($code)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $code)) { + $code = str_replace('*', '%', $code); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::CODE, $code, $comparison); + } + + /** + * Filter the query on the type column + * + * Example usage: + * + * $query->filterByType('fooValue'); // WHERE type = 'fooValue' + * $query->filterByType('%fooValue%'); // WHERE type LIKE '%fooValue%' + * + * + * @param string $type The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByType($type = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($type)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $type)) { + $type = str_replace('*', '%', $type); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::TYPE, $type, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the short_description column + * + * Example usage: + * + * $query->filterByShortDescription('fooValue'); // WHERE short_description = 'fooValue' + * $query->filterByShortDescription('%fooValue%'); // WHERE short_description LIKE '%fooValue%' + * + * + * @param string $shortDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByShortDescription($shortDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($shortDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $shortDescription)) { + $shortDescription = str_replace('*', '%', $shortDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::SHORT_DESCRIPTION, $shortDescription, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the value column + * + * Example usage: + * + * $query->filterByValue(1234); // WHERE value = 1234 + * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34) + * $query->filterByValue(array('min' => 12)); // WHERE value > 12 + * + * + * @param mixed $value The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByValue($value = null, $comparison = null) + { + if (is_array($value)) { + $useMinMax = false; + if (isset($value['min'])) { + $this->addUsingAlias(CouponVersionTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($value['max'])) { + $this->addUsingAlias(CouponVersionTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::VALUE, $value, $comparison); + } + + /** + * Filter the query on the is_used column + * + * Example usage: + * + * $query->filterByIsUsed(1234); // WHERE is_used = 1234 + * $query->filterByIsUsed(array(12, 34)); // WHERE is_used IN (12, 34) + * $query->filterByIsUsed(array('min' => 12)); // WHERE is_used > 12 + * + * + * @param mixed $isUsed The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByIsUsed($isUsed = null, $comparison = null) + { + if (is_array($isUsed)) { + $useMinMax = false; + if (isset($isUsed['min'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isUsed['max'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed, $comparison); + } + + /** + * Filter the query on the is_enabled column + * + * Example usage: + * + * $query->filterByIsEnabled(1234); // WHERE is_enabled = 1234 + * $query->filterByIsEnabled(array(12, 34)); // WHERE is_enabled IN (12, 34) + * $query->filterByIsEnabled(array('min' => 12)); // WHERE is_enabled > 12 + * + * + * @param mixed $isEnabled The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByIsEnabled($isEnabled = null, $comparison = null) + { + if (is_array($isEnabled)) { + $useMinMax = false; + if (isset($isEnabled['min'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_ENABLED, $isEnabled['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isEnabled['max'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_ENABLED, $isEnabled['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::IS_ENABLED, $isEnabled, $comparison); + } + + /** + * Filter the query on the expiration_date column + * + * Example usage: + * + * $query->filterByExpirationDate('2011-03-14'); // WHERE expiration_date = '2011-03-14' + * $query->filterByExpirationDate('now'); // WHERE expiration_date = '2011-03-14' + * $query->filterByExpirationDate(array('max' => 'yesterday')); // WHERE expiration_date > '2011-03-13' + * + * + * @param mixed $expirationDate The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByExpirationDate($expirationDate = null, $comparison = null) + { + if (is_array($expirationDate)) { + $useMinMax = false; + if (isset($expirationDate['min'])) { + $this->addUsingAlias(CouponVersionTableMap::EXPIRATION_DATE, $expirationDate['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($expirationDate['max'])) { + $this->addUsingAlias(CouponVersionTableMap::EXPIRATION_DATE, $expirationDate['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::EXPIRATION_DATE, $expirationDate, $comparison); + } + + /** + * Filter the query on the serialized_rules column + * + * Example usage: + * + * $query->filterBySerializedRules('fooValue'); // WHERE serialized_rules = 'fooValue' + * $query->filterBySerializedRules('%fooValue%'); // WHERE serialized_rules LIKE '%fooValue%' + * + * + * @param string $serializedRules The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterBySerializedRules($serializedRules = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($serializedRules)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $serializedRules)) { + $serializedRules = str_replace('*', '%', $serializedRules); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::SERIALIZED_RULES, $serializedRules, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(CouponVersionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(CouponVersionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(CouponVersionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(CouponVersionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query on the version column + * + * Example usage: + * + * $query->filterByVersion(1234); // WHERE version = 1234 + * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * + * + * @param mixed $version The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByVersion($version = null, $comparison = null) + { + if (is_array($version)) { + $useMinMax = false; + if (isset($version['min'])) { + $this->addUsingAlias(CouponVersionTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($version['max'])) { + $this->addUsingAlias(CouponVersionTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::VERSION, $version, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Coupon object + * + * @param \Thelia\Model\Coupon|ObjectCollection $coupon The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByCoupon($coupon, $comparison = null) + { + if ($coupon instanceof \Thelia\Model\Coupon) { + return $this + ->addUsingAlias(CouponVersionTableMap::ID, $coupon->getId(), $comparison); + } elseif ($coupon instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CouponVersionTableMap::ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCoupon() only accepts arguments of type \Thelia\Model\Coupon or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Coupon relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function joinCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Coupon'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Coupon'); + } + + return $this; + } + + /** + * Use the Coupon relation Coupon object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CouponQuery A secondary query class using the current class as primary query + */ + public function useCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCoupon($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery'); + } + + /** + * Exclude object from result + * + * @param ChildCouponVersion $couponVersion Object to remove from the list of results + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function prune($couponVersion = null) + { + if ($couponVersion) { + $this->addCond('pruneCond0', $this->getAliasedColName(CouponVersionTableMap::ID), $couponVersion->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(CouponVersionTableMap::VERSION), $couponVersion->getVersion(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the coupon_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponVersionTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CouponVersionTableMap::clearInstancePool(); + CouponVersionTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCouponVersion or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCouponVersion object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponVersionTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CouponVersionTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + CouponVersionTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CouponVersionTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // CouponVersionQuery diff --git a/core/lib/Thelia/Model/Base/ProductAssociatedContent.php b/core/lib/Thelia/Model/Base/ProductAssociatedContent.php new file mode 100644 index 000000000..bbc97d5d1 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProductAssociatedContent.php @@ -0,0 +1,1553 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ProductAssociatedContent instance. If + * obj is an instance of ProductAssociatedContent, delegates to + * equals(ProductAssociatedContent). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ProductAssociatedContent The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ProductAssociatedContent The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [product_id] column value. + * + * @return int + */ + public function getProductId() + { + + return $this->product_id; + } + + /** + * Get the [content_id] column value. + * + * @return int + */ + public function getContentId() + { + + return $this->content_id; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ProductAssociatedContentTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [product_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + */ + public function setProductId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->product_id !== $v) { + $this->product_id = $v; + $this->modifiedColumns[] = ProductAssociatedContentTableMap::PRODUCT_ID; + } + + if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { + $this->aProduct = null; + } + + + return $this; + } // setProductId() + + /** + * Set the value of [content_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + */ + public function setContentId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->content_id !== $v) { + $this->content_id = $v; + $this->modifiedColumns[] = ProductAssociatedContentTableMap::CONTENT_ID; + } + + if ($this->aContent !== null && $this->aContent->getId() !== $v) { + $this->aContent = null; + } + + + return $this; + } // setContentId() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = ProductAssociatedContentTableMap::POSITION; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ProductAssociatedContentTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ProductAssociatedContentTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductAssociatedContentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductAssociatedContentTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductAssociatedContentTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->content_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductAssociatedContentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductAssociatedContentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductAssociatedContentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ProductAssociatedContentTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ProductAssociatedContent object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { + $this->aProduct = null; + } + if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { + $this->aContent = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildProductAssociatedContentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aProduct = null; + $this->aContent = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ProductAssociatedContent::setDeleted() + * @see ProductAssociatedContent::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildProductAssociatedContentQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ProductAssociatedContentTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ProductAssociatedContentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ProductAssociatedContentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ProductAssociatedContentTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aProduct !== null) { + if ($this->aProduct->isModified() || $this->aProduct->isNew()) { + $affectedRows += $this->aProduct->save($con); + } + $this->setProduct($this->aProduct); + } + + if ($this->aContent !== null) { + if ($this->aContent->isModified() || $this->aContent->isNew()) { + $affectedRows += $this->aContent->save($con); + } + $this->setContent($this->aContent); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = ProductAssociatedContentTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProductAssociatedContentTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ProductAssociatedContentTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ProductAssociatedContentTableMap::PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; + } + if ($this->isColumnModified(ProductAssociatedContentTableMap::CONTENT_ID)) { + $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; + } + if ($this->isColumnModified(ProductAssociatedContentTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(ProductAssociatedContentTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(ProductAssociatedContentTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO product_associated_content (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'PRODUCT_ID': + $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); + break; + case 'CONTENT_ID': + $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProductAssociatedContentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getProductId(); + break; + case 2: + return $this->getContentId(); + break; + case 3: + return $this->getPosition(); + break; + case 4: + return $this->getCreatedAt(); + break; + case 5: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ProductAssociatedContent'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ProductAssociatedContent'][$this->getPrimaryKey()] = true; + $keys = ProductAssociatedContentTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getProductId(), + $keys[2] => $this->getContentId(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aProduct) { + $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aContent) { + $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProductAssociatedContentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setProductId($value); + break; + case 2: + $this->setContentId($value); + break; + case 3: + $this->setPosition($value); + break; + case 4: + $this->setCreatedAt($value); + break; + case 5: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = ProductAssociatedContentTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setContentId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(ProductAssociatedContentTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ProductAssociatedContentTableMap::ID)) $criteria->add(ProductAssociatedContentTableMap::ID, $this->id); + if ($this->isColumnModified(ProductAssociatedContentTableMap::PRODUCT_ID)) $criteria->add(ProductAssociatedContentTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(ProductAssociatedContentTableMap::CONTENT_ID)) $criteria->add(ProductAssociatedContentTableMap::CONTENT_ID, $this->content_id); + if ($this->isColumnModified(ProductAssociatedContentTableMap::POSITION)) $criteria->add(ProductAssociatedContentTableMap::POSITION, $this->position); + if ($this->isColumnModified(ProductAssociatedContentTableMap::CREATED_AT)) $criteria->add(ProductAssociatedContentTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ProductAssociatedContentTableMap::UPDATED_AT)) $criteria->add(ProductAssociatedContentTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(ProductAssociatedContentTableMap::DATABASE_NAME); + $criteria->add(ProductAssociatedContentTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\ProductAssociatedContent (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setProductId($this->getProductId()); + $copyObj->setContentId($this->getContentId()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\ProductAssociatedContent Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildProduct object. + * + * @param ChildProduct $v + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + * @throws PropelException + */ + public function setProduct(ChildProduct $v = null) + { + if ($v === null) { + $this->setProductId(NULL); + } else { + $this->setProductId($v->getId()); + } + + $this->aProduct = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildProduct object, it will not be re-added. + if ($v !== null) { + $v->addProductAssociatedContent($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. + * @throws PropelException + */ + public function getProduct(ConnectionInterface $con = null) + { + if ($this->aProduct === null && ($this->product_id !== null)) { + $this->aProduct = ChildProductQuery::create()->findPk($this->product_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aProduct->addProductAssociatedContents($this); + */ + } + + return $this->aProduct; + } + + /** + * Declares an association between this object and a ChildContent object. + * + * @param ChildContent $v + * @return \Thelia\Model\ProductAssociatedContent The current object (for fluent API support) + * @throws PropelException + */ + public function setContent(ChildContent $v = null) + { + if ($v === null) { + $this->setContentId(NULL); + } else { + $this->setContentId($v->getId()); + } + + $this->aContent = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildContent object, it will not be re-added. + if ($v !== null) { + $v->addProductAssociatedContent($this); + } + + + return $this; + } + + + /** + * Get the associated ChildContent object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContent The associated ChildContent object. + * @throws PropelException + */ + public function getContent(ConnectionInterface $con = null) + { + if ($this->aContent === null && ($this->content_id !== null)) { + $this->aContent = ChildContentQuery::create()->findPk($this->content_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aContent->addProductAssociatedContents($this); + */ + } + + return $this->aContent; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->product_id = null; + $this->content_id = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aProduct = null; + $this->aContent = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ProductAssociatedContentTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildProductAssociatedContent The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ProductAssociatedContentTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ProductAssociatedContentQuery.php b/core/lib/Thelia/Model/Base/ProductAssociatedContentQuery.php new file mode 100644 index 000000000..d387f40ed --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProductAssociatedContentQuery.php @@ -0,0 +1,804 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProductAssociatedContent|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ProductAssociatedContentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProductAssociatedContent A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, PRODUCT_ID, CONTENT_ID, POSITION, CREATED_AT, UPDATED_AT FROM product_associated_content WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildProductAssociatedContent(); + $obj->hydrate($row); + ProductAssociatedContentTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProductAssociatedContent|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(ProductAssociatedContentTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(ProductAssociatedContentTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductAssociatedContentTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the product_id column + * + * Example usage: + * + * $query->filterByProductId(1234); // WHERE product_id = 1234 + * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) + * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 + * + * + * @see filterByProduct() + * + * @param mixed $productId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByProductId($productId = null, $comparison = null) + { + if (is_array($productId)) { + $useMinMax = false; + if (isset($productId['min'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($productId['max'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductAssociatedContentTableMap::PRODUCT_ID, $productId, $comparison); + } + + /** + * Filter the query on the content_id column + * + * Example usage: + * + * $query->filterByContentId(1234); // WHERE content_id = 1234 + * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) + * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 + * + * + * @see filterByContent() + * + * @param mixed $contentId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByContentId($contentId = null, $comparison = null) + { + if (is_array($contentId)) { + $useMinMax = false; + if (isset($contentId['min'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($contentId['max'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductAssociatedContentTableMap::CONTENT_ID, $contentId, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductAssociatedContentTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductAssociatedContentTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(ProductAssociatedContentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductAssociatedContentTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Product object + * + * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByProduct($product, $comparison = null) + { + if ($product instanceof \Thelia\Model\Product) { + return $this + ->addUsingAlias(ProductAssociatedContentTableMap::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ProductAssociatedContentTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Product relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Product'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Product'); + } + + return $this; + } + + /** + * Use the Product relation Product object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query + */ + public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProduct($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Content object + * + * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function filterByContent($content, $comparison = null) + { + if ($content instanceof \Thelia\Model\Content) { + return $this + ->addUsingAlias(ProductAssociatedContentTableMap::CONTENT_ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ProductAssociatedContentTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Content relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Content'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Content'); + } + + return $this; + } + + /** + * Use the Content relation Content object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query + */ + public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); + } + + /** + * Exclude object from result + * + * @param ChildProductAssociatedContent $productAssociatedContent Object to remove from the list of results + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function prune($productAssociatedContent = null) + { + if ($productAssociatedContent) { + $this->addUsingAlias(ProductAssociatedContentTableMap::ID, $productAssociatedContent->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the product_associated_content table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ProductAssociatedContentTableMap::clearInstancePool(); + ProductAssociatedContentTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildProductAssociatedContent or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildProductAssociatedContent object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ProductAssociatedContentTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ProductAssociatedContentTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ProductAssociatedContentTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ProductAssociatedContentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ProductAssociatedContentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ProductAssociatedContentTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ProductAssociatedContentTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ProductAssociatedContentTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildProductAssociatedContentQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ProductAssociatedContentTableMap::CREATED_AT); + } + +} // ProductAssociatedContentQuery diff --git a/core/lib/Thelia/Model/CategoryAssociatedContent.php b/core/lib/Thelia/Model/CategoryAssociatedContent.php new file mode 100644 index 000000000..9296e6274 --- /dev/null +++ b/core/lib/Thelia/Model/CategoryAssociatedContent.php @@ -0,0 +1,9 @@ + array('Id', 'CategoryId', 'ContentId', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'categoryId', 'contentId', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CategoryAssociatedContentTableMap::ID, CategoryAssociatedContentTableMap::CATEGORY_ID, CategoryAssociatedContentTableMap::CONTENT_ID, CategoryAssociatedContentTableMap::POSITION, CategoryAssociatedContentTableMap::CREATED_AT, CategoryAssociatedContentTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CATEGORY_ID', 'CONTENT_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'category_id', 'content_id', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'CategoryId' => 1, 'ContentId' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'categoryId' => 1, 'contentId' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(CategoryAssociatedContentTableMap::ID => 0, CategoryAssociatedContentTableMap::CATEGORY_ID => 1, CategoryAssociatedContentTableMap::CONTENT_ID => 2, CategoryAssociatedContentTableMap::POSITION => 3, CategoryAssociatedContentTableMap::CREATED_AT => 4, CategoryAssociatedContentTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CATEGORY_ID' => 1, 'CONTENT_ID' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'category_id' => 1, 'content_id' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('category_associated_content'); + $this->setPhpName('CategoryAssociatedContent'); + $this->setClassName('\\Thelia\\Model\\CategoryAssociatedContent'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null); + $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CategoryAssociatedContentTableMap::CLASS_DEFAULT : CategoryAssociatedContentTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (CategoryAssociatedContent object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CategoryAssociatedContentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CategoryAssociatedContentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CategoryAssociatedContentTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CategoryAssociatedContentTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CategoryAssociatedContentTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CategoryAssociatedContentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CategoryAssociatedContentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + CategoryAssociatedContentTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(CategoryAssociatedContentTableMap::ID); + $criteria->addSelectColumn(CategoryAssociatedContentTableMap::CATEGORY_ID); + $criteria->addSelectColumn(CategoryAssociatedContentTableMap::CONTENT_ID); + $criteria->addSelectColumn(CategoryAssociatedContentTableMap::POSITION); + $criteria->addSelectColumn(CategoryAssociatedContentTableMap::CREATED_AT); + $criteria->addSelectColumn(CategoryAssociatedContentTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.CATEGORY_ID'); + $criteria->addSelectColumn($alias . '.CONTENT_ID'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(CategoryAssociatedContentTableMap::DATABASE_NAME)->getTable(CategoryAssociatedContentTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CategoryAssociatedContentTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CategoryAssociatedContentTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CategoryAssociatedContentTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a CategoryAssociatedContent or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CategoryAssociatedContent object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CategoryAssociatedContent) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CategoryAssociatedContentTableMap::DATABASE_NAME); + $criteria->add(CategoryAssociatedContentTableMap::ID, (array) $values, Criteria::IN); + } + + $query = CategoryAssociatedContentQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CategoryAssociatedContentTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CategoryAssociatedContentTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the category_associated_content table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CategoryAssociatedContentQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CategoryAssociatedContent or Criteria object. + * + * @param mixed $criteria Criteria or CategoryAssociatedContent object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryAssociatedContentTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CategoryAssociatedContent object + } + + if ($criteria->containsKey(CategoryAssociatedContentTableMap::ID) && $criteria->keyContainsValue(CategoryAssociatedContentTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CategoryAssociatedContentTableMap::ID.')'); + } + + + // Set the correct dbName + $query = CategoryAssociatedContentQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CategoryAssociatedContentTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CategoryAssociatedContentTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CouponI18nTableMap.php b/core/lib/Thelia/Model/Map/CouponI18nTableMap.php new file mode 100644 index 000000000..99d49216c --- /dev/null +++ b/core/lib/Thelia/Model/Map/CouponI18nTableMap.php @@ -0,0 +1,465 @@ + array('Id', 'Locale', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', ), + self::TYPE_COLNAME => array(CouponI18nTableMap::ID, CouponI18nTableMap::LOCALE, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', ), + self::TYPE_FIELDNAME => array('id', 'locale', ), + self::TYPE_NUM => array(0, 1, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, ), + self::TYPE_COLNAME => array(CouponI18nTableMap::ID => 0, CouponI18nTableMap::LOCALE => 1, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, ), + self::TYPE_NUM => array(0, 1, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('coupon_i18n'); + $this->setPhpName('CouponI18n'); + $this->setClassName('\\Thelia\\Model\\CouponI18n'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'coupon', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Coupon', '\\Thelia\\Model\\Coupon', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\CouponI18n $obj A \Thelia\Model\CouponI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\CouponI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\CouponI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CouponI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CouponI18nTableMap::CLASS_DEFAULT : CouponI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (CouponI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CouponI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CouponI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CouponI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CouponI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CouponI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CouponI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CouponI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + CouponI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(CouponI18nTableMap::ID); + $criteria->addSelectColumn(CouponI18nTableMap::LOCALE); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(CouponI18nTableMap::DATABASE_NAME)->getTable(CouponI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CouponI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CouponI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a CouponI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CouponI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CouponI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CouponI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(CouponI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(CouponI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = CouponI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CouponI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CouponI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the coupon_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CouponI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CouponI18n or Criteria object. + * + * @param mixed $criteria Criteria or CouponI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CouponI18n object + } + + + // Set the correct dbName + $query = CouponI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CouponI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CouponI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CouponVersionTableMap.php b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php new file mode 100644 index 000000000..6ce67d3f1 --- /dev/null +++ b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php @@ -0,0 +1,561 @@ + array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Value', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'CreatedAt', 'UpdatedAt', 'Version', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'value', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'createdAt', 'updatedAt', 'version', ), + self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::TITLE, CouponVersionTableMap::SHORT_DESCRIPTION, CouponVersionTableMap::DESCRIPTION, CouponVersionTableMap::VALUE, CouponVersionTableMap::IS_USED, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::SERIALIZED_RULES, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'VALUE', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), + self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'value', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'created_at', 'updated_at', 'version', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Value' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRules' => 10, 'CreatedAt' => 11, 'UpdatedAt' => 12, 'Version' => 13, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'value' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRules' => 10, 'createdAt' => 11, 'updatedAt' => 12, 'version' => 13, ), + self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::TITLE => 3, CouponVersionTableMap::SHORT_DESCRIPTION => 4, CouponVersionTableMap::DESCRIPTION => 5, CouponVersionTableMap::VALUE => 6, CouponVersionTableMap::IS_USED => 7, CouponVersionTableMap::IS_ENABLED => 8, CouponVersionTableMap::EXPIRATION_DATE => 9, CouponVersionTableMap::SERIALIZED_RULES => 10, CouponVersionTableMap::CREATED_AT => 11, CouponVersionTableMap::UPDATED_AT => 12, CouponVersionTableMap::VERSION => 13, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'VALUE' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES' => 10, 'CREATED_AT' => 11, 'UPDATED_AT' => 12, 'VERSION' => 13, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'value' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules' => 10, 'created_at' => 11, 'updated_at' => 12, 'version' => 13, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('coupon_version'); + $this->setPhpName('CouponVersion'); + $this->setClassName('\\Thelia\\Model\\CouponVersion'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'coupon', 'ID', true, null, null); + $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); + $this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null); + $this->addColumn('TITLE', 'Title', 'VARCHAR', true, 255, null); + $this->addColumn('SHORT_DESCRIPTION', 'ShortDescription', 'LONGVARCHAR', true, null, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', true, null, null); + $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null); + $this->addColumn('IS_USED', 'IsUsed', 'TINYINT', true, null, null); + $this->addColumn('IS_ENABLED', 'IsEnabled', 'TINYINT', true, null, null); + $this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null); + $this->addColumn('SERIALIZED_RULES', 'SerializedRules', 'LONGVARCHAR', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Coupon', '\\Thelia\\Model\\Coupon', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\CouponVersion $obj A \Thelia\Model\CouponVersion object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\CouponVersion object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\CouponVersion) { + $key = serialize(array((string) $value->getId(), (string) $value->getVersion())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CouponVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 13 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 13 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CouponVersionTableMap::CLASS_DEFAULT : CouponVersionTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (CouponVersion object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CouponVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CouponVersionTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CouponVersionTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CouponVersionTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CouponVersionTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CouponVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CouponVersionTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + CouponVersionTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(CouponVersionTableMap::ID); + $criteria->addSelectColumn(CouponVersionTableMap::CODE); + $criteria->addSelectColumn(CouponVersionTableMap::TYPE); + $criteria->addSelectColumn(CouponVersionTableMap::TITLE); + $criteria->addSelectColumn(CouponVersionTableMap::SHORT_DESCRIPTION); + $criteria->addSelectColumn(CouponVersionTableMap::DESCRIPTION); + $criteria->addSelectColumn(CouponVersionTableMap::VALUE); + $criteria->addSelectColumn(CouponVersionTableMap::IS_USED); + $criteria->addSelectColumn(CouponVersionTableMap::IS_ENABLED); + $criteria->addSelectColumn(CouponVersionTableMap::EXPIRATION_DATE); + $criteria->addSelectColumn(CouponVersionTableMap::SERIALIZED_RULES); + $criteria->addSelectColumn(CouponVersionTableMap::CREATED_AT); + $criteria->addSelectColumn(CouponVersionTableMap::UPDATED_AT); + $criteria->addSelectColumn(CouponVersionTableMap::VERSION); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.CODE'); + $criteria->addSelectColumn($alias . '.TYPE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.SHORT_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.VALUE'); + $criteria->addSelectColumn($alias . '.IS_USED'); + $criteria->addSelectColumn($alias . '.IS_ENABLED'); + $criteria->addSelectColumn($alias . '.EXPIRATION_DATE'); + $criteria->addSelectColumn($alias . '.SERIALIZED_RULES'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.VERSION'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(CouponVersionTableMap::DATABASE_NAME)->getTable(CouponVersionTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponVersionTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CouponVersionTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CouponVersionTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a CouponVersion or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CouponVersion object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponVersionTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CouponVersion) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CouponVersionTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(CouponVersionTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(CouponVersionTableMap::VERSION, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = CouponVersionQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CouponVersionTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CouponVersionTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the coupon_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CouponVersionQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CouponVersion or Criteria object. + * + * @param mixed $criteria Criteria or CouponVersion object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponVersionTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CouponVersion object + } + + + // Set the correct dbName + $query = CouponVersionQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CouponVersionTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CouponVersionTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProductAssociatedContentTableMap.php b/core/lib/Thelia/Model/Map/ProductAssociatedContentTableMap.php new file mode 100644 index 000000000..d4d1dadb8 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ProductAssociatedContentTableMap.php @@ -0,0 +1,456 @@ + array('Id', 'ProductId', 'ContentId', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'contentId', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProductAssociatedContentTableMap::ID, ProductAssociatedContentTableMap::PRODUCT_ID, ProductAssociatedContentTableMap::CONTENT_ID, ProductAssociatedContentTableMap::POSITION, ProductAssociatedContentTableMap::CREATED_AT, ProductAssociatedContentTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'CONTENT_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'content_id', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'ContentId' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'contentId' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(ProductAssociatedContentTableMap::ID => 0, ProductAssociatedContentTableMap::PRODUCT_ID => 1, ProductAssociatedContentTableMap::CONTENT_ID => 2, ProductAssociatedContentTableMap::POSITION => 3, ProductAssociatedContentTableMap::CREATED_AT => 4, ProductAssociatedContentTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'CONTENT_ID' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'content_id' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('product_associated_content'); + $this->setPhpName('ProductAssociatedContent'); + $this->setClassName('\\Thelia\\Model\\ProductAssociatedContent'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); + $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ProductAssociatedContentTableMap::CLASS_DEFAULT : ProductAssociatedContentTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (ProductAssociatedContent object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ProductAssociatedContentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProductAssociatedContentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ProductAssociatedContentTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ProductAssociatedContentTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ProductAssociatedContentTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ProductAssociatedContentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProductAssociatedContentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + ProductAssociatedContentTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(ProductAssociatedContentTableMap::ID); + $criteria->addSelectColumn(ProductAssociatedContentTableMap::PRODUCT_ID); + $criteria->addSelectColumn(ProductAssociatedContentTableMap::CONTENT_ID); + $criteria->addSelectColumn(ProductAssociatedContentTableMap::POSITION); + $criteria->addSelectColumn(ProductAssociatedContentTableMap::CREATED_AT); + $criteria->addSelectColumn(ProductAssociatedContentTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.PRODUCT_ID'); + $criteria->addSelectColumn($alias . '.CONTENT_ID'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(ProductAssociatedContentTableMap::DATABASE_NAME)->getTable(ProductAssociatedContentTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductAssociatedContentTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProductAssociatedContentTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProductAssociatedContentTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a ProductAssociatedContent or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ProductAssociatedContent object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ProductAssociatedContent) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ProductAssociatedContentTableMap::DATABASE_NAME); + $criteria->add(ProductAssociatedContentTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ProductAssociatedContentQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ProductAssociatedContentTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ProductAssociatedContentTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the product_associated_content table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ProductAssociatedContentQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ProductAssociatedContent or Criteria object. + * + * @param mixed $criteria Criteria or ProductAssociatedContent object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductAssociatedContentTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ProductAssociatedContent object + } + + if ($criteria->containsKey(ProductAssociatedContentTableMap::ID) && $criteria->keyContainsValue(ProductAssociatedContentTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProductAssociatedContentTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ProductAssociatedContentQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ProductAssociatedContentTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ProductAssociatedContentTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/ProductAssociatedContent.php b/core/lib/Thelia/Model/ProductAssociatedContent.php new file mode 100644 index 000000000..9b007baf1 --- /dev/null +++ b/core/lib/Thelia/Model/ProductAssociatedContent.php @@ -0,0 +1,9 @@ +filterByCode('EUR')->findOne( try { $stmt = $con->prepare("SET foreign_key_checks = 0"); $stmt->execute(); - + + $productAssociatedContent = Thelia\Model\ProductAssociatedContentQuery::create() + ->find(); + $productAssociatedContent->delete(); + + $categoryAssociatedContent = Thelia\Model\CategoryAssociatedContentQuery::create() + ->find(); + $categoryAssociatedContent->delete(); + $attributeCategory = Thelia\Model\AttributeCategoryQuery::create() ->find(); $attributeCategory->delete(); @@ -183,14 +191,60 @@ try { } } + //folders and contents + $contentIdList = array(); + for($i=0; $i<4; $i++) { + $folder = new Thelia\Model\Folder(); + $folder->setParent(0); + $folder->setVisible(rand(1, 10)>7 ? 0 : 1); + $folder->setPosition($i); + setI18n($faker, $folder); + + $folder->save(); + + $image = new FolderImage(); + $image->setFolderId($folder->getId()); + generate_image($image, 1, 'folder', $folder->getId()); + + for($j=1; $jsetParent($folder->getId()); + $subfolder->setVisible(rand(1, 10)>7 ? 0 : 1); + $subfolder->setPosition($j); + setI18n($faker, $subfolder); + + $subfolder->save(); + + $image = new FolderImage(); + $image->setFolderId($subfolder->getId()); + generate_image($image, 1, 'folder', $subfolder->getId()); + + for($k=0; $kaddFolder($subfolder); + $content->setVisible(rand(1, 10)>7 ? 0 : 1); + $content->setPosition($k); + setI18n($faker, $content); + + $content->save(); + $contentId = $content->getId(); + $contentIdList[] = $contentId; + + $image = new ContentImage(); + $image->setContentId($content->getId()); + generate_image($image, 1, 'content', $contentId); + } + } + } + //categories and products $productIdList = array(); $categoryIdList = array(); for($i=0; $i<4; $i++) { - $category = createCategory($faker, 0, $i, $categoryIdList); + $category = createCategory($faker, 0, $i, $categoryIdList, $contentIdList); for($j=1; $jgetId(), $j, $categoryIdList); + $subcategory = createCategory($faker, $category->getId(), $j, $categoryIdList, $contentIdList); for($k=0; $ksave(); } + //add random associated content + $alreadyPicked = array(); + for($i=1; $isetContentId($contentIdList[$pick]) + ->setProductId($productId) + ->setPosition($i) + ->save(); + } + //associate PSE and stocks to products for($i=0; $i $attributeAvId) { - - } - //associate features to products foreach($featureList as $featureId => $featureAvId) { $featureProduct = new Thelia\Model\FeatureProduct(); @@ -293,49 +358,6 @@ try { } } - //folders and contents - for($i=0; $i<4; $i++) { - $folder = new Thelia\Model\Folder(); - $folder->setParent(0); - $folder->setVisible(rand(1, 10)>7 ? 0 : 1); - $folder->setPosition($i); - setI18n($faker, $folder); - - $folder->save(); - - $image = new FolderImage(); - $image->setFolderId($folder->getId()); - generate_image($image, 1, 'folder', $folder->getId()); - - for($j=1; $jsetParent($folder->getId()); - $subfolder->setVisible(rand(1, 10)>7 ? 0 : 1); - $subfolder->setPosition($j); - setI18n($faker, $subfolder); - - $subfolder->save(); - - $image = new FolderImage(); - $image->setFolderId($subfolder->getId()); - generate_image($image, 1, 'folder', $subfolder->getId()); - - for($k=0; $kaddFolder($subfolder); - $content->setVisible(rand(1, 10)>7 ? 0 : 1); - $content->setPosition($k); - setI18n($faker, $content); - - $content->save(); - - $image = new ContentImage(); - $image->setContentId($content->getId()); - generate_image($image, 1, 'content', $content->getId()); - } - } - } - $con->commit(); } catch (Exception $e) { echo "error : ".$e->getMessage()."\n"; @@ -362,7 +384,7 @@ function createProduct($faker, $category, $position, &$productIdList) return $product; } -function createCategory($faker, $parent, $position, &$categoryIdList) +function createCategory($faker, $parent, $position, &$categoryIdList, $contentIdList) { $category = new Thelia\Model\Category(); $category->setParent($parent); @@ -371,12 +393,28 @@ function createCategory($faker, $parent, $position, &$categoryIdList) setI18n($faker, $category); $category->save(); - $cateogoryId = $category->getId(); - $categoryIdList[] = $cateogoryId; + $categoryId = $category->getId(); + $categoryIdList[] = $categoryId; + + //add random associated content + $alreadyPicked = array(); + for($i=1; $isetContentId($contentIdList[$pick]) + ->setCategoryId($categoryId) + ->setPosition($i) + ->save(); + } $image = new CategoryImage(); - $image->setCategoryId($cateogoryId); - generate_image($image, 1, 'category', $cateogoryId); + $image->setCategoryId($categoryId); + generate_image($image, 1, 'category', $categoryId); return $category; } diff --git a/install/sqldb.map b/install/sqldb.map new file mode 100644 index 000000000..63a93baa8 --- /dev/null +++ b/install/sqldb.map @@ -0,0 +1,2 @@ +# Sqlfile -> Database map +thelia.sql=thelia diff --git a/templates/default/category.html b/templates/default/category.html index 2f14976f9..149238bef 100755 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -7,11 +7,25 @@ {loop name="category0" type="category" parent="0" order="manual"}

    CATEGORY : #TITLE (#LOOP_COUNT / #LOOP_TOTAL)

    + + {ifloop rel="prod_ass_cont"} +
    Associated Content
    +
      + {loop name="prod_ass_cont" type="associated_content" category="#ID" order="associated_content"} +
    • #TITLE
    • + {/loop} +
    + {/ifloop} + {elseloop rel="prod_ass_cont"} +
    No associated content
    + {/elseloop} + {loop name="product" type="product" category="#ID"}

    PRODUCT : #REF (#LOOP_COUNT / #LOOP_TOTAL)

    #TITLE

    #DESCRIPTION

    + {ifloop rel="acc"}
    Accessories
      @@ -23,6 +37,19 @@ {elseloop rel="acc"}
      No accessory
      {/elseloop} + + {ifloop rel="prod_ass_cont"} +
      Associated Content
      +
        + {loop name="prod_ass_cont" type="associated_content" product="#ID" order="associated_content"} +
      • #TITLE
      • + {/loop} +
      + {/ifloop} + {elseloop rel="prod_ass_cont"} +
      No associated content
      + {/elseloop} + {ifloop rel="ft"}
      Features
        @@ -40,7 +67,7 @@ {elseloop rel="ft"}
        No feature
        {/elseloop} - {ifloop rel="pse"} +
        Product sale elements
        {assign var=current_product value=#ID} @@ -62,20 +89,32 @@
    {/loop} - {/ifloop} - {elseloop rel="ft"} -
    No feature
    - {/elseloop} +
    {/loop} {loop name="catgory1" type="category" parent="#ID"}

    SUBCATEGORY : #TITLE (#LOOP_COUNT / #LOOP_TOTAL)

    + + {ifloop rel="prod_ass_cont"} +
    Associated Content
    +
      + {loop name="prod_ass_cont" type="associated_content" category="#ID" order="associated_content"} +
    • #TITLE
    • + {/loop} +
    + {/ifloop} + {elseloop rel="prod_ass_cont"} +
    No associated content
    + {/elseloop} + {loop name="product" type="product" category="#ID"} +

    PRODUCT : #REF (#LOOP_COUNT / #LOOP_TOTAL)

    #TITLE

    #DESCRIPTION

    + {ifloop rel="acc"}
    Accessories
      @@ -87,6 +126,19 @@ {elseloop rel="acc"}
      No accessory
      {/elseloop} + + {ifloop rel="prod_ass_cont"} +
      Associated Content
      +
        + {loop name="prod_ass_cont" type="associated_content" product="#ID" order="associated_content"} +
      • #TITLE
      • + {/loop} +
      + {/ifloop} + {elseloop rel="prod_ass_cont"} +
      No associated content
      + {/elseloop} + {ifloop rel="ft"}
      Features
        @@ -103,6 +155,29 @@ {elseloop rel="ft"}
        No feature
        {/elseloop} + +
        Product sale elements
        + + {assign var=current_product value=#ID} + {loop name="pse" type="product_sale_elements" product="#ID"} +
        + {loop name="combi" type="attribute_combination" product_sale_element="#ID"} + #ATTRIBUTE_TITLE = #ATTRIBUTE_AVAILABILITY_TITLE
        + {/loop} +
        #WEIGHT g +
        {if #IS_PROMO == 1} #PROMO_PRICE € (instead of #PRICE) {else} #PRICE € {/if} +

        + Add + + to my cart +
      +
    + {/loop} +
    {/loop} From 27f6612c3279fd7428af9127eeaf4ac0d69d8334 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 23 Aug 2013 10:58:10 +0200 Subject: [PATCH 026/268] associated content loop test --- .../Template/Loop/AssociatedContentTest.php | 51 +++++++++++++++++++ install/sqldb.map | 2 - 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100755 core/lib/Thelia/Tests/Core/Template/Loop/AssociatedContentTest.php delete mode 100644 install/sqldb.map diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/AssociatedContentTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/AssociatedContentTest.php new file mode 100755 index 000000000..0a12ad076 --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/AssociatedContentTest.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\AssociatedContent; + +/** + * + * @author Etienne Roudeix + * + */ +class AssociatedContentTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\AssociatedContent'; + } + + public function getTestedInstance() + { + return new AssociatedContent($this->request, $this->dispatcher, $this->securityContext); + } + + public function getMandatoryArguments() + { + return array('product' => 1); + } +} diff --git a/install/sqldb.map b/install/sqldb.map deleted file mode 100644 index 63a93baa8..000000000 --- a/install/sqldb.map +++ /dev/null @@ -1,2 +0,0 @@ -# Sqlfile -> Database map -thelia.sql=thelia From 2d810540ecd2734822d4ba564ddc4d905fba9867 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 23 Aug 2013 12:37:18 +0200 Subject: [PATCH 027/268] loop review --- .../Core/Template/Loop/AssociatedContent.php | 3 +- .../Template/Loop/AttributeCombination.php | 6 +-- .../Core/Template/Loop/FeatureValue.php | 4 +- .../Core/Template/Loop/ProductSaleElement.php | 6 +-- templates/default/category.html | 41 ++----------------- 5 files changed, 14 insertions(+), 46 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php index 70d34b01a..5c73d0602 100755 --- a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php +++ b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php @@ -67,7 +67,8 @@ class AssociatedContent extends Content /** * @param $pagination * - * @return \Thelia\Core\Template\Element\LoopResult + * @return LoopResult + * @throws \InvalidArgumentException */ public function exec(&$pagination) { diff --git a/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php b/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php index e6cc804da..42df69ea3 100755 --- a/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php +++ b/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php @@ -58,7 +58,7 @@ class AttributeCombination extends BaseLoop protected function getArgDefinitions() { return new ArgumentCollection( - Argument::createIntTypeArgument('product_sale_element', null, true), + Argument::createIntTypeArgument('product_sale_elements', null, true), new Argument( 'order', new TypeCollection( @@ -98,9 +98,9 @@ class AttributeCombination extends BaseLoop 'ATTRIBUTE_AV_ID' ); - $productSaleElement = $this->getProduct_sale_element(); + $productSaleElements = $this->getProduct_sale_elements(); - $search->filterByProductSaleElementsId($productSaleElement, Criteria::EQUAL); + $search->filterByProductSaleElementsId($productSaleElements, Criteria::EQUAL); $orders = $this->getOrder(); diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php index 358b8d339..71070e25f 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php @@ -63,7 +63,7 @@ class FeatureValue extends BaseLoop Argument::createIntTypeArgument('product', null, true), Argument::createIntListTypeArgument('feature_availability'), Argument::createBooleanTypeArgument('exclude_feature_availability', 0), - Argument::createBooleanTypeArgument('exclude_default_values', 0), + Argument::createBooleanTypeArgument('exclude_personal_values', 0), new Argument( 'order', new TypeCollection( @@ -112,7 +112,7 @@ class FeatureValue extends BaseLoop $search->filterByFeatureAvId(null, Criteria::NULL); } - $excludeDefaultValues = $this->getExclude_default_values(); + $excludeDefaultValues = $this->getExclude_personal_values(); if($excludeDefaultValues == true) { $search->filterByByDefault(null, Criteria::NULL); } diff --git a/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php b/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php index 1db2bcda2..ec7cbc37f 100755 --- a/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php +++ b/core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php @@ -42,7 +42,7 @@ use Thelia\Type; * * Product Sale Elements loop * - * @todo : manage currency + * @todo : manage currency and attribute_availability * * Class ProductSaleElements * @package Thelia\Core\Template\Loop @@ -56,7 +56,7 @@ class ProductSaleElements extends BaseLoop protected function getArgDefinitions() { return new ArgumentCollection( - Argument::createIntTypeArgument('devise'), + Argument::createIntTypeArgument('currency'), Argument::createIntTypeArgument('product', null, true), new Argument( 'attribute_availability', @@ -106,7 +106,7 @@ class ProductSaleElements extends BaseLoop } } - $devise = $this->getDevise(); + $currency = $this->getCurrency(); $search->joinProductPrice('price', Criteria::INNER_JOIN); //->addJoinCondition('price', ''); diff --git a/templates/default/category.html b/templates/default/category.html index 149238bef..8b52f0afc 100755 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -1,6 +1,6 @@

    Category page

    -
    +

    CATALOG

    @@ -73,7 +73,7 @@ {assign var=current_product value=#ID} {loop name="pse" type="product_sale_elements" product="#ID"}
    - {loop name="combi" type="attribute_combination" product_sale_element="#ID"} + {loop name="combi" type="attribute_combination" product_sale_elements="#ID"} #ATTRIBUTE_TITLE = #ATTRIBUTE_AVAILABILITY_TITLE
    {/loop}
    #WEIGHT g @@ -161,7 +161,7 @@ {assign var=current_product value=#ID} {loop name="pse" type="product_sale_elements" product="#ID"}
    - {loop name="combi" type="attribute_combination" product_sale_element="#ID"} + {loop name="combi" type="attribute_combination" product_sale_elements="#ID"} #ATTRIBUTE_TITLE = #ATTRIBUTE_AVAILABILITY_TITLE
    {/loop}
    #WEIGHT g @@ -187,7 +187,7 @@
    -
    +

    ALL FEATURES AND THEIR AVAILABILITY

    @@ -221,37 +221,4 @@ {/loop} -
    - -
    - -

    SANDBOX

    - - {*loop name="product" type="product" order="promo,min_price" exclude_category="3" new="on" promo="off"} -

    PRODUCT : #REF / #TITLE

    - {/loop*} - -{*loop name="product" type="product" new="on" promo="off"} -

    PRODUCT : #REF / #TITLE

    -{/loop*} - - - - {*loop name="product" type="product" order="ref" feature_availability="1: (1 | 2) , 2: 4, 3: 433"} -

    PRODUCT : #REF / #TITLE

    - price : #PRICE €
    - promo price : #PROMO_PRICE €
    - is promo : #PROMO
    - is new : #NEW
    - weight : #WEIGHT
    - {/loop*} - - {*loop name="product" type="product" order="ref" feature_values="1: foo"} -

    PRODUCT : #REF / #TITLE

    - price : #PRICE €
    - promo price : #PROMO_PRICE €
    - is promo : #PROMO
    - is new : #NEW
    - weight : #WEIGHT
    - {/loop*}
    \ No newline at end of file From 3005a65463b48d443702a656f28ebe8c2e2f5c94 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 23 Aug 2013 12:38:52 +0200 Subject: [PATCH 028/268] loop test fix --- .../Tests/Core/Template/Loop/AttributeCombinationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/AttributeCombinationTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/AttributeCombinationTest.php index 208899bab..98d0575eb 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/AttributeCombinationTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/AttributeCombinationTest.php @@ -46,6 +46,6 @@ class AttributeCombinationTest extends BaseLoopTestor public function getMandatoryArguments() { - return array('product_sale_element' => 1); + return array('product_sale_elements' => 1); } } From eae86cd797dfd1fa8f5054a26a27f0640f50efee Mon Sep 17 00:00:00 2001 From: gmorel Date: Fri, 23 Aug 2013 20:00:32 +0200 Subject: [PATCH 029/268] WIP Coupon Refactor --- .../Thelia/Coupon/CouponAdapterInterface.php | 21 ++ core/lib/Thelia/Coupon/CouponBaseAdapter.php | 48 ++- core/lib/Thelia/Coupon/CouponFactory.php | 65 ++-- core/lib/Thelia/Coupon/CouponManager.php | 33 +- .../Thelia/Coupon/CouponRuleCollection.php | 88 ++++++ .../Thelia/Coupon/Rule/AvailableForDate.php | 29 +- .../Coupon/Rule/AvailableForLocationX.php | 27 +- .../Thelia/Coupon/Rule/AvailableForPeriod.php | 25 +- .../Coupon/Rule/AvailableForRepeatedDate.php | 25 +- .../Rule/AvailableForRepeatedPeriod.php | 35 ++- .../Coupon/Rule/AvailableForTotalAmount.php | 3 +- .../AvailableForTotalAmountForCategoryY.php | 26 -- .../Coupon/Rule/AvailableForXArticles.php | 27 +- .../Coupon/Rule/CouponRuleInterface.php | 2 - .../lib/Thelia/Coupon/Type/CouponAbstract.php | 99 ++++-- .../Thelia/Coupon/Type/CouponInterface.php | 44 ++- core/lib/Thelia/Coupon/Type/RemoveXAmount.php | 26 +- .../Exception/CouponExpiredException.php | 53 ++++ .../Thelia/Exception/InvalidRuleException.php | 4 +- .../InvalidRuleOperatorException.php | 3 +- .../Exception/InvalidRuleValueException.php | 3 +- core/lib/Thelia/Model/Base/Coupon.php | 284 ++++++++++------- core/lib/Thelia/Model/Base/CouponQuery.php | 137 +++++--- core/lib/Thelia/Model/Base/CouponVersion.php | 274 ++++++++++------ .../Thelia/Model/Base/CouponVersionQuery.php | 137 +++++--- core/lib/Thelia/Model/Map/CouponTableMap.php | 62 ++-- .../Model/Map/CouponVersionTableMap.php | 66 ++-- .../Tests/Coupon/CouponBaseAdapterTest.php | 2 +- .../Thelia/Tests/Coupon/CouponFactoryTest.php | 245 ++++++++++++++- .../Thelia/Tests/Coupon/CouponManagerTest.php | 297 ++++++++++++++---- .../Tests/Coupon/CouponRuleCollectionTest.php | 81 +++++ .../Tests/Coupon/Parameter/DateParamTest.php | 2 +- .../Coupon/Parameter/IntegerParamTest.php | 2 +- .../Coupon/Parameter/IntervalParamTest.php | 2 +- .../Tests/Coupon/Parameter/PriceParamTest.php | 2 +- .../Coupon/Parameter/QuantityParamTest.php | 2 +- .../Parameter/RepeatedDateParamTest.php | 2 +- .../Parameter/RepeatedIntervalParamTest.php | 2 +- .../Rule/AvailableForTotalAmountTest.php | 2 +- .../Coupon/Rule/AvailableForXArticlesTest.php | 2 +- .../{OperatorTest.php => OperatorsTest.php} | 4 +- .../Thelia/Tests/Coupon/RuleOrganizerTest.php | 2 +- .../Type/RemoveXAmountForCategoryYTest.php | 2 +- .../Tests/Coupon/Type/RemoveXAmountTest.php | 2 +- .../Type/RemoveXPercentForCategoryYTest.php | 2 +- .../Tests/Coupon/Type/RemoveXPercentTest.php | 2 +- core/lib/Thelia/Tools/PhpUnitUtils.php | 55 ++++ install/faker.php | 14 +- install/thelia.sql | 14 +- local/config/schema.xml | 13 +- 50 files changed, 1723 insertions(+), 676 deletions(-) create mode 100644 core/lib/Thelia/Coupon/CouponRuleCollection.php create mode 100644 core/lib/Thelia/Exception/CouponExpiredException.php create mode 100644 core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php rename core/lib/Thelia/Tests/Coupon/Rule/{OperatorTest.php => OperatorsTest.php} (98%) create mode 100644 core/lib/Thelia/Tools/PhpUnitUtils.php diff --git a/core/lib/Thelia/Coupon/CouponAdapterInterface.php b/core/lib/Thelia/Coupon/CouponAdapterInterface.php index 0a900183e..9db1160f1 100644 --- a/core/lib/Thelia/Coupon/CouponAdapterInterface.php +++ b/core/lib/Thelia/Coupon/CouponAdapterInterface.php @@ -23,6 +23,9 @@ namespace Thelia\Coupon; +use Thelia\Coupon\Type\CouponInterface; +use Thelia\Model\Coupon; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -93,4 +96,22 @@ interface CouponAdapterInterface */ public function getCurrentCoupons(); + /** + * Find one Coupon in the database from its code + * + * @param string $code Coupon code + * + * @return Coupon + */ + public function findOneCouponByCode($code); + + /** + * Save a Coupon in the database + * + * @param CouponInterface $coupon Coupon + * + * @return $this + */ + public function saveCoupon(CouponInterface $coupon); + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponBaseAdapter.php b/core/lib/Thelia/Coupon/CouponBaseAdapter.php index a79ac5407..180ddc3cd 100644 --- a/core/lib/Thelia/Coupon/CouponBaseAdapter.php +++ b/core/lib/Thelia/Coupon/CouponBaseAdapter.php @@ -23,6 +23,10 @@ namespace Thelia\Coupon; +use Thelia\Coupon\Type\CouponInterface; +use Thelia\Model\Coupon; +use Thelia\Model\CouponQuery; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -30,6 +34,7 @@ namespace Thelia\Coupon; * * @package Coupon * @author Guillaume MOREL + * @todo implements * */ class CouponBaseAdapter implements CouponAdapterInterface @@ -111,7 +116,7 @@ class CouponBaseAdapter implements CouponAdapterInterface */ public function getCurrentCoupons() { - $couponFactory = new CouponFactory(); + $couponFactory = new CouponFactory($this); // @todo Get from Session $couponCodes = array('XMAS', 'SPRINGBREAK'); @@ -124,5 +129,46 @@ class CouponBaseAdapter implements CouponAdapterInterface return $coupons; } + /** + * Find one Coupon in the database from its code + * + * @param string $code Coupon code + * + * @return Coupon + */ + public function findOneCouponByCode($code) + { + $couponQuery = CouponQuery::create(); + + return $couponQuery->findOneByCode($code); + } + + /** + * Save a Coupon in the database + * + * @param CouponInterface $coupon Coupon + * + * @return $this + */ + public function saveCoupon(CouponInterface $coupon) + { +// $couponModel = new Coupon(); +// $couponModel->setCode($coupon->getCode()); +// $couponModel->setType(get_class($coupon)); +// $couponModel->setTitle($coupon->getTitle()); +// $couponModel->setShortDescription($coupon->getShortDescription()); +// $couponModel->setDescription($coupon->getDescription()); +// $couponModel->setAmount($coupon->getEffect()); +// $couponModel->setIsUsed(0); +// $couponModel->setIsEnabled(1); +// $couponModel->set +// $couponModel->set +// $couponModel->set +// $couponModel->set +// $couponModel->set +// $couponModel->set +// $couponModel->set + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php index f81e95b97..d82bb3430 100644 --- a/core/lib/Thelia/Coupon/CouponFactory.php +++ b/core/lib/Thelia/Coupon/CouponFactory.php @@ -23,13 +23,12 @@ namespace Thelia\Coupon; +use Symfony\Component\Translation\Exception\NotFoundResourceException; use Thelia\Coupon\Type\CouponInterface; use Thelia\Coupon\Type\RemoveXAmount; -use Thelia\Model\Base\CouponQuery; +use Thelia\Exception\CouponExpiredException; use Thelia\Model\Coupon; -use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Encoder\JsonEncoder; -use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer; /** * Created by JetBrains PhpStorm. @@ -44,18 +43,41 @@ use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer; */ class CouponFactory { + /** @var CouponAdapterInterface Provide necessary value from Thelia*/ + protected $adapter; + + /** + * Constructor + * + * @param CouponAdapterInterface $adapter Provide necessary value from Thelia + */ + function __construct(CouponAdapterInterface $adapter) + { + $this->adapter = $adapter; + } + /** * Build a CouponInterface from its database data * * @param string $couponCode Coupon code ex: XMAS * + * @throws \Thelia\Exception\CouponExpiredException + * @throws \Symfony\Component\Translation\Exception\NotFoundResourceException * @return CouponInterface ready to be processed */ public function buildCouponFromCode($couponCode) { + /** @var Coupon $couponModel */ + $couponModel = $this->adapter->findOneCouponByCode($couponCode); + if ($couponModel === null) { + throw new NotFoundResourceException( + 'Coupon ' . $couponCode . ' not found in Database' + ); + } - $couponQuery = CouponQuery::create(); - $couponModel = $couponQuery->findByCode($couponCode); + if ($couponModel->getExpirationDate() < new \DateTime()) { + throw new CouponExpiredException($couponCode); + } return $this->buildCouponInterfacFromModel($couponModel); } @@ -74,40 +96,25 @@ class CouponFactory $couponClass = $model->getType(); /** @var CouponInterface $coupon*/ - $coupon = new $$couponClass( + $coupon = new $couponClass( $model->getCode(), $model->getTitle(), $model->getShortDescription(), $model->getDescription(), $model->getAmount(), $isCumulative, - $isRemovingPostage + $isRemovingPostage, + $model->getIsAvailableOnSpecialOffers(), + $model->getIsEnabled(), + $model->getMaxUsage(), + $model->getExpirationDate() ); - $normalizer = new GetSetMethodNormalizer(); - $encoder = new JsonEncoder(); - - $serializer = new Serializer(array($normalizer), array($encoder)); - - $o = new \ArrayObject(); - $unserializedRuleTypes = $o->unserialize( - $model->getSerializedRulesType() - ); - $unserializedRuleContents = $o->unserialize( - $model->getSerializedRulesContent() - ); - - $rules = array(); - foreach ($unserializedRuleTypes as $key => $unserializedRuleType) { - $rules[] = $serializer->deserialize( - $unserializedRuleContents[$key], - $unserializedRuleType, - 'json' - ); - } + /** @var CouponRuleCollection $rules */ + $rules = unserialize(base64_decode($model->getSerializedRules())); $coupon->setRules($rules); return $coupon; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index 765068c96..c36ad7c40 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -51,7 +51,7 @@ class CouponManager * * @param CouponAdapterInterface $adapter Provide necessary value from Thelia */ - function __construct($adapter) + function __construct(CouponAdapterInterface $adapter) { $this->adapter = $adapter; $this->coupons = $this->adapter->getCurrentCoupons(); @@ -69,7 +69,7 @@ class CouponManager $discount = 0.00; if (count($this->coupons) > 0) { - $couponsKept = $this->sortCoupons(); + $couponsKept = $this->sortCoupons($this->coupons); $isRemovingPostage = $this->isCouponRemovingPostage($couponsKept); if ($isRemovingPostage) { @@ -111,17 +111,36 @@ class CouponManager * Sort Coupon to keep * Coupon not cumulative cancels previous * + * @param array $coupons CouponInterface to process + * * @return array Array of CouponInterface sorted */ - protected function sortCoupons() + protected function sortCoupons(array $coupons) { $couponsKept = array(); /** @var CouponInterface $coupon */ - foreach ($this->coupons as $coupon) { - if (!$coupon->isCumulative()) { - $couponsKept = array(); - $couponsKept[] = $coupon; + foreach ($coupons as $coupon) { + if (!$coupon->isExpired()) { + if ($coupon->isCumulative()) { + if (isset($couponsKept[0])) { + /** @var CouponInterface $previousCoupon */ + $previousCoupon = $couponsKept[0]; + if ($previousCoupon->isCumulative()) { + // Add Coupon + $couponsKept[] = $coupon; + } else { + // Reset Coupons, add last + $couponsKept = array($coupon); + } + } else { + // Reset Coupons, add last + $couponsKept = array($coupon); + } + } else { + // Reset Coupons, add last + $couponsKept = array($coupon); + } } } diff --git a/core/lib/Thelia/Coupon/CouponRuleCollection.php b/core/lib/Thelia/Coupon/CouponRuleCollection.php new file mode 100644 index 000000000..3146cec56 --- /dev/null +++ b/core/lib/Thelia/Coupon/CouponRuleCollection.php @@ -0,0 +1,88 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon; + +use Symfony\Component\Serializer\Encoder\JsonEncoder; +use Thelia\Coupon\Rule\CouponRuleInterface; +use Thelia\Exception\InvalidRuleException; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Manage a set of v + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class CouponRuleCollection +{ + /** @var array Array of CouponRuleInterface */ + protected $rules = array(); + + /** + * Constructor + * + * @param array $rules Array of CouponRuleInterface + * + * @throws \Thelia\Exception\InvalidRuleException + */ + function __construct(array $rules) + { + foreach ($rules as $rule) { + if (!$rule instanceof CouponRuleInterface) { + throw new InvalidRuleException(get_class()); + } + } + $this->rules = $rules; + } + + /** + * Get Rules + * + * @return array Array of CouponRuleInterface + */ + public function getRules() + { + return $this->rules; + } + + /** + * Add a CouponRuleInterface to the Collection + * + * @param CouponRuleInterface $rule Rule + * + * @return $this + */ + public function add(CouponRuleInterface $rule) + { + $this->rules[] = $rule; + + return $this; + } + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForDate.php b/core/lib/Thelia/Coupon/Rule/AvailableForDate.php index 800db5066..1b5b27ef5 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForDate.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForDate.php @@ -23,6 +23,8 @@ namespace Thelia\Coupon\Rule; +use Thelia\Coupon\CouponAdapterInterface; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -34,31 +36,26 @@ namespace Thelia\Coupon\Rule; */ class AvailableForDate extends AvailableForPeriod { + /** - * Generate current Rule validator from adapter + * Check if backoffice inputs are relevant or not * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this + * @return bool */ - protected function setValidators(CouponAdapterInterface $adapter) + public function checkBackOfficeInput() { - parent::setValidators($adapter); // TODO: Change the autogenerated stub + // TODO: Implement checkBackOfficeInput() method. } /** - * Generate current Rule param to be validated from adapter + * Check if Checkout inputs are relevant or not * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this + * @return bool */ - protected function setParametersToValidate(CouponAdapterInterface $adapter) + public function checkCheckoutInput() { - parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub + // TODO: Implement checkCheckoutInput() method. } + + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php b/core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php index f0ef8926a..7f4d1bb33 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php @@ -34,31 +34,26 @@ namespace Thelia\Coupon\Rule; */ class AvailableForLocationX extends CouponRuleAbstract { + /** - * Generate current Rule validator from adapter + * Check if backoffice inputs are relevant or not * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this + * @return bool */ - protected function setValidators(CouponAdapterInterface $adapter) + public function checkBackOfficeInput() { - parent::setValidators($adapter); // TODO: Change the autogenerated stub + // TODO: Implement checkBackOfficeInput() method. } /** - * Generate current Rule param to be validated from adapter + * Check if Checkout inputs are relevant or not * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this + * @return bool */ - protected function setParametersToValidate(CouponAdapterInterface $adapter) + public function checkCheckoutInput() { - parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub + // TODO: Implement checkCheckoutInput() method. } + + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php b/core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php index fe7347c46..7097ca52c 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php @@ -34,31 +34,24 @@ namespace Thelia\Coupon\Rule; */ class AvailableForPeriod extends CouponRuleAbstract { + /** - * Generate current Rule validator from adapter + * Check if backoffice inputs are relevant or not * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this + * @return bool */ - protected function setValidators(CouponAdapterInterface $adapter) + public function checkBackOfficeInput() { - parent::setValidators($adapter); // TODO: Change the autogenerated stub + // TODO: Implement checkBackOfficeInput() method. } /** - * Generate current Rule param to be validated from adapter + * Check if Checkout inputs are relevant or not * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this + * @return bool */ - protected function setParametersToValidate(CouponAdapterInterface $adapter) + public function checkCheckoutInput() { - parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub + // TODO: Implement checkCheckoutInput() method. } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php index 21ebd01d3..f4d4be7d3 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php @@ -34,31 +34,24 @@ namespace Thelia\Coupon\Rule; */ class AvailableForRepeatedDate extends AvailableForDate { + /** - * Generate current Rule validator from adapter + * Check if backoffice inputs are relevant or not * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this + * @return bool */ - protected function setValidators(CouponAdapterInterface $adapter) + public function checkBackOfficeInput() { - parent::setValidators($adapter); // TODO: Change the autogenerated stub + // TODO: Implement checkBackOfficeInput() method. } /** - * Generate current Rule param to be validated from adapter + * Check if Checkout inputs are relevant or not * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this + * @return bool */ - protected function setParametersToValidate(CouponAdapterInterface $adapter) + public function checkCheckoutInput() { - parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub + // TODO: Implement checkCheckoutInput() method. } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php index 2824b584a..8cf30569b 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php @@ -23,6 +23,8 @@ namespace Thelia\Coupon\Rule; +use Thelia\Coupon\CouponAdapterInterface; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -34,19 +36,6 @@ namespace Thelia\Coupon\Rule; */ class AvailableForRepeatedPeriod extends AvailableForPeriod { - /** - * Generate current Rule validator from adapter - * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this - */ - protected function setValidators(CouponAdapterInterface $adapter) - { - parent::setValidators($adapter); // TODO: Change the autogenerated stub - } /** * Generate current Rule param to be validated from adapter @@ -61,4 +50,24 @@ class AvailableForRepeatedPeriod extends AvailableForPeriod { parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub } + + /** + * Check if backoffice inputs are relevant or not + * + * @return bool + */ + public function checkBackOfficeInput() + { + // TODO: Implement checkBackOfficeInput() method. + } + + /** + * Check if Checkout inputs are relevant or not + * + * @return bool + */ + public function checkCheckoutInput() + { + // TODO: Implement checkCheckoutInput() method. + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php index 2e109f9ec..b01f946a1 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php @@ -166,7 +166,8 @@ class AvailableForTotalAmount extends CouponRuleAbstract */ protected function setValidatorsFromAdapter(CouponAdapterInterface $adapter) { - $adapter->getRule($this); +// $adapter->getRule($this); + // @todo implement } /** diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php index a4153e5a1..6493da92a 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php @@ -34,31 +34,5 @@ namespace Thelia\Coupon\Rule; */ class AvailableForTotalAmountForCategoryY extends AvailableForTotalAmount { - /** - * Generate current Rule validator from adapter - * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this - */ - protected function setValidators(CouponAdapterInterface $adapter) - { - parent::setValidators($adapter); // TODO: Change the autogenerated stub - } - /** - * Generate current Rule param to be validated from adapter - * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this - */ - protected function setParametersToValidate(CouponAdapterInterface $adapter) - { - parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub - } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php b/core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php index 7016eda95..7a898205c 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php @@ -23,8 +23,6 @@ namespace Thelia\Coupon\Rule; -use Thelia\Type\IntType; - /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -38,32 +36,25 @@ use Thelia\Type\IntType; */ class AvailableForXArticles extends CouponRuleAbstract { + /** - * Generate current Rule validator from adapter + * Check if backoffice inputs are relevant or not * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this + * @return bool */ - protected function setValidators(CouponAdapterInterface $adapter) + public function checkBackOfficeInput() { - parent::setValidators($adapter); // TODO: Change the autogenerated stub + // TODO: Implement checkBackOfficeInput() method. } /** - * Generate current Rule param to be validated from adapter + * Check if Checkout inputs are relevant or not * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this + * @return bool */ - protected function setParametersToValidate(CouponAdapterInterface $adapter) + public function checkCheckoutInput() { - parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub + // TODO: Implement checkCheckoutInput() method. } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php b/core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php index 8ab6abe34..22ad31841 100644 --- a/core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php +++ b/core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php @@ -23,8 +23,6 @@ namespace Thelia\Coupon\Rule; -use Thelia\Coupon\CouponAdapterInterface; - /** * Created by JetBrains PhpStorm. * Date: 8/19/13 diff --git a/core/lib/Thelia/Coupon/Type/CouponAbstract.php b/core/lib/Thelia/Coupon/Type/CouponAbstract.php index 3ef3166b3..8e2f716ea 100644 --- a/core/lib/Thelia/Coupon/Type/CouponAbstract.php +++ b/core/lib/Thelia/Coupon/Type/CouponAbstract.php @@ -26,6 +26,7 @@ namespace Thelia\Coupon\Type; use Symfony\Component\Intl\Exception\NotImplementedException; use Thelia\Coupon\CouponAdapterInterface; use Thelia\Coupon\Rule\CouponRuleInterface; +use Thelia\Coupon\CouponRuleCollection; use Thelia\Coupon\RuleOrganizerInterface; use Thelia\Exception\InvalidRuleException; @@ -48,7 +49,7 @@ abstract class CouponAbstract implements CouponInterface /** @var RuleOrganizerInterface */ protected $organizer = null; - /** @var array Array of CouponRuleInterface */ + /** @var CouponRuleCollection Array of CouponRuleInterface */ protected $rules = null; /** @var string Coupon code (ex: XMAS) */ @@ -63,6 +64,12 @@ abstract class CouponAbstract implements CouponInterface /** @var string Coupon description */ protected $description = null; + /** @var bool if Coupon is enabled */ + protected $isEnabled = false; + + /** @var \DateTime Coupon expiration date */ + protected $expirationDate = null; + /** @var bool if Coupon is cumulative */ protected $isCumulative = false; @@ -72,6 +79,12 @@ abstract class CouponAbstract implements CouponInterface /** @var float Amount that will be removed from the Checkout (Coupon Effect) */ protected $amount = 0; + /** @var int Max time a Coupon can be used (-1 = unlimited) */ + protected $maxUsage = -1; + + /** @var bool if Coupon is available for Products already on special offers */ + protected $isAvailableOnSpecialOffers = false; + /** * Set Adapter containing all relevant data * @@ -176,13 +189,11 @@ abstract class CouponAbstract implements CouponInterface /** * Return condition to validate the Coupon or not * - * @return array An array of CouponRuleInterface + * @return CouponRuleCollection */ public function getRules() { - $arrayObject = new \ArrayObject($this->rules); - - return $arrayObject->getArrayCopy(); + return clone $this->rules; } /** @@ -195,7 +206,7 @@ abstract class CouponAbstract implements CouponInterface */ public function addRule(CouponRuleInterface $rule) { - $this->rules[] = $rule; + $this->rules->add($rule); return $this; } @@ -204,22 +215,14 @@ abstract class CouponAbstract implements CouponInterface * Replace the existing Rules by those given in parameter * If one Rule is badly implemented, no Rule will be added * - * @param array $rules CouponRuleInterface to add + * @param CouponRuleCollection $rules CouponRuleInterface to add * * @return $this * @throws \Thelia\Exception\InvalidRuleException */ - public function setRules(array $rules) + public function setRules(CouponRuleCollection $rules) { - foreach ($rules as $rule) { - if (!$rule instanceof CouponRuleInterface) { - throw new InvalidRuleException(get_class()); - } - } - $this->rules = array(); - foreach ($rules as $rule) { - $this->addRule($rule); - } + $this->rules = $rules; return $this; } @@ -236,7 +239,7 @@ abstract class CouponAbstract implements CouponInterface $isMatching = true; /** @var CouponRuleInterface $rule */ - foreach ($this->rules as $rule) { + foreach ($this->rules->getRules() as $rule) { if (!$rule->isMatching()) { $isMatching = false; } @@ -245,5 +248,65 @@ abstract class CouponAbstract implements CouponInterface return $isMatching; } + /** + * Return Coupon expiration date + * + * @return \DateTime + */ + public function getExpirationDate() + { + return clone $this->expirationDate; + } + + /** + * Check if the Coupon can be used against a + * product already with a special offer price + * + * @return boolean + */ + public function isAvailableOnSpecialOffers() + { + return $this->isAvailableOnSpecialOffers; + } + + + /** + * Check if Coupon has been disabled by admin + * + * @return boolean + */ + public function isEnabled() + { + return $this->isEnabled; + } + + /** + * Return how many time the Coupon can be used again + * Ex : -1 unlimited + * + * @return int + */ + public function getMaxUsage() + { + return $this->maxUsage; + } + + /** + * Check if the Coupon is already Expired + * + * @return bool + */ + public function isExpired() + { + $ret = true; + + if ($this->expirationDate < new \DateTime()) { + $ret = false; + } + + return $ret; + } + + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Type/CouponInterface.php b/core/lib/Thelia/Coupon/Type/CouponInterface.php index 8c51126ea..1d470bb69 100644 --- a/core/lib/Thelia/Coupon/Type/CouponInterface.php +++ b/core/lib/Thelia/Coupon/Type/CouponInterface.php @@ -23,6 +23,8 @@ namespace Thelia\Coupon\Type; +use Thelia\Coupon\CouponRuleCollection; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -114,10 +116,48 @@ interface CouponInterface * Replace the existing Rules by those given in parameter * If one Rule is badly implemented, no Rule will be added * - * @param array $rules CouponRuleInterface to add + * @param CouponRuleCollection $rules CouponRuleInterface to add * * @return $this * @throws \Thelia\Exception\InvalidRuleException */ - public function setRules(array $rules); + public function setRules(CouponRuleCollection $rules); + + /** + * Return Coupon expiration date + * + * @return \DateTime + */ + public function getExpirationDate(); + + /** + * Check if the Coupon can be used against a + * product already with a special offer price + * + * @return boolean + */ + public function isAvailableOnSpecialOffers(); + + + /** + * Check if Coupon has been disabled by admin + * + * @return boolean + */ + public function isEnabled(); + + /** + * Return how many time the Coupon can be used again + * Ex : -1 unlimited + * + * @return int + */ + public function getMaxUsage(); + + /** + * Check if the Coupon is already Expired + * + * @return bool + */ + public function isExpired(); } diff --git a/core/lib/Thelia/Coupon/Type/RemoveXAmount.php b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php index d7cfeb989..a0d715141 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXAmount.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php @@ -41,15 +41,20 @@ class RemoveXAmount extends CouponAbstract /** * Constructor * - * @param string $code Coupon code (ex: XMAS) - * @param string $title Coupon title (ex: Coupon for XMAS) - * @param string $shortDescription Coupon short description - * @param string $description Coupon description - * @param float $amount Coupon amount to deduce - * @param bool $isCumulative if Coupon is cumulative - * @param bool $isRemovingPostage if Coupon is removing postage + * @param string $code Coupon code (ex: XMAS) + * @param string $title Coupon title (ex: Coupon for XMAS) + * @param string $shortDescription Coupon short description + * @param string $description Coupon description + * @param float $amount Coupon amount to deduce + * @param bool $isCumulative If Coupon is cumulative + * @param bool $isRemovingPostage If Coupon is removing postage + * @param bool $isAvailableOnSpecialOffers If available on Product already + * on special offer price + * @param bool $isEnabled False if Coupon is disabled by admin + * @param int $maxUsage How many usage left + * @param \Datetime $expirationDate When the Code is expiring */ - function __construct($code, $title, $shortDescription, $description, $amount, $isCumulative, $isRemovingPostage) + function __construct($code, $title, $shortDescription, $description, $amount, $isCumulative, $isRemovingPostage, $isAvailableOnSpecialOffers, $isEnabled, $maxUsage, \DateTime $expirationDate) { $this->code = $code; $this->title = $title; @@ -60,6 +65,11 @@ class RemoveXAmount extends CouponAbstract $this->isRemovingPostage = $isRemovingPostage; $this->amount = $amount; + + $this->isAvailableOnSpecialOffers = $isAvailableOnSpecialOffers; + $this->isEnabled = $isEnabled; + $this->maxUsage = $maxUsage; + $this->expirationDate = $expirationDate; } } diff --git a/core/lib/Thelia/Exception/CouponExpiredException.php b/core/lib/Thelia/Exception/CouponExpiredException.php new file mode 100644 index 000000000..c1ccace0a --- /dev/null +++ b/core/lib/Thelia/Exception/CouponExpiredException.php @@ -0,0 +1,53 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Exception; + +use Thelia\Log\Tlog; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when an Expired Coupon is tried + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class CouponExpiredException extends \Exception +{ + /** + * CouponExpiredException thrown when a Coupon is expired + * + * @param string $couponCode Coupon code + */ + public function __construct($couponCode) + { + $message = 'Expired Coupon ' . $couponCode . 'attempt'; + Tlog::getInstance()->addInfo($message); + + parent::__construct($message); + } +} diff --git a/core/lib/Thelia/Exception/InvalidRuleException.php b/core/lib/Thelia/Exception/InvalidRuleException.php index 834a6e962..a891ded4a 100644 --- a/core/lib/Thelia/Exception/InvalidRuleException.php +++ b/core/lib/Thelia/Exception/InvalidRuleException.php @@ -42,9 +42,9 @@ class InvalidRuleException extends \RuntimeException * InvalidRuleOperatorException thrown when a Rule is badly implemented * * @param string $className Class name - * @param string $parameter array key parameter */ - public function __construct($className) { + public function __construct($className) + { $message = 'Invalid Rule given to ' . $className; Tlog::getInstance()->addError($message); diff --git a/core/lib/Thelia/Exception/InvalidRuleOperatorException.php b/core/lib/Thelia/Exception/InvalidRuleOperatorException.php index 82556b2ef..d40c723c2 100644 --- a/core/lib/Thelia/Exception/InvalidRuleOperatorException.php +++ b/core/lib/Thelia/Exception/InvalidRuleOperatorException.php @@ -44,7 +44,8 @@ class InvalidRuleOperatorException extends \RuntimeException * @param string $className Class name * @param string $parameter array key parameter */ - public function __construct($className, $parameter) { + public function __construct($className, $parameter) + { $message = 'Invalid Operator for Rule ' . $className . ' on parameter ' . $parameter; Tlog::getInstance()->addError($message); diff --git a/core/lib/Thelia/Exception/InvalidRuleValueException.php b/core/lib/Thelia/Exception/InvalidRuleValueException.php index cbb86d16f..2f16f32f1 100644 --- a/core/lib/Thelia/Exception/InvalidRuleValueException.php +++ b/core/lib/Thelia/Exception/InvalidRuleValueException.php @@ -44,7 +44,8 @@ class InvalidRuleValueException extends \RuntimeException * @param string $className Class name * @param string $parameter array key parameter */ - public function __construct($className, $parameter) { + public function __construct($className, $parameter) + { $message = 'Invalid Parameter for Rule ' . $className . ' on parameter ' . $parameter; Tlog::getInstance()->addError($message); diff --git a/core/lib/Thelia/Model/Base/Coupon.php b/core/lib/Thelia/Model/Base/Coupon.php index 643b438b6..1d1bfe1e2 100644 --- a/core/lib/Thelia/Model/Base/Coupon.php +++ b/core/lib/Thelia/Model/Base/Coupon.php @@ -123,16 +123,10 @@ abstract class Coupon implements ActiveRecordInterface protected $expiration_date; /** - * The value for the serialized_rules_type field. + * The value for the serialized_rules field. * @var string */ - protected $serialized_rules_type; - - /** - * The value for the serialized_rules_content field. - * @var string - */ - protected $serialized_rules_content; + protected $serialized_rules; /** * The value for the is_cumulative field. @@ -146,6 +140,18 @@ abstract class Coupon implements ActiveRecordInterface */ protected $is_removing_postage; + /** + * The value for the max_usage field. + * @var int + */ + protected $max_usage; + + /** + * The value for the is_available_on_special_offers field. + * @var boolean + */ + protected $is_available_on_special_offers; + /** * The value for the created_at field. * @var string @@ -618,25 +624,14 @@ abstract class Coupon implements ActiveRecordInterface } /** - * Get the [serialized_rules_type] column value. + * Get the [serialized_rules] column value. * * @return string */ - public function getSerializedRulesType() + public function getSerializedRules() { - return $this->serialized_rules_type; - } - - /** - * Get the [serialized_rules_content] column value. - * - * @return string - */ - public function getSerializedRulesContent() - { - - return $this->serialized_rules_content; + return $this->serialized_rules; } /** @@ -661,6 +656,28 @@ abstract class Coupon implements ActiveRecordInterface return $this->is_removing_postage; } + /** + * Get the [max_usage] column value. + * + * @return int + */ + public function getMaxUsage() + { + + return $this->max_usage; + } + + /** + * Get the [is_available_on_special_offers] column value. + * + * @return boolean + */ + public function getIsAvailableOnSpecialOffers() + { + + return $this->is_available_on_special_offers; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -923,46 +940,25 @@ abstract class Coupon implements ActiveRecordInterface } // setExpirationDate() /** - * Set the value of [serialized_rules_type] column. + * Set the value of [serialized_rules] column. * * @param string $v new value * @return \Thelia\Model\Coupon The current object (for fluent API support) */ - public function setSerializedRulesType($v) + public function setSerializedRules($v) { if ($v !== null) { $v = (string) $v; } - if ($this->serialized_rules_type !== $v) { - $this->serialized_rules_type = $v; - $this->modifiedColumns[] = CouponTableMap::SERIALIZED_RULES_TYPE; + if ($this->serialized_rules !== $v) { + $this->serialized_rules = $v; + $this->modifiedColumns[] = CouponTableMap::SERIALIZED_RULES; } return $this; - } // setSerializedRulesType() - - /** - * Set the value of [serialized_rules_content] column. - * - * @param string $v new value - * @return \Thelia\Model\Coupon The current object (for fluent API support) - */ - public function setSerializedRulesContent($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->serialized_rules_content !== $v) { - $this->serialized_rules_content = $v; - $this->modifiedColumns[] = CouponTableMap::SERIALIZED_RULES_CONTENT; - } - - - return $this; - } // setSerializedRulesContent() + } // setSerializedRules() /** * Set the value of [is_cumulative] column. @@ -1006,6 +1002,56 @@ abstract class Coupon implements ActiveRecordInterface return $this; } // setIsRemovingPostage() + /** + * Set the value of [max_usage] column. + * + * @param int $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setMaxUsage($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->max_usage !== $v) { + $this->max_usage = $v; + $this->modifiedColumns[] = CouponTableMap::MAX_USAGE; + } + + + return $this; + } // setMaxUsage() + + /** + * Sets the value of the [is_available_on_special_offers] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setIsAvailableOnSpecialOffers($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_available_on_special_offers !== $v) { + $this->is_available_on_special_offers = $v; + $this->modifiedColumns[] = CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS; + } + + + return $this; + } // setIsAvailableOnSpecialOffers() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -1143,31 +1189,34 @@ abstract class Coupon implements ActiveRecordInterface } $this->expiration_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponTableMap::translateFieldName('SerializedRulesType', TableMap::TYPE_PHPNAME, $indexType)]; - $this->serialized_rules_type = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponTableMap::translateFieldName('SerializedRules', TableMap::TYPE_PHPNAME, $indexType)]; + $this->serialized_rules = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponTableMap::translateFieldName('SerializedRulesContent', TableMap::TYPE_PHPNAME, $indexType)]; - $this->serialized_rules_content = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)]; $this->is_cumulative = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)]; $this->is_removing_postage = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponTableMap::translateFieldName('MaxUsage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->max_usage = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CouponTableMap::translateFieldName('IsAvailableOnSpecialOffers', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_available_on_special_offers = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CouponTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : CouponTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; $this->version = (null !== $col) ? (int) $col : null; $this->resetModified(); @@ -1177,7 +1226,7 @@ abstract class Coupon implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 17; // 17 = CouponTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 18; // 18 = CouponTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Coupon object", 0, $e); @@ -1493,11 +1542,8 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::EXPIRATION_DATE)) { $modifiedColumns[':p' . $index++] = 'EXPIRATION_DATE'; } - if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES_TYPE)) { - $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES_TYPE'; - } - if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES_CONTENT)) { - $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES_CONTENT'; + if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES)) { + $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES'; } if ($this->isColumnModified(CouponTableMap::IS_CUMULATIVE)) { $modifiedColumns[':p' . $index++] = 'IS_CUMULATIVE'; @@ -1505,6 +1551,12 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::IS_REMOVING_POSTAGE)) { $modifiedColumns[':p' . $index++] = 'IS_REMOVING_POSTAGE'; } + if ($this->isColumnModified(CouponTableMap::MAX_USAGE)) { + $modifiedColumns[':p' . $index++] = 'MAX_USAGE'; + } + if ($this->isColumnModified(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) { + $modifiedColumns[':p' . $index++] = 'IS_AVAILABLE_ON_SPECIAL_OFFERS'; + } if ($this->isColumnModified(CouponTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1555,11 +1607,8 @@ abstract class Coupon implements ActiveRecordInterface case 'EXPIRATION_DATE': $stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case 'SERIALIZED_RULES_TYPE': - $stmt->bindValue($identifier, $this->serialized_rules_type, PDO::PARAM_STR); - break; - case 'SERIALIZED_RULES_CONTENT': - $stmt->bindValue($identifier, $this->serialized_rules_content, PDO::PARAM_STR); + case 'SERIALIZED_RULES': + $stmt->bindValue($identifier, $this->serialized_rules, PDO::PARAM_STR); break; case 'IS_CUMULATIVE': $stmt->bindValue($identifier, $this->is_cumulative, PDO::PARAM_INT); @@ -1567,6 +1616,12 @@ abstract class Coupon implements ActiveRecordInterface case 'IS_REMOVING_POSTAGE': $stmt->bindValue($identifier, $this->is_removing_postage, PDO::PARAM_INT); break; + case 'MAX_USAGE': + $stmt->bindValue($identifier, $this->max_usage, PDO::PARAM_INT); + break; + case 'IS_AVAILABLE_ON_SPECIAL_OFFERS': + $stmt->bindValue($identifier, (int) $this->is_available_on_special_offers, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1669,24 +1724,27 @@ abstract class Coupon implements ActiveRecordInterface return $this->getExpirationDate(); break; case 10: - return $this->getSerializedRulesType(); + return $this->getSerializedRules(); break; case 11: - return $this->getSerializedRulesContent(); - break; - case 12: return $this->getIsCumulative(); break; - case 13: + case 12: return $this->getIsRemovingPostage(); break; + case 13: + return $this->getMaxUsage(); + break; case 14: - return $this->getCreatedAt(); + return $this->getIsAvailableOnSpecialOffers(); break; case 15: - return $this->getUpdatedAt(); + return $this->getCreatedAt(); break; case 16: + return $this->getUpdatedAt(); + break; + case 17: return $this->getVersion(); break; default: @@ -1728,13 +1786,14 @@ abstract class Coupon implements ActiveRecordInterface $keys[7] => $this->getIsUsed(), $keys[8] => $this->getIsEnabled(), $keys[9] => $this->getExpirationDate(), - $keys[10] => $this->getSerializedRulesType(), - $keys[11] => $this->getSerializedRulesContent(), - $keys[12] => $this->getIsCumulative(), - $keys[13] => $this->getIsRemovingPostage(), - $keys[14] => $this->getCreatedAt(), - $keys[15] => $this->getUpdatedAt(), - $keys[16] => $this->getVersion(), + $keys[10] => $this->getSerializedRules(), + $keys[11] => $this->getIsCumulative(), + $keys[12] => $this->getIsRemovingPostage(), + $keys[13] => $this->getMaxUsage(), + $keys[14] => $this->getIsAvailableOnSpecialOffers(), + $keys[15] => $this->getCreatedAt(), + $keys[16] => $this->getUpdatedAt(), + $keys[17] => $this->getVersion(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1817,24 +1876,27 @@ abstract class Coupon implements ActiveRecordInterface $this->setExpirationDate($value); break; case 10: - $this->setSerializedRulesType($value); + $this->setSerializedRules($value); break; case 11: - $this->setSerializedRulesContent($value); - break; - case 12: $this->setIsCumulative($value); break; - case 13: + case 12: $this->setIsRemovingPostage($value); break; + case 13: + $this->setMaxUsage($value); + break; case 14: - $this->setCreatedAt($value); + $this->setIsAvailableOnSpecialOffers($value); break; case 15: - $this->setUpdatedAt($value); + $this->setCreatedAt($value); break; case 16: + $this->setUpdatedAt($value); + break; + case 17: $this->setVersion($value); break; } // switch() @@ -1871,13 +1933,14 @@ abstract class Coupon implements ActiveRecordInterface if (array_key_exists($keys[7], $arr)) $this->setIsUsed($arr[$keys[7]]); if (array_key_exists($keys[8], $arr)) $this->setIsEnabled($arr[$keys[8]]); if (array_key_exists($keys[9], $arr)) $this->setExpirationDate($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setSerializedRulesType($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setSerializedRulesContent($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setIsCumulative($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setIsRemovingPostage($arr[$keys[13]]); - if (array_key_exists($keys[14], $arr)) $this->setCreatedAt($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setUpdatedAt($arr[$keys[15]]); - if (array_key_exists($keys[16], $arr)) $this->setVersion($arr[$keys[16]]); + if (array_key_exists($keys[10], $arr)) $this->setSerializedRules($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setIsCumulative($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setIsRemovingPostage($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setMaxUsage($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setCreatedAt($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setUpdatedAt($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setVersion($arr[$keys[17]]); } /** @@ -1899,10 +1962,11 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::IS_USED)) $criteria->add(CouponTableMap::IS_USED, $this->is_used); if ($this->isColumnModified(CouponTableMap::IS_ENABLED)) $criteria->add(CouponTableMap::IS_ENABLED, $this->is_enabled); if ($this->isColumnModified(CouponTableMap::EXPIRATION_DATE)) $criteria->add(CouponTableMap::EXPIRATION_DATE, $this->expiration_date); - if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES_TYPE)) $criteria->add(CouponTableMap::SERIALIZED_RULES_TYPE, $this->serialized_rules_type); - if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES_CONTENT)) $criteria->add(CouponTableMap::SERIALIZED_RULES_CONTENT, $this->serialized_rules_content); + if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES)) $criteria->add(CouponTableMap::SERIALIZED_RULES, $this->serialized_rules); if ($this->isColumnModified(CouponTableMap::IS_CUMULATIVE)) $criteria->add(CouponTableMap::IS_CUMULATIVE, $this->is_cumulative); if ($this->isColumnModified(CouponTableMap::IS_REMOVING_POSTAGE)) $criteria->add(CouponTableMap::IS_REMOVING_POSTAGE, $this->is_removing_postage); + if ($this->isColumnModified(CouponTableMap::MAX_USAGE)) $criteria->add(CouponTableMap::MAX_USAGE, $this->max_usage); + if ($this->isColumnModified(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) $criteria->add(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $this->is_available_on_special_offers); if ($this->isColumnModified(CouponTableMap::CREATED_AT)) $criteria->add(CouponTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) $criteria->add(CouponTableMap::UPDATED_AT, $this->updated_at); if ($this->isColumnModified(CouponTableMap::VERSION)) $criteria->add(CouponTableMap::VERSION, $this->version); @@ -1978,10 +2042,11 @@ abstract class Coupon implements ActiveRecordInterface $copyObj->setIsUsed($this->getIsUsed()); $copyObj->setIsEnabled($this->getIsEnabled()); $copyObj->setExpirationDate($this->getExpirationDate()); - $copyObj->setSerializedRulesType($this->getSerializedRulesType()); - $copyObj->setSerializedRulesContent($this->getSerializedRulesContent()); + $copyObj->setSerializedRules($this->getSerializedRules()); $copyObj->setIsCumulative($this->getIsCumulative()); $copyObj->setIsRemovingPostage($this->getIsRemovingPostage()); + $copyObj->setMaxUsage($this->getMaxUsage()); + $copyObj->setIsAvailableOnSpecialOffers($this->getIsAvailableOnSpecialOffers()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); $copyObj->setVersion($this->getVersion()); @@ -2765,10 +2830,11 @@ abstract class Coupon implements ActiveRecordInterface $this->is_used = null; $this->is_enabled = null; $this->expiration_date = null; - $this->serialized_rules_type = null; - $this->serialized_rules_content = null; + $this->serialized_rules = null; $this->is_cumulative = null; $this->is_removing_postage = null; + $this->max_usage = null; + $this->is_available_on_special_offers = null; $this->created_at = null; $this->updated_at = null; $this->version = null; @@ -3008,10 +3074,11 @@ abstract class Coupon implements ActiveRecordInterface $version->setIsUsed($this->getIsUsed()); $version->setIsEnabled($this->getIsEnabled()); $version->setExpirationDate($this->getExpirationDate()); - $version->setSerializedRulesType($this->getSerializedRulesType()); - $version->setSerializedRulesContent($this->getSerializedRulesContent()); + $version->setSerializedRules($this->getSerializedRules()); $version->setIsCumulative($this->getIsCumulative()); $version->setIsRemovingPostage($this->getIsRemovingPostage()); + $version->setMaxUsage($this->getMaxUsage()); + $version->setIsAvailableOnSpecialOffers($this->getIsAvailableOnSpecialOffers()); $version->setCreatedAt($this->getCreatedAt()); $version->setUpdatedAt($this->getUpdatedAt()); $version->setVersion($this->getVersion()); @@ -3062,10 +3129,11 @@ abstract class Coupon implements ActiveRecordInterface $this->setIsUsed($version->getIsUsed()); $this->setIsEnabled($version->getIsEnabled()); $this->setExpirationDate($version->getExpirationDate()); - $this->setSerializedRulesType($version->getSerializedRulesType()); - $this->setSerializedRulesContent($version->getSerializedRulesContent()); + $this->setSerializedRules($version->getSerializedRules()); $this->setIsCumulative($version->getIsCumulative()); $this->setIsRemovingPostage($version->getIsRemovingPostage()); + $this->setMaxUsage($version->getMaxUsage()); + $this->setIsAvailableOnSpecialOffers($version->getIsAvailableOnSpecialOffers()); $this->setCreatedAt($version->getCreatedAt()); $this->setUpdatedAt($version->getUpdatedAt()); $this->setVersion($version->getVersion()); diff --git a/core/lib/Thelia/Model/Base/CouponQuery.php b/core/lib/Thelia/Model/Base/CouponQuery.php index 196dbbdaa..c7ae0eabd 100644 --- a/core/lib/Thelia/Model/Base/CouponQuery.php +++ b/core/lib/Thelia/Model/Base/CouponQuery.php @@ -32,10 +32,11 @@ use Thelia\Model\Map\CouponTableMap; * @method ChildCouponQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column * @method ChildCouponQuery orderByIsEnabled($order = Criteria::ASC) Order by the is_enabled column * @method ChildCouponQuery orderByExpirationDate($order = Criteria::ASC) Order by the expiration_date column - * @method ChildCouponQuery orderBySerializedRulesType($order = Criteria::ASC) Order by the serialized_rules_type column - * @method ChildCouponQuery orderBySerializedRulesContent($order = Criteria::ASC) Order by the serialized_rules_content column + * @method ChildCouponQuery orderBySerializedRules($order = Criteria::ASC) Order by the serialized_rules column * @method ChildCouponQuery orderByIsCumulative($order = Criteria::ASC) Order by the is_cumulative column * @method ChildCouponQuery orderByIsRemovingPostage($order = Criteria::ASC) Order by the is_removing_postage column + * @method ChildCouponQuery orderByMaxUsage($order = Criteria::ASC) Order by the max_usage column + * @method ChildCouponQuery orderByIsAvailableOnSpecialOffers($order = Criteria::ASC) Order by the is_available_on_special_offers column * @method ChildCouponQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCouponQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @method ChildCouponQuery orderByVersion($order = Criteria::ASC) Order by the version column @@ -50,10 +51,11 @@ use Thelia\Model\Map\CouponTableMap; * @method ChildCouponQuery groupByIsUsed() Group by the is_used column * @method ChildCouponQuery groupByIsEnabled() Group by the is_enabled column * @method ChildCouponQuery groupByExpirationDate() Group by the expiration_date column - * @method ChildCouponQuery groupBySerializedRulesType() Group by the serialized_rules_type column - * @method ChildCouponQuery groupBySerializedRulesContent() Group by the serialized_rules_content column + * @method ChildCouponQuery groupBySerializedRules() Group by the serialized_rules column * @method ChildCouponQuery groupByIsCumulative() Group by the is_cumulative column * @method ChildCouponQuery groupByIsRemovingPostage() Group by the is_removing_postage column + * @method ChildCouponQuery groupByMaxUsage() Group by the max_usage column + * @method ChildCouponQuery groupByIsAvailableOnSpecialOffers() Group by the is_available_on_special_offers column * @method ChildCouponQuery groupByCreatedAt() Group by the created_at column * @method ChildCouponQuery groupByUpdatedAt() Group by the updated_at column * @method ChildCouponQuery groupByVersion() Group by the version column @@ -87,10 +89,11 @@ use Thelia\Model\Map\CouponTableMap; * @method ChildCoupon findOneByIsUsed(int $is_used) Return the first ChildCoupon filtered by the is_used column * @method ChildCoupon findOneByIsEnabled(int $is_enabled) Return the first ChildCoupon filtered by the is_enabled column * @method ChildCoupon findOneByExpirationDate(string $expiration_date) Return the first ChildCoupon filtered by the expiration_date column - * @method ChildCoupon findOneBySerializedRulesType(string $serialized_rules_type) Return the first ChildCoupon filtered by the serialized_rules_type column - * @method ChildCoupon findOneBySerializedRulesContent(string $serialized_rules_content) Return the first ChildCoupon filtered by the serialized_rules_content column + * @method ChildCoupon findOneBySerializedRules(string $serialized_rules) Return the first ChildCoupon filtered by the serialized_rules column * @method ChildCoupon findOneByIsCumulative(int $is_cumulative) Return the first ChildCoupon filtered by the is_cumulative column * @method ChildCoupon findOneByIsRemovingPostage(int $is_removing_postage) Return the first ChildCoupon filtered by the is_removing_postage column + * @method ChildCoupon findOneByMaxUsage(int $max_usage) Return the first ChildCoupon filtered by the max_usage column + * @method ChildCoupon findOneByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return the first ChildCoupon filtered by the is_available_on_special_offers column * @method ChildCoupon findOneByCreatedAt(string $created_at) Return the first ChildCoupon filtered by the created_at column * @method ChildCoupon findOneByUpdatedAt(string $updated_at) Return the first ChildCoupon filtered by the updated_at column * @method ChildCoupon findOneByVersion(int $version) Return the first ChildCoupon filtered by the version column @@ -105,10 +108,11 @@ use Thelia\Model\Map\CouponTableMap; * @method array findByIsUsed(int $is_used) Return ChildCoupon objects filtered by the is_used column * @method array findByIsEnabled(int $is_enabled) Return ChildCoupon objects filtered by the is_enabled column * @method array findByExpirationDate(string $expiration_date) Return ChildCoupon objects filtered by the expiration_date column - * @method array findBySerializedRulesType(string $serialized_rules_type) Return ChildCoupon objects filtered by the serialized_rules_type column - * @method array findBySerializedRulesContent(string $serialized_rules_content) Return ChildCoupon objects filtered by the serialized_rules_content column + * @method array findBySerializedRules(string $serialized_rules) Return ChildCoupon objects filtered by the serialized_rules column * @method array findByIsCumulative(int $is_cumulative) Return ChildCoupon objects filtered by the is_cumulative column * @method array findByIsRemovingPostage(int $is_removing_postage) Return ChildCoupon objects filtered by the is_removing_postage column + * @method array findByMaxUsage(int $max_usage) Return ChildCoupon objects filtered by the max_usage column + * @method array findByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return ChildCoupon objects filtered by the is_available_on_special_offers column * @method array findByCreatedAt(string $created_at) Return ChildCoupon objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCoupon objects filtered by the updated_at column * @method array findByVersion(int $version) Return ChildCoupon objects filtered by the version column @@ -207,7 +211,7 @@ abstract class CouponQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, AMOUNT, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES_TYPE, SERIALIZED_RULES_CONTENT, IS_CUMULATIVE, IS_REMOVING_POSTAGE, CREATED_AT, UPDATED_AT, VERSION FROM coupon WHERE ID = :p0'; + $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, AMOUNT, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES, IS_CUMULATIVE, IS_REMOVING_POSTAGE, MAX_USAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, CREATED_AT, UPDATED_AT, VERSION FROM coupon WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -649,61 +653,32 @@ abstract class CouponQuery extends ModelCriteria } /** - * Filter the query on the serialized_rules_type column + * Filter the query on the serialized_rules column * * Example usage: * - * $query->filterBySerializedRulesType('fooValue'); // WHERE serialized_rules_type = 'fooValue' - * $query->filterBySerializedRulesType('%fooValue%'); // WHERE serialized_rules_type LIKE '%fooValue%' + * $query->filterBySerializedRules('fooValue'); // WHERE serialized_rules = 'fooValue' + * $query->filterBySerializedRules('%fooValue%'); // WHERE serialized_rules LIKE '%fooValue%' * * - * @param string $serializedRulesType The value to use as filter. + * @param string $serializedRules The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterBySerializedRulesType($serializedRulesType = null, $comparison = null) + public function filterBySerializedRules($serializedRules = null, $comparison = null) { if (null === $comparison) { - if (is_array($serializedRulesType)) { + if (is_array($serializedRules)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $serializedRulesType)) { - $serializedRulesType = str_replace('*', '%', $serializedRulesType); + } elseif (preg_match('/[\%\*]/', $serializedRules)) { + $serializedRules = str_replace('*', '%', $serializedRules); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(CouponTableMap::SERIALIZED_RULES_TYPE, $serializedRulesType, $comparison); - } - - /** - * Filter the query on the serialized_rules_content column - * - * Example usage: - * - * $query->filterBySerializedRulesContent('fooValue'); // WHERE serialized_rules_content = 'fooValue' - * $query->filterBySerializedRulesContent('%fooValue%'); // WHERE serialized_rules_content LIKE '%fooValue%' - * - * - * @param string $serializedRulesContent The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCouponQuery The current query, for fluid interface - */ - public function filterBySerializedRulesContent($serializedRulesContent = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($serializedRulesContent)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $serializedRulesContent)) { - $serializedRulesContent = str_replace('*', '%', $serializedRulesContent); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CouponTableMap::SERIALIZED_RULES_CONTENT, $serializedRulesContent, $comparison); + return $this->addUsingAlias(CouponTableMap::SERIALIZED_RULES, $serializedRules, $comparison); } /** @@ -788,6 +763,74 @@ abstract class CouponQuery extends ModelCriteria return $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison); } + /** + * Filter the query on the max_usage column + * + * Example usage: + * + * $query->filterByMaxUsage(1234); // WHERE max_usage = 1234 + * $query->filterByMaxUsage(array(12, 34)); // WHERE max_usage IN (12, 34) + * $query->filterByMaxUsage(array('min' => 12)); // WHERE max_usage > 12 + * + * + * @param mixed $maxUsage The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByMaxUsage($maxUsage = null, $comparison = null) + { + if (is_array($maxUsage)) { + $useMinMax = false; + if (isset($maxUsage['min'])) { + $this->addUsingAlias(CouponTableMap::MAX_USAGE, $maxUsage['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($maxUsage['max'])) { + $this->addUsingAlias(CouponTableMap::MAX_USAGE, $maxUsage['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponTableMap::MAX_USAGE, $maxUsage, $comparison); + } + + /** + * Filter the query on the is_available_on_special_offers column + * + * Example usage: + * + * $query->filterByIsAvailableOnSpecialOffers(true); // WHERE is_available_on_special_offers = true + * $query->filterByIsAvailableOnSpecialOffers('yes'); // WHERE is_available_on_special_offers = true + * + * + * @param boolean|string $isAvailableOnSpecialOffers The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers = null, $comparison = null) + { + if (is_string($isAvailableOnSpecialOffers)) { + $is_available_on_special_offers = in_array(strtolower($isAvailableOnSpecialOffers), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $isAvailableOnSpecialOffers, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/CouponVersion.php b/core/lib/Thelia/Model/Base/CouponVersion.php index 5fcf14d45..9952d80bc 100644 --- a/core/lib/Thelia/Model/Base/CouponVersion.php +++ b/core/lib/Thelia/Model/Base/CouponVersion.php @@ -116,16 +116,10 @@ abstract class CouponVersion implements ActiveRecordInterface protected $expiration_date; /** - * The value for the serialized_rules_type field. + * The value for the serialized_rules field. * @var string */ - protected $serialized_rules_type; - - /** - * The value for the serialized_rules_content field. - * @var string - */ - protected $serialized_rules_content; + protected $serialized_rules; /** * The value for the is_cumulative field. @@ -139,6 +133,18 @@ abstract class CouponVersion implements ActiveRecordInterface */ protected $is_removing_postage; + /** + * The value for the max_usage field. + * @var int + */ + protected $max_usage; + + /** + * The value for the is_available_on_special_offers field. + * @var boolean + */ + protected $is_available_on_special_offers; + /** * The value for the created_at field. * @var string @@ -558,25 +564,14 @@ abstract class CouponVersion implements ActiveRecordInterface } /** - * Get the [serialized_rules_type] column value. + * Get the [serialized_rules] column value. * * @return string */ - public function getSerializedRulesType() + public function getSerializedRules() { - return $this->serialized_rules_type; - } - - /** - * Get the [serialized_rules_content] column value. - * - * @return string - */ - public function getSerializedRulesContent() - { - - return $this->serialized_rules_content; + return $this->serialized_rules; } /** @@ -601,6 +596,28 @@ abstract class CouponVersion implements ActiveRecordInterface return $this->is_removing_postage; } + /** + * Get the [max_usage] column value. + * + * @return int + */ + public function getMaxUsage() + { + + return $this->max_usage; + } + + /** + * Get the [is_available_on_special_offers] column value. + * + * @return boolean + */ + public function getIsAvailableOnSpecialOffers() + { + + return $this->is_available_on_special_offers; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -867,46 +884,25 @@ abstract class CouponVersion implements ActiveRecordInterface } // setExpirationDate() /** - * Set the value of [serialized_rules_type] column. + * Set the value of [serialized_rules] column. * * @param string $v new value * @return \Thelia\Model\CouponVersion The current object (for fluent API support) */ - public function setSerializedRulesType($v) + public function setSerializedRules($v) { if ($v !== null) { $v = (string) $v; } - if ($this->serialized_rules_type !== $v) { - $this->serialized_rules_type = $v; - $this->modifiedColumns[] = CouponVersionTableMap::SERIALIZED_RULES_TYPE; + if ($this->serialized_rules !== $v) { + $this->serialized_rules = $v; + $this->modifiedColumns[] = CouponVersionTableMap::SERIALIZED_RULES; } return $this; - } // setSerializedRulesType() - - /** - * Set the value of [serialized_rules_content] column. - * - * @param string $v new value - * @return \Thelia\Model\CouponVersion The current object (for fluent API support) - */ - public function setSerializedRulesContent($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->serialized_rules_content !== $v) { - $this->serialized_rules_content = $v; - $this->modifiedColumns[] = CouponVersionTableMap::SERIALIZED_RULES_CONTENT; - } - - - return $this; - } // setSerializedRulesContent() + } // setSerializedRules() /** * Set the value of [is_cumulative] column. @@ -950,6 +946,56 @@ abstract class CouponVersion implements ActiveRecordInterface return $this; } // setIsRemovingPostage() + /** + * Set the value of [max_usage] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setMaxUsage($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->max_usage !== $v) { + $this->max_usage = $v; + $this->modifiedColumns[] = CouponVersionTableMap::MAX_USAGE; + } + + + return $this; + } // setMaxUsage() + + /** + * Sets the value of the [is_available_on_special_offers] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setIsAvailableOnSpecialOffers($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_available_on_special_offers !== $v) { + $this->is_available_on_special_offers = $v; + $this->modifiedColumns[] = CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS; + } + + + return $this; + } // setIsAvailableOnSpecialOffers() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -1087,31 +1133,34 @@ abstract class CouponVersion implements ActiveRecordInterface } $this->expiration_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponVersionTableMap::translateFieldName('SerializedRulesType', TableMap::TYPE_PHPNAME, $indexType)]; - $this->serialized_rules_type = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponVersionTableMap::translateFieldName('SerializedRules', TableMap::TYPE_PHPNAME, $indexType)]; + $this->serialized_rules = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponVersionTableMap::translateFieldName('SerializedRulesContent', TableMap::TYPE_PHPNAME, $indexType)]; - $this->serialized_rules_content = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponVersionTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponVersionTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)]; $this->is_cumulative = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponVersionTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponVersionTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)]; $this->is_removing_postage = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CouponVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponVersionTableMap::translateFieldName('MaxUsage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->max_usage = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CouponVersionTableMap::translateFieldName('IsAvailableOnSpecialOffers', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_available_on_special_offers = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CouponVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CouponVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CouponVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CouponVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : CouponVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; $this->version = (null !== $col) ? (int) $col : null; $this->resetModified(); @@ -1121,7 +1170,7 @@ abstract class CouponVersion implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 17; // 17 = CouponVersionTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 18; // 18 = CouponVersionTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\CouponVersion object", 0, $e); @@ -1372,11 +1421,8 @@ abstract class CouponVersion implements ActiveRecordInterface if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) { $modifiedColumns[':p' . $index++] = 'EXPIRATION_DATE'; } - if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES_TYPE)) { - $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES_TYPE'; - } - if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES_CONTENT)) { - $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES_CONTENT'; + if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES)) { + $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES'; } if ($this->isColumnModified(CouponVersionTableMap::IS_CUMULATIVE)) { $modifiedColumns[':p' . $index++] = 'IS_CUMULATIVE'; @@ -1384,6 +1430,12 @@ abstract class CouponVersion implements ActiveRecordInterface if ($this->isColumnModified(CouponVersionTableMap::IS_REMOVING_POSTAGE)) { $modifiedColumns[':p' . $index++] = 'IS_REMOVING_POSTAGE'; } + if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) { + $modifiedColumns[':p' . $index++] = 'MAX_USAGE'; + } + if ($this->isColumnModified(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) { + $modifiedColumns[':p' . $index++] = 'IS_AVAILABLE_ON_SPECIAL_OFFERS'; + } if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1434,11 +1486,8 @@ abstract class CouponVersion implements ActiveRecordInterface case 'EXPIRATION_DATE': $stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case 'SERIALIZED_RULES_TYPE': - $stmt->bindValue($identifier, $this->serialized_rules_type, PDO::PARAM_STR); - break; - case 'SERIALIZED_RULES_CONTENT': - $stmt->bindValue($identifier, $this->serialized_rules_content, PDO::PARAM_STR); + case 'SERIALIZED_RULES': + $stmt->bindValue($identifier, $this->serialized_rules, PDO::PARAM_STR); break; case 'IS_CUMULATIVE': $stmt->bindValue($identifier, $this->is_cumulative, PDO::PARAM_INT); @@ -1446,6 +1495,12 @@ abstract class CouponVersion implements ActiveRecordInterface case 'IS_REMOVING_POSTAGE': $stmt->bindValue($identifier, $this->is_removing_postage, PDO::PARAM_INT); break; + case 'MAX_USAGE': + $stmt->bindValue($identifier, $this->max_usage, PDO::PARAM_INT); + break; + case 'IS_AVAILABLE_ON_SPECIAL_OFFERS': + $stmt->bindValue($identifier, (int) $this->is_available_on_special_offers, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1541,24 +1596,27 @@ abstract class CouponVersion implements ActiveRecordInterface return $this->getExpirationDate(); break; case 10: - return $this->getSerializedRulesType(); + return $this->getSerializedRules(); break; case 11: - return $this->getSerializedRulesContent(); - break; - case 12: return $this->getIsCumulative(); break; - case 13: + case 12: return $this->getIsRemovingPostage(); break; + case 13: + return $this->getMaxUsage(); + break; case 14: - return $this->getCreatedAt(); + return $this->getIsAvailableOnSpecialOffers(); break; case 15: - return $this->getUpdatedAt(); + return $this->getCreatedAt(); break; case 16: + return $this->getUpdatedAt(); + break; + case 17: return $this->getVersion(); break; default: @@ -1600,13 +1658,14 @@ abstract class CouponVersion implements ActiveRecordInterface $keys[7] => $this->getIsUsed(), $keys[8] => $this->getIsEnabled(), $keys[9] => $this->getExpirationDate(), - $keys[10] => $this->getSerializedRulesType(), - $keys[11] => $this->getSerializedRulesContent(), - $keys[12] => $this->getIsCumulative(), - $keys[13] => $this->getIsRemovingPostage(), - $keys[14] => $this->getCreatedAt(), - $keys[15] => $this->getUpdatedAt(), - $keys[16] => $this->getVersion(), + $keys[10] => $this->getSerializedRules(), + $keys[11] => $this->getIsCumulative(), + $keys[12] => $this->getIsRemovingPostage(), + $keys[13] => $this->getMaxUsage(), + $keys[14] => $this->getIsAvailableOnSpecialOffers(), + $keys[15] => $this->getCreatedAt(), + $keys[16] => $this->getUpdatedAt(), + $keys[17] => $this->getVersion(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1683,24 +1742,27 @@ abstract class CouponVersion implements ActiveRecordInterface $this->setExpirationDate($value); break; case 10: - $this->setSerializedRulesType($value); + $this->setSerializedRules($value); break; case 11: - $this->setSerializedRulesContent($value); - break; - case 12: $this->setIsCumulative($value); break; - case 13: + case 12: $this->setIsRemovingPostage($value); break; + case 13: + $this->setMaxUsage($value); + break; case 14: - $this->setCreatedAt($value); + $this->setIsAvailableOnSpecialOffers($value); break; case 15: - $this->setUpdatedAt($value); + $this->setCreatedAt($value); break; case 16: + $this->setUpdatedAt($value); + break; + case 17: $this->setVersion($value); break; } // switch() @@ -1737,13 +1799,14 @@ abstract class CouponVersion implements ActiveRecordInterface if (array_key_exists($keys[7], $arr)) $this->setIsUsed($arr[$keys[7]]); if (array_key_exists($keys[8], $arr)) $this->setIsEnabled($arr[$keys[8]]); if (array_key_exists($keys[9], $arr)) $this->setExpirationDate($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setSerializedRulesType($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setSerializedRulesContent($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setIsCumulative($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setIsRemovingPostage($arr[$keys[13]]); - if (array_key_exists($keys[14], $arr)) $this->setCreatedAt($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setUpdatedAt($arr[$keys[15]]); - if (array_key_exists($keys[16], $arr)) $this->setVersion($arr[$keys[16]]); + if (array_key_exists($keys[10], $arr)) $this->setSerializedRules($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setIsCumulative($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setIsRemovingPostage($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setMaxUsage($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setCreatedAt($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setUpdatedAt($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setVersion($arr[$keys[17]]); } /** @@ -1765,10 +1828,11 @@ abstract class CouponVersion implements ActiveRecordInterface if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) $criteria->add(CouponVersionTableMap::IS_USED, $this->is_used); if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) $criteria->add(CouponVersionTableMap::IS_ENABLED, $this->is_enabled); if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) $criteria->add(CouponVersionTableMap::EXPIRATION_DATE, $this->expiration_date); - if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES_TYPE)) $criteria->add(CouponVersionTableMap::SERIALIZED_RULES_TYPE, $this->serialized_rules_type); - if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES_CONTENT)) $criteria->add(CouponVersionTableMap::SERIALIZED_RULES_CONTENT, $this->serialized_rules_content); + if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES)) $criteria->add(CouponVersionTableMap::SERIALIZED_RULES, $this->serialized_rules); if ($this->isColumnModified(CouponVersionTableMap::IS_CUMULATIVE)) $criteria->add(CouponVersionTableMap::IS_CUMULATIVE, $this->is_cumulative); if ($this->isColumnModified(CouponVersionTableMap::IS_REMOVING_POSTAGE)) $criteria->add(CouponVersionTableMap::IS_REMOVING_POSTAGE, $this->is_removing_postage); + if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) $criteria->add(CouponVersionTableMap::MAX_USAGE, $this->max_usage); + if ($this->isColumnModified(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) $criteria->add(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $this->is_available_on_special_offers); if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) $criteria->add(CouponVersionTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CouponVersionTableMap::UPDATED_AT)) $criteria->add(CouponVersionTableMap::UPDATED_AT, $this->updated_at); if ($this->isColumnModified(CouponVersionTableMap::VERSION)) $criteria->add(CouponVersionTableMap::VERSION, $this->version); @@ -1852,10 +1916,11 @@ abstract class CouponVersion implements ActiveRecordInterface $copyObj->setIsUsed($this->getIsUsed()); $copyObj->setIsEnabled($this->getIsEnabled()); $copyObj->setExpirationDate($this->getExpirationDate()); - $copyObj->setSerializedRulesType($this->getSerializedRulesType()); - $copyObj->setSerializedRulesContent($this->getSerializedRulesContent()); + $copyObj->setSerializedRules($this->getSerializedRules()); $copyObj->setIsCumulative($this->getIsCumulative()); $copyObj->setIsRemovingPostage($this->getIsRemovingPostage()); + $copyObj->setMaxUsage($this->getMaxUsage()); + $copyObj->setIsAvailableOnSpecialOffers($this->getIsAvailableOnSpecialOffers()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); $copyObj->setVersion($this->getVersion()); @@ -1952,10 +2017,11 @@ abstract class CouponVersion implements ActiveRecordInterface $this->is_used = null; $this->is_enabled = null; $this->expiration_date = null; - $this->serialized_rules_type = null; - $this->serialized_rules_content = null; + $this->serialized_rules = null; $this->is_cumulative = null; $this->is_removing_postage = null; + $this->max_usage = null; + $this->is_available_on_special_offers = null; $this->created_at = null; $this->updated_at = null; $this->version = null; diff --git a/core/lib/Thelia/Model/Base/CouponVersionQuery.php b/core/lib/Thelia/Model/Base/CouponVersionQuery.php index 2ea0e23d7..71ce72aee 100644 --- a/core/lib/Thelia/Model/Base/CouponVersionQuery.php +++ b/core/lib/Thelia/Model/Base/CouponVersionQuery.php @@ -31,10 +31,11 @@ use Thelia\Model\Map\CouponVersionTableMap; * @method ChildCouponVersionQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column * @method ChildCouponVersionQuery orderByIsEnabled($order = Criteria::ASC) Order by the is_enabled column * @method ChildCouponVersionQuery orderByExpirationDate($order = Criteria::ASC) Order by the expiration_date column - * @method ChildCouponVersionQuery orderBySerializedRulesType($order = Criteria::ASC) Order by the serialized_rules_type column - * @method ChildCouponVersionQuery orderBySerializedRulesContent($order = Criteria::ASC) Order by the serialized_rules_content column + * @method ChildCouponVersionQuery orderBySerializedRules($order = Criteria::ASC) Order by the serialized_rules column * @method ChildCouponVersionQuery orderByIsCumulative($order = Criteria::ASC) Order by the is_cumulative column * @method ChildCouponVersionQuery orderByIsRemovingPostage($order = Criteria::ASC) Order by the is_removing_postage column + * @method ChildCouponVersionQuery orderByMaxUsage($order = Criteria::ASC) Order by the max_usage column + * @method ChildCouponVersionQuery orderByIsAvailableOnSpecialOffers($order = Criteria::ASC) Order by the is_available_on_special_offers column * @method ChildCouponVersionQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCouponVersionQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @method ChildCouponVersionQuery orderByVersion($order = Criteria::ASC) Order by the version column @@ -49,10 +50,11 @@ use Thelia\Model\Map\CouponVersionTableMap; * @method ChildCouponVersionQuery groupByIsUsed() Group by the is_used column * @method ChildCouponVersionQuery groupByIsEnabled() Group by the is_enabled column * @method ChildCouponVersionQuery groupByExpirationDate() Group by the expiration_date column - * @method ChildCouponVersionQuery groupBySerializedRulesType() Group by the serialized_rules_type column - * @method ChildCouponVersionQuery groupBySerializedRulesContent() Group by the serialized_rules_content column + * @method ChildCouponVersionQuery groupBySerializedRules() Group by the serialized_rules column * @method ChildCouponVersionQuery groupByIsCumulative() Group by the is_cumulative column * @method ChildCouponVersionQuery groupByIsRemovingPostage() Group by the is_removing_postage column + * @method ChildCouponVersionQuery groupByMaxUsage() Group by the max_usage column + * @method ChildCouponVersionQuery groupByIsAvailableOnSpecialOffers() Group by the is_available_on_special_offers column * @method ChildCouponVersionQuery groupByCreatedAt() Group by the created_at column * @method ChildCouponVersionQuery groupByUpdatedAt() Group by the updated_at column * @method ChildCouponVersionQuery groupByVersion() Group by the version column @@ -78,10 +80,11 @@ use Thelia\Model\Map\CouponVersionTableMap; * @method ChildCouponVersion findOneByIsUsed(int $is_used) Return the first ChildCouponVersion filtered by the is_used column * @method ChildCouponVersion findOneByIsEnabled(int $is_enabled) Return the first ChildCouponVersion filtered by the is_enabled column * @method ChildCouponVersion findOneByExpirationDate(string $expiration_date) Return the first ChildCouponVersion filtered by the expiration_date column - * @method ChildCouponVersion findOneBySerializedRulesType(string $serialized_rules_type) Return the first ChildCouponVersion filtered by the serialized_rules_type column - * @method ChildCouponVersion findOneBySerializedRulesContent(string $serialized_rules_content) Return the first ChildCouponVersion filtered by the serialized_rules_content column + * @method ChildCouponVersion findOneBySerializedRules(string $serialized_rules) Return the first ChildCouponVersion filtered by the serialized_rules column * @method ChildCouponVersion findOneByIsCumulative(int $is_cumulative) Return the first ChildCouponVersion filtered by the is_cumulative column * @method ChildCouponVersion findOneByIsRemovingPostage(int $is_removing_postage) Return the first ChildCouponVersion filtered by the is_removing_postage column + * @method ChildCouponVersion findOneByMaxUsage(int $max_usage) Return the first ChildCouponVersion filtered by the max_usage column + * @method ChildCouponVersion findOneByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return the first ChildCouponVersion filtered by the is_available_on_special_offers column * @method ChildCouponVersion findOneByCreatedAt(string $created_at) Return the first ChildCouponVersion filtered by the created_at column * @method ChildCouponVersion findOneByUpdatedAt(string $updated_at) Return the first ChildCouponVersion filtered by the updated_at column * @method ChildCouponVersion findOneByVersion(int $version) Return the first ChildCouponVersion filtered by the version column @@ -96,10 +99,11 @@ use Thelia\Model\Map\CouponVersionTableMap; * @method array findByIsUsed(int $is_used) Return ChildCouponVersion objects filtered by the is_used column * @method array findByIsEnabled(int $is_enabled) Return ChildCouponVersion objects filtered by the is_enabled column * @method array findByExpirationDate(string $expiration_date) Return ChildCouponVersion objects filtered by the expiration_date column - * @method array findBySerializedRulesType(string $serialized_rules_type) Return ChildCouponVersion objects filtered by the serialized_rules_type column - * @method array findBySerializedRulesContent(string $serialized_rules_content) Return ChildCouponVersion objects filtered by the serialized_rules_content column + * @method array findBySerializedRules(string $serialized_rules) Return ChildCouponVersion objects filtered by the serialized_rules column * @method array findByIsCumulative(int $is_cumulative) Return ChildCouponVersion objects filtered by the is_cumulative column * @method array findByIsRemovingPostage(int $is_removing_postage) Return ChildCouponVersion objects filtered by the is_removing_postage column + * @method array findByMaxUsage(int $max_usage) Return ChildCouponVersion objects filtered by the max_usage column + * @method array findByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return ChildCouponVersion objects filtered by the is_available_on_special_offers column * @method array findByCreatedAt(string $created_at) Return ChildCouponVersion objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCouponVersion objects filtered by the updated_at column * @method array findByVersion(int $version) Return ChildCouponVersion objects filtered by the version column @@ -191,7 +195,7 @@ abstract class CouponVersionQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, AMOUNT, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES_TYPE, SERIALIZED_RULES_CONTENT, IS_CUMULATIVE, IS_REMOVING_POSTAGE, CREATED_AT, UPDATED_AT, VERSION FROM coupon_version WHERE ID = :p0 AND VERSION = :p1'; + $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, AMOUNT, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES, IS_CUMULATIVE, IS_REMOVING_POSTAGE, MAX_USAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, CREATED_AT, UPDATED_AT, VERSION FROM coupon_version WHERE ID = :p0 AND VERSION = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -647,61 +651,32 @@ abstract class CouponVersionQuery extends ModelCriteria } /** - * Filter the query on the serialized_rules_type column + * Filter the query on the serialized_rules column * * Example usage: * - * $query->filterBySerializedRulesType('fooValue'); // WHERE serialized_rules_type = 'fooValue' - * $query->filterBySerializedRulesType('%fooValue%'); // WHERE serialized_rules_type LIKE '%fooValue%' + * $query->filterBySerializedRules('fooValue'); // WHERE serialized_rules = 'fooValue' + * $query->filterBySerializedRules('%fooValue%'); // WHERE serialized_rules LIKE '%fooValue%' * * - * @param string $serializedRulesType The value to use as filter. + * @param string $serializedRules The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCouponVersionQuery The current query, for fluid interface */ - public function filterBySerializedRulesType($serializedRulesType = null, $comparison = null) + public function filterBySerializedRules($serializedRules = null, $comparison = null) { if (null === $comparison) { - if (is_array($serializedRulesType)) { + if (is_array($serializedRules)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $serializedRulesType)) { - $serializedRulesType = str_replace('*', '%', $serializedRulesType); + } elseif (preg_match('/[\%\*]/', $serializedRules)) { + $serializedRules = str_replace('*', '%', $serializedRules); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(CouponVersionTableMap::SERIALIZED_RULES_TYPE, $serializedRulesType, $comparison); - } - - /** - * Filter the query on the serialized_rules_content column - * - * Example usage: - * - * $query->filterBySerializedRulesContent('fooValue'); // WHERE serialized_rules_content = 'fooValue' - * $query->filterBySerializedRulesContent('%fooValue%'); // WHERE serialized_rules_content LIKE '%fooValue%' - * - * - * @param string $serializedRulesContent The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCouponVersionQuery The current query, for fluid interface - */ - public function filterBySerializedRulesContent($serializedRulesContent = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($serializedRulesContent)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $serializedRulesContent)) { - $serializedRulesContent = str_replace('*', '%', $serializedRulesContent); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CouponVersionTableMap::SERIALIZED_RULES_CONTENT, $serializedRulesContent, $comparison); + return $this->addUsingAlias(CouponVersionTableMap::SERIALIZED_RULES, $serializedRules, $comparison); } /** @@ -786,6 +761,74 @@ abstract class CouponVersionQuery extends ModelCriteria return $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison); } + /** + * Filter the query on the max_usage column + * + * Example usage: + * + * $query->filterByMaxUsage(1234); // WHERE max_usage = 1234 + * $query->filterByMaxUsage(array(12, 34)); // WHERE max_usage IN (12, 34) + * $query->filterByMaxUsage(array('min' => 12)); // WHERE max_usage > 12 + * + * + * @param mixed $maxUsage The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByMaxUsage($maxUsage = null, $comparison = null) + { + if (is_array($maxUsage)) { + $useMinMax = false; + if (isset($maxUsage['min'])) { + $this->addUsingAlias(CouponVersionTableMap::MAX_USAGE, $maxUsage['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($maxUsage['max'])) { + $this->addUsingAlias(CouponVersionTableMap::MAX_USAGE, $maxUsage['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::MAX_USAGE, $maxUsage, $comparison); + } + + /** + * Filter the query on the is_available_on_special_offers column + * + * Example usage: + * + * $query->filterByIsAvailableOnSpecialOffers(true); // WHERE is_available_on_special_offers = true + * $query->filterByIsAvailableOnSpecialOffers('yes'); // WHERE is_available_on_special_offers = true + * + * + * @param boolean|string $isAvailableOnSpecialOffers The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers = null, $comparison = null) + { + if (is_string($isAvailableOnSpecialOffers)) { + $is_available_on_special_offers = in_array(strtolower($isAvailableOnSpecialOffers), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $isAvailableOnSpecialOffers, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Map/CouponTableMap.php b/core/lib/Thelia/Model/Map/CouponTableMap.php index dfc987b21..d3ba620bf 100644 --- a/core/lib/Thelia/Model/Map/CouponTableMap.php +++ b/core/lib/Thelia/Model/Map/CouponTableMap.php @@ -57,7 +57,7 @@ class CouponTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 17; + const NUM_COLUMNS = 18; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CouponTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 17; + const NUM_HYDRATE_COLUMNS = 18; /** * the column name for the ID field @@ -120,14 +120,9 @@ class CouponTableMap extends TableMap const EXPIRATION_DATE = 'coupon.EXPIRATION_DATE'; /** - * the column name for the SERIALIZED_RULES_TYPE field + * the column name for the SERIALIZED_RULES field */ - const SERIALIZED_RULES_TYPE = 'coupon.SERIALIZED_RULES_TYPE'; - - /** - * the column name for the SERIALIZED_RULES_CONTENT field - */ - const SERIALIZED_RULES_CONTENT = 'coupon.SERIALIZED_RULES_CONTENT'; + const SERIALIZED_RULES = 'coupon.SERIALIZED_RULES'; /** * the column name for the IS_CUMULATIVE field @@ -139,6 +134,16 @@ class CouponTableMap extends TableMap */ const IS_REMOVING_POSTAGE = 'coupon.IS_REMOVING_POSTAGE'; + /** + * the column name for the MAX_USAGE field + */ + const MAX_USAGE = 'coupon.MAX_USAGE'; + + /** + * the column name for the IS_AVAILABLE_ON_SPECIAL_OFFERS field + */ + const IS_AVAILABLE_ON_SPECIAL_OFFERS = 'coupon.IS_AVAILABLE_ON_SPECIAL_OFFERS'; + /** * the column name for the CREATED_AT field */ @@ -175,12 +180,12 @@ class CouponTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Amount', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRulesType', 'SerializedRulesContent', 'IsCumulative', 'IsRemovingPostage', 'CreatedAt', 'UpdatedAt', 'Version', ), - self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'amount', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRulesType', 'serializedRulesContent', 'isCumulative', 'isRemovingPostage', 'createdAt', 'updatedAt', 'version', ), - self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::TITLE, CouponTableMap::SHORT_DESCRIPTION, CouponTableMap::DESCRIPTION, CouponTableMap::AMOUNT, CouponTableMap::IS_USED, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::SERIALIZED_RULES_TYPE, CouponTableMap::SERIALIZED_RULES_CONTENT, CouponTableMap::IS_CUMULATIVE, CouponTableMap::IS_REMOVING_POSTAGE, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ), - self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'AMOUNT', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES_TYPE', 'SERIALIZED_RULES_CONTENT', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), - self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'amount', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules_type', 'serialized_rules_content', 'is_cumulative', 'is_removing_postage', 'created_at', 'updated_at', 'version', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ) + self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Amount', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'IsCumulative', 'IsRemovingPostage', 'MaxUsage', 'IsAvailableOnSpecialOffers', 'CreatedAt', 'UpdatedAt', 'Version', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'amount', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'isCumulative', 'isRemovingPostage', 'maxUsage', 'isAvailableOnSpecialOffers', 'createdAt', 'updatedAt', 'version', ), + self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::TITLE, CouponTableMap::SHORT_DESCRIPTION, CouponTableMap::DESCRIPTION, CouponTableMap::AMOUNT, CouponTableMap::IS_USED, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::SERIALIZED_RULES, CouponTableMap::IS_CUMULATIVE, CouponTableMap::IS_REMOVING_POSTAGE, CouponTableMap::MAX_USAGE, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'AMOUNT', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'MAX_USAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), + self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'amount', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'is_cumulative', 'is_removing_postage', 'max_usage', 'is_available_on_special_offers', 'created_at', 'updated_at', 'version', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); /** @@ -190,12 +195,12 @@ class CouponTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Amount' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRulesType' => 10, 'SerializedRulesContent' => 11, 'IsCumulative' => 12, 'IsRemovingPostage' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, 'Version' => 16, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'amount' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRulesType' => 10, 'serializedRulesContent' => 11, 'isCumulative' => 12, 'isRemovingPostage' => 13, 'createdAt' => 14, 'updatedAt' => 15, 'version' => 16, ), - self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::TITLE => 3, CouponTableMap::SHORT_DESCRIPTION => 4, CouponTableMap::DESCRIPTION => 5, CouponTableMap::AMOUNT => 6, CouponTableMap::IS_USED => 7, CouponTableMap::IS_ENABLED => 8, CouponTableMap::EXPIRATION_DATE => 9, CouponTableMap::SERIALIZED_RULES_TYPE => 10, CouponTableMap::SERIALIZED_RULES_CONTENT => 11, CouponTableMap::IS_CUMULATIVE => 12, CouponTableMap::IS_REMOVING_POSTAGE => 13, CouponTableMap::CREATED_AT => 14, CouponTableMap::UPDATED_AT => 15, CouponTableMap::VERSION => 16, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'AMOUNT' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES_TYPE' => 10, 'SERIALIZED_RULES_CONTENT' => 11, 'IS_CUMULATIVE' => 12, 'IS_REMOVING_POSTAGE' => 13, 'CREATED_AT' => 14, 'UPDATED_AT' => 15, 'VERSION' => 16, ), - self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'amount' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules_type' => 10, 'serialized_rules_content' => 11, 'is_cumulative' => 12, 'is_removing_postage' => 13, 'created_at' => 14, 'updated_at' => 15, 'version' => 16, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Amount' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRules' => 10, 'IsCumulative' => 11, 'IsRemovingPostage' => 12, 'MaxUsage' => 13, 'IsAvailableOnSpecialOffers' => 14, 'CreatedAt' => 15, 'UpdatedAt' => 16, 'Version' => 17, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'amount' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRules' => 10, 'isCumulative' => 11, 'isRemovingPostage' => 12, 'maxUsage' => 13, 'isAvailableOnSpecialOffers' => 14, 'createdAt' => 15, 'updatedAt' => 16, 'version' => 17, ), + self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::TITLE => 3, CouponTableMap::SHORT_DESCRIPTION => 4, CouponTableMap::DESCRIPTION => 5, CouponTableMap::AMOUNT => 6, CouponTableMap::IS_USED => 7, CouponTableMap::IS_ENABLED => 8, CouponTableMap::EXPIRATION_DATE => 9, CouponTableMap::SERIALIZED_RULES => 10, CouponTableMap::IS_CUMULATIVE => 11, CouponTableMap::IS_REMOVING_POSTAGE => 12, CouponTableMap::MAX_USAGE => 13, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 14, CouponTableMap::CREATED_AT => 15, CouponTableMap::UPDATED_AT => 16, CouponTableMap::VERSION => 17, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'AMOUNT' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES' => 10, 'IS_CUMULATIVE' => 11, 'IS_REMOVING_POSTAGE' => 12, 'MAX_USAGE' => 13, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 14, 'CREATED_AT' => 15, 'UPDATED_AT' => 16, 'VERSION' => 17, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'amount' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules' => 10, 'is_cumulative' => 11, 'is_removing_postage' => 12, 'max_usage' => 13, 'is_available_on_special_offers' => 14, 'created_at' => 15, 'updated_at' => 16, 'version' => 17, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); /** @@ -224,10 +229,11 @@ class CouponTableMap extends TableMap $this->addColumn('IS_USED', 'IsUsed', 'TINYINT', true, null, null); $this->addColumn('IS_ENABLED', 'IsEnabled', 'TINYINT', true, null, null); $this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null); - $this->addColumn('SERIALIZED_RULES_TYPE', 'SerializedRulesType', 'LONGVARCHAR', true, null, null); - $this->addColumn('SERIALIZED_RULES_CONTENT', 'SerializedRulesContent', 'LONGVARCHAR', true, null, null); + $this->addColumn('SERIALIZED_RULES', 'SerializedRules', 'LONGVARCHAR', true, null, null); $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'TINYINT', true, null, null); $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'TINYINT', true, null, null); + $this->addColumn('MAX_USAGE', 'MaxUsage', 'INTEGER', true, null, null); + $this->addColumn('IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IsAvailableOnSpecialOffers', 'BOOLEAN', true, 1, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0); @@ -416,10 +422,11 @@ class CouponTableMap extends TableMap $criteria->addSelectColumn(CouponTableMap::IS_USED); $criteria->addSelectColumn(CouponTableMap::IS_ENABLED); $criteria->addSelectColumn(CouponTableMap::EXPIRATION_DATE); - $criteria->addSelectColumn(CouponTableMap::SERIALIZED_RULES_TYPE); - $criteria->addSelectColumn(CouponTableMap::SERIALIZED_RULES_CONTENT); + $criteria->addSelectColumn(CouponTableMap::SERIALIZED_RULES); $criteria->addSelectColumn(CouponTableMap::IS_CUMULATIVE); $criteria->addSelectColumn(CouponTableMap::IS_REMOVING_POSTAGE); + $criteria->addSelectColumn(CouponTableMap::MAX_USAGE); + $criteria->addSelectColumn(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS); $criteria->addSelectColumn(CouponTableMap::CREATED_AT); $criteria->addSelectColumn(CouponTableMap::UPDATED_AT); $criteria->addSelectColumn(CouponTableMap::VERSION); @@ -434,10 +441,11 @@ class CouponTableMap extends TableMap $criteria->addSelectColumn($alias . '.IS_USED'); $criteria->addSelectColumn($alias . '.IS_ENABLED'); $criteria->addSelectColumn($alias . '.EXPIRATION_DATE'); - $criteria->addSelectColumn($alias . '.SERIALIZED_RULES_TYPE'); - $criteria->addSelectColumn($alias . '.SERIALIZED_RULES_CONTENT'); + $criteria->addSelectColumn($alias . '.SERIALIZED_RULES'); $criteria->addSelectColumn($alias . '.IS_CUMULATIVE'); $criteria->addSelectColumn($alias . '.IS_REMOVING_POSTAGE'); + $criteria->addSelectColumn($alias . '.MAX_USAGE'); + $criteria->addSelectColumn($alias . '.IS_AVAILABLE_ON_SPECIAL_OFFERS'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); $criteria->addSelectColumn($alias . '.VERSION'); diff --git a/core/lib/Thelia/Model/Map/CouponVersionTableMap.php b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php index 68ece7a0f..9db387a86 100644 --- a/core/lib/Thelia/Model/Map/CouponVersionTableMap.php +++ b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php @@ -57,7 +57,7 @@ class CouponVersionTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 17; + const NUM_COLUMNS = 18; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CouponVersionTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 17; + const NUM_HYDRATE_COLUMNS = 18; /** * the column name for the ID field @@ -120,14 +120,9 @@ class CouponVersionTableMap extends TableMap const EXPIRATION_DATE = 'coupon_version.EXPIRATION_DATE'; /** - * the column name for the SERIALIZED_RULES_TYPE field + * the column name for the SERIALIZED_RULES field */ - const SERIALIZED_RULES_TYPE = 'coupon_version.SERIALIZED_RULES_TYPE'; - - /** - * the column name for the SERIALIZED_RULES_CONTENT field - */ - const SERIALIZED_RULES_CONTENT = 'coupon_version.SERIALIZED_RULES_CONTENT'; + const SERIALIZED_RULES = 'coupon_version.SERIALIZED_RULES'; /** * the column name for the IS_CUMULATIVE field @@ -139,6 +134,16 @@ class CouponVersionTableMap extends TableMap */ const IS_REMOVING_POSTAGE = 'coupon_version.IS_REMOVING_POSTAGE'; + /** + * the column name for the MAX_USAGE field + */ + const MAX_USAGE = 'coupon_version.MAX_USAGE'; + + /** + * the column name for the IS_AVAILABLE_ON_SPECIAL_OFFERS field + */ + const IS_AVAILABLE_ON_SPECIAL_OFFERS = 'coupon_version.IS_AVAILABLE_ON_SPECIAL_OFFERS'; + /** * the column name for the CREATED_AT field */ @@ -166,12 +171,12 @@ class CouponVersionTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Amount', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRulesType', 'SerializedRulesContent', 'IsCumulative', 'IsRemovingPostage', 'CreatedAt', 'UpdatedAt', 'Version', ), - self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'amount', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRulesType', 'serializedRulesContent', 'isCumulative', 'isRemovingPostage', 'createdAt', 'updatedAt', 'version', ), - self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::TITLE, CouponVersionTableMap::SHORT_DESCRIPTION, CouponVersionTableMap::DESCRIPTION, CouponVersionTableMap::AMOUNT, CouponVersionTableMap::IS_USED, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::SERIALIZED_RULES_TYPE, CouponVersionTableMap::SERIALIZED_RULES_CONTENT, CouponVersionTableMap::IS_CUMULATIVE, CouponVersionTableMap::IS_REMOVING_POSTAGE, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ), - self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'AMOUNT', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES_TYPE', 'SERIALIZED_RULES_CONTENT', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), - self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'amount', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules_type', 'serialized_rules_content', 'is_cumulative', 'is_removing_postage', 'created_at', 'updated_at', 'version', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ) + self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Amount', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'IsCumulative', 'IsRemovingPostage', 'MaxUsage', 'IsAvailableOnSpecialOffers', 'CreatedAt', 'UpdatedAt', 'Version', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'amount', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'isCumulative', 'isRemovingPostage', 'maxUsage', 'isAvailableOnSpecialOffers', 'createdAt', 'updatedAt', 'version', ), + self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::TITLE, CouponVersionTableMap::SHORT_DESCRIPTION, CouponVersionTableMap::DESCRIPTION, CouponVersionTableMap::AMOUNT, CouponVersionTableMap::IS_USED, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::SERIALIZED_RULES, CouponVersionTableMap::IS_CUMULATIVE, CouponVersionTableMap::IS_REMOVING_POSTAGE, CouponVersionTableMap::MAX_USAGE, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'AMOUNT', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'MAX_USAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), + self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'amount', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'is_cumulative', 'is_removing_postage', 'max_usage', 'is_available_on_special_offers', 'created_at', 'updated_at', 'version', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); /** @@ -181,12 +186,12 @@ class CouponVersionTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Amount' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRulesType' => 10, 'SerializedRulesContent' => 11, 'IsCumulative' => 12, 'IsRemovingPostage' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, 'Version' => 16, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'amount' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRulesType' => 10, 'serializedRulesContent' => 11, 'isCumulative' => 12, 'isRemovingPostage' => 13, 'createdAt' => 14, 'updatedAt' => 15, 'version' => 16, ), - self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::TITLE => 3, CouponVersionTableMap::SHORT_DESCRIPTION => 4, CouponVersionTableMap::DESCRIPTION => 5, CouponVersionTableMap::AMOUNT => 6, CouponVersionTableMap::IS_USED => 7, CouponVersionTableMap::IS_ENABLED => 8, CouponVersionTableMap::EXPIRATION_DATE => 9, CouponVersionTableMap::SERIALIZED_RULES_TYPE => 10, CouponVersionTableMap::SERIALIZED_RULES_CONTENT => 11, CouponVersionTableMap::IS_CUMULATIVE => 12, CouponVersionTableMap::IS_REMOVING_POSTAGE => 13, CouponVersionTableMap::CREATED_AT => 14, CouponVersionTableMap::UPDATED_AT => 15, CouponVersionTableMap::VERSION => 16, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'AMOUNT' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES_TYPE' => 10, 'SERIALIZED_RULES_CONTENT' => 11, 'IS_CUMULATIVE' => 12, 'IS_REMOVING_POSTAGE' => 13, 'CREATED_AT' => 14, 'UPDATED_AT' => 15, 'VERSION' => 16, ), - self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'amount' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules_type' => 10, 'serialized_rules_content' => 11, 'is_cumulative' => 12, 'is_removing_postage' => 13, 'created_at' => 14, 'updated_at' => 15, 'version' => 16, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Amount' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRules' => 10, 'IsCumulative' => 11, 'IsRemovingPostage' => 12, 'MaxUsage' => 13, 'IsAvailableOnSpecialOffers' => 14, 'CreatedAt' => 15, 'UpdatedAt' => 16, 'Version' => 17, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'amount' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRules' => 10, 'isCumulative' => 11, 'isRemovingPostage' => 12, 'maxUsage' => 13, 'isAvailableOnSpecialOffers' => 14, 'createdAt' => 15, 'updatedAt' => 16, 'version' => 17, ), + self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::TITLE => 3, CouponVersionTableMap::SHORT_DESCRIPTION => 4, CouponVersionTableMap::DESCRIPTION => 5, CouponVersionTableMap::AMOUNT => 6, CouponVersionTableMap::IS_USED => 7, CouponVersionTableMap::IS_ENABLED => 8, CouponVersionTableMap::EXPIRATION_DATE => 9, CouponVersionTableMap::SERIALIZED_RULES => 10, CouponVersionTableMap::IS_CUMULATIVE => 11, CouponVersionTableMap::IS_REMOVING_POSTAGE => 12, CouponVersionTableMap::MAX_USAGE => 13, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 14, CouponVersionTableMap::CREATED_AT => 15, CouponVersionTableMap::UPDATED_AT => 16, CouponVersionTableMap::VERSION => 17, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'AMOUNT' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES' => 10, 'IS_CUMULATIVE' => 11, 'IS_REMOVING_POSTAGE' => 12, 'MAX_USAGE' => 13, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 14, 'CREATED_AT' => 15, 'UPDATED_AT' => 16, 'VERSION' => 17, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'amount' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules' => 10, 'is_cumulative' => 11, 'is_removing_postage' => 12, 'max_usage' => 13, 'is_available_on_special_offers' => 14, 'created_at' => 15, 'updated_at' => 16, 'version' => 17, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); /** @@ -215,10 +220,11 @@ class CouponVersionTableMap extends TableMap $this->addColumn('IS_USED', 'IsUsed', 'TINYINT', true, null, null); $this->addColumn('IS_ENABLED', 'IsEnabled', 'TINYINT', true, null, null); $this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null); - $this->addColumn('SERIALIZED_RULES_TYPE', 'SerializedRulesType', 'LONGVARCHAR', true, null, null); - $this->addColumn('SERIALIZED_RULES_CONTENT', 'SerializedRulesContent', 'LONGVARCHAR', true, null, null); + $this->addColumn('SERIALIZED_RULES', 'SerializedRules', 'LONGVARCHAR', true, null, null); $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'TINYINT', true, null, null); $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'TINYINT', true, null, null); + $this->addColumn('MAX_USAGE', 'MaxUsage', 'INTEGER', true, null, null); + $this->addColumn('IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IsAvailableOnSpecialOffers', 'BOOLEAN', true, 1, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0); @@ -299,11 +305,11 @@ class CouponVersionTableMap extends TableMap public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { // If the PK cannot be derived from the row, return NULL. - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 16 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 17 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { return null; } - return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 16 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 17 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); } /** @@ -429,10 +435,11 @@ class CouponVersionTableMap extends TableMap $criteria->addSelectColumn(CouponVersionTableMap::IS_USED); $criteria->addSelectColumn(CouponVersionTableMap::IS_ENABLED); $criteria->addSelectColumn(CouponVersionTableMap::EXPIRATION_DATE); - $criteria->addSelectColumn(CouponVersionTableMap::SERIALIZED_RULES_TYPE); - $criteria->addSelectColumn(CouponVersionTableMap::SERIALIZED_RULES_CONTENT); + $criteria->addSelectColumn(CouponVersionTableMap::SERIALIZED_RULES); $criteria->addSelectColumn(CouponVersionTableMap::IS_CUMULATIVE); $criteria->addSelectColumn(CouponVersionTableMap::IS_REMOVING_POSTAGE); + $criteria->addSelectColumn(CouponVersionTableMap::MAX_USAGE); + $criteria->addSelectColumn(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS); $criteria->addSelectColumn(CouponVersionTableMap::CREATED_AT); $criteria->addSelectColumn(CouponVersionTableMap::UPDATED_AT); $criteria->addSelectColumn(CouponVersionTableMap::VERSION); @@ -447,10 +454,11 @@ class CouponVersionTableMap extends TableMap $criteria->addSelectColumn($alias . '.IS_USED'); $criteria->addSelectColumn($alias . '.IS_ENABLED'); $criteria->addSelectColumn($alias . '.EXPIRATION_DATE'); - $criteria->addSelectColumn($alias . '.SERIALIZED_RULES_TYPE'); - $criteria->addSelectColumn($alias . '.SERIALIZED_RULES_CONTENT'); + $criteria->addSelectColumn($alias . '.SERIALIZED_RULES'); $criteria->addSelectColumn($alias . '.IS_CUMULATIVE'); $criteria->addSelectColumn($alias . '.IS_REMOVING_POSTAGE'); + $criteria->addSelectColumn($alias . '.MAX_USAGE'); + $criteria->addSelectColumn($alias . '.IS_AVAILABLE_ON_SPECIAL_OFFERS'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); $criteria->addSelectColumn($alias . '.VERSION'); diff --git a/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php b/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php index 932dba9fc..78fd5e74f 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php @@ -28,7 +28,7 @@ namespace Thelia\Coupon; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test CouponBaseAdapter Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index 465754cd3..ed3331f87 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -23,12 +23,20 @@ namespace Thelia\Coupon; +use Thelia\Coupon\Parameter\PriceParam; +use Thelia\Coupon\Parameter\RuleValidator; +use Thelia\Coupon\Rule\AvailableForTotalAmount; +use Thelia\Coupon\Rule\CouponRuleInterface; +use Thelia\Coupon\Rule\Operators; +use Thelia\Exception\CouponExpiredException; +use Thelia\Model\Coupon; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test CouponFactory Class * * @package Coupon * @author Guillaume MOREL @@ -36,10 +44,89 @@ namespace Thelia\Coupon; */ class CouponFactoryTest extends \PHPUnit_Framework_TestCase { + + CONST VALID_SHORT_DESCRIPTION = 'Coupon for Christmas removing 10€ if your total checkout is more than 40€'; + CONST VALID_DESCRIPTION = '

    Lorem ipsum dolor sit amet

    Consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla. + +Donec rhoncus leo mauris, id porttitor ante luctus tempus. + +Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla. + +Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros. + +Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non. + +Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'; + /** - * @var CouponFactory + * Generate valid CouponInterface + * + * @param $code + * @param $type + * @param $title + * @param $shortDescription + * @param $description + * @param $amount + * @param $isUsed + * @param $isEnabled + * @param $expirationDate + * @param $rules + * @param $isCumulative + * @param $isRemovingPostage + * + * @return CouponInterface */ - protected $object; + public function generateValidCoupon( + $code = 'XMAS1', + $type = '\Thelia\Coupon\Type\RemoveXAmount', + $title = 'Christmas coupon', + $shortDescription = self::VALID_SHORT_DESCRIPTION, + $description = self::VALID_DESCRIPTION, + $amount = 10.00, + $isUsed = 1, + $isEnabled = 1, + $expirationDate = null, + $rules = null, + $isCumulative = 1, + $isRemovingPostage = 0 + ) { + $coupon = new Coupon(); + $coupon->setCode($code); + $coupon->setType($type); + $coupon->setTitle($title); + $coupon->setShortDescription($shortDescription); + $coupon->setDescription($description); + $coupon->setAmount($amount); + $coupon->setIsUsed($isUsed); + $coupon->setIsEnabled($isEnabled); + + if ($expirationDate === null) { + $date = new \DateTime(); + $coupon->setExpirationDate( + $date->setTimestamp(strtotime("today + 2 months")) + ); + } + + if ($rules === null) { + $rules = $this->generateValidRules(); + } + + $couponFactory = new CouponFactory(new CouponBaseAdapter()); + $serializedData = $couponFactory->convertRulesInstancesIntoSerialized( + $rules + ); + + $coupon->setSerializedRulesType($serializedData['rulesType']); + $coupon->setSerializedRulesContent($serializedData['rulesContent']); + + $coupon->setIsCumulative($isCumulative); + $coupon->setIsRemovingPostage($isRemovingPostage); + + return $coupon; + } + /** * Sets up the fixture, for example, opens a network connection. @@ -47,7 +134,145 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->object = new CouponFactory; + } + + + + /** + * Fake CouponQuery->findByCode + * + * @param string $code + * @param string $type + * @param string $title + * @param string $shortDescription + * @param string $description + * @param float $amount + * @param int $isUsed + * @param int $isEnabled + * @param null $expirationDate + * @param null $rules + * @param int $isCumulative + * @param int $isRemovingPostage + * @return Coupon + */ + public function generateCouponModelMock( + $code, + $type, + $title, + $shortDescription, + $description, + $amount, + $isUsed, + $isEnabled, + $expirationDate, + $rules, + $isCumulative, + $isRemovingPostage + ) { + $coupon = $this->generateValidCoupon( + $code, + $type, + $title, + $shortDescription, + $description, + $amount, + $isUsed, + $isEnabled, + $expirationDate, + $rules, + $isCumulative, + $isRemovingPostage + ); + + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->getMock( + 'Thelia\Coupon\CouponBaseAdapter', + array('findOneCouponByCode'), + array() + ); + $stubCouponBaseAdapter->expects($this->any()) + ->method('findOneCouponByCode') + ->will($this->returnValue($coupon)); + + return $stubCouponBaseAdapter; + } + + + + /** + * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode + * @expectedException Thelia\Exception\CouponExpiredException + */ + public function testBuildCouponFromCodeExpiredDateBefore() + { + $date = new \DateTime(); + $date->setTimestamp(strtotime("today - 2 months")); + + /** @var CouponAdapterInterface $mockAdapter */ + $mockAdapter = $this->generateCouponModelMock(null, null, null, null, null, null, null, null, $date); + $couponFactory = new CouponFactory($mockAdapter); + $coupon = $couponFactory->buildCouponFromCode('XMAS1'); + } + + /** + * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode + * @expectedException Thelia\Exception\CouponExpiredException + */ + public function testBuildCouponFromCodeExpiredDateEquals() + { + $date = new \DateTime(); + + /** @var CouponAdapterInterface $mockAdapter */ + $mockAdapter = $this->generateCouponModelMock(null, null, null, null, null, null, null, null, $date); + $couponFactory = new CouponFactory($mockAdapter); + $coupon = $couponFactory->buildCouponFromCode('XMAS1'); + } + + /** + * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode + */ + public function testBuildCouponFromCode() + { + /** @var CouponAdapterInterface $mockAdapter */ + $mockAdapter = $this->generateCouponModelMock(); + $couponFactory = new CouponFactory($mockAdapter); + $coupon = $couponFactory->buildCouponFromCode('XMAS1'); + + $CouponManager = new CouponManager($mockAdapter) + } + + /** + * Generate valid CouponRuleInterfaces + * + * @return array Array of CouponRuleInterface + */ + protected function generateValidRules() + { + $rule1 = new AvailableForTotalAmount( + array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + new PriceParam( + 40.00, + 'EUR' + ) + ) + ) + ); + $rule2 = new AvailableForTotalAmount( + array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::INFERIOR, + new PriceParam( + 400.00, + 'EUR' + ) + ) + ) + ); + $rules = array($rule1, $rule2); + + return $rules; } /** @@ -57,16 +282,4 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase protected function tearDown() { } - - /** - * @covers Thelia\Coupon\CouponFactory::buildCouponFromId - * @todo Implement testBuildCouponFromId(). - */ - public function testBuildCouponFromId() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } } diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index c7d2233f4..9234642c9 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -23,12 +23,20 @@ namespace Thelia\Coupon; +use Thelia\Coupon\Parameter\PriceParam; +use Thelia\Coupon\Parameter\RuleValidator; +use Thelia\Coupon\Rule\AvailableForTotalAmount; +use Thelia\Coupon\Rule\Operators; +use Thelia\Coupon\Type\RemoveXAmount; +use Thelia\Model\Coupon; +use Thelia\Tools\PhpUnitUtils; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test CouponManager Class * * @package Coupon * @author Guillaume MOREL @@ -36,10 +44,21 @@ namespace Thelia\Coupon; */ class CouponManagerTest extends \PHPUnit_Framework_TestCase { - /** - * @var CouponManager - */ - protected $object; + + CONST VALID_SHORT_DESCRIPTION = 'Coupon for Christmas removing 10€ if your total checkout is more than 40€'; + CONST VALID_DESCRIPTION = '

    Lorem ipsum dolor sit amet

    Consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla. + +Donec rhoncus leo mauris, id porttitor ante luctus tempus. + +Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla. + +Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros. + +Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non. + +Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'; /** * Sets up the fixture, for example, opens a network connection. @@ -47,7 +66,211 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->object = new CouponManager; + } + + + /** + * Generate valid CouponInterface + * + * @param string $code + * @param string $title + * @param string $shortDescription + * @param string $description + * @param float $amount + * @param bool $isEnabled + * @param $expirationDate + * @param $rules + * @param bool $isCumulative + * @param bool $isRemovingPostage + * @param bool $isAvailableOnSpecialOffers + * @param int $maxUsage + * + * @return CouponInterface + */ + public function generateValidCoupon( + $code = 'XMAS1', + $title = 'Christmas coupon', + $shortDescription = self::VALID_SHORT_DESCRIPTION, + $description = self::VALID_DESCRIPTION, + $amount = 10.00, + $isEnabled = true, + $expirationDate = null, + $rules = null, + $isCumulative = true, + $isRemovingPostage = false, + $isAvailableOnSpecialOffers = true, + $maxUsage = 40 + ) { + if ($expirationDate === null) { + $expirationDate = new \DateTime(); + $expirationDate->setTimestamp(strtotime("today + 2 months")); + } + + $coupon = new RemoveXAmount($code, $title, $shortDescription, $description, $amount, $isCumulative, $isRemovingPostage, $isAvailableOnSpecialOffers, $isEnabled, $maxUsage, $expirationDate); + + if ($rules === null) { + $rules = $this->generateValidRules(); + } + + $coupon->setRules($rules); + + return $coupon; + } + +// /** +// * @covers Thelia\Coupon\CouponManager::getDiscount +// * @todo Implement testGetDiscount(). +// */ +// public function testGetDiscountOneCoupon() +// { +// $this->markTestIncomplete( +// 'This test has not been implemented yet.' +// ); +// /** @var CouponInterface $coupon */ +// $coupon = $this->generateValidCoupon(); +// +// +// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// $stubCouponBaseAdapter = $this->getMock( +// 'Thelia\Coupon\CouponBaseAdapter', +// array( +// 'getCurrentCoupons', +// 'getCheckoutTotalPriceWithoutDiscountAndPostagePrice' +// ), +// array() +// ); +// +// // Returns -10euros not removing postage Coupon +// // If 40 < total amount 400 +// $stubCouponBaseAdapter->expects($this->any()) +// ->method('getCurrentCoupons') +// ->will($this->returnValue(array($coupon))); +// +// // Return Checkout product amoun = 100euros +// $stubCouponBaseAdapter->expects($this->any()) +// ->method('getCheckoutTotalPriceWithoutDiscountAndPostagePrice') +// ->will($this->returnValue(100.00)); +// +// $couponManager = new CouponManager($stubCouponBaseAdapter); +// $discount = $couponManager->getDiscount(); +// +// $expected = 10.00; +// $actual = $discount; +// $this->assertEquals($expected, $actual); +// } +// +// /** +// * @covers Thelia\Coupon\CouponManager::getDiscount +// * @todo Implement testGetDiscount(). +// */ +// public function testGetDiscountAlwaysInferiorToPrice() +// { +// // Remove the following lines when you implement this test. +// $this->markTestIncomplete( +// 'This test has not been implemented yet.' +// ); +// } +// +// /** +// * @covers Thelia\Coupon\CouponManager::getDiscount +// * @covers Thelia\Coupon\CouponManager::sortCoupons +// * @todo Implement testGetDiscount(). +// */ +// public function testGetDiscountCouponNotCumulativeCancelOthers() +// { +// // Remove the following lines when you implement this test. +// $this->markTestIncomplete( +// 'This test has not been implemented yet.' +// ); +// } +// +// /** +// * @covers Thelia\Coupon\CouponManager::getDiscount +// * @covers Thelia\Coupon\CouponManager::sortCoupons +// * @todo Implement testGetDiscount(). +// */ +// public function testGetDiscountCouponCumulativeCumulatesWithOthers() +// { +// // Remove the following lines when you implement this test. +// $this->markTestIncomplete( +// 'This test has not been implemented yet.' +// ); +// } +// +// /** +// * @covers Thelia\Coupon\CouponManager::isCouponRemovingPostage +// * @covers Thelia\Coupon\CouponManager::sortCoupons +// * @todo Implement testGetDiscount(). +// */ +// public function testIsCouponRemovingPostage() +// { +// // Remove the following lines when you implement this test. +// $this->markTestIncomplete( +// 'This test has not been implemented yet.' +// ); +// } + + /** + * @covers Thelia\Coupon\CouponManager::sortCoupons + */ + public function testCouponCumulationOneCouponNotCumulative() + { + // Given + /** @var CouponInterface $coupon */ + $couponCumulative1 = $this->generateValidCoupon(null, null, null, null, null, null, null, null, true); + $couponCumulative2 = $this->generateValidCoupon(null, null, null, null, null, null, null, null, true); + $couponNotCumulative1 = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false); + $couponNotCumulative2 = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false); + + $coupons = array($couponCumulative1); + + // When + $sortedCoupons = PhpUnitUtils::callMethod( + new CouponManager(new CouponBaseAdapter()), + 'sortCoupons', + $coupons + ); + + // Then + $expected = $coupons; + $actual = $sortedCoupons; + + $this->assertSame($expected, $actual, 'Array Sorted despite there is only once'); + } + + + /** + * Generate valid CouponRuleInterfaces + * + * @return array Array of CouponRuleInterface + */ + protected function generateValidRules() + { + $rule1 = new AvailableForTotalAmount( + array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + new PriceParam( + 40.00, + 'EUR' + ) + ) + ) + ); + $rule2 = new AvailableForTotalAmount( + array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::INFERIOR, + new PriceParam( + 400.00, + 'EUR' + ) + ) + ) + ); + $rules = new CouponRuleCollection(array($rule1, $rule2)); + + return $rules; } /** @@ -58,66 +281,4 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase { } - /** - * @covers Thelia\Coupon\CouponManager::getDiscount - * @todo Implement testGetDiscount(). - */ - public function testGetDiscount() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\CouponManager::getDiscount - * @todo Implement testGetDiscount(). - */ - public function testGetDiscountAlwaysInferiorToPrice() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\CouponManager::getDiscount - * @covers Thelia\Coupon\CouponManager::sortCoupons - * @todo Implement testGetDiscount(). - */ - public function testGetDiscountCouponNotCumulativeCancelOthers() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\CouponManager::getDiscount - * @covers Thelia\Coupon\CouponManager::sortCoupons - * @todo Implement testGetDiscount(). - */ - public function testGetDiscountCouponCumulativeCumulatesWithOthers() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\CouponManager::isCouponRemovingPostage - * @covers Thelia\Coupon\CouponManager::sortCoupons - * @todo Implement testGetDiscount(). - */ - public function testIsCouponRemovingPostage() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } } diff --git a/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php b/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php new file mode 100644 index 000000000..081aee2dd --- /dev/null +++ b/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php @@ -0,0 +1,81 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon; + +use Thelia\Coupon\Parameter\PriceParam; +use Thelia\Coupon\Parameter\RuleValidator; +use Thelia\Coupon\Rule\AvailableForTotalAmount; +use Thelia\Coupon\Rule\Operators; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Unit Test CouponRuleCollection Class + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class CouponRuleCollectionTest extends \PHPUnit_Framework_TestCase +{ + /** + * + */ + public function testRuleSerialisation() + { + $rule1 = new AvailableForTotalAmount( + array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + new PriceParam( + 40.00, + 'EUR' + ) + ) + ) + ); + $rule2 = new AvailableForTotalAmount( + array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::INFERIOR, + new PriceParam( + 400.00, + 'EUR' + ) + ) + ) + ); + $rules = new CouponRuleCollection(array($rule1, $rule2)); + + $serializedRules = base64_encode(serialize($rules)); + $unserializedRules = unserialize(base64_decode($serializedRules)); + + $expected = $rules; + $actual = $unserializedRules; + + $this->assertEquals($expected, $actual); + } +} diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php index 3062568c4..4c26bfa2f 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php @@ -31,7 +31,7 @@ use Thelia\Coupon\Parameter\DateParam; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test DateParam Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php index bcc24542e..05f19955d 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php @@ -31,7 +31,7 @@ use Thelia\Coupon\Parameter\IntegerParam; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test IntegerParam Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php index 59583bfe6..73571ba5b 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php @@ -31,7 +31,7 @@ use Thelia\Coupon\Parameter\IntervalParam; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test IntervalParam Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php index c85b5af1a..62d552e0b 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php @@ -31,7 +31,7 @@ use Thelia\Coupon\Parameter\PriceParam; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test PriceParam Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php index c7ee0d915..6a9d9d737 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php @@ -31,7 +31,7 @@ use Thelia\Coupon\Parameter\QuantityParam; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test QuantityParam Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php index 5e0bf033d..f9a6f0d18 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php @@ -32,7 +32,7 @@ use Thelia\Coupon\Parameter\RepeatedDateParam; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test RepeatedDateParam Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php index 6830d5670..fe5866b0f 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php @@ -31,7 +31,7 @@ use Thelia\Coupon\Parameter\RepeatedIntervalParam; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test RepeatedIntervalParam Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php index 73833cd23..15c07ba1a 100644 --- a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php +++ b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php @@ -35,7 +35,7 @@ use Thelia\Exception\InvalidRuleValueException; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test AvailableForTotalAmount Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php index 2110f76bb..8bffc05a9 100644 --- a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php +++ b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php @@ -30,7 +30,7 @@ use Thelia\Coupon\Rule\AvailableForXArticles; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test AvailableForXArticles Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/Rule/OperatorTest.php b/core/lib/Thelia/Tests/Coupon/Rule/OperatorsTest.php similarity index 98% rename from core/lib/Thelia/Tests/Coupon/Rule/OperatorTest.php rename to core/lib/Thelia/Tests/Coupon/Rule/OperatorsTest.php index 2fbf6f339..bf4fbc75d 100644 --- a/core/lib/Thelia/Tests/Coupon/Rule/OperatorTest.php +++ b/core/lib/Thelia/Tests/Coupon/Rule/OperatorsTest.php @@ -31,13 +31,13 @@ use Thelia\Coupon\Rule\Operators; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test Operators Class * * @package Coupon * @author Guillaume MOREL * */ -class OperatorTest extends \PHPUnit_Framework_TestCase +class OperatorsTest extends \PHPUnit_Framework_TestCase { /** diff --git a/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php b/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php index 5c8dfc983..3300cb19b 100644 --- a/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php +++ b/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php @@ -28,7 +28,7 @@ namespace Thelia\Coupon; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test RuleOrganizer Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php index 0178bae10..65bf2e344 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php @@ -28,7 +28,7 @@ namespace Thelia\Coupon; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test RemoveXAmountForCategoryY Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php index f9e765b35..f7287bb45 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php @@ -33,7 +33,7 @@ use Thelia\Coupon\Type\RemoveXAmount; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test RemoveXAmount Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php index 39533d62b..caa90f4ae 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php @@ -28,7 +28,7 @@ namespace Thelia\Coupon; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test RemoveXPercenForCategoryY Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php index a2dd87f62..7dfca8dd2 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php @@ -31,7 +31,7 @@ use Thelia\Coupon\Type\RemoveXPercent; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Unit Test RemoveXPercent Class * * @package Coupon * @author Guillaume MOREL diff --git a/core/lib/Thelia/Tools/PhpUnitUtils.php b/core/lib/Thelia/Tools/PhpUnitUtils.php new file mode 100644 index 000000000..e8a2d41ab --- /dev/null +++ b/core/lib/Thelia/Tools/PhpUnitUtils.php @@ -0,0 +1,55 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Tools; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Helper for Unit Testing + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class PhpUnitUtils +{ + /** + * Allow to call a protected methods + * + * @param string $obj Class name + namespace + * @param string $name Method name + * @param array $args Method arguments + * + * @return protected method result + */ + public static function callMethod($obj, $name, array $args) + { + $class = new \ReflectionClass(get_class($obj)); + $method = $class->getMethod($name); + $method->setAccessible(true); + return $method->invokeArgs($obj, $args); + } +} \ No newline at end of file diff --git a/install/faker.php b/install/faker.php index 7f0159a8d..73731f456 100755 --- a/install/faker.php +++ b/install/faker.php @@ -350,19 +350,9 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua ) ) ); - $rules = array($rule1, $rule2); + $rules = new \Thelia\Coupon\CouponRuleCollection(array($rule1, $rule2)); - $encoders = array(new XmlEncoder(), new JsonEncoder()); - $normalizers = array(new GetSetMethodNormalizer()); - $serializer = new Serializer($normalizers, $encoders); - - $ruleTypes = array(); - /** @var Thelia\Coupon\Rule\CouponRuleInterface $rule */ - foreach ($rules as $rule) { - $ruleTypes[] = get_class($rule); - } - $coupon1->setSerializedRulesType($serializer->serialize($ruleTypes, 'json')); - $coupon1->setSerializedRulesContent($serializer->serialize($rules, 'json')); + $coupon1->setSerializedRules(base64_encode(serialize($rules))); $coupon1->setIsCumulative(1); $coupon1->setIsRemovingPostage(0); diff --git a/install/thelia.sql b/install/thelia.sql index 83f86248e..5c099d02c 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -1089,10 +1089,11 @@ CREATE TABLE `coupon` `is_used` TINYINT NOT NULL, `is_enabled` TINYINT NOT NULL, `expiration_date` DATETIME NOT NULL, - `serialized_rules_type` TEXT NOT NULL, - `serialized_rules_content` TEXT NOT NULL, + `serialized_rules` TEXT NOT NULL, `is_cumulative` TINYINT NOT NULL, `is_removing_postage` TINYINT NOT NULL, + `max_usage` INTEGER NOT NULL, + `is_available_on_special_offers` TINYINT(1) NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, `version` INTEGER DEFAULT 0, @@ -1104,7 +1105,9 @@ CREATE TABLE `coupon` INDEX `idx_amount` (`amount`), INDEX `idx_expiration_date` (`expiration_date`), INDEX `idx_is_cumulative` (`is_cumulative`), - INDEX `idx_is_removing_postage` (`is_removing_postage`) + INDEX `idx_is_removing_postage` (`is_removing_postage`), + INDEX `idx_max_usage` (`max_usage`), + INDEX `idx_is_available_on_special_offers` (`is_available_on_special_offers`) ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -2183,10 +2186,11 @@ CREATE TABLE `coupon_version` `is_used` TINYINT NOT NULL, `is_enabled` TINYINT NOT NULL, `expiration_date` DATETIME NOT NULL, - `serialized_rules_type` TEXT NOT NULL, - `serialized_rules_content` TEXT NOT NULL, + `serialized_rules` TEXT NOT NULL, `is_cumulative` TINYINT NOT NULL, `is_removing_postage` TINYINT NOT NULL, + `max_usage` INTEGER NOT NULL, + `is_available_on_special_offers` TINYINT(1) NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, `version` INTEGER DEFAULT 0 NOT NULL, diff --git a/local/config/schema.xml b/local/config/schema.xml index 71914d771..0a4a76e89 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -799,10 +799,11 @@ - - + + + @@ -827,6 +828,12 @@ + + + + + + @@ -1119,4 +1126,4 @@ - \ No newline at end of file + From 803e93f61c74718aa5dcedacc77844baf984694b Mon Sep 17 00:00:00 2001 From: franck Date: Mon, 26 Aug 2013 09:59:01 +0200 Subject: [PATCH 030/268] Fixed typo --- core/lib/Thelia/Command/ClearImageCache.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Command/ClearImageCache.php b/core/lib/Thelia/Command/ClearImageCache.php index 801e2e8d0..8f11770a3 100644 --- a/core/lib/Thelia/Command/ClearImageCache.php +++ b/core/lib/Thelia/Command/ClearImageCache.php @@ -1,5 +1,4 @@ writeln(sprintf("Failed to clear image cache: %s", $ex->getMessage())); } } -} +} \ No newline at end of file From 96b3de7c8485a285c639219968cecedd3480bae4 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Mon, 26 Aug 2013 12:38:23 +0200 Subject: [PATCH 031/268] backend trasnlation in loops --- .../Thelia/Core/Template/Element/BaseLoop.php | 1 + .../Thelia/Core/Template/Loop/Attribute.php | 14 +++++++- .../Template/Loop/AttributeAvailability.php | 1 + .../Thelia/Core/Template/Loop/Category.php | 1 + .../lib/Thelia/Core/Template/Loop/Content.php | 1 + .../lib/Thelia/Core/Template/Loop/Country.php | 3 +- .../Thelia/Core/Template/Loop/Currency.php | 3 +- .../lib/Thelia/Core/Template/Loop/Feature.php | 1 + .../Template/Loop/FeatureAvailability.php | 1 + core/lib/Thelia/Core/Template/Loop/Folder.php | 1 + .../lib/Thelia/Core/Template/Loop/Product.php | 1 + core/lib/Thelia/Core/Template/Loop/Title.php | 3 +- .../Thelia/Model/Tools/ModelCriteriaTools.php | 29 +++++++++++++++ templates/default/debug.html | 35 +++++++------------ 14 files changed, 69 insertions(+), 26 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 9f3a03d5d..c3e2c5d36 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -80,6 +80,7 @@ abstract class BaseLoop Argument::createIntTypeArgument('offset', 0), Argument::createIntTypeArgument('page'), Argument::createIntTypeArgument('limit', PHP_INT_MAX), + Argument::createIntTypeArgument('backend_context', false), ); } diff --git a/core/lib/Thelia/Core/Template/Loop/Attribute.php b/core/lib/Thelia/Core/Template/Loop/Attribute.php index 84549aaa5..d71d73dfb 100755 --- a/core/lib/Thelia/Core/Template/Loop/Attribute.php +++ b/core/lib/Thelia/Core/Template/Loop/Attribute.php @@ -33,6 +33,7 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; +use Thelia\Model\Base\LangQuery; use Thelia\Model\Tools\ModelCriteriaTools; use Thelia\Model\Base\CategoryQuery; @@ -66,6 +67,7 @@ class Attribute extends BaseLoop Argument::createIntListTypeArgument('category'), Argument::createBooleanOrBothTypeArgument('visible', 1), Argument::createIntListTypeArgument('exclude'), + Argument::createIntTypeArgument('lang'), new Argument( 'order', new TypeCollection( @@ -85,8 +87,18 @@ class Attribute extends BaseLoop { $search = AttributeQuery::create(); + $backendContext = $this->getBackend_context(); + + $lang = $this->getLang(); + + $x = LangQuery::create()->findOneById($lang); + /* manage translations */ - ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + if($backendContext) { + ModelCriteriaTools::getBackEndI18n($search, $lang === null ? $this->request->getSession()->getLocale() : $x); + } else { + ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + } $id = $this->getId(); diff --git a/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php index ade493efa..5050f2060 100755 --- a/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php +++ b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php @@ -59,6 +59,7 @@ class AttributeAvailability extends BaseLoop Argument::createIntListTypeArgument('id'), Argument::createIntListTypeArgument('attribute'), Argument::createIntListTypeArgument('exclude'), + Argument::createIntTypeArgument('lang'), new Argument( 'order', new TypeCollection( diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 1233ccd4e..5448d6e29 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -77,6 +77,7 @@ class Category extends BaseLoop Argument::createBooleanTypeArgument('current'), Argument::createBooleanTypeArgument('not_empty', 0), Argument::createBooleanOrBothTypeArgument('visible', 1), + Argument::createIntTypeArgument('lang'), new Argument( 'order', new TypeCollection( diff --git a/core/lib/Thelia/Core/Template/Loop/Content.php b/core/lib/Thelia/Core/Template/Loop/Content.php index 3a81ff9f2..b35a545d0 100755 --- a/core/lib/Thelia/Core/Template/Loop/Content.php +++ b/core/lib/Thelia/Core/Template/Loop/Content.php @@ -65,6 +65,7 @@ class Content extends BaseLoop Argument::createBooleanTypeArgument('current_folder'), Argument::createIntTypeArgument('depth', 1), Argument::createBooleanOrBothTypeArgument('visible', 1), + Argument::createIntTypeArgument('lang'), new Argument( 'order', new TypeCollection( diff --git a/core/lib/Thelia/Core/Template/Loop/Country.php b/core/lib/Thelia/Core/Template/Loop/Country.php index d25951fb8..62a0029ff 100755 --- a/core/lib/Thelia/Core/Template/Loop/Country.php +++ b/core/lib/Thelia/Core/Template/Loop/Country.php @@ -56,7 +56,8 @@ class Country extends BaseLoop Argument::createIntListTypeArgument('id'), Argument::createIntListTypeArgument('area'), Argument::createBooleanTypeArgument('with_area'), - Argument::createIntListTypeArgument('exclude') + Argument::createIntListTypeArgument('exclude'), + Argument::createIntTypeArgument('lang') ); } diff --git a/core/lib/Thelia/Core/Template/Loop/Currency.php b/core/lib/Thelia/Core/Template/Loop/Currency.php index 08eacca08..922669250 100755 --- a/core/lib/Thelia/Core/Template/Loop/Currency.php +++ b/core/lib/Thelia/Core/Template/Loop/Currency.php @@ -55,7 +55,8 @@ class Currency extends BaseLoop return new ArgumentCollection( Argument::createIntListTypeArgument('id'), Argument::createIntListTypeArgument('exclude'), - Argument::createBooleanTypeArgument('default_only', false) + Argument::createBooleanTypeArgument('default_only', false), + Argument::createIntTypeArgument('lang') ); } diff --git a/core/lib/Thelia/Core/Template/Loop/Feature.php b/core/lib/Thelia/Core/Template/Loop/Feature.php index 0693a303a..dba4ccaaa 100755 --- a/core/lib/Thelia/Core/Template/Loop/Feature.php +++ b/core/lib/Thelia/Core/Template/Loop/Feature.php @@ -64,6 +64,7 @@ class Feature extends BaseLoop Argument::createIntListTypeArgument('category'), Argument::createBooleanOrBothTypeArgument('visible', 1), Argument::createIntListTypeArgument('exclude'), + Argument::createIntTypeArgument('lang'), new Argument( 'order', new TypeCollection( diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php index 272bb5211..a16be7743 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php @@ -57,6 +57,7 @@ class FeatureAvailability extends BaseLoop Argument::createIntListTypeArgument('id'), Argument::createIntListTypeArgument('feature'), Argument::createIntListTypeArgument('exclude'), + Argument::createIntTypeArgument('lang'), new Argument( 'order', new TypeCollection( diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php index 7062a55b4..d14c31892 100755 --- a/core/lib/Thelia/Core/Template/Loop/Folder.php +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -59,6 +59,7 @@ class Folder extends BaseLoop Argument::createBooleanTypeArgument('current'), Argument::createBooleanTypeArgument('not_empty', 0), Argument::createBooleanOrBothTypeArgument('visible', 1), + Argument::createIntTypeArgument('lang'), new Argument( 'order', new TypeCollection( diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 9c22a4987..f9752646b 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -85,6 +85,7 @@ class Product extends BaseLoop Argument::createBooleanTypeArgument('current_category'), Argument::createIntTypeArgument('depth', 1), Argument::createBooleanOrBothTypeArgument('visible', 1), + Argument::createIntTypeArgument('lang'), new Argument( 'order', new TypeCollection( diff --git a/core/lib/Thelia/Core/Template/Loop/Title.php b/core/lib/Thelia/Core/Template/Loop/Title.php index 843e29334..2402dc318 100755 --- a/core/lib/Thelia/Core/Template/Loop/Title.php +++ b/core/lib/Thelia/Core/Template/Loop/Title.php @@ -53,7 +53,8 @@ class Title extends BaseLoop protected function getArgDefinitions() { return new ArgumentCollection( - Argument::createIntListTypeArgument('id') + Argument::createIntListTypeArgument('id'), + Argument::createIntTypeArgument('lang') ); } diff --git a/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php index fd04ef3d9..656be5848 100755 --- a/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php +++ b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php @@ -43,6 +43,8 @@ class ModelCriteriaTools $search->addJoinObject($askedLocaleJoin, $askedLocaleI18nAlias) ->addJoinCondition($askedLocaleI18nAlias ,'`' . $askedLocaleI18nAlias . '`.LOCALE = ?', $askedLocale, null, \PDO::PARAM_STR); + $search->withColumn('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'TRANSLATION_EXISTS'); + foreach($columns as $column) { $search->withColumn('`' . $askedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column); } @@ -63,6 +65,8 @@ class ModelCriteriaTools $search->addJoinObject($askedLocaleJoin, $askedLocaleI18nAlias) ->addJoinCondition($askedLocaleI18nAlias ,'`' . $askedLocaleI18nAlias . '`.LOCALE = ?', $askedLocale, null, \PDO::PARAM_STR); + $search->withColumn('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'TRANSLATION_EXISTS'); + $search->where('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.ID)')->_or()->where('NOT ISNULL(`' . $defaultLocaleI18nAlias . '`.ID)'); foreach($columns as $column) { @@ -70,4 +74,29 @@ class ModelCriteriaTools } } } + + public static function getBackEndI18n(ModelCriteria &$search, $askedLocale, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') + { + if($foreignTable === null) { + $foreignTable = $search->getTableMap()->getName(); + $aliasPrefix = ''; + } else { + $aliasPrefix = $foreignTable . '_'; + } + + $askedLocaleI18nAlias = 'asked_locale_i18n'; + + $askedLocaleJoin = new Join(); + $askedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $askedLocaleI18nAlias); + $askedLocaleJoin->setJoinType(Criteria::LEFT_JOIN); + + $search->addJoinObject($askedLocaleJoin, $askedLocaleI18nAlias) + ->addJoinCondition($askedLocaleI18nAlias ,'`' . $askedLocaleI18nAlias . '`.LOCALE = ?', $askedLocale, null, \PDO::PARAM_STR); + + $search->withColumn('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'TRANSLATION_EXISTS'); + + foreach($columns as $column) { + $search->withColumn('`' . $askedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column); + } + } } diff --git a/templates/default/debug.html b/templates/default/debug.html index 251a9b891..62966680a 100755 --- a/templates/default/debug.html +++ b/templates/default/debug.html @@ -1,23 +1,14 @@ -{*loop name="product" type="product" new="on" promo="on" min_stock="20" attribute_non_strict_match="min_stock,promo"} -

    PRODUCT : #REF / #TITLE (#ID)

    -{/loop*} +

    ALL ATTRIBUTES AND THEIR AVAILABILITY

    -{*loop name="product" type="product" min_weight="1000" max_weight="6000" attribute_non_strict_match="*"} -

    PRODUCT : #REF / #TITLE (#ID)

    -{/loop*} - -{*loop name="product" type="product" min_price="100" max_price="300" min_stock="4" min_weight="6000" max_weight="7000" attribute_non_strict_match="*" promo="on"} -

    PRODUCT : #REF / #TITLE (#ID)

    -{/loop*} - -{*loop name="product" type="product" promo="0" min_stock="4" order="promo,min_price"} -

    PRODUCT : #REF / #TITLE (#ID)

    -{/loop*} - -{*loop name="product" type="product" order="promo,min_price"} -

    PRODUCT : #REF / #TITLE (#ID) / NEW : #NEW / PROMO : #PROMO / best price : #BEST_PRICE

    -{/loop*} - -{loop name="product" type="product"} -

    PRODUCT : #REF / #TITLE

    -{/loop} \ No newline at end of file +
      + {loop name="attr" type="attribute" order="manual"} +
    • + #TITLE +
        + {loop name="attrav" type="attribute_availability" order="manual" attribute="#ID"} +
      • #TITLE
      • + {/loop} +
      +
    • + {/loop} +
    \ No newline at end of file From 9174e5154ec7a9c09b75c404a7ad1691be57018b Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Mon, 26 Aug 2013 14:05:29 +0200 Subject: [PATCH 032/268] backend loop translation --- core/lib/Thelia/Config/Resources/config.xml | 1 + .../Thelia/Core/Template/Element/BaseLoop.php | 2 +- .../Thelia/Core/Template/Loop/Attribute.php | 9 +- .../Template/Loop/AttributeAvailability.php | 7 +- .../Template/Loop/AttributeCombination.php | 4 +- .../Thelia/Core/Template/Loop/Category.php | 7 +- .../lib/Thelia/Core/Template/Loop/Content.php | 7 +- .../lib/Thelia/Core/Template/Loop/Country.php | 7 +- .../Thelia/Core/Template/Loop/Currency.php | 8 +- .../lib/Thelia/Core/Template/Loop/Feature.php | 7 +- .../Template/Loop/FeatureAvailability.php | 7 +- .../Core/Template/Loop/FeatureValue.php | 2 +- core/lib/Thelia/Core/Template/Loop/Folder.php | 7 +- .../lib/Thelia/Core/Template/Loop/Product.php | 7 +- core/lib/Thelia/Core/Template/Loop/Title.php | 7 +- .../Thelia/Model/Tools/ModelCriteriaTools.php | 24 +- install/insert.sql | 551 +++++++++--------- templates/default/category.html | 12 + templates/default/debug.html | 8 +- 19 files changed, 380 insertions(+), 304 deletions(-) diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 39d8bc905..9ce06b83f 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -15,6 +15,7 @@ + diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index c3e2c5d36..72f782309 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -80,7 +80,7 @@ abstract class BaseLoop Argument::createIntTypeArgument('offset', 0), Argument::createIntTypeArgument('page'), Argument::createIntTypeArgument('limit', PHP_INT_MAX), - Argument::createIntTypeArgument('backend_context', false), + Argument::createBooleanTypeArgument('backend_context', false), ); } diff --git a/core/lib/Thelia/Core/Template/Loop/Attribute.php b/core/lib/Thelia/Core/Template/Loop/Attribute.php index d71d73dfb..41721350b 100755 --- a/core/lib/Thelia/Core/Template/Loop/Attribute.php +++ b/core/lib/Thelia/Core/Template/Loop/Attribute.php @@ -91,14 +91,8 @@ class Attribute extends BaseLoop $lang = $this->getLang(); - $x = LangQuery::create()->findOneById($lang); - /* manage translations */ - if($backendContext) { - ModelCriteriaTools::getBackEndI18n($search, $lang === null ? $this->request->getSession()->getLocale() : $x); - } else { - ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); - } + ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); $id = $this->getId(); @@ -163,6 +157,7 @@ class Attribute extends BaseLoop foreach ($attributes as $attribute) { $loopResultRow = new LoopResultRow(); $loopResultRow->set("ID", $attribute->getId()) + ->set("IS_TRANSLATED",$attribute->getVirtualColumn('IS_TRANSLATED')) ->set("TITLE",$attribute->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $attribute->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $attribute->getVirtualColumn('i18n_DESCRIPTION')) diff --git a/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php index 5050f2060..be42f5dab 100755 --- a/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php +++ b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php @@ -79,8 +79,12 @@ class AttributeAvailability extends BaseLoop { $search = AttributeAvQuery::create(); + $backendContext = $this->getBackend_context(); + + $lang = $this->getLang(); + /* manage translations */ - ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); $id = $this->getId(); @@ -127,6 +131,7 @@ class AttributeAvailability extends BaseLoop foreach ($attributesAv as $attributeAv) { $loopResultRow = new LoopResultRow(); $loopResultRow->set("ID", $attributeAv->getId()) + ->set("IS_TRANSLATED",$attributeAv->getVirtualColumn('IS_TRANSLATED')) ->set("TITLE",$attributeAv->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $attributeAv->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $attributeAv->getVirtualColumn('i18n_DESCRIPTION')) diff --git a/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php b/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php index 42df69ea3..833f1abb3 100755 --- a/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php +++ b/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php @@ -79,7 +79,7 @@ class AttributeCombination extends BaseLoop $search = AttributeCombinationQuery::create(); /* manage attribute translations */ - ModelCriteriaTools::getI18n( + ModelCriteriaTools::getFrontEndI18n( $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), @@ -89,7 +89,7 @@ class AttributeCombination extends BaseLoop ); /* manage attributeAv translations */ - ModelCriteriaTools::getI18n( + ModelCriteriaTools::getFrontEndI18n( $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 5448d6e29..9b497bb1a 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -98,8 +98,12 @@ class Category extends BaseLoop { $search = CategoryQuery::create(); + $backendContext = $this->getBackend_context(); + + $lang = $this->getLang(); + /* manage translations */ - ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); $id = $this->getId(); @@ -175,6 +179,7 @@ class Category extends BaseLoop $loopResultRow ->set("ID", $category->getId()) + ->set("IS_TRANSLATED",$category->getVirtualColumn('IS_TRANSLATED')) ->set("TITLE",$category->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $category->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION')) diff --git a/core/lib/Thelia/Core/Template/Loop/Content.php b/core/lib/Thelia/Core/Template/Loop/Content.php index b35a545d0..e97d63c55 100755 --- a/core/lib/Thelia/Core/Template/Loop/Content.php +++ b/core/lib/Thelia/Core/Template/Loop/Content.php @@ -88,8 +88,12 @@ class Content extends BaseLoop { $search = ContentQuery::create(); + $backendContext = $this->getBackend_context(); + + $lang = $this->getLang(); + /* manage translations */ - ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); $id = $this->getId(); @@ -216,6 +220,7 @@ class Content extends BaseLoop $loopResultRow = new LoopResultRow(); $loopResultRow->set("ID", $content->getId()) + ->set("IS_TRANSLATED",$content->getVirtualColumn('IS_TRANSLATED')) ->set("TITLE",$content->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $content->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $content->getVirtualColumn('i18n_DESCRIPTION')) diff --git a/core/lib/Thelia/Core/Template/Loop/Country.php b/core/lib/Thelia/Core/Template/Loop/Country.php index 62a0029ff..c6f7d16de 100755 --- a/core/lib/Thelia/Core/Template/Loop/Country.php +++ b/core/lib/Thelia/Core/Template/Loop/Country.php @@ -70,8 +70,12 @@ class Country extends BaseLoop { $search = CountryQuery::create(); + $backendContext = $this->getBackend_context(); + + $lang = $this->getLang(); + /* manage translations */ - ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); $id = $this->getId(); @@ -109,6 +113,7 @@ class Country extends BaseLoop foreach ($countries as $country) { $loopResultRow = new LoopResultRow(); $loopResultRow->set("ID", $country->getId()) + ->set("IS_TRANSLATED",$country->getVirtualColumn('IS_TRANSLATED')) ->set("TITLE",$country->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $country->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $country->getVirtualColumn('i18n_DESCRIPTION')) diff --git a/core/lib/Thelia/Core/Template/Loop/Currency.php b/core/lib/Thelia/Core/Template/Loop/Currency.php index 922669250..d833ff8ae 100755 --- a/core/lib/Thelia/Core/Template/Loop/Currency.php +++ b/core/lib/Thelia/Core/Template/Loop/Currency.php @@ -69,8 +69,12 @@ class Currency extends BaseLoop { $search = CurrencyQuery::create(); + $backendContext = $this->getBackend_context(); + + $lang = $this->getLang(); + /* manage translations */ - ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), array('NAME')); + ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), array('NAME')); $id = $this->getId(); @@ -100,8 +104,10 @@ class Currency extends BaseLoop foreach ($currencies as $currency) { $loopResultRow = new LoopResultRow(); $loopResultRow->set("ID", $currency->getId()) + ->set("IS_TRANSLATED",$currency->getVirtualColumn('IS_TRANSLATED')) ->set("NAME",$currency->getVirtualColumn('i18n_NAME')) ->set("ISOCODE", $currency->getCode()) + ->set("SYMBOL", $currency->getSymbol()) ->set("RATE", $currency->getRate()) ->set("IS_DEFAULT", $currency->getByDefault()); diff --git a/core/lib/Thelia/Core/Template/Loop/Feature.php b/core/lib/Thelia/Core/Template/Loop/Feature.php index dba4ccaaa..85d037080 100755 --- a/core/lib/Thelia/Core/Template/Loop/Feature.php +++ b/core/lib/Thelia/Core/Template/Loop/Feature.php @@ -84,8 +84,12 @@ class Feature extends BaseLoop { $search = FeatureQuery::create(); + $backendContext = $this->getBackend_context(); + + $lang = $this->getLang(); + /* manage translations */ - ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); $id = $this->getId(); @@ -150,6 +154,7 @@ class Feature extends BaseLoop foreach ($features as $feature) { $loopResultRow = new LoopResultRow(); $loopResultRow->set("ID", $feature->getId()) + ->set("IS_TRANSLATED",$feature->getVirtualColumn('IS_TRANSLATED')) ->set("TITLE",$feature->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $feature->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $feature->getVirtualColumn('i18n_DESCRIPTION')) diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php index a16be7743..ce6f8767a 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php @@ -77,8 +77,12 @@ class FeatureAvailability extends BaseLoop { $search = FeatureAvQuery::create(); + $backendContext = $this->getBackend_context(); + + $lang = $this->getLang(); + /* manage translations */ - ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); $id = $this->getId(); @@ -125,6 +129,7 @@ class FeatureAvailability extends BaseLoop foreach ($featuresAv as $featureAv) { $loopResultRow = new LoopResultRow(); $loopResultRow->set("ID", $featureAv->getId()) + ->set("IS_TRANSLATED",$featureAv->getVirtualColumn('IS_TRANSLATED')) ->set("TITLE",$featureAv->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $featureAv->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $featureAv->getVirtualColumn('i18n_DESCRIPTION')) diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php index 71070e25f..8a29d7c74 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php @@ -84,7 +84,7 @@ class FeatureValue extends BaseLoop $search = FeatureProductQuery::create(); /* manage featureAv translations */ - ModelCriteriaTools::getI18n( + ModelCriteriaTools::getFrontEndI18n( $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php index d14c31892..502e0895f 100755 --- a/core/lib/Thelia/Core/Template/Loop/Folder.php +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -80,8 +80,12 @@ class Folder extends BaseLoop { $search = FolderQuery::create(); + $backendContext = $this->getBackend_context(); + + $lang = $this->getLang(); + /* manage translations */ - ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); $id = $this->getId(); @@ -158,6 +162,7 @@ class Folder extends BaseLoop $loopResultRow ->set("ID", $folder->getId()) + ->set("IS_TRANSLATED",$folder->getVirtualColumn('IS_TRANSLATED')) ->set("TITLE",$folder->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $folder->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $folder->getVirtualColumn('i18n_DESCRIPTION')) diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index f9752646b..2f3d25f87 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -138,8 +138,12 @@ class Product extends BaseLoop { $search = ProductQuery::create(); + $backendContext = $this->getBackend_context(); + + $lang = $this->getLang(); + /* manage translations */ - ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); $attributeNonStrictMatch = $this->getAttribute_non_strict_match(); $isPSELeftJoinList = array(); @@ -511,6 +515,7 @@ class Product extends BaseLoop $loopResultRow->set("ID", $product->getId()) ->set("REF",$product->getRef()) + ->set("IS_TRANSLATED",$product->getVirtualColumn('IS_TRANSLATED')) ->set("TITLE",$product->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION')) diff --git a/core/lib/Thelia/Core/Template/Loop/Title.php b/core/lib/Thelia/Core/Template/Loop/Title.php index 2402dc318..caa5e7d87 100755 --- a/core/lib/Thelia/Core/Template/Loop/Title.php +++ b/core/lib/Thelia/Core/Template/Loop/Title.php @@ -67,8 +67,12 @@ class Title extends BaseLoop { $search = CustomerTitleQuery::create(); + $backendContext = $this->getBackend_context(); + + $lang = $this->getLang(); + /* manage translations */ - ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), array('SHORT', 'LONG')); + ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), array('SHORT', 'LONG')); $id = $this->getId(); @@ -86,6 +90,7 @@ class Title extends BaseLoop foreach ($titles as $title) { $loopResultRow = new LoopResultRow(); $loopResultRow->set("ID", $title->getId()) + ->set("IS_TRANSLATED",$title->getVirtualColumn('IS_TRANSLATED')) ->set("DEFAULT", $title->getByDefault()) ->set("SHORT", $title->getVirtualColumn('i18n_SHORT')) ->set("LONG", $title->getVirtualColumn('i18n_LONG')); diff --git a/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php index 656be5848..e9323ebfa 100755 --- a/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php +++ b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php @@ -23,7 +23,7 @@ class ModelCriteriaTools * @param null $foreignTable * @param string $foreignKey */ - public static function getI18n(ModelCriteria &$search, $defaultLangWithoutTranslation, $askedLocale, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') + public static function getFrontEndI18n(ModelCriteria &$search, $defaultLangWithoutTranslation, $askedLocale, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') { if($foreignTable === null) { $foreignTable = $search->getTableMap()->getName(); @@ -43,7 +43,7 @@ class ModelCriteriaTools $search->addJoinObject($askedLocaleJoin, $askedLocaleI18nAlias) ->addJoinCondition($askedLocaleI18nAlias ,'`' . $askedLocaleI18nAlias . '`.LOCALE = ?', $askedLocale, null, \PDO::PARAM_STR); - $search->withColumn('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'TRANSLATION_EXISTS'); + $search->withColumn('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED'); foreach($columns as $column) { $search->withColumn('`' . $askedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column); @@ -65,7 +65,7 @@ class ModelCriteriaTools $search->addJoinObject($askedLocaleJoin, $askedLocaleI18nAlias) ->addJoinCondition($askedLocaleI18nAlias ,'`' . $askedLocaleI18nAlias . '`.LOCALE = ?', $askedLocale, null, \PDO::PARAM_STR); - $search->withColumn('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'TRANSLATION_EXISTS'); + $search->withColumn('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED'); $search->where('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.ID)')->_or()->where('NOT ISNULL(`' . $defaultLocaleI18nAlias . '`.ID)'); @@ -93,10 +93,26 @@ class ModelCriteriaTools $search->addJoinObject($askedLocaleJoin, $askedLocaleI18nAlias) ->addJoinCondition($askedLocaleI18nAlias ,'`' . $askedLocaleI18nAlias . '`.LOCALE = ?', $askedLocale, null, \PDO::PARAM_STR); - $search->withColumn('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'TRANSLATION_EXISTS'); + $search->withColumn('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED'); foreach($columns as $column) { $search->withColumn('`' . $askedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column); } } + + public static function getI18n($backendContext, $lang, ModelCriteria &$search, $defaultLangWithoutTranslation, $currentLocale, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') + { + if($lang !== null) { + $localeSearch = LangQuery::create()->findOneById($lang); + if($localeSearch === null) { + throw new \InvalidArgumentException('Incorrect lang argument given in attribute loop'); + } + } + + if($backendContext) { + self::getBackEndI18n($search, $lang === null ? $currentLocale : $localeSearch->getLocale(), $columns, $foreignTable, $foreignKey); + } else { + self::getFrontEndI18n($search, $defaultLangWithoutTranslation, $lang === null ? $currentLocale : $localeSearch->getLocale(), $columns, $foreignTable, $foreignKey); + } + } } diff --git a/install/insert.sql b/install/insert.sql index 58fc9a70f..f5e5d6fdb 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -13,8 +13,6 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat ('images_library_path', 'local/media/images', 1, 0, NOW(), NOW()), ('image_cache_dir_from_web_root', 'cache/images', 1, 0, NOW(), NOW()); - - INSERT INTO `module` (`code`, `type`, `activate`, `position`, `created_at`, `updated_at`) VALUES ('test', '1', '1', '1', NOW(), NOW()); INSERT INTO `customer_title`(`id`, `by_default`, `position`, `created_at`, `updated_at`) VALUES @@ -23,12 +21,12 @@ INSERT INTO `customer_title`(`id`, `by_default`, `position`, `created_at`, `upda (3, 0, 3, NOW(), NOW()); INSERT INTO `customer_title_i18n` (`id`, `locale`, `short`, `long`) VALUES -(1, 'en_US', 'Mr', 'Mister'), -(1, 'fr_FR', 'M', 'Monsieur'), -(2, 'en_US', 'Mrs', 'Misses'), -(2, 'fr_FR', 'Mme', 'Madame'), -(3, 'en_US', 'Miss', 'Miss'), -(3, 'fr_FR', 'Mlle', 'Madamemoiselle'); +(1, 'fr_FR', 'Mr', 'Monsieur'), +(1, 'en_EN', 'M', 'Mister'), +(2, 'fr_FR', 'Mrs', 'Madame'), +(2, 'en_EN', 'Mme', 'Misses'), +(3, 'fr_FR', 'Miss', 'Madamemoiselle'), +(3, 'en_EN', 'Mlle', 'Miss'); INSERT INTO `currency` (`id` ,`code` ,`symbol` ,`rate`, `position` ,`by_default` ,`created_at` ,`updated_at`) VALUES @@ -38,9 +36,12 @@ VALUES INSERT INTO `currency_i18n` (`id` ,`locale` ,`name`) VALUES -(1, 'en_US', 'euro'), -(2, 'en_US', 'dollar'), -(3, 'en_US', 'pound'); +(1, 'fr_FR', 'euro'), +(1, 'en_EN', 'euro'), +(2, 'fr_FR', 'dollar'), +(2, 'en_EN', 'dollar'), +(3, 'fr_FR', 'livre'); +(3, 'en_EN', 'pound'); INSERT INTO `country` (`id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `created_at`, `updated_at`) VALUES @@ -310,795 +311,795 @@ INSERT INTO `country` (`id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `cr (268, NULL, '840', 'US', 'USA', NOW(), NOW()); INSERT INTO `country_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES -(1, 'en_US', 'Afghanistan', '', '', ''), +(1, 'en_EN', 'Afghanistan', '', '', ''), (1, 'es_ES', 'Afganistán', '', '', ''), (1, 'fr_FR', 'Afghanistan', '', '', ''), -(2, 'en_US', 'South Africa', '', '', ''), +(2, 'en_EN', 'South Africa', '', '', ''), (2, 'es_ES', 'Sudáfrica', '', '', ''), (2, 'fr_FR', 'Afrique du Sud', '', '', ''), -(3, 'en_US', 'Albania', '', '', ''), +(3, 'en_EN', 'Albania', '', '', ''), (3, 'es_ES', 'Albania', '', '', ''), (3, 'fr_FR', 'Albanie', '', '', ''), -(4, 'en_US', 'Algeria', '', '', ''), +(4, 'en_EN', 'Algeria', '', '', ''), (4, 'es_ES', 'Argelia', '', '', ''), (4, 'fr_FR', 'Algérie', '', '', ''), -(5, 'en_US', 'Germany', '', '', ''), +(5, 'en_EN', 'Germany', '', '', ''), (5, 'es_ES', 'Alemania', '', '', ''), (5, 'fr_FR', 'Allemagne', '', '', ''), -(6, 'en_US', 'Andorra', '', '', ''), +(6, 'en_EN', 'Andorra', '', '', ''), (6, 'es_ES', 'Andorra', '', '', ''), (6, 'fr_FR', 'Andorre', '', '', ''), -(7, 'en_US', 'Angola', '', '', ''), +(7, 'en_EN', 'Angola', '', '', ''), (7, 'es_ES', 'Angola', '', '', ''), (7, 'fr_FR', 'Angola', '', '', ''), -(8, 'en_US', 'Antigua and Barbuda', '', '', ''), +(8, 'en_EN', 'Antigua and Barbuda', '', '', ''), (8, 'es_ES', 'Antigua y Barbuda', '', '', ''), (8, 'fr_FR', 'Antigua-et-Barbuda', '', '', ''), -(9, 'en_US', 'Saudi Arabia', '', '', ''), +(9, 'en_EN', 'Saudi Arabia', '', '', ''), (9, 'es_ES', 'Arabia Saudita', '', '', ''), (9, 'fr_FR', 'Arabie saoudite', '', '', ''), -(10, 'en_US', 'Argentina', '', '', ''), +(10, 'en_EN', 'Argentina', '', '', ''), (10, 'es_ES', 'Argentina', '', '', ''), (10, 'fr_FR', 'Argentine', '', '', ''), -(11, 'en_US', 'Armenia', '', '', ''), +(11, 'en_EN', 'Armenia', '', '', ''), (11, 'es_ES', 'Armenia', '', '', ''), (11, 'fr_FR', 'Arménie', '', '', ''), -(12, 'en_US', 'Australia', '', '', ''), +(12, 'en_EN', 'Australia', '', '', ''), (12, 'es_ES', 'Australia', '', '', ''), (12, 'fr_FR', 'Australie', '', '', ''), -(13, 'en_US', 'Austria', '', '', ''), +(13, 'en_EN', 'Austria', '', '', ''), (13, 'es_ES', 'Austria', '', '', ''), (13, 'fr_FR', 'Autriche', '', '', ''), -(14, 'en_US', 'Azerbaijan', '', '', ''), +(14, 'en_EN', 'Azerbaijan', '', '', ''), (14, 'es_ES', 'Azerbaiyán', '', '', ''), (14, 'fr_FR', 'Azerbaïdjan', '', '', ''), -(15, 'en_US', 'Bahamas', '', '', ''), +(15, 'en_EN', 'Bahamas', '', '', ''), (15, 'es_ES', 'Bahamas', '', '', ''), (15, 'fr_FR', 'Bahamas', '', '', ''), -(16, 'en_US', 'Bahrain', '', '', ''), +(16, 'en_EN', 'Bahrain', '', '', ''), (16, 'es_ES', 'Bahrein', '', '', ''), (16, 'fr_FR', 'Bahreïn', '', '', ''), -(17, 'en_US', 'Bangladesh', '', '', ''), +(17, 'en_EN', 'Bangladesh', '', '', ''), (17, 'es_ES', 'Bangladesh', '', '', ''), (17, 'fr_FR', 'Bangladesh', '', '', ''), -(18, 'en_US', 'Barbados', '', '', ''), +(18, 'en_EN', 'Barbados', '', '', ''), (18, 'es_ES', 'Barbados', '', '', ''), (18, 'fr_FR', 'Barbade', '', '', ''), -(19, 'en_US', 'Belarus', '', '', ''), +(19, 'en_EN', 'Belarus', '', '', ''), (19, 'es_ES', 'Belarús', '', '', ''), (19, 'fr_FR', 'Belau', '', '', ''), -(20, 'en_US', 'Belgium', '', '', ''), +(20, 'en_EN', 'Belgium', '', '', ''), (20, 'es_ES', 'Bélgica', '', '', ''), (20, 'fr_FR', 'Belgique', '', '', ''), -(21, 'en_US', 'Belize', '', '', ''), +(21, 'en_EN', 'Belize', '', '', ''), (21, 'es_ES', 'Belice', '', '', ''), (21, 'fr_FR', 'Belize', '', '', ''), -(22, 'en_US', 'Benin', '', '', ''), +(22, 'en_EN', 'Benin', '', '', ''), (22, 'es_ES', 'Benin', '', '', ''), (22, 'fr_FR', 'Bénin', '', '', ''), -(23, 'en_US', 'Bhutan', '', '', ''), +(23, 'en_EN', 'Bhutan', '', '', ''), (23, 'es_ES', 'Bhután', '', '', ''), (23, 'fr_FR', 'Bhoutan', '', '', ''), -(24, 'en_US', 'Bielorussia', '', '', ''), +(24, 'en_EN', 'Bielorussia', '', '', ''), (24, 'es_ES', 'Bielorusia', '', '', ''), (24, 'fr_FR', 'Biélorussie', '', '', ''), -(25, 'en_US', 'Burma', '', '', ''), +(25, 'en_EN', 'Burma', '', '', ''), (25, 'es_ES', 'Birmania', '', '', ''), (25, 'fr_FR', 'Birmanie', '', '', ''), -(26, 'en_US', 'Bolivia', '', '', ''), +(26, 'en_EN', 'Bolivia', '', '', ''), (26, 'es_ES', 'Bolivia', '', '', ''), (26, 'fr_FR', 'Bolivie', '', '', ''), -(27, 'en_US', 'Bosnia and Herzegovina', '', '', ''), +(27, 'en_EN', 'Bosnia and Herzegovina', '', '', ''), (27, 'es_ES', 'Bosnia y Herzegovina', '', '', ''), (27, 'fr_FR', 'Bosnie-Herzégovine', '', '', ''), -(28, 'en_US', 'Botswana', '', '', ''), +(28, 'en_EN', 'Botswana', '', '', ''), (28, 'es_ES', 'Botswana', '', '', ''), (28, 'fr_FR', 'Botswana', '', '', ''), -(29, 'en_US', 'Brazil', '', '', ''), +(29, 'en_EN', 'Brazil', '', '', ''), (29, 'es_ES', 'Brasil', '', '', ''), (29, 'fr_FR', 'Brésil', '', '', ''), -(30, 'en_US', 'Brunei', '', '', ''), +(30, 'en_EN', 'Brunei', '', '', ''), (30, 'es_ES', 'Brunei', '', '', ''), (30, 'fr_FR', 'Brunei', '', '', ''), -(31, 'en_US', 'Bulgaria', '', '', ''), +(31, 'en_EN', 'Bulgaria', '', '', ''), (31, 'es_ES', 'Bulgaria', '', '', ''), (31, 'fr_FR', 'Bulgarie', '', '', ''), -(32, 'en_US', 'Burkina', '', '', ''), +(32, 'en_EN', 'Burkina', '', '', ''), (32, 'es_ES', 'Burkina', '', '', ''), (32, 'fr_FR', 'Burkina', '', '', ''), -(33, 'en_US', 'Burundi', '', '', ''), +(33, 'en_EN', 'Burundi', '', '', ''), (33, 'es_ES', 'Burundi', '', '', ''), (33, 'fr_FR', 'Burundi', '', '', ''), -(34, 'en_US', 'Cambodia', '', '', ''), +(34, 'en_EN', 'Cambodia', '', '', ''), (34, 'es_ES', 'Camboya', '', '', ''), (34, 'fr_FR', 'Cambodge', '', '', ''), -(35, 'en_US', 'Cameroon', '', '', ''), +(35, 'en_EN', 'Cameroon', '', '', ''), (35, 'es_ES', 'Camerún', '', '', ''), (35, 'fr_FR', 'Cameroun', '', '', ''), -(37, 'en_US', 'Cape Verde', '', '', ''), +(37, 'en_EN', 'Cape Verde', '', '', ''), (37, 'es_ES', 'Cabo Verde', '', '', ''), (37, 'fr_FR', 'Cap-Vert', '', '', ''), -(38, 'en_US', 'Chile', '', '', ''), +(38, 'en_EN', 'Chile', '', '', ''), (38, 'es_ES', 'Chile', '', '', ''), (38, 'fr_FR', 'Chili', '', '', ''), -(39, 'en_US', 'China', '', '', ''), +(39, 'en_EN', 'China', '', '', ''), (39, 'es_ES', 'China', '', '', ''), (39, 'fr_FR', 'Chine', '', '', ''), -(40, 'en_US', 'Cyprus', '', '', ''), +(40, 'en_EN', 'Cyprus', '', '', ''), (40, 'es_ES', 'Chipre', '', '', ''), (40, 'fr_FR', 'Chypre', '', '', ''), -(41, 'en_US', 'Colombia', '', '', ''), +(41, 'en_EN', 'Colombia', '', '', ''), (41, 'es_ES', 'Colombia', '', '', ''), (41, 'fr_FR', 'Colombie', '', '', ''), -(42, 'en_US', 'Comoros', '', '', ''), +(42, 'en_EN', 'Comoros', '', '', ''), (42, 'es_ES', 'Comoras', '', '', ''), (42, 'fr_FR', 'Comores', '', '', ''), -(43, 'en_US', 'Congo', '', '', ''), +(43, 'en_EN', 'Congo', '', '', ''), (43, 'es_ES', 'Congo', '', '', ''), (43, 'fr_FR', 'Congo', '', '', ''), -(44, 'en_US', 'Cook Islands', '', '', ''), +(44, 'en_EN', 'Cook Islands', '', '', ''), (44, 'es_ES', 'Cook', '', '', ''), (44, 'fr_FR', 'Cook', '', '', ''), -(45, 'en_US', 'North Korea', '', '', ''), +(45, 'en_EN', 'North Korea', '', '', ''), (45, 'es_ES', 'Corea del Norte', '', '', ''), (45, 'fr_FR', 'Corée du Nord', '', '', ''), -(46, 'en_US', 'South Korea', '', '', ''), +(46, 'en_EN', 'South Korea', '', '', ''), (46, 'es_ES', 'Corea del Sur', '', '', ''), (46, 'fr_FR', 'Corée du Sud', '', '', ''), -(47, 'en_US', 'Costa Rica', '', '', ''), +(47, 'en_EN', 'Costa Rica', '', '', ''), (47, 'es_ES', 'Costa Rica', '', '', ''), (47, 'fr_FR', 'Costa Rica', '', '', ''), -(48, 'en_US', 'Ivory Coast', '', '', ''), +(48, 'en_EN', 'Ivory Coast', '', '', ''), (48, 'es_ES', 'Costa de Marfil', '', '', ''), (48, 'fr_FR', 'Côte dIvoire', '', '', ''), -(49, 'en_US', 'Croatia', '', '', ''), +(49, 'en_EN', 'Croatia', '', '', ''), (49, 'es_ES', 'Croacia', '', '', ''), (49, 'fr_FR', 'Croatie', '', '', ''), -(50, 'en_US', 'Cuba', '', '', ''), +(50, 'en_EN', 'Cuba', '', '', ''), (50, 'es_ES', 'Cuba', '', '', ''), (50, 'fr_FR', 'Cuba', '', '', ''), -(51, 'en_US', 'Denmark', '', '', ''), +(51, 'en_EN', 'Denmark', '', '', ''), (51, 'es_ES', 'Dinamarca', '', '', ''), (51, 'fr_FR', 'Danemark', '', '', ''), -(52, 'en_US', 'Djibouti', '', '', ''), +(52, 'en_EN', 'Djibouti', '', '', ''), (52, 'es_ES', 'Djibouti', '', '', ''), (52, 'fr_FR', 'Djibouti', '', '', ''), -(53, 'en_US', 'Dominica', '', '', ''), +(53, 'en_EN', 'Dominica', '', '', ''), (53, 'es_ES', 'Dominica', '', '', ''), (53, 'fr_FR', 'Dominique', '', '', ''), -(54, 'en_US', 'Egypt', '', '', ''), +(54, 'en_EN', 'Egypt', '', '', ''), (54, 'es_ES', 'Egipto', '', '', ''), (54, 'fr_FR', 'Égypte', '', '', ''), -(55, 'en_US', 'United Arab Emirates', '', '', ''), +(55, 'en_EN', 'United Arab Emirates', '', '', ''), (55, 'es_ES', 'Emiratos Árabes Unidos', '', '', ''), (55, 'fr_FR', 'Émirats arabes unis', '', '', ''), -(56, 'en_US', 'Ecuador', '', '', ''), +(56, 'en_EN', 'Ecuador', '', '', ''), (56, 'es_ES', 'Ecuador', '', '', ''), (56, 'fr_FR', 'Équateur', '', '', ''), -(57, 'en_US', 'Eritrea', '', '', ''), +(57, 'en_EN', 'Eritrea', '', '', ''), (57, 'es_ES', 'Eritrea', '', '', ''), (57, 'fr_FR', 'Érythrée', '', '', ''), -(58, 'en_US', 'Spain', '', '', ''), +(58, 'en_EN', 'Spain', '', '', ''), (58, 'es_ES', 'España', '', '', ''), (58, 'fr_FR', 'Espagne', '', '', ''), -(59, 'en_US', 'Estonia', '', '', ''), +(59, 'en_EN', 'Estonia', '', '', ''), (59, 'es_ES', 'Estonia', '', '', ''), (59, 'fr_FR', 'Estonie', '', '', ''), -(61, 'en_US', 'Ethiopia', '', '', ''), +(61, 'en_EN', 'Ethiopia', '', '', ''), (61, 'es_ES', 'Etiopía', '', '', ''), (61, 'fr_FR', 'Éthiopie', '', '', ''), -(62, 'en_US', 'Fiji', '', '', ''), +(62, 'en_EN', 'Fiji', '', '', ''), (62, 'es_ES', 'Fiji', '', '', ''), (62, 'fr_FR', 'Fidji', '', '', ''), -(63, 'en_US', 'Finland', '', '', ''), +(63, 'en_EN', 'Finland', '', '', ''), (63, 'es_ES', 'Finlandia', '', '', ''), (63, 'fr_FR', 'Finlande', '', '', ''), -(64, 'en_US', 'France metropolitan', '', '', ''), +(64, 'en_EN', 'France metropolitan', '', '', ''), (64, 'es_ES', 'Francia', '', '', ''), (64, 'fr_FR', 'France métropolitaine', '', '', ''), -(65, 'en_US', 'Gabon', '', '', ''), +(65, 'en_EN', 'Gabon', '', '', ''), (65, 'es_ES', 'Gabón', '', '', ''), (65, 'fr_FR', 'Gabon', '', '', ''), -(66, 'en_US', 'Gambia', '', '', ''), +(66, 'en_EN', 'Gambia', '', '', ''), (66, 'es_ES', 'Gambia', '', '', ''), (66, 'fr_FR', 'Gambie', '', '', ''), -(67, 'en_US', 'Georgia', '', '', ''), +(67, 'en_EN', 'Georgia', '', '', ''), (67, 'es_ES', 'Georgia', '', '', ''), (67, 'fr_FR', 'Géorgie', '', '', ''), -(68, 'en_US', 'Ghana', '', '', ''), +(68, 'en_EN', 'Ghana', '', '', ''), (68, 'es_ES', 'Ghana', '', '', ''), (68, 'fr_FR', 'Ghana', '', '', ''), -(69, 'en_US', 'Greece', '', '', ''), +(69, 'en_EN', 'Greece', '', '', ''), (69, 'es_ES', 'Grecia', '', '', ''), (69, 'fr_FR', 'Grèce', '', '', ''), -(70, 'en_US', 'Grenada', '', '', ''), +(70, 'en_EN', 'Grenada', '', '', ''), (70, 'es_ES', 'Granada', '', '', ''), (70, 'fr_FR', 'Grenade', '', '', ''), -(71, 'en_US', 'Guatemala', '', '', ''), +(71, 'en_EN', 'Guatemala', '', '', ''), (71, 'es_ES', 'Guatemala', '', '', ''), (71, 'fr_FR', 'Guatemala', '', '', ''), -(72, 'en_US', 'Guinea', '', '', ''), +(72, 'en_EN', 'Guinea', '', '', ''), (72, 'es_ES', 'Guinea', '', '', ''), (72, 'fr_FR', 'Guinée', '', '', ''), -(73, 'en_US', 'Guinea-Bissau', '', '', ''), +(73, 'en_EN', 'Guinea-Bissau', '', '', ''), (73, 'es_ES', 'Guinea-Bissau', '', '', ''), (73, 'fr_FR', 'Guinée-Bissao', '', '', ''), -(74, 'en_US', 'Equatorial Guinea', '', '', ''), +(74, 'en_EN', 'Equatorial Guinea', '', '', ''), (74, 'es_ES', 'Guinea Ecuatorial', '', '', ''), (74, 'fr_FR', 'Guinée équatoriale', '', '', ''), -(75, 'en_US', 'Guyana', '', '', ''), +(75, 'en_EN', 'Guyana', '', '', ''), (75, 'es_ES', 'Guyana', '', '', ''), (75, 'fr_FR', 'Guyana', '', '', ''), -(76, 'en_US', 'Haiti', '', '', ''), +(76, 'en_EN', 'Haiti', '', '', ''), (76, 'es_ES', 'Haití', '', '', ''), (76, 'fr_FR', 'Haïti', '', '', ''), -(77, 'en_US', 'Honduras', '', '', ''), +(77, 'en_EN', 'Honduras', '', '', ''), (77, 'es_ES', 'Honduras', '', '', ''), (77, 'fr_FR', 'Honduras', '', '', ''), -(78, 'en_US', 'Hungary', '', '', ''), +(78, 'en_EN', 'Hungary', '', '', ''), (78, 'es_ES', 'Hungría', '', '', ''), (78, 'fr_FR', 'Hongrie', '', '', ''), -(79, 'en_US', 'India', '', '', ''), +(79, 'en_EN', 'India', '', '', ''), (79, 'es_ES', 'India', '', '', ''), (79, 'fr_FR', 'Inde', '', '', ''), -(80, 'en_US', 'Indonesia', '', '', ''), +(80, 'en_EN', 'Indonesia', '', '', ''), (80, 'es_ES', 'Indonesia', '', '', ''), (80, 'fr_FR', 'Indonésie', '', '', ''), -(81, 'en_US', 'Iran', '', '', ''), +(81, 'en_EN', 'Iran', '', '', ''), (81, 'es_ES', 'Irán', '', '', ''), (81, 'fr_FR', 'Iran', '', '', ''), -(82, 'en_US', 'Iraq', '', '', ''), +(82, 'en_EN', 'Iraq', '', '', ''), (82, 'es_ES', 'Iraq', '', '', ''), (82, 'fr_FR', 'Iraq', '', '', ''), -(83, 'en_US', 'Ireland', '', '', ''), +(83, 'en_EN', 'Ireland', '', '', ''), (83, 'es_ES', 'Irlanda', '', '', ''), (83, 'fr_FR', 'Irlande', '', '', ''), -(84, 'en_US', 'Iceland', '', '', ''), +(84, 'en_EN', 'Iceland', '', '', ''), (84, 'es_ES', 'Islandia', '', '', ''), (84, 'fr_FR', 'Islande', '', '', ''), -(85, 'en_US', 'Israel', '', '', ''), +(85, 'en_EN', 'Israel', '', '', ''), (85, 'es_ES', 'Israel', '', '', ''), (85, 'fr_FR', 'Israël', '', '', ''), -(86, 'en_US', 'Italy', '', '', ''), +(86, 'en_EN', 'Italy', '', '', ''), (86, 'es_ES', 'Italia', '', '', ''), (86, 'fr_FR', 'Italie', '', '', ''), -(87, 'en_US', 'Jamaica', '', '', ''), +(87, 'en_EN', 'Jamaica', '', '', ''), (87, 'es_ES', 'Jamaica', '', '', ''), (87, 'fr_FR', 'Jamaïque', '', '', ''), -(88, 'en_US', 'Japan', '', '', ''), +(88, 'en_EN', 'Japan', '', '', ''), (88, 'es_ES', 'Japón', '', '', ''), (88, 'fr_FR', 'Japon', '', '', ''), -(89, 'en_US', 'Jordan', '', '', ''), +(89, 'en_EN', 'Jordan', '', '', ''), (89, 'es_ES', 'Jordania', '', '', ''), (89, 'fr_FR', 'Jordanie', '', '', ''), -(90, 'en_US', 'Kazakhstan', '', '', ''), +(90, 'en_EN', 'Kazakhstan', '', '', ''), (90, 'es_ES', 'Kazajstán', '', '', ''), (90, 'fr_FR', 'Kazakhstan', '', '', ''), -(91, 'en_US', 'Kenya', '', '', ''), +(91, 'en_EN', 'Kenya', '', '', ''), (91, 'es_ES', 'Kenia', '', '', ''), (91, 'fr_FR', 'Kenya', '', '', ''), -(92, 'en_US', 'Kyrgyzstan', '', '', ''), +(92, 'en_EN', 'Kyrgyzstan', '', '', ''), (92, 'es_ES', 'Kirguistán', '', '', ''), (92, 'fr_FR', 'Kirghizistan', '', '', ''), -(93, 'en_US', 'Kiribati', '', '', ''), +(93, 'en_EN', 'Kiribati', '', '', ''), (93, 'es_ES', 'Kiribati', '', '', ''), (93, 'fr_FR', 'Kiribati', '', '', ''), -(94, 'en_US', 'Kuwait', '', '', ''), +(94, 'en_EN', 'Kuwait', '', '', ''), (94, 'es_ES', 'Kuwait', '', '', ''), (94, 'fr_FR', 'Koweït', '', '', ''), -(95, 'en_US', 'Laos', '', '', ''), +(95, 'en_EN', 'Laos', '', '', ''), (95, 'es_ES', 'Laos', '', '', ''), (95, 'fr_FR', 'Laos', '', '', ''), -(96, 'en_US', 'Lesotho', '', '', ''), +(96, 'en_EN', 'Lesotho', '', '', ''), (96, 'es_ES', 'Lesotho', '', '', ''), (96, 'fr_FR', 'Lesotho', '', '', ''), -(97, 'en_US', 'Latvia', '', '', ''), +(97, 'en_EN', 'Latvia', '', '', ''), (97, 'es_ES', 'Letonia', '', '', ''), (97, 'fr_FR', 'Lettonie', '', '', ''), -(98, 'en_US', 'Lebanon', '', '', ''), +(98, 'en_EN', 'Lebanon', '', '', ''), (98, 'es_ES', 'Líbano', '', '', ''), (98, 'fr_FR', 'Liban', '', '', ''), -(99, 'en_US', 'Liberia', '', '', ''), +(99, 'en_EN', 'Liberia', '', '', ''), (99, 'es_ES', 'Liberia', '', '', ''), (99, 'fr_FR', 'Liberia', '', '', ''), -(100, 'en_US', 'Libya', '', '', ''), +(100, 'en_EN', 'Libya', '', '', ''), (100, 'es_ES', 'Libia', '', '', ''), (100, 'fr_FR', 'Libye', '', '', ''), -(101, 'en_US', 'Liechtenstein', '', '', ''), +(101, 'en_EN', 'Liechtenstein', '', '', ''), (101, 'es_ES', 'Liechtenstein', '', '', ''), (101, 'fr_FR', 'Liechtenstein', '', '', ''), -(102, 'en_US', 'Lithuania', '', '', ''), +(102, 'en_EN', 'Lithuania', '', '', ''), (102, 'es_ES', 'Lituania', '', '', ''), (102, 'fr_FR', 'Lituanie', '', '', ''), -(103, 'en_US', 'Luxembourg', '', '', ''), +(103, 'en_EN', 'Luxembourg', '', '', ''), (103, 'es_ES', 'Luxemburgo', '', '', ''), (103, 'fr_FR', 'Luxembourg', '', '', ''), -(104, 'en_US', 'Macedonia', '', '', ''), +(104, 'en_EN', 'Macedonia', '', '', ''), (104, 'es_ES', 'Macedonia', '', '', ''), (104, 'fr_FR', 'Macédoine', '', '', ''), -(105, 'en_US', 'Madagascar', '', '', ''), +(105, 'en_EN', 'Madagascar', '', '', ''), (105, 'es_ES', 'Madagascar', '', '', ''), (105, 'fr_FR', 'Madagascar', '', '', ''), -(106, 'en_US', 'Malaysia', '', '', ''), +(106, 'en_EN', 'Malaysia', '', '', ''), (106, 'es_ES', 'Malasia', '', '', ''), (106, 'fr_FR', 'Malaisie', '', '', ''), -(107, 'en_US', 'Malawi', '', '', ''), +(107, 'en_EN', 'Malawi', '', '', ''), (107, 'es_ES', 'Malawi', '', '', ''), (107, 'fr_FR', 'Malawi', '', '', ''), -(108, 'en_US', 'Maldives', '', '', ''), +(108, 'en_EN', 'Maldives', '', '', ''), (108, 'es_ES', 'Maldivas', '', '', ''), (108, 'fr_FR', 'Maldives', '', '', ''), -(109, 'en_US', 'Mali', '', '', ''), +(109, 'en_EN', 'Mali', '', '', ''), (109, 'es_ES', 'Malí', '', '', ''), (109, 'fr_FR', 'Mali', '', '', ''), -(110, 'en_US', 'Malta', '', '', ''), +(110, 'en_EN', 'Malta', '', '', ''), (110, 'es_ES', 'Malta', '', '', ''), (110, 'fr_FR', 'Malte', '', '', ''), -(111, 'en_US', 'Morocco', '', '', ''), +(111, 'en_EN', 'Morocco', '', '', ''), (111, 'es_ES', 'Marruecos', '', '', ''), (111, 'fr_FR', 'Maroc', '', '', ''), -(112, 'en_US', 'Marshall Islands', '', '', ''), +(112, 'en_EN', 'Marshall Islands', '', '', ''), (112, 'es_ES', 'Marshall', '', '', ''), (112, 'fr_FR', 'Marshall', '', '', ''), -(113, 'en_US', 'Mauritius', '', '', ''), +(113, 'en_EN', 'Mauritius', '', '', ''), (113, 'es_ES', 'Mauricio', '', '', ''), (113, 'fr_FR', 'Maurice', '', '', ''), -(114, 'en_US', 'Mauritania', '', '', ''), +(114, 'en_EN', 'Mauritania', '', '', ''), (114, 'es_ES', 'Mauritania', '', '', ''), (114, 'fr_FR', 'Mauritanie', '', '', ''), -(115, 'en_US', 'Mexico', '', '', ''), +(115, 'en_EN', 'Mexico', '', '', ''), (115, 'es_ES', 'Méjico', '', '', ''), (115, 'fr_FR', 'Mexique', '', '', ''), -(116, 'en_US', 'Micronesia', '', '', ''), +(116, 'en_EN', 'Micronesia', '', '', ''), (116, 'es_ES', 'Micronesia', '', '', ''), (116, 'fr_FR', 'Micronésie', '', '', ''), -(117, 'en_US', 'Moldova', '', '', ''), +(117, 'en_EN', 'Moldova', '', '', ''), (117, 'es_ES', 'Moldova', '', '', ''), (117, 'fr_FR', 'Moldavie', '', '', ''), -(118, 'en_US', 'Monaco', '', '', ''), +(118, 'en_EN', 'Monaco', '', '', ''), (118, 'es_ES', 'Mónaco', '', '', ''), (118, 'fr_FR', 'Monaco', '', '', ''), -(119, 'en_US', 'Mongolia', '', '', ''), +(119, 'en_EN', 'Mongolia', '', '', ''), (119, 'es_ES', 'Mongolia', '', '', ''), (119, 'fr_FR', 'Mongolie', '', '', ''), -(120, 'en_US', 'Mozambique', '', '', ''), +(120, 'en_EN', 'Mozambique', '', '', ''), (120, 'es_ES', 'Mozambique', '', '', ''), (120, 'fr_FR', 'Mozambique', '', '', ''), -(121, 'en_US', 'Namibia', '', '', ''), +(121, 'en_EN', 'Namibia', '', '', ''), (121, 'es_ES', 'Namibia', '', '', ''), (121, 'fr_FR', 'Namibie', '', '', ''), -(122, 'en_US', 'Nauru', '', '', ''), +(122, 'en_EN', 'Nauru', '', '', ''), (122, 'es_ES', 'Nauru', '', '', ''), (122, 'fr_FR', 'Nauru', '', '', ''), -(123, 'en_US', 'Nepal', '', '', ''), +(123, 'en_EN', 'Nepal', '', '', ''), (123, 'es_ES', 'Nepal', '', '', ''), (123, 'fr_FR', 'Népal', '', '', ''), -(124, 'en_US', 'Nicaragua', '', '', ''), +(124, 'en_EN', 'Nicaragua', '', '', ''), (124, 'es_ES', 'Nicaragua', '', '', ''), (124, 'fr_FR', 'Nicaragua', '', '', ''), -(125, 'en_US', 'Niger', '', '', ''), +(125, 'en_EN', 'Niger', '', '', ''), (125, 'es_ES', 'Níger', '', '', ''), (125, 'fr_FR', 'Niger', '', '', ''), -(126, 'en_US', 'Nigeria', '', '', ''), +(126, 'en_EN', 'Nigeria', '', '', ''), (126, 'es_ES', 'Nigeria', '', '', ''), (126, 'fr_FR', 'Nigeria', '', '', ''), -(127, 'en_US', 'Niue', '', '', ''), +(127, 'en_EN', 'Niue', '', '', ''), (127, 'es_ES', 'Niue', '', '', ''), (127, 'fr_FR', 'Niue', '', '', ''), -(128, 'en_US', 'Norway', '', '', ''), +(128, 'en_EN', 'Norway', '', '', ''), (128, 'es_ES', 'Noruega', '', '', ''), (128, 'fr_FR', 'Norvège', '', '', ''), -(129, 'en_US', 'New Zealand', '', '', ''), +(129, 'en_EN', 'New Zealand', '', '', ''), (129, 'es_ES', 'Nueva Zelandia', '', '', ''), (129, 'fr_FR', 'Nouvelle-Zélande', '', '', ''), -(130, 'en_US', 'Oman', '', '', ''), +(130, 'en_EN', 'Oman', '', '', ''), (130, 'es_ES', 'Omán', '', '', ''), (130, 'fr_FR', 'Oman', '', '', ''), -(131, 'en_US', 'Uganda', '', '', ''), +(131, 'en_EN', 'Uganda', '', '', ''), (131, 'es_ES', 'Uganda', '', '', ''), (131, 'fr_FR', 'Ouganda', '', '', ''), -(132, 'en_US', 'Uzbekistan', '', '', ''), +(132, 'en_EN', 'Uzbekistan', '', '', ''), (132, 'es_ES', 'Uzbekistán', '', '', ''), (132, 'fr_FR', 'Ouzbékistan', '', '', ''), -(133, 'en_US', 'Pakistan', '', '', ''), +(133, 'en_EN', 'Pakistan', '', '', ''), (133, 'es_ES', 'Pakistán', '', '', ''), (133, 'fr_FR', 'Pakistan', '', '', ''), -(134, 'en_US', 'Panama', '', '', ''), +(134, 'en_EN', 'Panama', '', '', ''), (134, 'es_ES', 'Panamá', '', '', ''), (134, 'fr_FR', 'Panama', '', '', ''), -(135, 'en_US', 'Papua Nueva Guinea', '', '', ''), +(135, 'en_EN', 'Papua Nueva Guinea', '', '', ''), (135, 'es_ES', 'Papua Nueva Guinea', '', '', ''), (135, 'fr_FR', 'Papouasie', '', '', ''), -(136, 'en_US', 'Paraguay', '', '', ''), +(136, 'en_EN', 'Paraguay', '', '', ''), (136, 'es_ES', 'Paraguay', '', '', ''), (136, 'fr_FR', 'Paraguay', '', '', ''), -(137, 'en_US', 'Netherlands', '', '', ''), +(137, 'en_EN', 'Netherlands', '', '', ''), (137, 'es_ES', 'Países Bajos', '', '', ''), (137, 'fr_FR', 'Pays-Bas', '', '', ''), -(138, 'en_US', 'Peru', '', '', ''), +(138, 'en_EN', 'Peru', '', '', ''), (138, 'es_ES', 'Perú', '', '', ''), (138, 'fr_FR', 'Pérou', '', '', ''), -(139, 'en_US', 'Philippines', '', '', ''), +(139, 'en_EN', 'Philippines', '', '', ''), (139, 'es_ES', 'Filipinas', '', '', ''), (139, 'fr_FR', 'Philippines', '', '', ''), -(140, 'en_US', 'Poland', '', '', ''), +(140, 'en_EN', 'Poland', '', '', ''), (140, 'es_ES', 'Polonia', '', '', ''), (140, 'fr_FR', 'Pologne', '', '', ''), -(141, 'en_US', 'Portugal', '', '', ''), +(141, 'en_EN', 'Portugal', '', '', ''), (141, 'es_ES', 'Portugal', '', '', ''), (141, 'fr_FR', 'Portugal', '', '', ''), -(142, 'en_US', 'Qatar', '', '', ''), +(142, 'en_EN', 'Qatar', '', '', ''), (142, 'es_ES', 'Qatar', '', '', ''), (142, 'fr_FR', 'Qatar', '', '', ''), -(143, 'en_US', 'Central African Republic', '', '', ''), +(143, 'en_EN', 'Central African Republic', '', '', ''), (143, 'es_ES', 'República Centroafricana', '', '', ''), (143, 'fr_FR', 'République centrafricaine', '', '', ''), -(144, 'en_US', 'Dominican Republic', '', '', ''), +(144, 'en_EN', 'Dominican Republic', '', '', ''), (144, 'es_ES', 'República Dominicana', '', '', ''), (144, 'fr_FR', 'République dominicaine', '', '', ''), -(145, 'en_US', 'Czech Republic', '', '', ''), +(145, 'en_EN', 'Czech Republic', '', '', ''), (145, 'es_ES', 'República Checa', '', '', ''), (145, 'fr_FR', 'République tchèque', '', '', ''), -(146, 'en_US', 'Romania', '', '', ''), +(146, 'en_EN', 'Romania', '', '', ''), (146, 'es_ES', 'Rumania', '', '', ''), (146, 'fr_FR', 'Roumanie', '', '', ''), -(147, 'en_US', 'United Kingdom', '', '', ''), +(147, 'en_EN', 'United Kingdom', '', '', ''), (147, 'es_ES', 'Reino Unido', '', '', ''), (147, 'fr_FR', 'Royaume-Uni', '', '', ''), -(148, 'en_US', 'Russia', '', '', ''), +(148, 'en_EN', 'Russia', '', '', ''), (148, 'es_ES', 'Rusia', '', '', ''), (148, 'fr_FR', 'Russie', '', '', ''), -(149, 'en_US', 'Rwanda', '', '', ''), +(149, 'en_EN', 'Rwanda', '', '', ''), (149, 'es_ES', 'Ruanda', '', '', ''), (149, 'fr_FR', 'Rwanda', '', '', ''), -(150, 'en_US', 'Saint Kitts and Nevis', '', '', ''), +(150, 'en_EN', 'Saint Kitts and Nevis', '', '', ''), (150, 'es_ES', 'San Cristóbal', '', '', ''), (150, 'fr_FR', 'Saint-Christophe-et-Niévès', '', '', ''), -(151, 'en_US', 'Saint Lucia', '', '', ''), +(151, 'en_EN', 'Saint Lucia', '', '', ''), (151, 'es_ES', 'Santa Lucía', '', '', ''), (151, 'fr_FR', 'Sainte-Lucie', '', '', ''), -(152, 'en_US', 'San Marino', '', '', ''), +(152, 'en_EN', 'San Marino', '', '', ''), (152, 'es_ES', 'San Marino', '', '', ''), (152, 'fr_FR', 'Saint-Marin', '', '', ''), -(153, 'en_US', 'Saint Vincent and the Grenadines', '', '', ''), +(153, 'en_EN', 'Saint Vincent and the Grenadines', '', '', ''), (153, 'es_ES', 'San Vicente y las Granadinas', '', '', ''), (153, 'fr_FR', 'Saint-Vincent-et-les Grenadines', '', '', ''), -(154, 'en_US', 'Solomon Islands', '', '', ''), +(154, 'en_EN', 'Solomon Islands', '', '', ''), (154, 'es_ES', 'Salomón', '', '', ''), (154, 'fr_FR', 'Salomon', '', '', ''), -(155, 'en_US', 'El Salvador', '', '', ''), +(155, 'en_EN', 'El Salvador', '', '', ''), (155, 'es_ES', 'El Salvador', '', '', ''), (155, 'fr_FR', 'Salvador', '', '', ''), -(156, 'en_US', 'Western Samoa', '', '', ''), +(156, 'en_EN', 'Western Samoa', '', '', ''), (156, 'es_ES', 'Samoa', '', '', ''), (156, 'fr_FR', 'Samoa occidentales', '', '', ''), -(157, 'en_US', 'Sao Tome and Principe', '', '', ''), +(157, 'en_EN', 'Sao Tome and Principe', '', '', ''), (157, 'es_ES', 'Santo Tomé y Príncipe', '', '', ''), (157, 'fr_FR', 'Sao Tomé-et-Principe', '', '', ''), -(158, 'en_US', 'Senegal', '', '', ''), +(158, 'en_EN', 'Senegal', '', '', ''), (158, 'es_ES', 'Senegal', '', '', ''), (158, 'fr_FR', 'Sénégal', '', '', ''), -(159, 'en_US', 'Seychelles', '', '', ''), +(159, 'en_EN', 'Seychelles', '', '', ''), (159, 'es_ES', 'Seychelles', '', '', ''), (159, 'fr_FR', 'Seychelles', '', '', ''), -(160, 'en_US', 'Sierra Leone', '', '', ''), +(160, 'en_EN', 'Sierra Leone', '', '', ''), (160, 'es_ES', 'Sierra Leona', '', '', ''), (160, 'fr_FR', 'Sierra Leone', '', '', ''), -(161, 'en_US', 'Singapore', '', '', ''), +(161, 'en_EN', 'Singapore', '', '', ''), (161, 'es_ES', 'Singapur', '', '', ''), (161, 'fr_FR', 'Singapour', '', '', ''), -(162, 'en_US', 'Slovakia', '', '', ''), +(162, 'en_EN', 'Slovakia', '', '', ''), (162, 'es_ES', 'Eslovaquia', '', '', ''), (162, 'fr_FR', 'Slovaquie', '', '', ''), -(163, 'en_US', 'Slovenia', '', '', ''), +(163, 'en_EN', 'Slovenia', '', '', ''), (163, 'es_ES', 'Eslovenia', '', '', ''), (163, 'fr_FR', 'Slovénie', '', '', ''), -(164, 'en_US', 'Somalia', '', '', ''), +(164, 'en_EN', 'Somalia', '', '', ''), (164, 'es_ES', 'Somalia', '', '', ''), (164, 'fr_FR', 'Somalie', '', '', ''), -(165, 'en_US', 'Sudan', '', '', ''), +(165, 'en_EN', 'Sudan', '', '', ''), (165, 'es_ES', 'Sudán', '', '', ''), (165, 'fr_FR', 'Soudan', '', '', ''), -(166, 'en_US', 'Sri Lanka', '', '', ''), +(166, 'en_EN', 'Sri Lanka', '', '', ''), (166, 'es_ES', 'Sri Lanka', '', '', ''), (166, 'fr_FR', 'Sri Lanka', '', '', ''), -(167, 'en_US', 'Sweden', '', '', ''), +(167, 'en_EN', 'Sweden', '', '', ''), (167, 'es_ES', 'Suecia', '', '', ''), (167, 'fr_FR', 'Suède', '', '', ''), -(168, 'en_US', 'Switzerland', '', '', ''), +(168, 'en_EN', 'Switzerland', '', '', ''), (168, 'es_ES', 'Suiza', '', '', ''), (168, 'fr_FR', 'Suisse', '', '', ''), -(169, 'en_US', 'Suriname', '', '', ''), +(169, 'en_EN', 'Suriname', '', '', ''), (169, 'es_ES', 'Suriname', '', '', ''), (169, 'fr_FR', 'Suriname', '', '', ''), -(170, 'en_US', 'Swaziland', '', '', ''), +(170, 'en_EN', 'Swaziland', '', '', ''), (170, 'es_ES', 'Swazilandia', '', '', ''), (170, 'fr_FR', 'Swaziland', '', '', ''), -(171, 'en_US', 'Syria', '', '', ''), +(171, 'en_EN', 'Syria', '', '', ''), (171, 'es_ES', 'Siria', '', '', ''), (171, 'fr_FR', 'Syrie', '', '', ''), -(172, 'en_US', 'Tajikistan', '', '', ''), +(172, 'en_EN', 'Tajikistan', '', '', ''), (172, 'es_ES', 'Tayikistán', '', '', ''), (172, 'fr_FR', 'Tadjikistan', '', '', ''), -(173, 'en_US', 'Tanzania', '', '', ''), +(173, 'en_EN', 'Tanzania', '', '', ''), (173, 'es_ES', 'Tanzanía', '', '', ''), (173, 'fr_FR', 'Tanzanie', '', '', ''), -(174, 'en_US', 'Chad', '', '', ''), +(174, 'en_EN', 'Chad', '', '', ''), (174, 'es_ES', 'Chad', '', '', ''), (174, 'fr_FR', 'Tchad', '', '', ''), -(175, 'en_US', 'Thailand', '', '', ''), +(175, 'en_EN', 'Thailand', '', '', ''), (175, 'es_ES', 'Tailandia', '', '', ''), (175, 'fr_FR', 'Thaïlande', '', '', ''), -(176, 'en_US', 'Togo', '', '', ''), +(176, 'en_EN', 'Togo', '', '', ''), (176, 'es_ES', 'Togo', '', '', ''), (176, 'fr_FR', 'Togo', '', '', ''), -(177, 'en_US', 'Tonga', '', '', ''), +(177, 'en_EN', 'Tonga', '', '', ''), (177, 'es_ES', 'Tonga', '', '', ''), (177, 'fr_FR', 'Tonga', '', '', ''), -(178, 'en_US', 'Trinidad and Tobago', '', '', ''), +(178, 'en_EN', 'Trinidad and Tobago', '', '', ''), (178, 'es_ES', 'Trinidad y Tabago', '', '', ''), (178, 'fr_FR', 'Trinité-et-Tobago', '', '', ''), -(179, 'en_US', 'Tunisia', '', '', ''), +(179, 'en_EN', 'Tunisia', '', '', ''), (179, 'es_ES', 'Túnez', '', '', ''), (179, 'fr_FR', 'Tunisie', '', '', ''), -(180, 'en_US', 'Turkmenistan', '', '', ''), +(180, 'en_EN', 'Turkmenistan', '', '', ''), (180, 'es_ES', 'Turkmenistán', '', '', ''), (180, 'fr_FR', 'Turkménistan', '', '', ''), -(181, 'en_US', 'Turkey', '', '', ''), +(181, 'en_EN', 'Turkey', '', '', ''), (181, 'es_ES', 'Turquía', '', '', ''), (181, 'fr_FR', 'Turquie', '', '', ''), -(182, 'en_US', 'Tuvalu', '', '', ''), +(182, 'en_EN', 'Tuvalu', '', '', ''), (182, 'es_ES', 'Tuvalu', '', '', ''), (182, 'fr_FR', 'Tuvalu', '', '', ''), -(183, 'en_US', 'Ukraine', '', '', ''), +(183, 'en_EN', 'Ukraine', '', '', ''), (183, 'es_ES', 'Ucrania', '', '', ''), (183, 'fr_FR', 'Ukraine', '', '', ''), -(184, 'en_US', 'Uruguay', '', '', ''), +(184, 'en_EN', 'Uruguay', '', '', ''), (184, 'es_ES', 'Uruguay', '', '', ''), (184, 'fr_FR', 'Uruguay', '', '', ''), -(185, 'en_US', 'The Vatican', '', '', ''), +(185, 'en_EN', 'The Vatican', '', '', ''), (185, 'es_ES', 'El Vatican', '', '', ''), (185, 'fr_FR', 'Vatican', '', '', ''), -(186, 'en_US', 'Vanuatu', '', '', ''), +(186, 'en_EN', 'Vanuatu', '', '', ''), (186, 'es_ES', 'Vanuatu', '', '', ''), (186, 'fr_FR', 'Vanuatu', '', '', ''), -(187, 'en_US', 'Venezuela', '', '', ''), +(187, 'en_EN', 'Venezuela', '', '', ''), (187, 'es_ES', 'Venezuela', '', '', ''), (187, 'fr_FR', 'Venezuela', '', '', ''), -(188, 'en_US', 'Vietnam', '', '', ''), +(188, 'en_EN', 'Vietnam', '', '', ''), (188, 'es_ES', 'Viet Nam', '', '', ''), (188, 'fr_FR', 'Viêt Nam', '', '', ''), -(189, 'en_US', 'Yemen', '', '', ''), +(189, 'en_EN', 'Yemen', '', '', ''), (189, 'es_ES', 'Yemen', '', '', ''), (189, 'fr_FR', 'Yémen', '', '', ''), -(190, 'en_US', 'Yougoslavia', '', '', ''), +(190, 'en_EN', 'Yougoslavia', '', '', ''), (190, 'es_ES', 'Yugoslavia', '', '', ''), (190, 'fr_FR', 'Yougoslavie', '', '', ''), -(191, 'en_US', 'Zaire', '', '', ''), +(191, 'en_EN', 'Zaire', '', '', ''), (191, 'es_ES', 'Zaire', '', '', ''), (191, 'fr_FR', 'Zaïre', '', '', ''), -(192, 'en_US', 'Zambia', '', '', ''), +(192, 'en_EN', 'Zambia', '', '', ''), (192, 'es_ES', 'Zambia', '', '', ''), (192, 'fr_FR', 'Zambie', '', '', ''), -(193, 'en_US', 'Zimbabwe', '', '', ''), +(193, 'en_EN', 'Zimbabwe', '', '', ''), (193, 'es_ES', 'Zimbabwe', '', '', ''), (193, 'fr_FR', 'Zimbabwe', '', '', ''), -(196, 'en_US', 'USA - Alaska', '', '', ''), +(196, 'en_EN', 'USA - Alaska', '', '', ''), (196, 'es_ES', 'USA - Alaska', '', '', ''), (196, 'fr_FR', 'USA - Alaska', '', '', ''), -(197, 'en_US', 'USA - Arizona', '', '', ''), +(197, 'en_EN', 'USA - Arizona', '', '', ''), (197, 'es_ES', 'USA - Arizona', '', '', ''), (197, 'fr_FR', 'USA - Arizona', '', '', ''), -(198, 'en_US', 'USA - Arkansas', '', '', ''), +(198, 'en_EN', 'USA - Arkansas', '', '', ''), (198, 'es_ES', 'USA - Arkansas', '', '', ''), (198, 'fr_FR', 'USA - Arkansas', '', '', ''), -(199, 'en_US', 'USA - California', '', '', ''), +(199, 'en_EN', 'USA - California', '', '', ''), (199, 'es_ES', 'USA - California', '', '', ''), (199, 'fr_FR', 'USA - California', '', '', ''), -(200, 'en_US', 'USA - Colorado', '', '', ''), +(200, 'en_EN', 'USA - Colorado', '', '', ''), (200, 'es_ES', 'USA - Colorado', '', '', ''), (200, 'fr_FR', 'USA - Colorado', '', '', ''), -(201, 'en_US', 'USA - Connecticut', '', '', ''), +(201, 'en_EN', 'USA - Connecticut', '', '', ''), (201, 'es_ES', 'USA - Connecticut', '', '', ''), (201, 'fr_FR', 'USA - Connecticut', '', '', ''), -(202, 'en_US', 'USA - Delaware', '', '', ''), +(202, 'en_EN', 'USA - Delaware', '', '', ''), (202, 'es_ES', 'USA - Delaware', '', '', ''), (202, 'fr_FR', 'USA - Delaware', '', '', ''), -(203, 'en_US', 'USA - District Of Columbia', '', '', ''), +(203, 'en_EN', 'USA - District Of Columbia', '', '', ''), (203, 'es_ES', 'USA - District Of Columbia', '', '', ''), (203, 'fr_FR', 'USA - District Of Columbia', '', '', ''), -(204, 'en_US', 'USA - Florida', '', '', ''), +(204, 'en_EN', 'USA - Florida', '', '', ''), (204, 'es_ES', 'USA - Florida', '', '', ''), (204, 'fr_FR', 'USA - Florida', '', '', ''), -(205, 'en_US', 'USA - Georgia', '', '', ''), +(205, 'en_EN', 'USA - Georgia', '', '', ''), (205, 'es_ES', 'USA - Georgia', '', '', ''), (205, 'fr_FR', 'USA - Georgia', '', '', ''), -(206, 'en_US', 'USA - Hawaii', '', '', ''), +(206, 'en_EN', 'USA - Hawaii', '', '', ''), (206, 'es_ES', 'USA - Hawaii', '', '', ''), (206, 'fr_FR', 'USA - Hawaii', '', '', ''), -(207, 'en_US', 'USA - Idaho', '', '', ''), +(207, 'en_EN', 'USA - Idaho', '', '', ''), (207, 'es_ES', 'USA - Idaho', '', '', ''), (207, 'fr_FR', 'USA - Idaho', '', '', ''), -(208, 'en_US', 'USA - Illinois', '', '', ''), +(208, 'en_EN', 'USA - Illinois', '', '', ''), (208, 'es_ES', 'USA - Illinois', '', '', ''), (208, 'fr_FR', 'USA - Illinois', '', '', ''), -(209, 'en_US', 'USA - Indiana', '', '', ''), +(209, 'en_EN', 'USA - Indiana', '', '', ''), (209, 'es_ES', 'USA - Indiana', '', '', ''), (209, 'fr_FR', 'USA - Indiana', '', '', ''), -(210, 'en_US', 'USA - Iowa', '', '', ''), +(210, 'en_EN', 'USA - Iowa', '', '', ''), (210, 'es_ES', 'USA - Iowa', '', '', ''), (210, 'fr_FR', 'USA - Iowa', '', '', ''), -(211, 'en_US', 'USA - Kansas', '', '', ''), +(211, 'en_EN', 'USA - Kansas', '', '', ''), (211, 'es_ES', 'USA - Kansas', '', '', ''), (211, 'fr_FR', 'USA - Kansas', '', '', ''), -(212, 'en_US', 'USA - Kentucky', '', '', ''), +(212, 'en_EN', 'USA - Kentucky', '', '', ''), (212, 'es_ES', 'USA - Kentucky', '', '', ''), (212, 'fr_FR', 'USA - Kentucky', '', '', ''), -(213, 'en_US', 'USA - Louisiana', '', '', ''), +(213, 'en_EN', 'USA - Louisiana', '', '', ''), (213, 'es_ES', 'USA - Louisiana', '', '', ''), (213, 'fr_FR', 'USA - Louisiana', '', '', ''), -(214, 'en_US', 'USA - Maine', '', '', ''), +(214, 'en_EN', 'USA - Maine', '', '', ''), (214, 'es_ES', 'USA - Maine', '', '', ''), (214, 'fr_FR', 'USA - Maine', '', '', ''), -(215, 'en_US', 'USA - Maryland', '', '', ''), +(215, 'en_EN', 'USA - Maryland', '', '', ''), (215, 'es_ES', 'USA - Maryland', '', '', ''), (215, 'fr_FR', 'USA - Maryland', '', '', ''), -(216, 'en_US', 'USA - Massachusetts', '', '', ''), +(216, 'en_EN', 'USA - Massachusetts', '', '', ''), (216, 'es_ES', 'USA - Massachusetts', '', '', ''), (216, 'fr_FR', 'USA - Massachusetts', '', '', ''), -(217, 'en_US', 'USA - Michigan', '', '', ''), +(217, 'en_EN', 'USA - Michigan', '', '', ''), (217, 'es_ES', 'USA - Michigan', '', '', ''), (217, 'fr_FR', 'USA - Michigan', '', '', ''), -(218, 'en_US', 'USA - Minnesota', '', '', ''), +(218, 'en_EN', 'USA - Minnesota', '', '', ''), (218, 'es_ES', 'USA - Minnesota', '', '', ''), (218, 'fr_FR', 'USA - Minnesota', '', '', ''), -(219, 'en_US', 'USA - Mississippi', '', '', ''), +(219, 'en_EN', 'USA - Mississippi', '', '', ''), (219, 'es_ES', 'USA - Mississippi', '', '', ''), (219, 'fr_FR', 'USA - Mississippi', '', '', ''), -(220, 'en_US', 'USA - Missouri', '', '', ''), +(220, 'en_EN', 'USA - Missouri', '', '', ''), (220, 'es_ES', 'USA - Missouri', '', '', ''), (220, 'fr_FR', 'USA - Missouri', '', '', ''), -(221, 'en_US', 'USA - Montana', '', '', ''), +(221, 'en_EN', 'USA - Montana', '', '', ''), (221, 'es_ES', 'USA - Montana', '', '', ''), (221, 'fr_FR', 'USA - Montana', '', '', ''), -(222, 'en_US', 'USA - Nebraska', '', '', ''), +(222, 'en_EN', 'USA - Nebraska', '', '', ''), (222, 'es_ES', 'USA - Nebraska', '', '', ''), (222, 'fr_FR', 'USA - Nebraska', '', '', ''), -(223, 'en_US', 'USA - Nevada', '', '', ''), +(223, 'en_EN', 'USA - Nevada', '', '', ''), (223, 'es_ES', 'USA - Nevada', '', '', ''), (223, 'fr_FR', 'USA - Nevada', '', '', ''), -(224, 'en_US', 'USA - New Hampshire', '', '', ''), +(224, 'en_EN', 'USA - New Hampshire', '', '', ''), (224, 'es_ES', 'USA - New Hampshire', '', '', ''), (224, 'fr_FR', 'USA - New Hampshire', '', '', ''), -(225, 'en_US', 'USA - New Jersey', '', '', ''), +(225, 'en_EN', 'USA - New Jersey', '', '', ''), (225, 'es_ES', 'USA - New Jersey', '', '', ''), (225, 'fr_FR', 'USA - New Jersey', '', '', ''), -(226, 'en_US', 'USA - New Mexico', '', '', ''), +(226, 'en_EN', 'USA - New Mexico', '', '', ''), (226, 'es_ES', 'USA - New Mexico', '', '', ''), (226, 'fr_FR', 'USA - New Mexico', '', '', ''), -(227, 'en_US', 'USA - New York', '', '', ''), +(227, 'en_EN', 'USA - New York', '', '', ''), (227, 'es_ES', 'USA - New York', '', '', ''), (227, 'fr_FR', 'USA - New York', '', '', ''), -(228, 'en_US', 'USA - North Carolina', '', '', ''), +(228, 'en_EN', 'USA - North Carolina', '', '', ''), (228, 'es_ES', 'USA - North Carolina', '', '', ''), (228, 'fr_FR', 'USA - North Carolina', '', '', ''), -(229, 'en_US', 'USA - North Dakota', '', '', ''), +(229, 'en_EN', 'USA - North Dakota', '', '', ''), (229, 'es_ES', 'USA - North Dakota', '', '', ''), (229, 'fr_FR', 'USA - North Dakota', '', '', ''), -(230, 'en_US', 'USA - Ohio', '', '', ''), +(230, 'en_EN', 'USA - Ohio', '', '', ''), (230, 'es_ES', 'USA - Ohio', '', '', ''), (230, 'fr_FR', 'USA - Ohio', '', '', ''), -(231, 'en_US', 'USA - Oklahoma', '', '', ''), +(231, 'en_EN', 'USA - Oklahoma', '', '', ''), (231, 'es_ES', 'USA - Oklahoma', '', '', ''), (231, 'fr_FR', 'USA - Oklahoma', '', '', ''), -(232, 'en_US', 'USA - Oregon', '', '', ''), +(232, 'en_EN', 'USA - Oregon', '', '', ''), (232, 'es_ES', 'USA - Oregon', '', '', ''), (232, 'fr_FR', 'USA - Oregon', '', '', ''), -(233, 'en_US', 'USA - Pennsylvania', '', '', ''), +(233, 'en_EN', 'USA - Pennsylvania', '', '', ''), (233, 'es_ES', 'USA - Pennsylvania', '', '', ''), (233, 'fr_FR', 'USA - Pennsylvania', '', '', ''), -(234, 'en_US', 'USA - Rhode Island', '', '', ''), +(234, 'en_EN', 'USA - Rhode Island', '', '', ''), (234, 'es_ES', 'USA - Rhode Island', '', '', ''), (234, 'fr_FR', 'USA - Rhode Island', '', '', ''), -(235, 'en_US', 'USA - South Carolina', '', '', ''), +(235, 'en_EN', 'USA - South Carolina', '', '', ''), (235, 'es_ES', 'USA - South Carolina', '', '', ''), (235, 'fr_FR', 'USA - South Carolina', '', '', ''), -(236, 'en_US', 'USA - South Dakota', '', '', ''), +(236, 'en_EN', 'USA - South Dakota', '', '', ''), (236, 'es_ES', 'USA - South Dakota', '', '', ''), (236, 'fr_FR', 'USA - South Dakota', '', '', ''), -(237, 'en_US', 'USA - Tennessee', '', '', ''), +(237, 'en_EN', 'USA - Tennessee', '', '', ''), (237, 'es_ES', 'USA - Tennessee', '', '', ''), (237, 'fr_FR', 'USA - Tennessee', '', '', ''), -(238, 'en_US', 'USA - Texas', '', '', ''), +(238, 'en_EN', 'USA - Texas', '', '', ''), (238, 'es_ES', 'USA - Texas', '', '', ''), (238, 'fr_FR', 'USA - Texas', '', '', ''), -(239, 'en_US', 'USA - Utah', '', '', ''), +(239, 'en_EN', 'USA - Utah', '', '', ''), (239, 'es_ES', 'USA - Utah', '', '', ''), (239, 'fr_FR', 'USA - Utah', '', '', ''), -(240, 'en_US', 'USA - Vermont', '', '', ''), +(240, 'en_EN', 'USA - Vermont', '', '', ''), (240, 'es_ES', 'USA - Vermont', '', '', ''), (240, 'fr_FR', 'USA - Vermont', '', '', ''), -(241, 'en_US', 'USA - Virginia', '', '', ''), +(241, 'en_EN', 'USA - Virginia', '', '', ''), (241, 'es_ES', 'USA - Virginia', '', '', ''), (241, 'fr_FR', 'USA - Virginia', '', '', ''), -(242, 'en_US', 'USA - Washington', '', '', ''), +(242, 'en_EN', 'USA - Washington', '', '', ''), (242, 'es_ES', 'USA - Washington', '', '', ''), (242, 'fr_FR', 'USA - Washington', '', '', ''), -(243, 'en_US', 'USA - West Virginia', '', '', ''), +(243, 'en_EN', 'USA - West Virginia', '', '', ''), (243, 'es_ES', 'USA - West Virginia', '', '', ''), (243, 'fr_FR', 'USA - West Virginia', '', '', ''), -(244, 'en_US', 'USA - Wisconsin', '', '', ''), +(244, 'en_EN', 'USA - Wisconsin', '', '', ''), (244, 'es_ES', 'USA - Wisconsin', '', '', ''), (244, 'fr_FR', 'USA - Wisconsin', '', '', ''), -(245, 'en_US', 'USA - Wyoming', '', '', ''), +(245, 'en_EN', 'USA - Wyoming', '', '', ''), (245, 'es_ES', 'USA - Wyoming', '', '', ''), (245, 'fr_FR', 'USA - Wyoming', '', '', ''), -(246, 'en_US', 'Canada - Colombie-Britannique', '', '', ''), +(246, 'en_EN', 'Canada - Colombie-Britannique', '', '', ''), (246, 'es_ES', 'Canada - Colombie-Britannique', '', '', ''), (246, 'fr_FR', 'Canada - Colombie-Britannique', '', '', ''), -(247, 'en_US', 'Canada - Alberta', '', '', ''), +(247, 'en_EN', 'Canada - Alberta', '', '', ''), (247, 'es_ES', 'Canada - Alberta', '', '', ''), (247, 'fr_FR', 'Canada - Alberta', '', '', ''), -(248, 'en_US', 'Canada - Saskatchewan', '', '', ''), +(248, 'en_EN', 'Canada - Saskatchewan', '', '', ''), (248, 'es_ES', 'Canada - Saskatchewan', '', '', ''), (248, 'fr_FR', 'Canada - Saskatchewan', '', '', ''), -(249, 'en_US', 'Canada - Manitoba', '', '', ''), +(249, 'en_EN', 'Canada - Manitoba', '', '', ''), (249, 'es_ES', 'Canada - Manitoba', '', '', ''), (249, 'fr_FR', 'Canada - Manitoba', '', '', ''), -(250, 'en_US', 'Canada - Ontario', '', '', ''), +(250, 'en_EN', 'Canada - Ontario', '', '', ''), (250, 'es_ES', 'Canada - Ontario', '', '', ''), (250, 'fr_FR', 'Canada - Ontario', '', '', ''), -(251, 'en_US', 'Canada - Québec', '', '', ''), +(251, 'en_EN', 'Canada - Québec', '', '', ''), (251, 'es_ES', 'Canada - Québec', '', '', ''), (251, 'fr_FR', 'Canada - Québec', '', '', ''), -(252, 'en_US', 'Canada - Nouveau-Brunswick', '', '', ''), +(252, 'en_EN', 'Canada - Nouveau-Brunswick', '', '', ''), (252, 'es_ES', 'Canada - Nouveau-Brunswick', '', '', ''), (252, 'fr_FR', 'Canada - Nouveau-Brunswick', '', '', ''), -(253, 'en_US', 'Canada - Nouvelle-Écosse', '', '', ''), +(253, 'en_EN', 'Canada - Nouvelle-Écosse', '', '', ''), (253, 'es_ES', 'Canada - Nouvelle-Écosse', '', '', ''), (253, 'fr_FR', 'Canada - Nouvelle-Écosse', '', '', ''), -(254, 'en_US', 'Canada - Île-du-Prince-Édouard ', '', '', ''), +(254, 'en_EN', 'Canada - Île-du-Prince-Édouard ', '', '', ''), (254, 'es_ES', 'Canada - Île-du-Prince-Édouard ', '', '', ''), (254, 'fr_FR', 'Canada - Île-du-Prince-Édouard ', '', '', ''), -(255, 'en_US', 'Canada - Terre-Neuve-et-Labrador ', '', '', ''), +(255, 'en_EN', 'Canada - Terre-Neuve-et-Labrador ', '', '', ''), (255, 'es_ES', 'Canada - Terre-Neuve-et-Labrador ', '', '', ''), (255, 'fr_FR', 'Canada - Terre-Neuve-et-Labrador ', '', '', ''), -(256, 'en_US', 'Canada - Yukon', '', '', ''), +(256, 'en_EN', 'Canada - Yukon', '', '', ''), (256, 'es_ES', 'Canada - Yukon', '', '', ''), (256, 'fr_FR', 'Canada - Yukon', '', '', ''), -(257, 'en_US', 'Canada - Territoires-du-Nord-Ouest', '', '', ''), +(257, 'en_EN', 'Canada - Territoires-du-Nord-Ouest', '', '', ''), (257, 'es_ES', 'Canada - Territoires-du-Nord-Ouest', '', '', ''), (257, 'fr_FR', 'Canada - Territoires-du-Nord-Ouest', '', '', ''), -(258, 'en_US', 'Canada - Nunavut', '', '', ''), +(258, 'en_EN', 'Canada - Nunavut', '', '', ''), (258, 'es_ES', 'Canada - Nunavut', '', '', ''), (258, 'fr_FR', 'Canada - Nunavut', '', '', ''), -(259, 'en_US', 'Guadeloupe', '', '', ''), +(259, 'en_EN', 'Guadeloupe', '', '', ''), (259, 'es_ES', 'Guadeloupe', '', '', ''), (259, 'fr_FR', 'Guadeloupe', '', '', ''), -(260, 'en_US', 'Guyane Française', '', '', ''), +(260, 'en_EN', 'Guyane Française', '', '', ''), (260, 'es_ES', 'Guyane Française', '', '', ''), (260, 'fr_FR', 'Guyane Française', '', '', ''), -(261, 'en_US', 'Martinique', '', '', ''), +(261, 'en_EN', 'Martinique', '', '', ''), (261, 'es_ES', 'Martinique', '', '', ''), (261, 'fr_FR', 'Martinique', '', '', ''), -(262, 'en_US', 'Mayotte', '', '', ''), +(262, 'en_EN', 'Mayotte', '', '', ''), (262, 'es_ES', 'Mayotte', '', '', ''), (262, 'fr_FR', 'Mayotte', '', '', ''), -(263, 'en_US', 'Réunion(La)', '', '', ''), +(263, 'en_EN', 'Réunion(La)', '', '', ''), (263, 'es_ES', 'Réunion(La)', '', '', ''), (263, 'fr_FR', 'Réunion(La)', '', '', ''), -(264, 'en_US', 'St Pierre et Miquelon', '', '', ''), +(264, 'en_EN', 'St Pierre et Miquelon', '', '', ''), (264, 'es_ES', 'St Pierre et Miquelon', '', '', ''), (264, 'fr_FR', 'St Pierre et Miquelon', '', '', ''), -(265, 'en_US', 'Nouvelle-Calédonie', '', '', ''), +(265, 'en_EN', 'Nouvelle-Calédonie', '', '', ''), (265, 'es_ES', 'Nouvelle-Calédonie', '', '', ''), (265, 'fr_FR', 'Nouvelle-Calédonie', '', '', ''), -(266, 'en_US', 'Polynésie française', '', '', ''), +(266, 'en_EN', 'Polynésie française', '', '', ''), (266, 'es_ES', 'Polynésie française', '', '', ''), (266, 'fr_FR', 'Polynésie française', '', '', ''), -(267, 'en_US', 'Wallis-et-Futuna', '', '', ''), +(267, 'en_EN', 'Wallis-et-Futuna', '', '', ''), (267, 'es_ES', 'Wallis-et-Futuna', '', '', ''), (267, 'fr_FR', 'Wallis-et-Futuna', '', '', ''), -(268, 'en_US', 'USA - Alabama', '', '', ''), +(268, 'en_EN', 'USA - Alabama', '', '', ''), (268, 'es_ES', 'USA - Alabama', '', '', ''), (268, 'fr_FR', 'USA - Alabama', '', '', ''); diff --git a/templates/default/category.html b/templates/default/category.html index 8b52f0afc..af4cdcf14 100755 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -221,4 +221,16 @@ {/loop} +
    + +

    CURRENCIES

    + +
      + {loop name="cur" type="currency"} +
    • + #NAME (#SYMBOL) +
    • + {/loop} +
    +
    \ No newline at end of file diff --git a/templates/default/debug.html b/templates/default/debug.html index 62966680a..21f69ad33 100755 --- a/templates/default/debug.html +++ b/templates/default/debug.html @@ -1,12 +1,12 @@

    ALL ATTRIBUTES AND THEIR AVAILABILITY

      - {loop name="attr" type="attribute" order="manual"} + {loop name="attr" type="attribute" order="manual" lang="2" backend_context="true"}
    • - #TITLE + {if #IS_TRANSLATED == 1}#TITLE{else}to be translated{/if}
        - {loop name="attrav" type="attribute_availability" order="manual" attribute="#ID"} -
      • #TITLE
      • + {loop name="attrav" type="attribute_availability" order="manual" attribute="#ID" lang="3"} +
      • {if #IS_TRANSLATED == 1}#TITLE{else}to be translated{/if}
      • {/loop}
    • From 430baa6cdaf14e9930bf18a4dcfa8ad84168589d Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Mon, 26 Aug 2013 14:44:39 +0200 Subject: [PATCH 033/268] url output in loops --- core/lib/Thelia/Core/Template/Loop/Content.php | 1 + core/lib/Thelia/Core/Template/Loop/Folder.php | 1 + core/lib/Thelia/Core/Template/Loop/Product.php | 1 + core/lib/Thelia/Model/Category.php | 4 +++- core/lib/Thelia/Model/Content.php | 6 +++++- core/lib/Thelia/Model/Folder.php | 5 +++++ core/lib/Thelia/Model/Product.php | 7 ++++++- 7 files changed, 22 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Content.php b/core/lib/Thelia/Core/Template/Loop/Content.php index e97d63c55..6632a184c 100755 --- a/core/lib/Thelia/Core/Template/Loop/Content.php +++ b/core/lib/Thelia/Core/Template/Loop/Content.php @@ -226,6 +226,7 @@ class Content extends BaseLoop ->set("DESCRIPTION", $content->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM", $content->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("POSITION", $content->getPosition()) + ->set("URL", $content->getUrl()) ; $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php index 502e0895f..c95b0dc42 100755 --- a/core/lib/Thelia/Core/Template/Loop/Folder.php +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -168,6 +168,7 @@ class Folder extends BaseLoop ->set("DESCRIPTION", $folder->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("PARENT", $folder->getParent()) + ->set("URL", $folder->getUrl()) ->set("CONTENT_COUNT", $folder->countChild()) ->set("VISIBLE", $folder->getVisible() ? "1" : "0") ->set("POSITION", $folder->getPosition()) diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 2f3d25f87..10112ef28 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -520,6 +520,7 @@ class Product extends BaseLoop ->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("URL", $product->getUrl()) ->set("BEST_PRICE", $product->getVirtualColumn('real_lowest_price')) ->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo')) ->set("IS_NEW", $product->getVirtualColumn('main_product_is_new')) diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php index 35ac49e0e..a05b46b71 100755 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -5,7 +5,8 @@ namespace Thelia\Model; use Thelia\Model\Base\Category as BaseCategory; use Propel\Runtime\ActiveQuery\Criteria; -class Category extends BaseCategory { +class Category extends BaseCategory +{ /** * @return int number of child for the current category */ @@ -18,6 +19,7 @@ class Category extends BaseCategory { { } + /** * Create a new category. * diff --git a/core/lib/Thelia/Model/Content.php b/core/lib/Thelia/Model/Content.php index 19b76bba2..3b5af9ede 100755 --- a/core/lib/Thelia/Model/Content.php +++ b/core/lib/Thelia/Model/Content.php @@ -4,6 +4,10 @@ namespace Thelia\Model; use Thelia\Model\Base\Content as BaseContent; -class Content extends BaseContent { +class Content extends BaseContent +{ + public function getUrl() + { + } } diff --git a/core/lib/Thelia/Model/Folder.php b/core/lib/Thelia/Model/Folder.php index a19ab6796..1179f6e72 100755 --- a/core/lib/Thelia/Model/Folder.php +++ b/core/lib/Thelia/Model/Folder.php @@ -14,6 +14,11 @@ class Folder extends BaseFolder return FolderQuery::countChild($this->getId()); } + public function getUrl() + { + + } + /** * * count all products for current category and sub categories diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php index ca26317e0..ae693e0aa 100755 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -5,5 +5,10 @@ namespace Thelia\Model; use Thelia\Model\Base\Product as BaseProduct; use Thelia\Model\ProductSaleElements; -class Product extends BaseProduct { +class Product extends BaseProduct +{ + public function getUrl() + { + + } } From f8dfa640596ba5c6b74301a506f78c4e69c6dfc9 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Mon, 26 Aug 2013 16:38:56 +0200 Subject: [PATCH 034/268] load test --- ...er_100categories_1000products_4locales.php | 173 ++++++++++++++++++ templates/default/tester.html | 11 ++ web/index_dev.php | 3 +- 3 files changed, 186 insertions(+), 1 deletion(-) create mode 100755 install/faker_100categories_1000products_4locales.php create mode 100755 templates/default/tester.html diff --git a/install/faker_100categories_1000products_4locales.php b/install/faker_100categories_1000products_4locales.php new file mode 100755 index 000000000..ce18aa5c7 --- /dev/null +++ b/install/faker_100categories_1000products_4locales.php @@ -0,0 +1,173 @@ +beginTransaction(); + +$currency = \Thelia\Model\CurrencyQuery::create()->filterByCode('EUR')->findOne(); + +try { + $stmt = $con->prepare("SET foreign_key_checks = 0"); + $stmt->execute(); + + $productAssociatedContent = Thelia\Model\ProductAssociatedContentQuery::create() + ->find(); + $productAssociatedContent->delete(); + + $categoryAssociatedContent = Thelia\Model\CategoryAssociatedContentQuery::create() + ->find(); + $categoryAssociatedContent->delete(); + + $attributeCategory = Thelia\Model\AttributeCategoryQuery::create() + ->find(); + $attributeCategory->delete(); + + $featureCategory = Thelia\Model\FeatureCategoryQuery::create() + ->find(); + $featureCategory->delete(); + + $featureProduct = Thelia\Model\FeatureProductQuery::create() + ->find(); + $featureProduct->delete(); + + $attributeCombination = Thelia\Model\AttributeCombinationQuery::create() + ->find(); + $attributeCombination->delete(); + + $feature = Thelia\Model\FeatureQuery::create() + ->find(); + $feature->delete(); + + $feature = Thelia\Model\FeatureI18nQuery::create() + ->find(); + $feature->delete(); + + $featureAv = Thelia\Model\FeatureAvQuery::create() + ->find(); + $featureAv->delete(); + + $featureAv = Thelia\Model\FeatureAvI18nQuery::create() + ->find(); + $featureAv->delete(); + + $attribute = Thelia\Model\AttributeQuery::create() + ->find(); + $attribute->delete(); + + $attribute = Thelia\Model\AttributeI18nQuery::create() + ->find(); + $attribute->delete(); + + $attributeAv = Thelia\Model\AttributeAvQuery::create() + ->find(); + $attributeAv->delete(); + + $attributeAv = Thelia\Model\AttributeAvI18nQuery::create() + ->find(); + $attributeAv->delete(); + + $category = Thelia\Model\CategoryQuery::create() + ->find(); + $category->delete(); + + $category = Thelia\Model\CategoryI18nQuery::create() + ->find(); + $category->delete(); + + $product = Thelia\Model\ProductQuery::create() + ->find(); + $product->delete(); + + $product = Thelia\Model\ProductI18nQuery::create() + ->find(); + $product->delete(); + + $customer = Thelia\Model\CustomerQuery::create() + ->find(); + $customer->delete(); + + $folder = Thelia\Model\FolderQuery::create() + ->find(); + $folder->delete(); + + $folder = Thelia\Model\FolderI18nQuery::create() + ->find(); + $folder->delete(); + + $content = Thelia\Model\ContentQuery::create() + ->find(); + $content->delete(); + + $content = Thelia\Model\ContentI18nQuery::create() + ->find(); + $content->delete(); + + $accessory = Thelia\Model\AccessoryQuery::create() + ->find(); + $accessory->delete(); + + $stock = \Thelia\Model\ProductSaleElementsQuery::create() + ->find(); + $stock->delete(); + + $productPrice = \Thelia\Model\ProductPriceQuery::create() + ->find(); + $productPrice->delete(); + + $stmt = $con->prepare("SET foreign_key_checks = 1"); + $stmt->execute(); + + //categories and products + for($i=0; $i<100; $i++) { + $category = new Thelia\Model\Category(); + $category->setParent(0); + $category->setVisible(1); + $category->setPosition($i); + setI18n($faker, $category); + + $category->save(); + + for($j=0; $j<10; $j++) { + $product = new Thelia\Model\Product(); + $product->setRef($category->getId() . '_' . $j . '_' . $faker->randomNumber(8)); + $product->addCategory($category); + $product->setVisible(1); + $product->setPosition($j); + setI18n($faker, $product); + + $product->save(); + } + } + + $con->commit(); +} catch (Exception $e) { + echo "error : ".$e->getMessage()."\n"; + $con->rollBack(); +} + +function setI18n($faker, &$object) +{ + $localeList = array('fr_FR', 'en_EN', 'es_ES', 'it_IT'); + + $title = $faker->text(20); + $description = $faker->text(50); + + foreach($localeList as $locale) { + $object->setLocale($locale); + + $object->setTitle($locale . ' : ' . $title); + $object->setDescription($locale . ' : ' . $description); + } +} + diff --git a/templates/default/tester.html b/templates/default/tester.html new file mode 100755 index 000000000..b53396d3f --- /dev/null +++ b/templates/default/tester.html @@ -0,0 +1,11 @@ +
        +{loop name="car" type="category"} +
      • +
          + {loop name="product" type="product" category="#ID"} +
        • #REF
        • + {/loop} +
        +
      • +{/loop} +
      \ No newline at end of file diff --git a/web/index_dev.php b/web/index_dev.php index cb9a3d6f0..8991dc4a8 100755 --- a/web/index_dev.php +++ b/web/index_dev.php @@ -25,4 +25,5 @@ $response = $thelia->handle($request)->prepare($request)->send(); $thelia->terminate($request, $response); -echo "\n"; \ No newline at end of file +echo "\n"; +echo "\n"; \ No newline at end of file From e971179a60535ea6ac624e3f978c506888cf3183 Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 27 Aug 2013 13:28:57 +0200 Subject: [PATCH 035/268] WIP Coupon Default Implementation + Unit test in order to validate the chain - effect - application field - condition --- .../Thelia/Coupon/CouponAdapterInterface.php | 21 +- core/lib/Thelia/Coupon/CouponBaseAdapter.php | 32 +- core/lib/Thelia/Coupon/CouponFactory.php | 12 +- core/lib/Thelia/Coupon/CouponManager.php | 38 +- .../Thelia/Coupon/CouponRuleCollection.php | 12 +- .../Thelia/Coupon/Rule/AvailableForDate.php | 2 - .../Rule/AvailableForRepeatedPeriod.php | 4 +- .../Coupon/Rule/AvailableForTotalAmount.php | 28 +- .../Thelia/Coupon/Rule/CouponRuleAbstract.php | 41 +- .../Coupon/Rule/CouponRuleInterface.php | 31 +- core/lib/Thelia/Coupon/Rule/Operators.php | 4 +- .../lib/Thelia/Coupon/Type/CouponAbstract.php | 57 +- .../Thelia/Coupon/Type/CouponInterface.php | 19 +- .../lib/Thelia/Coupon/Type/RemoveXPercent.php | 17 +- .../ComparableInterface.php | 2 +- .../{Parameter => Validator}/DateParam.php | 6 +- .../{Parameter => Validator}/IntegerParam.php | 6 +- .../IntervalParam.php | 4 +- .../{Parameter => Validator}/PriceParam.php | 6 +- .../QuantityParam.php | 2 +- .../RepeatedDateParam.php | 2 +- .../RepeatedIntervalParam.php | 2 +- .../RepeatedParam.php | 4 +- .../RuleParameterAbstract.php} | 11 +- .../RuleValidator.php | 2 +- .../Exception/NotImplementedException.php | 43 + .../Thelia/Tests/Coupon/CouponFactoryTest.php | 289 ++++--- .../Thelia/Tests/Coupon/CouponManagerTest.php | 806 ++++++++++++++---- .../Tests/Coupon/CouponRuleCollectionTest.php | 4 +- .../Tests/Coupon/Parameter/DateParamTest.php | 2 +- .../Coupon/Parameter/IntegerParamTest.php | 2 +- .../Coupon/Parameter/IntervalParamTest.php | 2 +- .../Tests/Coupon/Parameter/PriceParamTest.php | 2 +- .../Coupon/Parameter/QuantityParamTest.php | 2 +- .../Parameter/RepeatedDateParamTest.php | 2 +- .../Parameter/RepeatedIntervalParamTest.php | 10 +- .../Rule/AvailableForTotalAmountTest.php | 11 +- .../Coupon/Rule/AvailableForXArticlesTest.php | 26 +- .../Tests/Coupon/Rule/OperatorsTest.php | 38 +- .../Tests/Coupon/Type/RemoveXAmountTest.php | 185 ++-- .../Type/RemoveXPercentForCategoryYTest.php | 4 +- .../Tests/Coupon/Type/RemoveXPercentTest.php | 4 +- core/lib/Thelia/Tools/PhpUnitUtils.php | 4 +- 43 files changed, 1184 insertions(+), 617 deletions(-) rename core/lib/Thelia/Coupon/{Parameter => Validator}/ComparableInterface.php (98%) rename core/lib/Thelia/Coupon/{Parameter => Validator}/DateParam.php (95%) rename core/lib/Thelia/Coupon/{Parameter => Validator}/IntegerParam.php (95%) rename core/lib/Thelia/Coupon/{Parameter => Validator}/IntervalParam.php (97%) rename core/lib/Thelia/Coupon/{Parameter => Validator}/PriceParam.php (96%) rename core/lib/Thelia/Coupon/{Parameter => Validator}/QuantityParam.php (98%) rename core/lib/Thelia/Coupon/{Parameter => Validator}/RepeatedDateParam.php (99%) rename core/lib/Thelia/Coupon/{Parameter => Validator}/RepeatedIntervalParam.php (99%) rename core/lib/Thelia/Coupon/{Parameter => Validator}/RepeatedParam.php (98%) rename core/lib/Thelia/Coupon/{Parameter/RuleParameterInterface.php => Validator/RuleParameterAbstract.php} (89%) rename core/lib/Thelia/Coupon/{Parameter => Validator}/RuleValidator.php (98%) create mode 100644 core/lib/Thelia/Exception/NotImplementedException.php diff --git a/core/lib/Thelia/Coupon/CouponAdapterInterface.php b/core/lib/Thelia/Coupon/CouponAdapterInterface.php index 9db1160f1..21ff870f6 100644 --- a/core/lib/Thelia/Coupon/CouponAdapterInterface.php +++ b/core/lib/Thelia/Coupon/CouponAdapterInterface.php @@ -23,6 +23,8 @@ namespace Thelia\Coupon; +use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\Translation\TranslatorInterface; use Thelia\Coupon\Type\CouponInterface; use Thelia\Model\Coupon; @@ -70,10 +72,11 @@ interface CouponAdapterInterface /** * Return Products total price + * CartTotalPrice = Checkout total - discount - postage * * @return float */ - public function getCheckoutTotalPriceWithoutDiscountAndPostagePrice(); + public function getCartTotalPrice(); /** * Return Checkout total postage (only) price @@ -87,7 +90,7 @@ interface CouponAdapterInterface * * @return int */ - public function getNbArticlesInTheCart(); + public function getNbArticlesInCart(); /** * Return all Coupon given during the Checkout @@ -114,4 +117,18 @@ interface CouponAdapterInterface */ public function saveCoupon(CouponInterface $coupon); + /** + * Return platform Container + * + * @return Container + */ + public function getContainer(); + + /** + * Return platform TranslatorInterface + * + * @return TranslatorInterface + */ + public function getTranslator(); + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponBaseAdapter.php b/core/lib/Thelia/Coupon/CouponBaseAdapter.php index 180ddc3cd..3809612a7 100644 --- a/core/lib/Thelia/Coupon/CouponBaseAdapter.php +++ b/core/lib/Thelia/Coupon/CouponBaseAdapter.php @@ -23,6 +23,8 @@ namespace Thelia\Coupon; +use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\Translation\TranslatorInterface; use Thelia\Coupon\Type\CouponInterface; use Thelia\Model\Coupon; use Thelia\Model\CouponQuery; @@ -94,9 +96,9 @@ class CouponBaseAdapter implements CouponAdapterInterface * * @return float */ - public function getCheckoutTotalPriceWithoutDiscountAndPostagePrice() + public function getCartTotalPrice() { - // TODO: Implement getCheckoutTotalPriceWithoutDiscountAndPostagePrice() method. + // TODO: Implement getCartTotalPrice() method. } /** @@ -104,9 +106,9 @@ class CouponBaseAdapter implements CouponAdapterInterface * * @return int */ - public function getNbArticlesInTheCart() + public function getNbArticlesInCart() { - // TODO: Implement getNbArticlesInTheCart() method. + // TODO: Implement getNbArticlesInCart() method. } /** @@ -158,7 +160,7 @@ class CouponBaseAdapter implements CouponAdapterInterface // $couponModel->setTitle($coupon->getTitle()); // $couponModel->setShortDescription($coupon->getShortDescription()); // $couponModel->setDescription($coupon->getDescription()); -// $couponModel->setAmount($coupon->getEffect()); +// $couponModel->setAmount($coupon->getDiscount()); // $couponModel->setIsUsed(0); // $couponModel->setIsEnabled(1); // $couponModel->set @@ -170,5 +172,23 @@ class CouponBaseAdapter implements CouponAdapterInterface // $couponModel->set } + /** + * Return plateform Container + * + * @return Container + */ + public function getContainer() + { + // TODO: Implement getCheckoutPostagePrice() method. + } -} \ No newline at end of file + /** + * Return platform TranslatorInterface + * + * @return TranslatorInterface + */ + public function getTranslator() + { + return $this->getContainer()->get('thelia.translator'); + } +} diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php index d82bb3430..a77871ffd 100644 --- a/core/lib/Thelia/Coupon/CouponFactory.php +++ b/core/lib/Thelia/Coupon/CouponFactory.php @@ -25,8 +25,8 @@ namespace Thelia\Coupon; use Symfony\Component\Translation\Exception\NotFoundResourceException; use Thelia\Coupon\Type\CouponInterface; -use Thelia\Coupon\Type\RemoveXAmount; use Thelia\Exception\CouponExpiredException; +use Thelia\Exception\InvalidRuleException; use Thelia\Model\Coupon; use Symfony\Component\Serializer\Encoder\JsonEncoder; @@ -79,7 +79,15 @@ class CouponFactory throw new CouponExpiredException($couponCode); } - return $this->buildCouponInterfacFromModel($couponModel); + /** @var CouponInterface $couponInterface */ + $couponInterface = $this->buildCouponInterfacFromModel($couponModel); + if ($couponInterface->getRules()->isEmpty()) { + throw new InvalidRuleException( + get_class($couponInterface) + ); + } + + return $couponInterface; } /** diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index c36ad7c40..b913de66d 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -70,16 +70,20 @@ class CouponManager if (count($this->coupons) > 0) { $couponsKept = $this->sortCoupons($this->coupons); + $isRemovingPostage = $this->isCouponRemovingPostage($couponsKept); + $discount = $this->getEffect($couponsKept); + if ($isRemovingPostage) { $postage = $this->adapter->getCheckoutPostagePrice(); - $discount -= $postage; + $discount += $postage; } // Just In Case test - if ($discount >= $this->adapter->getCheckoutTotalPrice()) { - $discount = 0.00; + $checkoutTotalPrice = $this->adapter->getCartTotalPrice(); + if ($discount >= $checkoutTotalPrice) { + $discount = $checkoutTotalPrice; } } @@ -144,6 +148,34 @@ class CouponManager } } + $coupons = $couponsKept; + $couponsKept = array(); + + /** @var CouponInterface $coupon */ + foreach ($coupons as $coupon) { + if ($coupon->isMatching($this->adapter)) { + $couponsKept[] = $coupon; + } + } + return $couponsKept; } + + /** + * Process given Coupon in order to get their cumulative effects + * + * @param array $coupons CouponInterface to process + * + * @return float discount + */ + protected function getEffect(array $coupons) + { + $discount = 0.00; + /** @var CouponInterface $coupon */ + foreach ($coupons as $coupon) { + $discount += $coupon->getDiscount($this->adapter); + } + + return $discount; + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponRuleCollection.php b/core/lib/Thelia/Coupon/CouponRuleCollection.php index 3146cec56..06f0b15af 100644 --- a/core/lib/Thelia/Coupon/CouponRuleCollection.php +++ b/core/lib/Thelia/Coupon/CouponRuleCollection.php @@ -32,7 +32,7 @@ use Thelia\Exception\InvalidRuleException; * Date: 8/19/13 * Time: 3:24 PM * - * Manage a set of v + * Manage a set of CouponRuleInterface * * @package Coupon * @author Guillaume MOREL @@ -84,5 +84,15 @@ class CouponRuleCollection return $this; } + /** + * Check if there is at least one rule in the collection + * + * @return bool + */ + public function isEmpty() + { + return isEmpty($this->rules); + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForDate.php b/core/lib/Thelia/Coupon/Rule/AvailableForDate.php index 1b5b27ef5..81cb54a91 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForDate.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForDate.php @@ -23,8 +23,6 @@ namespace Thelia\Coupon\Rule; -use Thelia\Coupon\CouponAdapterInterface; - /** * Created by JetBrains PhpStorm. * Date: 8/19/13 diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php index 8cf30569b..4f67889c2 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php @@ -46,9 +46,9 @@ class AvailableForRepeatedPeriod extends AvailableForPeriod * @throws \Symfony\Component\Intl\Exception\NotImplementedException * @return $this */ - protected function setParametersToValidate(CouponAdapterInterface $adapter) + public function setParametersToValidate(CouponAdapterInterface $adapter) { - parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub + // @todo implement } /** diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php index b01f946a1..aa1e40339 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php +++ b/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php @@ -25,8 +25,8 @@ namespace Thelia\Coupon\Rule; use Symfony\Component\Intl\Exception\NotImplementedException; use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Coupon\Parameter\PriceParam; -use Thelia\Coupon\Parameter\RuleValidator; +use Thelia\Coupon\Validator\PriceParam; +use Thelia\Coupon\Validator\RuleValidator; use Thelia\Exception\InvalidRuleException; use Thelia\Exception\InvalidRuleOperatorException; use Thelia\Exception\InvalidRuleValueException; @@ -63,13 +63,12 @@ class AvailableForTotalAmount extends CouponRuleAbstract * * @param array $validators Array of RuleValidator * validating $paramsToValidate against - * @param array $validated Parameters to be paramsToValidate * * @throws \Thelia\Exception\InvalidRuleException */ - public function __construct(array $validators, array $validated = null) + public function __construct(array $validators) { - parent::__construct($validators, $validated); + parent::__construct($validators); if (isset($validators[self::PARAM1_PRICE]) && $validators[self::PARAM1_PRICE] instanceof RuleValidator @@ -138,7 +137,7 @@ class AvailableForTotalAmount extends CouponRuleAbstract /** * Check if a price is valid * - * @param int $price Price to check + * @param float $price Price to check * * @throws InvalidRuleValueException if Value is not allowed * @return bool @@ -155,21 +154,6 @@ class AvailableForTotalAmount extends CouponRuleAbstract return true; } - /** - * Generate current Rule validator from adapter - * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this - */ - protected function setValidatorsFromAdapter(CouponAdapterInterface $adapter) - { -// $adapter->getRule($this); - // @todo implement - } - /** * Generate current Rule param to be validated from adapter * @@ -181,7 +165,7 @@ class AvailableForTotalAmount extends CouponRuleAbstract protected function setParametersToValidate(CouponAdapterInterface $adapter) { $this->paramsToValidate = array( - self::PARAM1_PRICE => $adapter->getCheckoutTotalPrice() + self::PARAM1_PRICE => $adapter->getCartTotalPrice() ); return $this; diff --git a/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php b/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php index 4bdd0d57d..7d0b741bb 100644 --- a/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php +++ b/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php @@ -25,8 +25,8 @@ namespace Thelia\Coupon\Rule; use Symfony\Component\Intl\Exception\NotImplementedException; use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Coupon\Parameter\ComparableInterface; -use Thelia\Coupon\Parameter\RuleValidator; +use Thelia\Coupon\Validator\ComparableInterface; +use Thelia\Coupon\Validator\RuleValidator; use Thelia\Exception\InvalidRuleException; use Thelia\Exception\InvalidRuleOperatorException; @@ -72,14 +72,12 @@ abstract class CouponRuleAbstract implements CouponRuleInterface * * @param array $validators Array of RuleValidator * validating $paramsToValidate against - * @param array $validated Parameters to be paramsToValidate * * @throws InvalidRuleException */ - public function __construct(array $validators, array $validated = null) + public function __construct(array $validators) { $this->setValidators($validators); - $this->paramsToValidate = $validated; } /** @@ -106,10 +104,14 @@ abstract class CouponRuleAbstract implements CouponRuleInterface /** * Check if the current Checkout matches this condition * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * * @return bool */ - public function isMatching() + public function isMatching(CouponAdapterInterface $adapter) { + $this->setParametersToValidate($adapter); $this->checkBackOfficeInput(); $this->checkCheckoutInput(); @@ -118,10 +120,10 @@ abstract class CouponRuleAbstract implements CouponRuleInterface foreach ($this->validators as $param => $validator) { $a = $this->paramsToValidate[$param]; $operator = $validator->getOperator(); - /** @var ComparableInterface, RuleParameterInterface $b */ + /** @var ComparableInterface, RuleParameterAbstract $b */ $b = $validator->getParam(); - if (!Operators::isValidAccordingToOperator($a, $operator, $b)) { + if (!Operators::isValid($a, $operator, $b)) { $isMatching = false; } } @@ -160,35 +162,18 @@ abstract class CouponRuleAbstract implements CouponRuleInterface return true; } - /** - * Generate current Rule validator from adapter - * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException - * @return $this - */ - protected function setValidatorsFromAdapter(CouponAdapterInterface $adapter) - { - throw new NotImplementedException( - 'CouponRuleInterface::setValidators needs to be implemented' - ); - } - /** * Generate current Rule param to be validated from adapter * * @param CouponAdapterInterface $adapter allowing to gather * all necessary Thelia variables * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException + * @throws \Thelia\Exception\NotImplementedException * @return $this */ protected function setParametersToValidate(CouponAdapterInterface $adapter) { - throw new NotImplementedException( - 'CouponRuleInterface::setValidators needs to be implemented' - ); + throw new \Thelia\Exception\NotImplementedException(); } + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php b/core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php index 22ad31841..6aaca802c 100644 --- a/core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php +++ b/core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php @@ -23,6 +23,8 @@ namespace Thelia\Coupon\Rule; +use Thelia\Coupon\CouponAdapterInterface; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -53,9 +55,12 @@ interface CouponRuleInterface /** * Check if the current Checkout matches this condition * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * * @return bool */ - public function isMatching(); + public function isMatching(CouponAdapterInterface $adapter); /** * Return all available Operators for this Rule @@ -64,26 +69,4 @@ interface CouponRuleInterface */ public function getAvailableOperators(); -// /** -// * Generate current Rule validator from adapter -// * Ex : -// * $validator = array( -// * -// * @param CouponAdapterInterface $adapter allowing to gather -// * all necessary Thelia variables -// * -// * @return array Validators : array of ComparableInterface -// */ -// public function getValidators(CouponAdapterInterface $adapter); -// -// /** -// * Retrieve all param to validate from adapter -// * -// * @param CouponAdapterInterface $adapter allowing to gather -// * all necessary Thelia variables -// * -// * @return array Validators : array of ComparableInterface -// */ -// public function getParamToValidate(CouponAdapterInterface $adapter); - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Coupon/Rule/Operators.php b/core/lib/Thelia/Coupon/Rule/Operators.php index c11198caf..fb188c3cd 100644 --- a/core/lib/Thelia/Coupon/Rule/Operators.php +++ b/core/lib/Thelia/Coupon/Rule/Operators.php @@ -23,7 +23,7 @@ namespace Thelia\Coupon\Rule; -use Thelia\Coupon\Parameter\ComparableInterface; +use Thelia\Coupon\Validator\ComparableInterface; /** * Created by JetBrains PhpStorm. @@ -60,7 +60,7 @@ abstract class Operators * * @return bool */ - public static function isValidAccordingToOperator($a, $operator, ComparableInterface $b) + public static function isValid($a, $operator, ComparableInterface $b) { $ret = false; diff --git a/core/lib/Thelia/Coupon/Type/CouponAbstract.php b/core/lib/Thelia/Coupon/Type/CouponAbstract.php index 8e2f716ea..750c62e5c 100644 --- a/core/lib/Thelia/Coupon/Type/CouponAbstract.php +++ b/core/lib/Thelia/Coupon/Type/CouponAbstract.php @@ -43,9 +43,6 @@ use Thelia\Exception\InvalidRuleException; */ abstract class CouponAbstract implements CouponInterface { - /** @var CouponAdapterInterface Provide necessary value from Thelia*/ - protected $adapter; - /** @var RuleOrganizerInterface */ protected $organizer = null; @@ -85,20 +82,6 @@ abstract class CouponAbstract implements CouponInterface /** @var bool if Coupon is available for Products already on special offers */ protected $isAvailableOnSpecialOffers = false; - /** - * Set Adapter containing all relevant data - * - * @param CouponAdapterInterface $adapter Adapter - * - * @return $this - */ - public function setAdapter($adapter) - { - $this->adapter = $adapter; - - return $this; - } - /** * Set Rule Organizer * @@ -178,12 +161,15 @@ abstract class CouponAbstract implements CouponInterface /** * Return effects generated by the coupon * A negative value - * @ + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * * @return float Amount removed from the Total Checkout */ - public function getEffect() + public function getDiscount(CouponAdapterInterface $adapter) { - return -$this->amount; + return $this->amount; } /** @@ -196,21 +182,6 @@ abstract class CouponAbstract implements CouponInterface return clone $this->rules; } - /** - * Add a Rule to the Coupon - * - * @param CouponRuleInterface $rule Condition needed to match - * in order to get the Coupon effect - * - * @return $this - */ - public function addRule(CouponRuleInterface $rule) - { - $this->rules->add($rule); - - return $this; - } - /** * Replace the existing Rules by those given in parameter * If one Rule is badly implemented, no Rule will be added @@ -230,17 +201,19 @@ abstract class CouponAbstract implements CouponInterface /** * Check if the current Coupon is matching its conditions (Rules) * Thelia variables are given by the CouponAdapterInterface - * In $this->adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables * * @return bool */ - public function isMatching() + public function isMatching(CouponAdapterInterface $adapter) { $isMatching = true; /** @var CouponRuleInterface $rule */ foreach ($this->rules->getRules() as $rule) { - if (!$rule->isMatching()) { + if (!$rule->isMatching($adapter)) { $isMatching = false; } } @@ -300,13 +273,11 @@ abstract class CouponAbstract implements CouponInterface { $ret = true; - if ($this->expirationDate < new \DateTime()) { + $now = new \DateTime(); + if ($this->expirationDate > $now) { $ret = false; } return $ret; } - - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Coupon/Type/CouponInterface.php b/core/lib/Thelia/Coupon/Type/CouponInterface.php index 1d470bb69..df1a82f40 100644 --- a/core/lib/Thelia/Coupon/Type/CouponInterface.php +++ b/core/lib/Thelia/Coupon/Type/CouponInterface.php @@ -23,6 +23,7 @@ namespace Thelia\Coupon\Type; +use Thelia\Coupon\CouponAdapterInterface; use Thelia\Coupon\CouponRuleCollection; /** @@ -71,7 +72,7 @@ interface CouponInterface * If is cumulative you can sum Coupon effects * If not cancel all other Coupon and take the last given * - * @return string + * @return bool */ public function isCumulative(); @@ -84,33 +85,37 @@ interface CouponInterface /** * Return effects generated by the coupon - * A negative value + * A positive value * * Effects could also affect something else than the final Checkout price * CouponAdapter could be use to directly pass a Session value * some would wish to modify * Hence affecting a wide variety of Thelia elements - * Ex : $this->adapter->getTheliaInternalValue + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables * * @return float Amount removed from the Total Checkout */ - public function getEffect(); + public function getDiscount(CouponAdapterInterface $adapter); /** * Return condition to validate the Coupon or not * - * @return array An array of CouponRuleInterface + * @return CouponRuleCollection A set of CouponRuleInterface */ public function getRules(); /** * Check if the current Coupon is matching its conditions (Rules) * Thelia variables are given by the CouponAdapterInterface - * In $this->adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables * * @return bool */ - public function isMatching(); + public function isMatching(CouponAdapterInterface $adapter); /** * Replace the existing Rules by those given in parameter diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php index 5fd25ae8f..da63a4281 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php @@ -23,6 +23,7 @@ namespace Thelia\Coupon\Type; +use Thelia\Coupon\CouponAdapterInterface; use Thelia\Coupon\Type\CouponAbstract; use Thelia\Exception\MissingAdapterException; @@ -67,26 +68,24 @@ class RemoveXPercent extends CouponAbstract * Return effects generated by the coupon * A negative value * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * * @throws \Thelia\Exception\MissingAdapterException * @throws \InvalidArgumentException * @return float */ - public function getEffect() + public function getDiscount(CouponAdapterInterface $adapter) { - if ($this->adapter === null) { - throw new MissingAdapterException( - 'Cant calculate effect : CouponAdapterInterface is missing.' - ); - } - if ($this->percent >= 100) { throw new \InvalidArgumentException( 'Percentage must be inferior to 100' ); } - $basePrice = $this->adapter - ->getCheckoutTotalPriceWithoutDiscountAndPostagePrice(); + $basePrice =$adapter + ->getCartTotalPrice(); + return $basePrice * (( 100 - $this->percent ) / 100); } diff --git a/core/lib/Thelia/Coupon/Parameter/ComparableInterface.php b/core/lib/Thelia/Coupon/Validator/ComparableInterface.php similarity index 98% rename from core/lib/Thelia/Coupon/Parameter/ComparableInterface.php rename to core/lib/Thelia/Coupon/Validator/ComparableInterface.php index 26bb3ca30..3b70c5e37 100644 --- a/core/lib/Thelia/Coupon/Parameter/ComparableInterface.php +++ b/core/lib/Thelia/Coupon/Validator/ComparableInterface.php @@ -21,7 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Parameter; +namespace Thelia\Coupon\Validator; /** * Comparable interface diff --git a/core/lib/Thelia/Coupon/Parameter/DateParam.php b/core/lib/Thelia/Coupon/Validator/DateParam.php similarity index 95% rename from core/lib/Thelia/Coupon/Parameter/DateParam.php rename to core/lib/Thelia/Coupon/Validator/DateParam.php index 989477210..062c750e5 100644 --- a/core/lib/Thelia/Coupon/Parameter/DateParam.php +++ b/core/lib/Thelia/Coupon/Validator/DateParam.php @@ -21,9 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Parameter; - -use Thelia\Coupon\Parameter\ComparableInterface; +namespace Thelia\Coupon\Validator; /** * Created by JetBrains PhpStorm. @@ -36,7 +34,7 @@ use Thelia\Coupon\Parameter\ComparableInterface; * @author Guillaume MOREL * */ -class DateParam implements ComparableInterface, RuleParameterInterface +class DateParam extends RuleParameterAbstract { /** @var \DateTime Date */ protected $dateTime = null; diff --git a/core/lib/Thelia/Coupon/Parameter/IntegerParam.php b/core/lib/Thelia/Coupon/Validator/IntegerParam.php similarity index 95% rename from core/lib/Thelia/Coupon/Parameter/IntegerParam.php rename to core/lib/Thelia/Coupon/Validator/IntegerParam.php index 14d63417b..7c8303809 100644 --- a/core/lib/Thelia/Coupon/Parameter/IntegerParam.php +++ b/core/lib/Thelia/Coupon/Validator/IntegerParam.php @@ -21,9 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Parameter; - -use Thelia\Coupon\Parameter\ComparableInterface; +namespace Thelia\Coupon\Validator; /** * Created by JetBrains PhpStorm. @@ -36,7 +34,7 @@ use Thelia\Coupon\Parameter\ComparableInterface; * @author Guillaume MOREL * */ -class IntegerParam implements ComparableInterface, RuleParameterInterface +class IntegerParam extends RuleParameterAbstract { /** @var int Integer to compare with */ protected $integer = 0; diff --git a/core/lib/Thelia/Coupon/Parameter/IntervalParam.php b/core/lib/Thelia/Coupon/Validator/IntervalParam.php similarity index 97% rename from core/lib/Thelia/Coupon/Parameter/IntervalParam.php rename to core/lib/Thelia/Coupon/Validator/IntervalParam.php index 3e29d24be..1b310c9d1 100644 --- a/core/lib/Thelia/Coupon/Parameter/IntervalParam.php +++ b/core/lib/Thelia/Coupon/Validator/IntervalParam.php @@ -21,7 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Parameter; +namespace Thelia\Coupon\Validator; /** * Created by JetBrains PhpStorm. @@ -34,7 +34,7 @@ namespace Thelia\Coupon\Parameter; * @author Guillaume MOREL * */ -class IntervalParam implements ComparableInterface, RuleParameterInterface +class IntervalParam extends RuleParameterAbstract { /** @var \DatePeriod Date period */ protected $datePeriod = null; diff --git a/core/lib/Thelia/Coupon/Parameter/PriceParam.php b/core/lib/Thelia/Coupon/Validator/PriceParam.php similarity index 96% rename from core/lib/Thelia/Coupon/Parameter/PriceParam.php rename to core/lib/Thelia/Coupon/Validator/PriceParam.php index 2f3834777..44eae3234 100644 --- a/core/lib/Thelia/Coupon/Parameter/PriceParam.php +++ b/core/lib/Thelia/Coupon/Validator/PriceParam.php @@ -21,9 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Parameter; - -use Thelia\Coupon\Parameter\ComparableInterface; +namespace Thelia\Coupon\Validator; /** * Created by JetBrains PhpStorm. @@ -37,7 +35,7 @@ use Thelia\Coupon\Parameter\ComparableInterface; * @author Guillaume MOREL * */ -class PriceParam implements ComparableInterface, RuleParameterInterface +class PriceParam extends RuleParameterAbstract { /** @var float Positive Float to compare with */ protected $price = null; diff --git a/core/lib/Thelia/Coupon/Parameter/QuantityParam.php b/core/lib/Thelia/Coupon/Validator/QuantityParam.php similarity index 98% rename from core/lib/Thelia/Coupon/Parameter/QuantityParam.php rename to core/lib/Thelia/Coupon/Validator/QuantityParam.php index 526aa4152..dc842605f 100644 --- a/core/lib/Thelia/Coupon/Parameter/QuantityParam.php +++ b/core/lib/Thelia/Coupon/Validator/QuantityParam.php @@ -21,7 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Parameter; +namespace Thelia\Coupon\Validator; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php b/core/lib/Thelia/Coupon/Validator/RepeatedDateParam.php similarity index 99% rename from core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php rename to core/lib/Thelia/Coupon/Validator/RepeatedDateParam.php index 2e99391e6..f0524edc7 100644 --- a/core/lib/Thelia/Coupon/Parameter/RepeatedDateParam.php +++ b/core/lib/Thelia/Coupon/Validator/RepeatedDateParam.php @@ -21,7 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Parameter; +namespace Thelia\Coupon\Validator; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php b/core/lib/Thelia/Coupon/Validator/RepeatedIntervalParam.php similarity index 99% rename from core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php rename to core/lib/Thelia/Coupon/Validator/RepeatedIntervalParam.php index 3c4de7348..9f61f4db1 100644 --- a/core/lib/Thelia/Coupon/Parameter/RepeatedIntervalParam.php +++ b/core/lib/Thelia/Coupon/Validator/RepeatedIntervalParam.php @@ -21,7 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Parameter; +namespace Thelia\Coupon\Validator; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Coupon/Parameter/RepeatedParam.php b/core/lib/Thelia/Coupon/Validator/RepeatedParam.php similarity index 98% rename from core/lib/Thelia/Coupon/Parameter/RepeatedParam.php rename to core/lib/Thelia/Coupon/Validator/RepeatedParam.php index dba3de0af..675228456 100644 --- a/core/lib/Thelia/Coupon/Parameter/RepeatedParam.php +++ b/core/lib/Thelia/Coupon/Validator/RepeatedParam.php @@ -21,7 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Parameter; +namespace Thelia\Coupon\Validator; use DateInterval; use DatePeriod; @@ -38,7 +38,7 @@ use DateTime; * @author Guillaume MOREL * */ -abstract class RepeatedParam implements ComparableInterface, RuleParameterInterface +abstract class RepeatedParam extends RuleParameterAbstract { /** @var DateTime The start date of the period. */ protected $from = null; diff --git a/core/lib/Thelia/Coupon/Parameter/RuleParameterInterface.php b/core/lib/Thelia/Coupon/Validator/RuleParameterAbstract.php similarity index 89% rename from core/lib/Thelia/Coupon/Parameter/RuleParameterInterface.php rename to core/lib/Thelia/Coupon/Validator/RuleParameterAbstract.php index 4583bd799..3e96682cd 100644 --- a/core/lib/Thelia/Coupon/Parameter/RuleParameterInterface.php +++ b/core/lib/Thelia/Coupon/Validator/RuleParameterAbstract.php @@ -21,7 +21,9 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Parameter; +namespace Thelia\Coupon\Validator; + +use Thelia\Exception\NotImplementedException; /** * Created by JetBrains PhpStorm. @@ -34,12 +36,15 @@ namespace Thelia\Coupon\Parameter; * @author Guillaume MOREL * */ -interface RuleParameterInterface +abstract class RuleParameterAbstract implements ComparableInterface { /** * Get Parameter value to test against * * @return mixed */ - public function getValue(); + public function getValue() + { + return new NotImplementedException(); + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Parameter/RuleValidator.php b/core/lib/Thelia/Coupon/Validator/RuleValidator.php similarity index 98% rename from core/lib/Thelia/Coupon/Parameter/RuleValidator.php rename to core/lib/Thelia/Coupon/Validator/RuleValidator.php index f6ffc3b13..064677751 100644 --- a/core/lib/Thelia/Coupon/Parameter/RuleValidator.php +++ b/core/lib/Thelia/Coupon/Validator/RuleValidator.php @@ -21,7 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Parameter; +namespace Thelia\Coupon\Validator; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Exception/NotImplementedException.php b/core/lib/Thelia/Exception/NotImplementedException.php new file mode 100644 index 000000000..991f4d325 --- /dev/null +++ b/core/lib/Thelia/Exception/NotImplementedException.php @@ -0,0 +1,43 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Exception; + +use Symfony\Component\DependencyInjection\Exception\BadMethodCallException; +use Thelia\Log\Tlog; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Thrown when an Abstract method has not been implemented + * + * @package Exception + * @author Guillaume MOREL + * + */ +class NotImplementedException extends BadMethodCallException +{ + +} diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index ed3331f87..c33b2327a 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -23,14 +23,16 @@ namespace Thelia\Coupon; -use Thelia\Coupon\Parameter\PriceParam; -use Thelia\Coupon\Parameter\RuleValidator; +use Thelia\Coupon\Validator\PriceParam; +use Thelia\Coupon\Validator\RuleValidator; use Thelia\Coupon\Rule\AvailableForTotalAmount; -use Thelia\Coupon\Rule\CouponRuleInterface; use Thelia\Coupon\Rule\Operators; +use Thelia\Coupon\Type\CouponInterface; use Thelia\Exception\CouponExpiredException; use Thelia\Model\Coupon; +require_once 'CouponManagerTest.php'; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -45,89 +47,6 @@ use Thelia\Model\Coupon; class CouponFactoryTest extends \PHPUnit_Framework_TestCase { - CONST VALID_SHORT_DESCRIPTION = 'Coupon for Christmas removing 10€ if your total checkout is more than 40€'; - CONST VALID_DESCRIPTION = '

      Lorem ipsum dolor sit amet

      Consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla. - -Donec rhoncus leo mauris, id porttitor ante luctus tempus. - -Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla. - -Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros. - -Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non. - -Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'; - - /** - * Generate valid CouponInterface - * - * @param $code - * @param $type - * @param $title - * @param $shortDescription - * @param $description - * @param $amount - * @param $isUsed - * @param $isEnabled - * @param $expirationDate - * @param $rules - * @param $isCumulative - * @param $isRemovingPostage - * - * @return CouponInterface - */ - public function generateValidCoupon( - $code = 'XMAS1', - $type = '\Thelia\Coupon\Type\RemoveXAmount', - $title = 'Christmas coupon', - $shortDescription = self::VALID_SHORT_DESCRIPTION, - $description = self::VALID_DESCRIPTION, - $amount = 10.00, - $isUsed = 1, - $isEnabled = 1, - $expirationDate = null, - $rules = null, - $isCumulative = 1, - $isRemovingPostage = 0 - ) { - $coupon = new Coupon(); - $coupon->setCode($code); - $coupon->setType($type); - $coupon->setTitle($title); - $coupon->setShortDescription($shortDescription); - $coupon->setDescription($description); - $coupon->setAmount($amount); - $coupon->setIsUsed($isUsed); - $coupon->setIsEnabled($isEnabled); - - if ($expirationDate === null) { - $date = new \DateTime(); - $coupon->setExpirationDate( - $date->setTimestamp(strtotime("today + 2 months")) - ); - } - - if ($rules === null) { - $rules = $this->generateValidRules(); - } - - $couponFactory = new CouponFactory(new CouponBaseAdapter()); - $serializedData = $couponFactory->convertRulesInstancesIntoSerialized( - $rules - ); - - $coupon->setSerializedRulesType($serializedData['rulesType']); - $coupon->setSerializedRulesContent($serializedData['rulesContent']); - - $coupon->setIsCumulative($isCumulative); - $coupon->setIsRemovingPostage($isRemovingPostage); - - return $coupon; - } - - /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -136,38 +55,37 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua { } - - /** * Fake CouponQuery->findByCode * - * @param string $code - * @param string $type - * @param string $title - * @param string $shortDescription - * @param string $description - * @param float $amount - * @param int $isUsed - * @param int $isEnabled - * @param null $expirationDate - * @param null $rules - * @param int $isCumulative - * @param int $isRemovingPostage + * @param string $code Coupon code + * @param string $type Coupon type (object) + * @param string $title Coupon title + * @param string $shortDescription Coupon short description + * @param string $description Coupon description + * @param float $amount Coupon amount + * @param bool $isUsed If Coupon has been used yet + * @param bool $isEnabled If Coupon is enabled + * @param \DateTime $expirationDate When Coupon expires + * @param CouponRuleCollection $rules Coupon rules + * @param bool $isCumulative If Coupon is cumulative + * @param bool $isRemovingPostage If Coupon is removing postage + * * @return Coupon */ public function generateCouponModelMock( - $code, - $type, - $title, - $shortDescription, - $description, - $amount, - $isUsed, - $isEnabled, - $expirationDate, - $rules, - $isCumulative, - $isRemovingPostage + $code = null, + $type = null, + $title = null, + $shortDescription = null, + $description = null, + $amount = null, + $isUsed = null, + $isEnabled = null, + $expirationDate = null, + $rules = null, + $isCumulative = null, + $isRemovingPostage = null ) { $coupon = $this->generateValidCoupon( $code, @@ -200,8 +118,10 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua /** + * Test if an expired Coupon is build or not (superior) + * * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode - * @expectedException Thelia\Exception\CouponExpiredException + * @expectedException \Thelia\Exception\CouponExpiredException */ public function testBuildCouponFromCodeExpiredDateBefore() { @@ -215,8 +135,10 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua } /** + * Test if an expired Coupon is build or not (equal) + * * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode - * @expectedException Thelia\Exception\CouponExpiredException + * @expectedException \Thelia\Exception\CouponExpiredException */ public function testBuildCouponFromCodeExpiredDateEquals() { @@ -229,6 +151,22 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua } /** + * Test if an expired Coupon is build or not (equal) + * + * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode + * @expectedException \Thelia\Exception\InvalidRuleException + */ + public function testBuildCouponFromCodeWithoutRule() + { + /** @var CouponAdapterInterface $mockAdapter */ + $mockAdapter = $this->generateCouponModelMock(null, null, null, null, null, null, null, null, null, new CouponRuleCollection(array())); + $couponFactory = new CouponFactory($mockAdapter); + $coupon = $couponFactory->buildCouponFromCode('XMAS1'); + } + + /** + * Test if a CouponInterface can be built from database + * * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode */ public function testBuildCouponFromCode() @@ -236,15 +174,32 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua /** @var CouponAdapterInterface $mockAdapter */ $mockAdapter = $this->generateCouponModelMock(); $couponFactory = new CouponFactory($mockAdapter); + /** @var CouponInterface $coupon */ $coupon = $couponFactory->buildCouponFromCode('XMAS1'); - $CouponManager = new CouponManager($mockAdapter) + $this->assertEquals('XMAS1', $coupon->getCode()); + $this->assertEquals('Thelia\Coupon\Type\RemoveXAmount', get_class($coupon)); + $this->assertEquals(CouponManagerTest::VALID_TITLE, $coupon->getTitle()); + $this->assertEquals(CouponManagerTest::VALID_SHORT_DESCRIPTION, $coupon->getShortDescription()); + $this->assertEquals(CouponManagerTest::VALID_DESCRIPTION, $coupon->getDescription()); + $this->assertEquals(10.00, $coupon->getDiscount()); + $this->assertEquals(1, $coupon->isEnabled()); + + $date = new \DateTime(); + $date->setTimestamp(strtotime("today + 2 months")); + $this->assertEquals($date, $coupon->getExpirationDate()); + + $rules = $this->generateValidRules(); + $this->assertEquals($rules, $coupon->getRules()); + + $this->assertEquals(1, $coupon->isCumulative()); + $this->assertEquals(0, $coupon->isRemovingPostage()); } /** * Generate valid CouponRuleInterfaces * - * @return array Array of CouponRuleInterface + * @return CouponRuleCollection Set of CouponRuleInterface */ protected function generateValidRules() { @@ -270,11 +225,111 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua ) ) ); - $rules = array($rule1, $rule2); + $rules = new CouponRuleCollection(array($rule1, $rule2)); return $rules; } + /** + * Generate valid CouponInterface + * + * @param string $code Coupon code + * @param string $type Coupon type (object) + * @param string $title Coupon title + * @param string $shortDescription Coupon short description + * @param string $description Coupon description + * @param float $amount Coupon amount + * @param bool $isUsed If Coupon has been used yet + * @param bool $isEnabled If Coupon is enabled + * @param \DateTime $expirationDate When Coupon expires + * @param CouponRuleCollection $rules Coupon rules + * @param bool $isCumulative If Coupon is cumulative + * @param bool $isRemovingPostage If Coupon is removing postage + * + * @return Coupon + */ + public function generateValidCoupon( + $code = null, + $type = null, + $title = null, + $shortDescription = null, + $description = null, + $amount = null, + $isUsed = null, + $isEnabled = null, + $expirationDate = null, + $rules = null, + $isCumulative = null, + $isRemovingPostage = null + ) { + $coupon = new Coupon(); + + if ($code === null) { + $code = 'XMAS1'; + } + $coupon->setCode($code); + + if ($type === null) { + $type = 'Thelia\Coupon\Type\RemoveXAmount'; + } + $coupon->setType($type); + + if ($title === null) { + $title = CouponManagerTest::VALID_TITLE; + } + $coupon->setTitle($title); + + if ($shortDescription === null) { + $shortDescription = CouponManagerTest::VALID_SHORT_DESCRIPTION; + } + $coupon->setShortDescription($shortDescription); + + if ($description === null) { + $description = CouponManagerTest::VALID_DESCRIPTION; + } + $coupon->setDescription($description); + + if ($amount === null) { + $amount = 10.00; + } + $coupon->setAmount($amount); + + if ($isUsed === null) { + $isUsed = 1; + } + $coupon->setIsUsed($isUsed); + + if ($isEnabled === null) { + $isEnabled = 1; + } + $coupon->setIsEnabled($isEnabled); + + if ($isCumulative === null) { + $isCumulative = 1; + } + if ($isRemovingPostage === null) { + $isRemovingPostage = 0; + } + + if ($expirationDate === null) { + $date = new \DateTime(); + $coupon->setExpirationDate( + $date->setTimestamp(strtotime("today + 2 months")) + ); + } + + if ($rules === null) { + $rules = $this->generateValidRules(); + } + + $coupon->setSerializedRules(base64_encode(serialize($rules))); + + $coupon->setIsCumulative($isCumulative); + $coupon->setIsRemovingPostage($isRemovingPostage); + + return $coupon; + } + /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index 9234642c9..b5b9cefbe 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -23,12 +23,12 @@ namespace Thelia\Coupon; -use Thelia\Coupon\Parameter\PriceParam; -use Thelia\Coupon\Parameter\RuleValidator; +use Thelia\Coupon\Validator\PriceParam; +use Thelia\Coupon\Validator\RuleValidator; use Thelia\Coupon\Rule\AvailableForTotalAmount; use Thelia\Coupon\Rule\Operators; +use Thelia\Coupon\Type\CouponInterface; use Thelia\Coupon\Type\RemoveXAmount; -use Thelia\Model\Coupon; use Thelia\Tools\PhpUnitUtils; /** @@ -44,7 +44,8 @@ use Thelia\Tools\PhpUnitUtils; */ class CouponManagerTest extends \PHPUnit_Framework_TestCase { - + CONST VALID_CODE = 'XMAS'; + CONST VALID_TITLE = 'XMAS coupon'; CONST VALID_SHORT_DESCRIPTION = 'Coupon for Christmas removing 10€ if your total checkout is more than 40€'; CONST VALID_DESCRIPTION = '

      Lorem ipsum dolor sit amet

      Consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla. @@ -68,167 +69,171 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua { } - /** - * Generate valid CouponInterface + * Test getDiscount() behaviour + * Entering : 1 valid Coupon (If 40 < total amount 400) - 10euros * - * @param string $code - * @param string $title - * @param string $shortDescription - * @param string $description - * @param float $amount - * @param bool $isEnabled - * @param $expirationDate - * @param $rules - * @param bool $isCumulative - * @param bool $isRemovingPostage - * @param bool $isAvailableOnSpecialOffers - * @param int $maxUsage - * - * @return CouponInterface + * @covers Thelia\Coupon\CouponManager::getDiscount */ - public function generateValidCoupon( - $code = 'XMAS1', - $title = 'Christmas coupon', - $shortDescription = self::VALID_SHORT_DESCRIPTION, - $description = self::VALID_DESCRIPTION, - $amount = 10.00, - $isEnabled = true, - $expirationDate = null, - $rules = null, - $isCumulative = true, - $isRemovingPostage = false, - $isAvailableOnSpecialOffers = true, - $maxUsage = 40 - ) { - if ($expirationDate === null) { - $expirationDate = new \DateTime(); - $expirationDate->setTimestamp(strtotime("today + 2 months")); - } + public function testGetDiscountOneCoupon() + { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; - $coupon = new RemoveXAmount($code, $title, $shortDescription, $description, $amount, $isCumulative, $isRemovingPostage, $isAvailableOnSpecialOffers, $isEnabled, $maxUsage, $expirationDate); + /** @var CouponInterface $coupon */ + $coupon = self::generateValidCoupon(); - if ($rules === null) { - $rules = $this->generateValidRules(); - } + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter(array($coupon), $cartTotalPrice, $checkoutTotalPrice); - $coupon->setRules($rules); + $couponManager = new CouponManager($stubCouponBaseAdapter); + $discount = $couponManager->getDiscount(); - return $coupon; + $expected = 10.00; + $actual = $discount; + $this->assertEquals($expected, $actual); } -// /** -// * @covers Thelia\Coupon\CouponManager::getDiscount -// * @todo Implement testGetDiscount(). -// */ -// public function testGetDiscountOneCoupon() -// { -// $this->markTestIncomplete( -// 'This test has not been implemented yet.' -// ); -// /** @var CouponInterface $coupon */ -// $coupon = $this->generateValidCoupon(); -// -// -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ -// $stubCouponBaseAdapter = $this->getMock( -// 'Thelia\Coupon\CouponBaseAdapter', -// array( -// 'getCurrentCoupons', -// 'getCheckoutTotalPriceWithoutDiscountAndPostagePrice' -// ), -// array() -// ); -// -// // Returns -10euros not removing postage Coupon -// // If 40 < total amount 400 -// $stubCouponBaseAdapter->expects($this->any()) -// ->method('getCurrentCoupons') -// ->will($this->returnValue(array($coupon))); -// -// // Return Checkout product amoun = 100euros -// $stubCouponBaseAdapter->expects($this->any()) -// ->method('getCheckoutTotalPriceWithoutDiscountAndPostagePrice') -// ->will($this->returnValue(100.00)); -// -// $couponManager = new CouponManager($stubCouponBaseAdapter); -// $discount = $couponManager->getDiscount(); -// -// $expected = 10.00; -// $actual = $discount; -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * @covers Thelia\Coupon\CouponManager::getDiscount -// * @todo Implement testGetDiscount(). -// */ -// public function testGetDiscountAlwaysInferiorToPrice() -// { -// // Remove the following lines when you implement this test. -// $this->markTestIncomplete( -// 'This test has not been implemented yet.' -// ); -// } -// -// /** -// * @covers Thelia\Coupon\CouponManager::getDiscount -// * @covers Thelia\Coupon\CouponManager::sortCoupons -// * @todo Implement testGetDiscount(). -// */ -// public function testGetDiscountCouponNotCumulativeCancelOthers() -// { -// // Remove the following lines when you implement this test. -// $this->markTestIncomplete( -// 'This test has not been implemented yet.' -// ); -// } -// -// /** -// * @covers Thelia\Coupon\CouponManager::getDiscount -// * @covers Thelia\Coupon\CouponManager::sortCoupons -// * @todo Implement testGetDiscount(). -// */ -// public function testGetDiscountCouponCumulativeCumulatesWithOthers() -// { -// // Remove the following lines when you implement this test. -// $this->markTestIncomplete( -// 'This test has not been implemented yet.' -// ); -// } -// -// /** -// * @covers Thelia\Coupon\CouponManager::isCouponRemovingPostage -// * @covers Thelia\Coupon\CouponManager::sortCoupons -// * @todo Implement testGetDiscount(). -// */ -// public function testIsCouponRemovingPostage() -// { -// // Remove the following lines when you implement this test. -// $this->markTestIncomplete( -// 'This test has not been implemented yet.' -// ); -// } + /** + * Test getDiscount() behaviour + * Entering : 1 valid Coupon (If 40 < total amount 400) - 10euros + * 1 valid Coupon (If total amount > 20) - 15euros + * + * @covers Thelia\Coupon\CouponManager::getDiscount + */ + public function testGetDiscountTwoCoupon() + { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; + + /** @var CouponInterface $coupon1 */ + $coupon1 = self::generateValidCoupon(); + $rule1 = new AvailableForTotalAmount( + array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + new PriceParam( + 40.00, + 'EUR' + ) + ) + ) + ); + $rules = new CouponRuleCollection(array($rule1)); + /** @var CouponInterface $coupon2 */ + $coupon2 = $this->generateValidCoupon('XMAS2', null, null, null, 15.00, null, null, $rules); + + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter(array($coupon1, $coupon2), $cartTotalPrice, $checkoutTotalPrice); + + $couponManager = new CouponManager($stubCouponBaseAdapter); + $discount = $couponManager->getDiscount(); + + $expected = 25.00; + $actual = $discount; + $this->assertEquals($expected, $actual); + } /** + * Test getDiscount() behaviour + * For a Cart of 21euros + * Entering : 1 valid Coupon (If total amount > 20) - 30euros + * + * @covers Thelia\Coupon\CouponManager::getDiscount + */ + public function testGetDiscountAlwaysInferiorToPrice() + { + $cartTotalPrice = 21.00; + $checkoutTotalPrice = 26.00; + + $rule1 = new AvailableForTotalAmount( + array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + new PriceParam( + 20.00, + 'EUR' + ) + ) + ) + ); + $rules = new CouponRuleCollection(array($rule1)); + /** @var CouponInterface $coupon */ + $coupon = $this->generateValidCoupon('XMAS2', null, null, null, 30.00, null, null, $rules); + + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter(array($coupon), $cartTotalPrice, $checkoutTotalPrice); + + $couponManager = new CouponManager($stubCouponBaseAdapter); + $discount = $couponManager->getDiscount(); + + $expected = 21.00; + $actual = $discount; + $this->assertEquals($expected, $actual); + } + + + /** + * Check if removing postage on discout is working + * @covers Thelia\Coupon\CouponManager::isCouponRemovingPostage + * @covers Thelia\Coupon\CouponManager::sortCoupons + */ + public function testIsCouponRemovingPostage() + { + $cartTotalPrice = 21.00; + $checkoutTotalPrice = 27.00; + + $rule1 = new AvailableForTotalAmount( + array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + new PriceParam( + 20.00, + 'EUR' + ) + ) + ) + ); + $rules = new CouponRuleCollection(array($rule1)); + /** @var CouponInterface $coupon */ + $coupon = $this->generateValidCoupon('XMAS2', null, null, null, 30.00, null, null, $rules, null, true); + + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter(array($coupon), $cartTotalPrice, $checkoutTotalPrice); + + $couponManager = new CouponManager($stubCouponBaseAdapter); + $discount = $couponManager->getDiscount(); + + $expected = 21.00; + $actual = $discount; + $this->assertEquals($expected, $actual); + } + + /** + * Testing how multiple Coupon behaviour + * Entering 1 Coupon not cumulative + * * @covers Thelia\Coupon\CouponManager::sortCoupons */ public function testCouponCumulationOneCouponNotCumulative() { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; + // Given /** @var CouponInterface $coupon */ - $couponCumulative1 = $this->generateValidCoupon(null, null, null, null, null, null, null, null, true); - $couponCumulative2 = $this->generateValidCoupon(null, null, null, null, null, null, null, null, true); - $couponNotCumulative1 = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false); - $couponNotCumulative2 = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false); + $couponCumulative1 = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false); $coupons = array($couponCumulative1); + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); + // When $sortedCoupons = PhpUnitUtils::callMethod( - new CouponManager(new CouponBaseAdapter()), + new CouponManager($stubCouponBaseAdapter), 'sortCoupons', - $coupons + array($coupons) ); // Then @@ -238,13 +243,402 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $this->assertSame($expected, $actual, 'Array Sorted despite there is only once'); } + /** + * Testing how multiple Coupon behaviour + * Entering 1 Coupon cumulative + * + * @covers Thelia\Coupon\CouponManager::sortCoupons + */ + public function testCouponCumulationOneCouponCumulative() + { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; + + // Given + /** @var CouponInterface $coupon */ + $couponCumulative1 = $this->generateValidCoupon(null, null, null, null, null, null, null, null, true); + + $coupons = array($couponCumulative1); + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); + + // When + $sortedCoupons = PhpUnitUtils::callMethod( + new CouponManager($stubCouponBaseAdapter), + 'sortCoupons', + array($coupons) + ); + + // Then + $expected = $coupons; + $actual = $sortedCoupons; + + $this->assertSame($expected, $actual, 'Array Sorted despite there is only once'); + } + + /** + * Testing how multiple Coupon behaviour + * Entering 1 Coupon cumulative + * 1 Coupon cumulative + * + * @covers Thelia\Coupon\CouponManager::sortCoupons + */ + public function testCouponCumulationTwoCouponCumulative() + { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; + + // Given + /** @var CouponInterface $coupon */ + $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, true); + $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, true); + + $coupons = array($couponCumulative1, $couponCumulative2); + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); + + // When + $sortedCoupons = PhpUnitUtils::callMethod( + new CouponManager($stubCouponBaseAdapter), + 'sortCoupons', + array($coupons) + ); + + // Then + $expected = $coupons; + $actual = $sortedCoupons; + + $this->assertSame($expected, $actual, 'Array Sorted despite both Coupon can be accumulated'); + } + + /** + * Testing how multiple Coupon behaviour + * Entering 1 Coupon cumulative + * 1 Coupon non cumulative + * + * @covers Thelia\Coupon\CouponManager::sortCoupons + */ + public function testCouponCumulationOneCouponCumulativeOneNonCumulative() + { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; + + // Given + /** @var CouponInterface $coupon */ + $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, true); + $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, false); + + $coupons = array($couponCumulative1, $couponCumulative2); + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); + + // When + $sortedCoupons = PhpUnitUtils::callMethod( + new CouponManager($stubCouponBaseAdapter), + 'sortCoupons', + array($coupons) + ); + + // Then + $expected = array($couponCumulative2); + $actual = $sortedCoupons; + + $this->assertSame($expected, $actual, 'Array Sorted despite both Coupon can be accumulated'); + } + + /** + * Testing how multiple Coupon behaviour + * Entering 1 Coupon non cumulative + * 1 Coupon cumulative + * + * @covers Thelia\Coupon\CouponManager::sortCoupons + */ + public function testCouponCumulationOneCouponNonCumulativeOneCumulative() + { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; + + // Given + /** @var CouponInterface $coupon */ + $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, false); + $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, true); + + $coupons = array($couponCumulative1, $couponCumulative2); + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); + + // When + $sortedCoupons = PhpUnitUtils::callMethod( + new CouponManager($stubCouponBaseAdapter), + 'sortCoupons', + array($coupons) + ); + + // Then + $expected = array($couponCumulative2); + $actual = $sortedCoupons; + + $this->assertSame($expected, $actual, 'Array Sorted despite both Coupon can be accumulated'); + } + + /** + * Testing how multiple Coupon behaviour + * Entering 1 Coupon non cumulative + * 1 Coupon non cumulative + * + * @covers Thelia\Coupon\CouponManager::sortCoupons + */ + public function testCouponCumulationTwoCouponNonCumulative() + { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; + + // Given + /** @var CouponInterface $coupon */ + $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, false); + $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, false); + + $coupons = array($couponCumulative1, $couponCumulative2); + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); + + // When + $sortedCoupons = PhpUnitUtils::callMethod( + new CouponManager($stubCouponBaseAdapter), + 'sortCoupons', + array($coupons) + ); + + // Then + $expected = array($couponCumulative2); + $actual = $sortedCoupons; + + $this->assertSame($expected, $actual, 'Array Sorted despite both Coupon can be accumulated'); + } + + /** + * Testing how multiple Coupon behaviour + * Entering 1 Coupon cumulative expired + * + * @covers Thelia\Coupon\CouponManager::sortCoupons + */ + public function testCouponCumulationOneCouponCumulativeExpired() + { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; + + // Given + /** @var CouponInterface $coupon */ + $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, new \DateTime(), null, true); + + $coupons = array($couponCumulative1); + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); + + // When + $sortedCoupons = PhpUnitUtils::callMethod( + new CouponManager($stubCouponBaseAdapter), + 'sortCoupons', + array($coupons) + ); + + // Then + $expected = array(); + $actual = $sortedCoupons; + + $this->assertSame($expected, $actual, 'Coupon expired ignored'); + } + + /** + * Testing how multiple Coupon behaviour + * Entering 1 Coupon cumulative expired + * 1 Coupon cumulative expired + * + * @covers Thelia\Coupon\CouponManager::sortCoupons + */ + public function testCouponCumulationTwoCouponCumulativeExpired() + { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; + + // Given + /** @var CouponInterface $coupon */ + $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, new \DateTime(), null, true); + $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, new \DateTime(), null, true); + + $coupons = array($couponCumulative1, $couponCumulative2); + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); + + // When + $sortedCoupons = PhpUnitUtils::callMethod( + new CouponManager($stubCouponBaseAdapter), + 'sortCoupons', + array($coupons) + ); + + // Then + $expected = array(); + $actual = $sortedCoupons; + + $this->assertSame($expected, $actual, 'Coupon expired ignored'); + } + + /** + * Testing how multiple Coupon behaviour + * Entering 1 Coupon cumulative expired + * 1 Coupon cumulative valid + * + * @covers Thelia\Coupon\CouponManager::sortCoupons + */ + public function testCouponCumulationOneCouponCumulativeExpiredOneNonExpired() + { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; + + // Given + /** @var CouponInterface $coupon */ + $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, new \DateTime(), null, true); + $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, true); + + $coupons = array($couponCumulative1, $couponCumulative2); + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); + + // When + $sortedCoupons = PhpUnitUtils::callMethod( + new CouponManager($stubCouponBaseAdapter), + 'sortCoupons', + array($coupons) + ); + + // Then + $expected = array($couponCumulative2); + $actual = $sortedCoupons; + + $this->assertSame($expected, $actual, 'Coupon expired ignored'); + } + + /** + * Testing how multiple Coupon behaviour + * Entering 1 Coupon cumulative valid + * 1 Coupon cumulative expired + * + * @covers Thelia\Coupon\CouponManager::sortCoupons + */ + public function testCouponCumulationOneCouponCumulativeNonExpiredOneExpired() + { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; + + // Given + /** @var CouponInterface $coupon */ + $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, true); + $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, new \DateTime(), null, true); + + $coupons = array($couponCumulative1, $couponCumulative2); + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); + + // When + $sortedCoupons = PhpUnitUtils::callMethod( + new CouponManager($stubCouponBaseAdapter), + 'sortCoupons', + array($coupons) + ); + + // Then + $expected = array($couponCumulative1); + $actual = $sortedCoupons; + + $this->assertSame($expected, $actual, 'Coupon expired ignored'); + } + + /** + * Testing how multiple Coupon behaviour + * Entering 1 Coupon cumulative valid + * 1 Coupon cumulative valid + * 1 Coupon cumulative valid + * 1 Coupon cumulative valid + * + * @covers Thelia\Coupon\CouponManager::sortCoupons + */ + public function testCouponCumulationFourCouponCumulative() + { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; + + // Given + /** @var CouponInterface $coupon */ + $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, true); + $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, true); + $couponCumulative3 = $this->generateValidCoupon('XMAS3', null, null, null, null, null, null, null, true); + $couponCumulative4 = $this->generateValidCoupon('XMAS4', null, null, null, null, null, null, null, true); + + $coupons = array($couponCumulative1, $couponCumulative2, $couponCumulative3, $couponCumulative4); + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); + + // When + $sortedCoupons = PhpUnitUtils::callMethod( + new CouponManager($stubCouponBaseAdapter), + 'sortCoupons', + array($coupons) + ); + + // Then + $expected = $coupons; + $actual = $sortedCoupons; + + $this->assertSame($expected, $actual, 'Coupon cumulative ignored'); + } + + /** + * Testing how multiple Coupon behaviour + * Entering 1 Coupon cumulative valid + * 1 Coupon cumulative valid + * 1 Coupon cumulative valid + * 1 Coupon non cumulative valid + * + * @covers Thelia\Coupon\CouponManager::sortCoupons + */ + public function testCouponCumulationThreeCouponCumulativeOneNonCumulative() + { + $cartTotalPrice = 100.00; + $checkoutTotalPrice = 120.00; + + // Given + /** @var CouponInterface $coupon */ + $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, true); + $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, true); + $couponCumulative3 = $this->generateValidCoupon('XMAS3', null, null, null, null, null, null, null, true); + $couponCumulative4 = $this->generateValidCoupon('XMAS4', null, null, null, null, null, null, null, false); + + $coupons = array($couponCumulative1, $couponCumulative2, $couponCumulative3, $couponCumulative4); + /** @var CouponAdapterInterface $stubCouponBaseAdapter */ + $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); + + // When + $sortedCoupons = PhpUnitUtils::callMethod( + new CouponManager($stubCouponBaseAdapter), + 'sortCoupons', + array($coupons) + ); + + // Then + $expected = array($couponCumulative4); + $actual = $sortedCoupons; + + $this->assertSame($expected, $actual, 'Coupon cumulative ignored'); + } + /** * Generate valid CouponRuleInterfaces * * @return array Array of CouponRuleInterface */ - protected function generateValidRules() + public static function generateValidRules() { $rule1 = new AvailableForTotalAmount( array( @@ -281,4 +675,130 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua { } + /** + * Generate a fake Adapter + * + * @param array $coupons Coupons + * @param float $cartTotalPrice Cart total price + * @param float $checkoutTotalPrice Checkout total price + * @param float $postagePrice Checkout postage price + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ + public function generateFakeAdapter(array $coupons, $cartTotalPrice, $checkoutTotalPrice, $postagePrice = 6.00) + { + $stubCouponBaseAdapter = $this->getMock( + 'Thelia\Coupon\CouponBaseAdapter', + array( + 'getCurrentCoupons', + 'getCartTotalPrice', + 'getCheckoutTotalPrice', + 'getCheckoutPostagePrice' + ), + array() + ); + + $stubCouponBaseAdapter->expects($this->any()) + ->method('getCurrentCoupons') + ->will($this->returnValue(($coupons))); + + // Return Cart product amount = $cartTotalPrice euros + $stubCouponBaseAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue($cartTotalPrice)); + + // Return Checkout amount = $checkoutTotalPrice euros + $stubCouponBaseAdapter->expects($this->any()) + ->method('getCheckoutTotalPrice') + ->will($this->returnValue($checkoutTotalPrice)); + + $stubCouponBaseAdapter->expects($this->any()) + ->method('getCheckoutPostagePrice') + ->will($this->returnValue($postagePrice)); + + return $stubCouponBaseAdapter; + } + + /** + * Generate valid CouponInterface + * + * @param string $code Coupon Code + * @param string $title Coupon Title + * @param string $shortDescription Coupon short + * description + * @param string $description Coupon description + * @param float $amount Coupon discount + * @param bool $isEnabled Is Coupon enabled + * @param \DateTime $expirationDate Coupon expiration date + * @param CouponRuleCollection $rules Coupon rules + * @param bool $isCumulative If is cumulative + * @param bool $isRemovingPostage If is removing postage + * @param bool $isAvailableOnSpecialOffers If is available on + * special offers or not + * @param int $maxUsage How many time a Coupon + * can be used + * + * @return CouponInterface + */ + public static function generateValidCoupon( + $code = null, + $title = null, + $shortDescription = null, + $description = null, + $amount = null, + $isEnabled = null, + $expirationDate = null, + $rules = null, + $isCumulative = null, + $isRemovingPostage = null, + $isAvailableOnSpecialOffers = null, + $maxUsage = null + ) { + if ($code === null) { + $code = self::VALID_CODE; + } + if ($title === null) { + $title = self::VALID_TITLE; + } + if ($shortDescription === null) { + $shortDescription = self::VALID_SHORT_DESCRIPTION; + } + if ($description === null) { + $description = self::VALID_DESCRIPTION; + } + if ($amount === null) { + $amount = 10.00; + } + if ($isEnabled === null) { + $isEnabled = true; + } + if ($isCumulative === null) { + $isCumulative = true; + } + if ($isRemovingPostage === null) { + $isRemovingPostage = false; + } + if ($isAvailableOnSpecialOffers === null) { + $isAvailableOnSpecialOffers = true; + } + if ($maxUsage === null) { + $maxUsage = 40; + } + + if ($expirationDate === null) { + $expirationDate = new \DateTime(); + $expirationDate->setTimestamp(strtotime("today + 2 months")); + } + + $coupon = new RemoveXAmount($code, $title, $shortDescription, $description, $amount, $isCumulative, $isRemovingPostage, $isAvailableOnSpecialOffers, $isEnabled, $maxUsage, $expirationDate); + + if ($rules === null) { + $rules = self::generateValidRules(); + } + + $coupon->setRules($rules); + + return $coupon; + } + } diff --git a/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php b/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php index 081aee2dd..e399b6f37 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php @@ -23,8 +23,8 @@ namespace Thelia\Coupon; -use Thelia\Coupon\Parameter\PriceParam; -use Thelia\Coupon\Parameter\RuleValidator; +use Thelia\Coupon\Validator\PriceParam; +use Thelia\Coupon\Validator\RuleValidator; use Thelia\Coupon\Rule\AvailableForTotalAmount; use Thelia\Coupon\Rule\Operators; diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php index 4c26bfa2f..bbfe4015a 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use InvalidArgumentException; -use Thelia\Coupon\Parameter\DateParam; +use Thelia\Coupon\Validator\DateParam; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php index 05f19955d..b8938d102 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use InvalidArgumentException; -use Thelia\Coupon\Parameter\IntegerParam; +use Thelia\Coupon\Validator\IntegerParam; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php index 73571ba5b..c068dfc01 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use InvalidArgumentException; -use Thelia\Coupon\Parameter\IntervalParam; +use Thelia\Coupon\Validator\IntervalParam; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php index 62d552e0b..19f19fd4e 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use InvalidArgumentException; -use Thelia\Coupon\Parameter\PriceParam; +use Thelia\Coupon\Validator\PriceParam; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php index 6a9d9d737..17343121c 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use InvalidArgumentException; -use Thelia\Coupon\Parameter\QuantityParam; +use Thelia\Coupon\Validator\QuantityParam; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php index f9a6f0d18..66c970a4f 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php @@ -25,7 +25,7 @@ namespace Thelia\Coupon; use InvalidArgumentException; use Symfony\Component\Intl\Exception\NotImplementedException; -use Thelia\Coupon\Parameter\RepeatedDateParam; +use Thelia\Coupon\Validator\RepeatedDateParam; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php index fe5866b0f..dc7a1335d 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php +++ b/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use Symfony\Component\Intl\Exception\NotImplementedException; -use Thelia\Coupon\Parameter\RepeatedIntervalParam; +use Thelia\Coupon\Validator\RepeatedIntervalParam; /** * Created by JetBrains PhpStorm. @@ -75,7 +75,7 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo * */ - public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriodBegining() + public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriodBeginning() { $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-07-08"); @@ -138,7 +138,7 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo * */ - public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriodBegining() + public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriodBeginning() { $startDateValidator = new \DateTime("2012-08-08"); $dateToValidate = new \DateTime("2012-08-08"); @@ -264,7 +264,7 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo * */ - public function testNotEqualsDateRepeatEveryMonthFourTimeInTheBegining() + public function testNotEqualsDateRepeatEveryMonthFourTimeInTheBeginning() { $startDateValidator = new \DateTime("2012-10-08"); $dateToValidate = new \DateTime("2012-07-19"); @@ -348,7 +348,7 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase /** * @covers Thelia\Coupon\Parameter\DateParam::compareTo - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ public function testInvalidArgumentException() { diff --git a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php index 15c07ba1a..63d78615f 100644 --- a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php +++ b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php @@ -23,8 +23,8 @@ namespace Thelia\Coupon; -use Thelia\Coupon\Parameter\PriceParam; -use Thelia\Coupon\Parameter\RuleValidator; +use Thelia\Coupon\Validator\PriceParam; +use Thelia\Coupon\Validator\RuleValidator; use Thelia\Coupon\Rule\AvailableForTotalAmount; use Thelia\Coupon\Rule\Operators; use Thelia\Exception\InvalidRuleOperatorException; @@ -52,6 +52,11 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase { } + /** + * Generate valid CouponBaseAdapter + * + * @return CouponAdapterInterface + */ protected function generateValidCouponBaseAdapterMock() { /** @var CouponAdapterInterface $stubTheliaAdapter */ @@ -130,7 +135,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase /** * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput - * @expectedException ErrorException + * @expectedException \ErrorException * */ public function testInValidBackOfficeInputValue() diff --git a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php index 8bffc05a9..3579eacf3 100644 --- a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php +++ b/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php @@ -52,11 +52,11 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase /** @var CouponAdapterInterface $stubTheliaAdapter */ $stubTheliaAdapter = $this->getMock( 'CouponBaseAdapter', - array('getNbArticlesInTheCart'), + array('getNbArticlesInCart'), array() ); $stubTheliaAdapter->expects($this->any()) - ->method('getNbArticlesInTheCart') + ->method('getNbArticlesInCart') ->will($this->returnValue(4)); return $stubTheliaAdapter; @@ -73,7 +73,7 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(4); - $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = true; @@ -92,7 +92,7 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(4.5); - $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; @@ -100,7 +100,7 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); $validators = array(-1); - $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; @@ -108,7 +108,7 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); $validators = array('bad'); - $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; @@ -129,7 +129,7 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(4); - $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = true; @@ -148,7 +148,7 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(4.5); - $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; @@ -156,7 +156,7 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); $validators = array(-1); - $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; @@ -164,7 +164,7 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); $validators = array('bad'); - $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; @@ -183,7 +183,7 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(4); - $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = true; @@ -202,7 +202,7 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(5); - $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = true; @@ -221,7 +221,7 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); $validators = array(3); - $validated = array($stubTheliaAdapter->getNbArticlesInTheCart()); + $validated = array($stubTheliaAdapter->getNbArticlesInCart()); $rule = new AvailableForXArticles($validators, $validated); $expected = false; diff --git a/core/lib/Thelia/Tests/Coupon/Rule/OperatorsTest.php b/core/lib/Thelia/Tests/Coupon/Rule/OperatorsTest.php index bf4fbc75d..22a83dc8b 100644 --- a/core/lib/Thelia/Tests/Coupon/Rule/OperatorsTest.php +++ b/core/lib/Thelia/Tests/Coupon/Rule/OperatorsTest.php @@ -23,7 +23,7 @@ namespace Thelia\Coupon; -use Thelia\Coupon\Parameter\QuantityParam; +use Thelia\Coupon\Validator\QuantityParam; use Thelia\Coupon\Rule\Operators; /** @@ -61,7 +61,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(12); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertTrue($actual); @@ -80,7 +80,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(12); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertFalse($actual); @@ -99,7 +99,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(12); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertFalse($actual); @@ -118,7 +118,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(11); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertTrue($actual); @@ -137,7 +137,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(11); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertTrue($actual); @@ -156,7 +156,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(11); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertFalse($actual); @@ -175,7 +175,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(12); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertTrue($actual); @@ -194,7 +194,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(12); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertFalse($actual); @@ -213,7 +213,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(12); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertFalse($actual); @@ -232,7 +232,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(13); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertTrue($actual); @@ -251,7 +251,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(13); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertTrue($actual); @@ -270,7 +270,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(13); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertFalse($actual); @@ -289,7 +289,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(12); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertTrue($actual); @@ -308,7 +308,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(12); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertFalse($actual); @@ -327,7 +327,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(12); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertFalse($actual); @@ -346,7 +346,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(11); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertTrue($actual); @@ -365,7 +365,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(11); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertFalse($actual); @@ -384,7 +384,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $b = new QuantityParam(11); // When - $actual = Operators::isValidAccordingToOperator($a, $operator, $b); + $actual = Operators::isValid($a, $operator, $b); // Then $this->assertFalse($actual); diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php index f7287bb45..72313f9ec 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php @@ -23,11 +23,14 @@ namespace Thelia\Coupon; -use Thelia\Coupon\Parameter\PriceParam; +use Thelia\Coupon\Validator\PriceParam; +use Thelia\Coupon\Validator\RuleValidator; use Thelia\Coupon\Rule\AvailableForTotalAmount; use Thelia\Coupon\Rule\Operators; use Thelia\Coupon\Type\RemoveXAmount; +require_once '../CouponManagerTest.php'; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -41,11 +44,6 @@ use Thelia\Coupon\Type\RemoveXAmount; */ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase { - - CONST VALID_COUPON_CODE = 'XMAS'; - CONST VALID_COUPON_TITLE = 'XMAS Coupon'; - CONST VALID_COUPON_SHORT_DESCRIPTION = 'Coupon for christmas'; - CONST VALID_COUPON_DESCRIPTION = '

      Lorem

      ipsum'; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -55,37 +53,6 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase } - - protected function generateValidCumulativeRemovingPostageCoupon() - { - $coupon = new RemoveXAmount( - self::VALID_COUPON_CODE, - self::VALID_COUPON_TITLE, - self::VALID_COUPON_SHORT_DESCRIPTION, - self::VALID_COUPON_DESCRIPTION, - 30.00, - true, - true - ); - - return $coupon; - } - - protected function generateValidNonCumulativeNonRemovingPostageCoupon() - { - $coupon = new RemoveXAmount( - self::VALID_COUPON_CODE, - self::VALID_COUPON_TITLE, - self::VALID_COUPON_SHORT_DESCRIPTION, - self::VALID_COUPON_DESCRIPTION, - 30.00, - false, - false - ); - - return $coupon; - } - /** * * @covers Thelia\Coupon\type\RemoveXAmount::getCode @@ -96,28 +63,25 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase */ public function testDisplay() { + $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, true, true); - $coupon = $this->generateValidCumulativeRemovingPostageCoupon(); - - $expected = self::VALID_COUPON_CODE; + $expected = CouponManagerTest::VALID_CODE; $actual = $coupon->getCode(); $this->assertEquals($expected, $actual); - $expected = self::VALID_COUPON_TITLE; + $expected = CouponManagerTest::VALID_TITLE; $actual = $coupon->getTitle(); $this->assertEquals($expected, $actual); - $expected = self::VALID_COUPON_SHORT_DESCRIPTION; + $expected = CouponManagerTest::VALID_SHORT_DESCRIPTION; $actual = $coupon->getShortDescription(); $this->assertEquals($expected, $actual); - $expected = self::VALID_COUPON_DESCRIPTION; + $expected = CouponManagerTest::VALID_DESCRIPTION; $actual = $coupon->getDescription(); $this->assertEquals($expected, $actual); - } - /** * * @covers Thelia\Coupon\type\RemoveXAmount::isCumulative @@ -126,7 +90,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testIsCumulative() { - $coupon = $this->generateValidCumulativeRemovingPostageCoupon(); + $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, true, true); $actual = $coupon->isCumulative(); $this->assertTrue($actual); @@ -140,7 +104,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testIsNotCumulative() { - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); $actual = $coupon->isCumulative(); $this->assertFalse($actual); @@ -154,8 +118,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase */ public function testIsRemovingPostage() { - - $coupon = $this->generateValidCumulativeRemovingPostageCoupon(); + $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, true, true); $actual = $coupon->isRemovingPostage(); $this->assertTrue($actual); @@ -169,7 +132,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testIsNotRemovingPostage() { - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); $actual = $coupon->isRemovingPostage(); $this->assertFalse($actual); @@ -184,43 +147,13 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testGetEffect() { - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); - $expected = -30.00; - $actual = $coupon->getEffect(); + $expected = 10; + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } - /** - * - * @covers Thelia\Coupon\type\RemoveXAmount::addRule - * @covers Thelia\Coupon\type\RemoveXAmount::getRules - * - */ - public function testAddRuleValid() - { - // Given - $rule1 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( - Operators::INFERIOR, - 100.23 - ); - $rule2 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( - Operators::SUPERIOR, - 421.23 - ); - - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); - - // When - $coupon->addRule($rule1) - ->addRule($rule2); - - // Then - $expected = 2; - $this->assertCount($expected, $coupon->getRules()); - } - - /** * * @covers Thelia\Coupon\type\RemoveXAmount::setRules @@ -230,29 +163,27 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testSetRulesValid() { // Given - $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::EQUAL, 20.00 ); - $rule1 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + $rule1 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::INFERIOR, 100.23 ); - $rule2 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + $rule2 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::SUPERIOR, 421.23 ); - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When - $coupon->addRule($rule0) - ->setRules(array($rule1, $rule2)); - + $coupon->setRules(new CouponRuleCollection(array($rule0, $rule1, $rule2))); // Then - $expected = 2; - $this->assertCount($expected, $coupon->getRules()); + $expected = 3; + $this->assertCount($expected, $coupon->getRules()->getRules()); } /** @@ -264,21 +195,20 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testSetRulesInvalid() { // Given - $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::EQUAL, 20.00 ); - $rule1 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + $rule1 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::INFERIOR, 100.23 ); $rule2 = $this; - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When - $coupon->addRule($rule0) - ->setRules(array($rule1, $rule2)); + $coupon->setRules(new CouponRuleCollection(array($rule0, $rule1, $rule2))); } /** @@ -289,18 +219,18 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountInferiorTo400Valid() { // Given - $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::INFERIOR, 400.00 ); - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When - $coupon->addRule($rule0); + $coupon->setRules(new CouponRuleCollection(array($rule0))); // Then - $expected = -30.00; - $actual = $coupon->getEffect(); + $expected = 10.00; + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -312,18 +242,18 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountInferiorOrEqualTo400Valid() { // Given - $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::INFERIOR_OR_EQUAL, 400.00 ); - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When - $coupon->addRule($rule0); + $coupon->setRules(new CouponRuleCollection(array($rule0))); // Then - $expected = -30.00; - $actual = $coupon->getEffect(); + $expected = 10.00; + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -335,18 +265,18 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountEqualTo400Valid() { // Given - $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::EQUAL, 400.00 ); - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When - $coupon->addRule($rule0); + $coupon->setRules(new CouponRuleCollection(array($rule0))); // Then - $expected = -30.00; - $actual = $coupon->getEffect(); + $expected = 10.00; + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -358,18 +288,18 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountSuperiorOrEqualTo400Valid() { // Given - $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::SUPERIOR_OR_EQUAL, 400.00 ); - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When - $coupon->addRule($rule0); + $coupon->setRules(new CouponRuleCollection(array($rule0))); // Then - $expected = -30.00; - $actual = $coupon->getEffect(); + $expected = 10.00; + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -381,18 +311,18 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountSuperiorTo400Valid() { // Given - $rule0 = $this->generateValideRuleAvailableForTotalAmountOperatorTo( + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::SUPERIOR, 400.00 ); - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When - $coupon->addRule($rule0); + $coupon->setRules(new CouponRuleCollection(array($rule0))); // Then - $expected = -30.00; - $actual = $coupon->getEffect(); + $expected = 10.00; + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -415,12 +345,15 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase * * @return AvailableForTotalAmount */ - protected function generateValideRuleAvailableForTotalAmountOperatorTo($operator, $amount) + protected function generateValidRuleAvailableForTotalAmountOperatorTo($operator, $amount) { $validators = array( - AvailableForTotalAmount::PARAM1_PRICE => array( - AvailableForTotalAmount::OPERATOR => $operator, - AvailableForTotalAmount::VALUE => new PriceParam($amount, 'EUR') + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + $operator, + new PriceParam( + $amount, + 'EUR' + ) ) ); diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php index caa90f4ae..24388104d 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php @@ -28,13 +28,13 @@ namespace Thelia\Coupon; * Date: 8/19/13 * Time: 3:24 PM * - * Unit Test RemoveXPercenForCategoryY Class + * Unit Test RemoveXPercentForCategoryY Class * * @package Coupon * @author Guillaume MOREL * */ -class RemoveXPercenForCategoryYTest extends \PHPUnit_Framework_TestCase +class RemoveXPercentForCategoryYTest extends \PHPUnit_Framework_TestCase { /** diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php index 7dfca8dd2..5d110d3df 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php @@ -171,7 +171,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase /** * - * @covers Thelia\Coupon\Type\RemoveXPercent::getEffect + * @covers Thelia\Coupon\Type\RemoveXPercent::getDiscount * */ public function testGetEffect() @@ -180,7 +180,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); $expected = -30.00; - $actual = $coupon->getEffect(); + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } diff --git a/core/lib/Thelia/Tools/PhpUnitUtils.php b/core/lib/Thelia/Tools/PhpUnitUtils.php index e8a2d41ab..89bd3b148 100644 --- a/core/lib/Thelia/Tools/PhpUnitUtils.php +++ b/core/lib/Thelia/Tools/PhpUnitUtils.php @@ -39,11 +39,11 @@ class PhpUnitUtils /** * Allow to call a protected methods * - * @param string $obj Class name + namespace + * @param Object $obj Class name + namespace * @param string $name Method name * @param array $args Method arguments * - * @return protected method result + * @return mixed protected method result */ public static function callMethod($obj, $name, array $args) { From c24e82758f494d045ba79321e69b955e604210d7 Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 27 Aug 2013 18:53:18 +0200 Subject: [PATCH 036/268] WIP Coupon Refactor : creating dedicated reusable module for Constraints Adding ConstraintManager Secured : - Effects : RemoveXPercent + RemoveXAmount - Validators : all except ModelParam (need CustomerModelParam, AreaModelParam, CountryModelParam ?) - Conditions : AvailableForTotalAmount --- .../Thelia/Constraint/ConstraintManager.php | 82 ++++ .../Rule/AvailableForDate.php | 4 +- .../Rule/AvailableForLocationX.php | 4 +- .../Rule/AvailableForPeriod.php | 4 +- .../Rule/AvailableForRepeatedDate.php | 4 +- .../Rule/AvailableForRepeatedPeriod.php | 4 +- .../Rule/AvailableForTotalAmount.php | 45 +- .../AvailableForTotalAmountForCategoryY.php | 4 +- .../Rule/AvailableForXArticles.php | 4 +- .../Rule/CouponRuleAbstract.php | 8 +- .../Rule/CouponRuleInterface.php | 19 +- .../{Coupon => Constraint}/Rule/Operators.php | 68 ++- .../Validator/ComparableInterface.php | 2 +- .../Validator/DateParam.php | 25 +- .../Validator/IntegerParam.php | 24 +- .../Validator/IntervalParam.php | 57 ++- .../Constraint/Validator/ModelParam.php | 115 +++++ .../Validator/PriceParam.php | 32 +- .../Validator/QuantityParam.php | 29 +- .../Validator/RepeatedDateParam.php | 23 +- .../Validator/RepeatedIntervalParam.php | 23 +- .../Validator/RepeatedParam.php | 50 ++- .../Validator/RuleParameterAbstract.php | 20 +- .../Validator/RuleValidator.php | 4 +- .../Thelia/Coupon/CouponAdapterInterface.php | 8 + core/lib/Thelia/Coupon/CouponBaseAdapter.php | 14 +- core/lib/Thelia/Coupon/CouponManager.php | 2 +- .../Thelia/Coupon/CouponRuleCollection.php | 2 +- .../lib/Thelia/Coupon/Type/CouponAbstract.php | 23 +- .../Thelia/Coupon/Type/CouponInterface.php | 14 + core/lib/Thelia/Coupon/Type/RemoveXAmount.php | 71 ++- .../lib/Thelia/Coupon/Type/RemoveXPercent.php | 76 +++- .../Constraint/ConstraintManagerTest.php | 142 ++++++ .../Rule/AvailableForTotalAmountTest.php | 43 +- .../Rule/AvailableForXArticlesTest.php | 4 +- .../Rule/OperatorsTest.php | 42 +- .../Validator}/DateParamTest.php | 37 +- .../Validator}/IntegerParamTest.php | 36 +- .../Validator}/IntervalParamTest.php | 40 +- .../Validator}/PriceParamTest.php | 57 ++- .../Validator}/QuantityParamTest.php | 43 +- .../Validator}/RepeatedDateParamTest.php | 63 ++- .../Validator}/RepeatedIntervalParamTest.php | 81 +++- .../Thelia/Tests/Coupon/CouponFactoryTest.php | 14 +- .../Thelia/Tests/Coupon/CouponManagerTest.php | 30 +- .../Tests/Coupon/CouponRuleCollectionTest.php | 14 +- .../Tests/Coupon/Type/RemoveXAmountTest.php | 48 +- .../Tests/Coupon/Type/RemoveXPercentTest.php | 424 ++++++++++++++---- 48 files changed, 1632 insertions(+), 350 deletions(-) create mode 100644 core/lib/Thelia/Constraint/ConstraintManager.php rename core/lib/Thelia/{Coupon => Constraint}/Rule/AvailableForDate.php (97%) rename core/lib/Thelia/{Coupon => Constraint}/Rule/AvailableForLocationX.php (97%) rename core/lib/Thelia/{Coupon => Constraint}/Rule/AvailableForPeriod.php (97%) rename core/lib/Thelia/{Coupon => Constraint}/Rule/AvailableForRepeatedDate.php (97%) rename core/lib/Thelia/{Coupon => Constraint}/Rule/AvailableForRepeatedPeriod.php (98%) rename core/lib/Thelia/{Coupon => Constraint}/Rule/AvailableForTotalAmount.php (84%) rename core/lib/Thelia/{Coupon => Constraint}/Rule/AvailableForTotalAmountForCategoryY.php (97%) rename core/lib/Thelia/{Coupon => Constraint}/Rule/AvailableForXArticles.php (97%) rename core/lib/Thelia/{Coupon => Constraint}/Rule/CouponRuleAbstract.php (97%) rename core/lib/Thelia/{Coupon => Constraint}/Rule/CouponRuleInterface.php (91%) rename core/lib/Thelia/{Coupon => Constraint}/Rule/Operators.php (69%) rename core/lib/Thelia/{Coupon => Constraint}/Validator/ComparableInterface.php (98%) rename core/lib/Thelia/{Coupon => Constraint}/Validator/DateParam.php (84%) rename core/lib/Thelia/{Coupon => Constraint}/Validator/IntegerParam.php (85%) rename core/lib/Thelia/{Coupon => Constraint}/Validator/IntervalParam.php (76%) create mode 100644 core/lib/Thelia/Constraint/Validator/ModelParam.php rename core/lib/Thelia/{Coupon => Constraint}/Validator/PriceParam.php (81%) rename core/lib/Thelia/{Coupon => Constraint}/Validator/QuantityParam.php (81%) rename core/lib/Thelia/{Coupon => Constraint}/Validator/RepeatedDateParam.php (87%) rename core/lib/Thelia/{Coupon => Constraint}/Validator/RepeatedIntervalParam.php (89%) rename core/lib/Thelia/{Coupon => Constraint}/Validator/RepeatedParam.php (89%) rename core/lib/Thelia/{Coupon => Constraint}/Validator/RuleParameterAbstract.php (85%) rename core/lib/Thelia/{Coupon => Constraint}/Validator/RuleValidator.php (97%) create mode 100644 core/lib/Thelia/Tests/Constraint/ConstraintManagerTest.php rename core/lib/Thelia/Tests/{Coupon => Constraint}/Rule/AvailableForTotalAmountTest.php (94%) rename core/lib/Thelia/Tests/{Coupon => Constraint}/Rule/AvailableForXArticlesTest.php (99%) rename core/lib/Thelia/Tests/{Coupon => Constraint}/Rule/OperatorsTest.php (92%) rename core/lib/Thelia/Tests/{Coupon/Parameter => Constraint/Validator}/DateParamTest.php (75%) rename core/lib/Thelia/Tests/{Coupon/Parameter => Constraint/Validator}/IntegerParamTest.php (75%) rename core/lib/Thelia/Tests/{Coupon/Parameter => Constraint/Validator}/IntervalParamTest.php (74%) rename core/lib/Thelia/Tests/{Coupon/Parameter => Constraint/Validator}/PriceParamTest.php (73%) rename core/lib/Thelia/Tests/{Coupon/Parameter => Constraint/Validator}/QuantityParamTest.php (75%) rename core/lib/Thelia/Tests/{Coupon/Parameter => Constraint/Validator}/RepeatedDateParamTest.php (78%) rename core/lib/Thelia/Tests/{Coupon/Parameter => Constraint/Validator}/RepeatedIntervalParamTest.php (80%) diff --git a/core/lib/Thelia/Constraint/ConstraintManager.php b/core/lib/Thelia/Constraint/ConstraintManager.php new file mode 100644 index 000000000..6cbcbb1be --- /dev/null +++ b/core/lib/Thelia/Constraint/ConstraintManager.php @@ -0,0 +1,82 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Constraint; + +use Thelia\Coupon\CouponAdapterInterface; +use Thelia\Coupon\CouponRuleCollection; + + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Manage how Constraint could interact + * + * @package Constraint + * @author Guillaume MOREL + * + */ +class ConstraintManager +{ + /** @var CouponAdapterInterface Provide necessary value from Thelia*/ + protected $adapter; + + /** @var array CouponRuleCollection to process*/ + protected $rules = null; + + /** + * Constructor + * + * @param CouponAdapterInterface $adapter Provide necessary value from Thelia + * @param CouponRuleCollection $rules Rules associated with the Constraint + */ + function __construct(CouponAdapterInterface $adapter, CouponRuleCollection $rules) + { + $this->adapter = $adapter; + $this->rule = $rules; + } + + /** + * Check if the current Coupon is matching its conditions (Rules) + * Thelia variables are given by the CouponAdapterInterface + * + * @return bool + */ + public function isMatching() + { + $isMatching = true; + + /** @var CouponRuleInterface $rule */ + foreach ($this->rules->getRules() as $rule) { + if (!$rule->isMatching($this->adapter)) { + $isMatching = false; + } + } + + return $isMatching; + } + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForDate.php b/core/lib/Thelia/Constraint/Rule/AvailableForDate.php similarity index 97% rename from core/lib/Thelia/Coupon/Rule/AvailableForDate.php rename to core/lib/Thelia/Constraint/Rule/AvailableForDate.php index 81cb54a91..1ddfd0350 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForDate.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForDate.php @@ -21,14 +21,14 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Rule; +namespace Thelia\Constraint\Rule; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php b/core/lib/Thelia/Constraint/Rule/AvailableForLocationX.php similarity index 97% rename from core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php rename to core/lib/Thelia/Constraint/Rule/AvailableForLocationX.php index 7f4d1bb33..5c3ec494c 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForLocationX.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForLocationX.php @@ -21,14 +21,14 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Rule; +namespace Thelia\Constraint\Rule; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php b/core/lib/Thelia/Constraint/Rule/AvailableForPeriod.php similarity index 97% rename from core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php rename to core/lib/Thelia/Constraint/Rule/AvailableForPeriod.php index 7097ca52c..30679a973 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForPeriod.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForPeriod.php @@ -21,14 +21,14 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Rule; +namespace Thelia\Constraint\Rule; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php b/core/lib/Thelia/Constraint/Rule/AvailableForRepeatedDate.php similarity index 97% rename from core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php rename to core/lib/Thelia/Constraint/Rule/AvailableForRepeatedDate.php index f4d4be7d3..3449a7f5b 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedDate.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForRepeatedDate.php @@ -21,14 +21,14 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Rule; +namespace Thelia\Constraint\Rule; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php b/core/lib/Thelia/Constraint/Rule/AvailableForRepeatedPeriod.php similarity index 98% rename from core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php rename to core/lib/Thelia/Constraint/Rule/AvailableForRepeatedPeriod.php index 4f67889c2..f5bf9bafc 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForRepeatedPeriod.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForRepeatedPeriod.php @@ -21,7 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Rule; +namespace Thelia\Constraint\Rule; use Thelia\Coupon\CouponAdapterInterface; @@ -30,7 +30,7 @@ use Thelia\Coupon\CouponAdapterInterface; * Date: 8/19/13 * Time: 3:24 PM * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmount.php similarity index 84% rename from core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php rename to core/lib/Thelia/Constraint/Rule/AvailableForTotalAmount.php index aa1e40339..704df073e 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmount.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmount.php @@ -21,12 +21,12 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Rule; +namespace Thelia\Constraint\Rule; use Symfony\Component\Intl\Exception\NotImplementedException; use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Coupon\Validator\PriceParam; -use Thelia\Coupon\Validator\RuleValidator; +use Thelia\Constraint\Validator\PriceParam; +use Thelia\Constraint\Validator\RuleValidator; use Thelia\Exception\InvalidRuleException; use Thelia\Exception\InvalidRuleOperatorException; use Thelia\Exception\InvalidRuleValueException; @@ -39,7 +39,7 @@ use Thelia\Exception\InvalidRuleValueException; * Rule AvailableForTotalAmount * Check if a Checkout total amount match criteria * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -182,5 +182,42 @@ class AvailableForTotalAmount extends CouponRuleAbstract return $this->validators; } + /** + * Get I18n name + * + * @return string + */ + public function getName() + { + return $this->adapter + ->getTranslator() + ->trans('Cart total amount', null, 'constraint'); + } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + $i18nOperator = Operators::getI18n( + $this->adapter, $this->priceValidator->getOperator() + ); + + $toolTip = $this->adapter + ->getTranslator() + ->trans( + 'If cart total amount is %operator% %amount% %currency%', + array( + '%operator%' => $i18nOperator, + '%amount%' => $this->priceValidator->getParam()->getPrice(), + '%currency%' => $this->priceValidator->getParam()->getCurrency() + ), + 'constraint' + ); + + return $toolTip; + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountForCategoryY.php similarity index 97% rename from core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php rename to core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountForCategoryY.php index 6493da92a..0f9f7f10b 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForTotalAmountForCategoryY.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountForCategoryY.php @@ -21,14 +21,14 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Rule; +namespace Thelia\Constraint\Rule; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ diff --git a/core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php b/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php similarity index 97% rename from core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php rename to core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php index 7a898205c..b38a53ce4 100644 --- a/core/lib/Thelia/Coupon/Rule/AvailableForXArticles.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php @@ -21,7 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Rule; +namespace Thelia\Constraint\Rule; /** * Created by JetBrains PhpStorm. @@ -30,7 +30,7 @@ namespace Thelia\Coupon\Rule; * * Check a Checkout against its Product number * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ diff --git a/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php b/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php similarity index 97% rename from core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php rename to core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php index 7d0b741bb..9fbcc21fc 100644 --- a/core/lib/Thelia/Coupon/Rule/CouponRuleAbstract.php +++ b/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php @@ -21,12 +21,12 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Rule; +namespace Thelia\Constraint\Rule; use Symfony\Component\Intl\Exception\NotImplementedException; use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Coupon\Validator\ComparableInterface; -use Thelia\Coupon\Validator\RuleValidator; +use Thelia\Constraint\Validator\ComparableInterface; +use Thelia\Constraint\Validator\RuleValidator; use Thelia\Exception\InvalidRuleException; use Thelia\Exception\InvalidRuleOperatorException; @@ -37,7 +37,7 @@ use Thelia\Exception\InvalidRuleOperatorException; * * Assist in writing a condition of whether the Rule is applied or not * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ diff --git a/core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php b/core/lib/Thelia/Constraint/Rule/CouponRuleInterface.php similarity index 91% rename from core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php rename to core/lib/Thelia/Constraint/Rule/CouponRuleInterface.php index 6aaca802c..9e75c7fe1 100644 --- a/core/lib/Thelia/Coupon/Rule/CouponRuleInterface.php +++ b/core/lib/Thelia/Constraint/Rule/CouponRuleInterface.php @@ -21,7 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Rule; +namespace Thelia\Constraint\Rule; use Thelia\Coupon\CouponAdapterInterface; @@ -32,7 +32,7 @@ use Thelia\Coupon\CouponAdapterInterface; * * Represents a condition of whether the Rule is applied or not * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -69,4 +69,19 @@ interface CouponRuleInterface */ public function getAvailableOperators(); + + /** + * Get I18n name + * + * @return string + */ + public function getName(); + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip(); + } diff --git a/core/lib/Thelia/Coupon/Rule/Operators.php b/core/lib/Thelia/Constraint/Rule/Operators.php similarity index 69% rename from core/lib/Thelia/Coupon/Rule/Operators.php rename to core/lib/Thelia/Constraint/Rule/Operators.php index fb188c3cd..41ed7428c 100644 --- a/core/lib/Thelia/Coupon/Rule/Operators.php +++ b/core/lib/Thelia/Constraint/Rule/Operators.php @@ -21,9 +21,9 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Rule; +namespace Thelia\Constraint\Rule; -use Thelia\Coupon\Validator\ComparableInterface; +use Thelia\Constraint\Validator\ComparableInterface; /** * Created by JetBrains PhpStorm. @@ -32,7 +32,7 @@ use Thelia\Coupon\Validator\ComparableInterface; * * Represent available Operations in rule checking * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -106,4 +106,66 @@ abstract class Operators return $ret; } + + /** + * Get operator translation + * + * @param CouponAdapterInterface $adapter Provide necessary value from Thelia + * @param string $operator Operator const + * + * @return string + */ + public static function getI18n(CouponAdapterInterface $adapter, $operator) + { + $translator = $adapter->getTranslator(); + + $ret = $operator; + switch ($operator) { + case self::INFERIOR: + $ret = $translator->trans( + 'inferior to', + null, + 'constraint' + ); + break; + case self::INFERIOR_OR_EQUAL: + $ret = $translator->trans( + 'inferior or equals to', + null, + 'constraint' + ); + break; + case self::EQUAL: + $ret = $translator->trans( + 'equals to', + null, + 'constraint' + ); + break; + case self::SUPERIOR_OR_EQUAL: + $ret = $translator->trans( + 'superior or equals to', + null, + 'constraint' + ); + break; + case self::SUPERIOR: + $ret = $translator->trans( + 'superior to', + null, + 'constraint' + ); + break; + case self::DIFFERENT: + $ret = $translator->trans( + 'different from', + null, + 'constraint' + ); + break; + default: + } + + return $ret; + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Validator/ComparableInterface.php b/core/lib/Thelia/Constraint/Validator/ComparableInterface.php similarity index 98% rename from core/lib/Thelia/Coupon/Validator/ComparableInterface.php rename to core/lib/Thelia/Constraint/Validator/ComparableInterface.php index 3b70c5e37..d06187fb0 100644 --- a/core/lib/Thelia/Coupon/Validator/ComparableInterface.php +++ b/core/lib/Thelia/Constraint/Validator/ComparableInterface.php @@ -21,7 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Validator; +namespace Thelia\Constraint\Validator; /** * Comparable interface diff --git a/core/lib/Thelia/Coupon/Validator/DateParam.php b/core/lib/Thelia/Constraint/Validator/DateParam.php similarity index 84% rename from core/lib/Thelia/Coupon/Validator/DateParam.php rename to core/lib/Thelia/Constraint/Validator/DateParam.php index 062c750e5..ae7eff858 100644 --- a/core/lib/Thelia/Coupon/Validator/DateParam.php +++ b/core/lib/Thelia/Constraint/Validator/DateParam.php @@ -21,7 +21,9 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Validator; +namespace Thelia\Constraint\Validator; + +use Thelia\Coupon\CouponAdapterInterface; /** * Created by JetBrains PhpStorm. @@ -30,7 +32,7 @@ namespace Thelia\Coupon\Validator; * * Represent a DateTime * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -42,11 +44,13 @@ class DateParam extends RuleParameterAbstract /** * Constructor * - * @param \DateTime $dateTime DateTime + * @param CouponAdapterInterface $adapter Provide necessary value from Thelia + * @param \DateTime $dateTime DateTime */ - public function __construct(\DateTime $dateTime) + public function __construct(CouponAdapterInterface $adapter, \DateTime $dateTime) { $this->dateTime = $dateTime; + $this->adapter = $adapter; } /** @@ -101,5 +105,16 @@ class DateParam extends RuleParameterAbstract return clone $this->dateTime; } + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + return $this->adapter + ->getTranslator() + ->trans('A date (ex: YYYY-MM-DD HH:MM:SS)', null, 'constraint'); + } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Coupon/Validator/IntegerParam.php b/core/lib/Thelia/Constraint/Validator/IntegerParam.php similarity index 85% rename from core/lib/Thelia/Coupon/Validator/IntegerParam.php rename to core/lib/Thelia/Constraint/Validator/IntegerParam.php index 7c8303809..c783655c8 100644 --- a/core/lib/Thelia/Coupon/Validator/IntegerParam.php +++ b/core/lib/Thelia/Constraint/Validator/IntegerParam.php @@ -21,7 +21,9 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Validator; +namespace Thelia\Constraint\Validator; + +use Thelia\Coupon\CouponAdapterInterface; /** * Created by JetBrains PhpStorm. @@ -30,7 +32,7 @@ namespace Thelia\Coupon\Validator; * * Represent an Integer * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -42,11 +44,13 @@ class IntegerParam extends RuleParameterAbstract /** * Constructor * - * @param int $integer Integer + * @param CouponAdapterInterface $adapter Provide necessary value from Thelia + * @param int $integer Integer */ - public function __construct($integer) + public function __construct(CouponAdapterInterface $adapter, $integer) { $this->integer = $integer; + $this->adapter = $adapter; } /** @@ -102,4 +106,16 @@ class IntegerParam extends RuleParameterAbstract return $this->integer; } + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + return $this->adapter + ->getTranslator() + ->trans('A number (ex: 42)', null, 'constraint'); + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Validator/IntervalParam.php b/core/lib/Thelia/Constraint/Validator/IntervalParam.php similarity index 76% rename from core/lib/Thelia/Coupon/Validator/IntervalParam.php rename to core/lib/Thelia/Constraint/Validator/IntervalParam.php index 1b310c9d1..a4554760a 100644 --- a/core/lib/Thelia/Coupon/Validator/IntervalParam.php +++ b/core/lib/Thelia/Constraint/Validator/IntervalParam.php @@ -21,7 +21,9 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Validator; +namespace Thelia\Constraint\Validator; + +use Thelia\Coupon\CouponAdapterInterface; /** * Created by JetBrains PhpStorm. @@ -30,7 +32,7 @@ namespace Thelia\Coupon\Validator; * * Represent an DateTime period * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -39,17 +41,50 @@ class IntervalParam extends RuleParameterAbstract /** @var \DatePeriod Date period */ protected $datePeriod = null; + /** @var \DateTime Start date */ + protected $start = null; + + /** @var \DateInterval Interval date */ + protected $interval = null; + /** * Constructor * - * @param \DateTime $start Start interval - * @param \DateInterval $interval Period + * @param CouponAdapterInterface $adapter Provide necessary value from Thelia + * @param \DateTime $start Start interval + * @param \DateInterval $interval Period */ - public function __construct(\DateTime $start, \DateInterval $interval) + public function __construct(CouponAdapterInterface $adapter, \DateTime $start, \DateInterval $interval) { $this->datePeriod = new \DatePeriod($start, $interval, 1); + $this->adapter = $adapter; + + $this->start = $start; + $this->interval = $interval; } + /** + * Get Interval + * + * @return \DateInterval + */ + public function getInterval() + { + return $this->interval; + } + + /** + * Get start date + * + * @return \DateTime + */ + public function getStart() + { + return $this->start; + } + + + /** * Get DatePeriod * @@ -115,4 +150,16 @@ class IntervalParam extends RuleParameterAbstract { return clone $this->datePeriod; } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + return $this->adapter + ->getTranslator() + ->trans('An interval between two dates', null, 'constraint'); + } } \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Validator/ModelParam.php b/core/lib/Thelia/Constraint/Validator/ModelParam.php new file mode 100644 index 000000000..7ff4567b8 --- /dev/null +++ b/core/lib/Thelia/Constraint/Validator/ModelParam.php @@ -0,0 +1,115 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Constraint\Validator; + +use InvalidArgumentException; +use Thelia\Coupon\CouponAdapterInterface; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Represent a Model + * + * @package Constraint + * @author Guillaume MOREL + * + */ +class ModelParam extends IntegerParam +{ + /** @var string Model Class name */ + protected $modelClass = null; + + /** @var ModelCriteria */ + protected $queryBuilder = null; + + /** + * Constructor + * + * @param CouponAdapterInterface $adapter Provide necessary value from Thelia + * @param int $integer Integer + * @param string $modelClass Model class name + * + * @throws InvalidArgumentException + */ + public function __construct(CouponAdapterInterface $adapter, $integer, $modelClass) + { + if ($integer < 0) { + $integer = 0; + } + $this->integer = $integer; + $this->adapter = $adapter; + + $this->modelClass = $modelClass; + $queryClassName = $modelClass . 'Query'; + try { + $this->queryBuilder = $queryClassName::create(); + } catch (\Exception $e) { + throw new InvalidArgumentException('ModelParam can only compare Models'); + } + } + + /** + * Compare the current object to the passed $other. + * + * Returns 0 if they are semantically equal, 1 if the other object + * is less than the current one, or -1 if its more than the current one. + * + * This method should not check for identity using ===, only for semantically equality for example + * when two different DateTime instances point to the exact same Date + TZ. + * + * @param mixed $other Object + * + * @throws InvalidArgumentException + * @return int + */ + public function compareTo($other) + { + if (!is_integer($other) || $other < 0) { + throw new InvalidArgumentException( + 'IntegerParam can compare only positive int' + ); + } + + return parent::compareTo($other); + } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + return $this->adapter + ->getTranslator() + ->trans( + 'A Model', + null, + 'constraint' + ); + } + +} diff --git a/core/lib/Thelia/Coupon/Validator/PriceParam.php b/core/lib/Thelia/Constraint/Validator/PriceParam.php similarity index 81% rename from core/lib/Thelia/Coupon/Validator/PriceParam.php rename to core/lib/Thelia/Constraint/Validator/PriceParam.php index 44eae3234..90538a73e 100644 --- a/core/lib/Thelia/Coupon/Validator/PriceParam.php +++ b/core/lib/Thelia/Constraint/Validator/PriceParam.php @@ -21,7 +21,9 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Validator; +namespace Thelia\Constraint\Validator; + +use Thelia\Coupon\CouponAdapterInterface; /** * Created by JetBrains PhpStorm. @@ -31,7 +33,7 @@ namespace Thelia\Coupon\Validator; * Represent a Price * Positive value with currency * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -46,13 +48,15 @@ class PriceParam extends RuleParameterAbstract /** * Constructor * - * @param float $price Positive float - * @param string $currency Currency Code ISO 4217 EUR|USD|GBP + * @param CouponAdapterInterface $adapter Provide necessary value from Thelia + * @param float $price Positive float + * @param string $currency Currency Code ISO 4217 EUR|USD|GBP */ - public function __construct($price, $currency) + public function __construct(CouponAdapterInterface $adapter, $price, $currency) { $this->price = $price; $this->currency = $currency; + $this->adapter = $adapter; } /** @@ -120,4 +124,22 @@ class PriceParam extends RuleParameterAbstract { return $this->price; } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + return $this->adapter + ->getTranslator() + ->trans( + 'A price in %currency% (ex: 14.50)', + array( + '%currency%' => $this->currency + ), + 'constraint' + ); + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Validator/QuantityParam.php b/core/lib/Thelia/Constraint/Validator/QuantityParam.php similarity index 81% rename from core/lib/Thelia/Coupon/Validator/QuantityParam.php rename to core/lib/Thelia/Constraint/Validator/QuantityParam.php index dc842605f..5d5132e5b 100644 --- a/core/lib/Thelia/Coupon/Validator/QuantityParam.php +++ b/core/lib/Thelia/Constraint/Validator/QuantityParam.php @@ -21,7 +21,9 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Validator; +namespace Thelia\Constraint\Validator; + +use Thelia\Coupon\CouponAdapterInterface; /** * Created by JetBrains PhpStorm. @@ -30,7 +32,7 @@ namespace Thelia\Coupon\Validator; * * Represent a Quantity * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -40,14 +42,16 @@ class QuantityParam extends IntegerParam /** * Constructor * - * @param int $integer Integer + * @param CouponAdapterInterface $adapter Provide necessary value from Thelia + * @param int $integer Integer */ - public function __construct($integer) + public function __construct(CouponAdapterInterface $adapter, $integer) { if ($integer < 0) { $integer = 0; } $this->integer = $integer; + $this->adapter = $adapter; } /** @@ -75,4 +79,21 @@ class QuantityParam extends IntegerParam return parent::compareTo($other); } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + return $this->adapter + ->getTranslator() + ->trans( + 'A positive quantity (ex: 42)', + null, + 'constraint' + ); + } + } diff --git a/core/lib/Thelia/Coupon/Validator/RepeatedDateParam.php b/core/lib/Thelia/Constraint/Validator/RepeatedDateParam.php similarity index 87% rename from core/lib/Thelia/Coupon/Validator/RepeatedDateParam.php rename to core/lib/Thelia/Constraint/Validator/RepeatedDateParam.php index f0524edc7..0e8a558cf 100644 --- a/core/lib/Thelia/Coupon/Validator/RepeatedDateParam.php +++ b/core/lib/Thelia/Constraint/Validator/RepeatedDateParam.php @@ -21,7 +21,9 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Validator; +namespace Thelia\Constraint\Validator; + +use Thelia\Coupon\CouponAdapterInterface; /** * Created by JetBrains PhpStorm. @@ -38,7 +40,7 @@ namespace Thelia\Coupon\Validator; * x5 : $this->recurrences How many repeated cycle, 1st excluded * x6 : How many occurrence * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -46,10 +48,13 @@ class RepeatedDateParam extends RepeatedParam { /** * Constructor + * + * @param CouponAdapterInterface $adapter Provide necessary value from Thelia */ - public function __construct() + public function __construct(CouponAdapterInterface $adapter) { $this->defaultConstructor(); + $this->adapter = $adapter; } /** @@ -97,4 +102,16 @@ class RepeatedDateParam extends RepeatedParam { return clone $this->datePeriod; } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + return $this->adapter + ->getTranslator() + ->trans('A date (ex: YYYY-MM-DD HH:MM:SS)', null, 'constraint'); + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Validator/RepeatedIntervalParam.php b/core/lib/Thelia/Constraint/Validator/RepeatedIntervalParam.php similarity index 89% rename from core/lib/Thelia/Coupon/Validator/RepeatedIntervalParam.php rename to core/lib/Thelia/Constraint/Validator/RepeatedIntervalParam.php index 9f61f4db1..e37cd3b45 100644 --- a/core/lib/Thelia/Coupon/Validator/RepeatedIntervalParam.php +++ b/core/lib/Thelia/Constraint/Validator/RepeatedIntervalParam.php @@ -21,7 +21,9 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Validator; +namespace Thelia\Constraint\Validator; + +use Thelia\Coupon\CouponAdapterInterface; /** * Created by JetBrains PhpStorm. @@ -39,7 +41,7 @@ namespace Thelia\Coupon\Validator; * x6 : How many occurrence * **** : $this->durationInDays Duration of a period * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -75,10 +77,13 @@ class RepeatedIntervalParam extends RepeatedParam /** * Constructor + * + * @param CouponAdapterInterface $adapter Provide necessary value from Thelia */ - public function __construct() + public function __construct(CouponAdapterInterface $adapter) { $this->defaultConstructor(); + $this->adapter = $adapter; } /** @@ -131,4 +136,16 @@ class RepeatedIntervalParam extends RepeatedParam { return clone $this->datePeriod; } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + return $this->adapter + ->getTranslator() + ->trans('A date (ex: YYYY-MM-DD HH:MM:SS)', null, 'constraint'); + } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Validator/RepeatedParam.php b/core/lib/Thelia/Constraint/Validator/RepeatedParam.php similarity index 89% rename from core/lib/Thelia/Coupon/Validator/RepeatedParam.php rename to core/lib/Thelia/Constraint/Validator/RepeatedParam.php index 675228456..1188e4fbb 100644 --- a/core/lib/Thelia/Coupon/Validator/RepeatedParam.php +++ b/core/lib/Thelia/Constraint/Validator/RepeatedParam.php @@ -21,7 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Validator; +namespace Thelia\Constraint\Validator; use DateInterval; use DatePeriod; @@ -34,7 +34,7 @@ use DateTime; * * Allow to set the way a parameter can be repeated across the time * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -52,6 +52,52 @@ abstract class RepeatedParam extends RuleParameterAbstract /** @var DatePeriod dates recurring at regular intervals, over a given period */ protected $datePeriod = null; + /** @var int Frequency the object will be repeated */ + protected $frequency = null; + + /** @var int $nbRepetition Time the object will be repeated */ + protected $nbRepetition = null; + + /** + * Get frequency + * + * @return int + */ + public function getFrequency() + { + return $this->frequency; + } + + /** + * Get Interval + * + * @return \DateInterval + */ + public function getInterval() + { + return $this->interval; + } + + /** + * Get number of time it will be repeated + * + * @return int + */ + public function getNbRepetition() + { + return $this->nbRepetition; + } + + /** + * Get number of recurrences + * + * @return int + */ + public function getRecurrences() + { + return $this->recurrences; + } + /** * Generate default repetition * Every 1 week 100 times from now diff --git a/core/lib/Thelia/Coupon/Validator/RuleParameterAbstract.php b/core/lib/Thelia/Constraint/Validator/RuleParameterAbstract.php similarity index 85% rename from core/lib/Thelia/Coupon/Validator/RuleParameterAbstract.php rename to core/lib/Thelia/Constraint/Validator/RuleParameterAbstract.php index 3e96682cd..d8326d66f 100644 --- a/core/lib/Thelia/Coupon/Validator/RuleParameterAbstract.php +++ b/core/lib/Thelia/Constraint/Validator/RuleParameterAbstract.php @@ -21,8 +21,9 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Validator; +namespace Thelia\Constraint\Validator; +use Thelia\Coupon\CouponAdapterInterface; use Thelia\Exception\NotImplementedException; /** @@ -32,12 +33,15 @@ use Thelia\Exception\NotImplementedException; * * Get a Param value * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ abstract class RuleParameterAbstract implements ComparableInterface { + /** @var CouponAdapterInterface Provide necessary value from Thelia*/ + protected $adapter; + /** * Get Parameter value to test against * @@ -47,4 +51,16 @@ abstract class RuleParameterAbstract implements ComparableInterface { return new NotImplementedException(); } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + return new NotImplementedException(); + } + + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Validator/RuleValidator.php b/core/lib/Thelia/Constraint/Validator/RuleValidator.php similarity index 97% rename from core/lib/Thelia/Coupon/Validator/RuleValidator.php rename to core/lib/Thelia/Constraint/Validator/RuleValidator.php index 064677751..9b0093bc9 100644 --- a/core/lib/Thelia/Coupon/Validator/RuleValidator.php +++ b/core/lib/Thelia/Constraint/Validator/RuleValidator.php @@ -21,7 +21,7 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon\Validator; +namespace Thelia\Constraint\Validator; /** * Created by JetBrains PhpStorm. @@ -30,7 +30,7 @@ namespace Thelia\Coupon\Validator; * * Allow to validate parameters * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ diff --git a/core/lib/Thelia/Coupon/CouponAdapterInterface.php b/core/lib/Thelia/Coupon/CouponAdapterInterface.php index 21ff870f6..4325da3ae 100644 --- a/core/lib/Thelia/Coupon/CouponAdapterInterface.php +++ b/core/lib/Thelia/Coupon/CouponAdapterInterface.php @@ -131,4 +131,12 @@ interface CouponAdapterInterface */ public function getTranslator(); + /** + * Return the main currency + * THe one used to set prices in BackOffice + * + * @return string + */ + public function getMainCurrency(); + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponBaseAdapter.php b/core/lib/Thelia/Coupon/CouponBaseAdapter.php index 3809612a7..70c9ebf94 100644 --- a/core/lib/Thelia/Coupon/CouponBaseAdapter.php +++ b/core/lib/Thelia/Coupon/CouponBaseAdapter.php @@ -179,7 +179,7 @@ class CouponBaseAdapter implements CouponAdapterInterface */ public function getContainer() { - // TODO: Implement getCheckoutPostagePrice() method. + // TODO: Implement getContainer() method. } /** @@ -191,4 +191,16 @@ class CouponBaseAdapter implements CouponAdapterInterface { return $this->getContainer()->get('thelia.translator'); } + + + /** + * Return the main currency + * THe one used to set prices in BackOffice + * + * @return string + */ + public function getMainCurrency() + { + // TODO: Implement getMainCurrency() method. + } } diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index b913de66d..272cb7ed7 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -38,7 +38,7 @@ use Thelia\Coupon\Type\CouponInterface; */ class CouponManager { - /** @var CouponAdapterInterface Provide necessary value from Thelia*/ + /** @var CouponAdapterInterface Provides necessary value from Thelia */ protected $adapter; /** @var array CouponInterface to process*/ diff --git a/core/lib/Thelia/Coupon/CouponRuleCollection.php b/core/lib/Thelia/Coupon/CouponRuleCollection.php index 06f0b15af..2f1a51dc0 100644 --- a/core/lib/Thelia/Coupon/CouponRuleCollection.php +++ b/core/lib/Thelia/Coupon/CouponRuleCollection.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use Symfony\Component\Serializer\Encoder\JsonEncoder; -use Thelia\Coupon\Rule\CouponRuleInterface; +use Thelia\Constraint\Rule\CouponRuleInterface; use Thelia\Exception\InvalidRuleException; /** diff --git a/core/lib/Thelia/Coupon/Type/CouponAbstract.php b/core/lib/Thelia/Coupon/Type/CouponAbstract.php index 750c62e5c..a5e82c83e 100644 --- a/core/lib/Thelia/Coupon/Type/CouponAbstract.php +++ b/core/lib/Thelia/Coupon/Type/CouponAbstract.php @@ -24,8 +24,8 @@ namespace Thelia\Coupon\Type; use Symfony\Component\Intl\Exception\NotImplementedException; +use Thelia\Constraint\ConstraintManager; use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Coupon\Rule\CouponRuleInterface; use Thelia\Coupon\CouponRuleCollection; use Thelia\Coupon\RuleOrganizerInterface; use Thelia\Exception\InvalidRuleException; @@ -43,12 +43,18 @@ use Thelia\Exception\InvalidRuleException; */ abstract class CouponAbstract implements CouponInterface { + /** @var CouponAdapterInterface Provides necessary value from Thelia */ + protected $adapter = null; + /** @var RuleOrganizerInterface */ protected $organizer = null; /** @var CouponRuleCollection Array of CouponRuleInterface */ protected $rules = null; + /** @var ConstraintManager CouponRuleInterface Manager*/ + protected $constraintManager = null; + /** @var string Coupon code (ex: XMAS) */ protected $code = null; @@ -194,6 +200,10 @@ abstract class CouponAbstract implements CouponInterface public function setRules(CouponRuleCollection $rules) { $this->rules = $rules; + $this->constraintManager = new ConstraintManager( + $this->adapter, + $this->rules + ); return $this; } @@ -209,16 +219,7 @@ abstract class CouponAbstract implements CouponInterface */ public function isMatching(CouponAdapterInterface $adapter) { - $isMatching = true; - - /** @var CouponRuleInterface $rule */ - foreach ($this->rules->getRules() as $rule) { - if (!$rule->isMatching($adapter)) { - $isMatching = false; - } - } - - return $isMatching; + return $this->constraintManager->isMatching(); } /** diff --git a/core/lib/Thelia/Coupon/Type/CouponInterface.php b/core/lib/Thelia/Coupon/Type/CouponInterface.php index df1a82f40..334520104 100644 --- a/core/lib/Thelia/Coupon/Type/CouponInterface.php +++ b/core/lib/Thelia/Coupon/Type/CouponInterface.php @@ -165,4 +165,18 @@ interface CouponInterface * @return bool */ public function isExpired(); + + /** + * Get I18n name + * + * @return string + */ + public function getName(); + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip(); } diff --git a/core/lib/Thelia/Coupon/Type/RemoveXAmount.php b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php index a0d715141..672c8a856 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXAmount.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php @@ -23,6 +23,7 @@ namespace Thelia\Coupon\Type; +use Thelia\Constraint\ConstraintManager; use Thelia\Coupon\Type\CouponAbstract; /** @@ -41,20 +42,34 @@ class RemoveXAmount extends CouponAbstract /** * Constructor * - * @param string $code Coupon code (ex: XMAS) - * @param string $title Coupon title (ex: Coupon for XMAS) - * @param string $shortDescription Coupon short description - * @param string $description Coupon description - * @param float $amount Coupon amount to deduce - * @param bool $isCumulative If Coupon is cumulative - * @param bool $isRemovingPostage If Coupon is removing postage - * @param bool $isAvailableOnSpecialOffers If available on Product already - * on special offer price - * @param bool $isEnabled False if Coupon is disabled by admin - * @param int $maxUsage How many usage left - * @param \Datetime $expirationDate When the Code is expiring + * @param CouponInterface $adapter Provides necessary value from Thelia + * @param string $code Coupon code (ex: XMAS) + * @param string $title Coupon title (ex: Coupon for XMAS) + * @param string $shortDescription Coupon short description + * @param string $description Coupon description + * @param float $amount Coupon amount to deduce + * @param bool $isCumulative If Coupon is cumulative + * @param bool $isRemovingPostage If Coupon is removing postage + * @param bool $isAvailableOnSpecialOffers If available on Product already + * on special offer price + * @param bool $isEnabled False if Coupon is disabled by admin + * @param int $maxUsage How many usage left + * @param \Datetime $expirationDate When the Code is expiring */ - function __construct($code, $title, $shortDescription, $description, $amount, $isCumulative, $isRemovingPostage, $isAvailableOnSpecialOffers, $isEnabled, $maxUsage, \DateTime $expirationDate) + function __construct( + $adapter, + $code, + $title, + $shortDescription, + $description, + $amount, + $isCumulative, + $isRemovingPostage, + $isAvailableOnSpecialOffers, + $isEnabled, + $maxUsage, + \DateTime $expirationDate + ) { $this->code = $code; $this->title = $title; @@ -70,6 +85,36 @@ class RemoveXAmount extends CouponAbstract $this->isEnabled = $isEnabled; $this->maxUsage = $maxUsage; $this->expirationDate = $expirationDate; + $this->adapter = $adapter; } + /** + * Get I18n name + * + * @return string + */ + public function getName() + { + return $this->adapter + ->getTranslator() + ->trans('Remove X amount to total cart', null, 'constraint'); + } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + $toolTip = $this->adapter + ->getTranslator() + ->trans( + 'This coupon will remove the entered amount to the customer total checkout. If the discount is superior to the total checkout price the customer will only pay the postage. Unless if the coupon is set to remove postage too.', + null, + 'constraint' + ); + + return $toolTip; + } } diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php index da63a4281..5d1d14b63 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php @@ -43,15 +43,33 @@ class RemoveXPercent extends CouponAbstract /** * Constructor * - * @param string $code Coupon code (ex: XMAS) - * @param string $title Coupon title (ex: Coupon for XMAS) - * @param string $shortDescription Coupon short description - * @param string $description Coupon description - * @param float $percent Coupon % to deduce (ex:3.14 for 3.14%) - * @param bool $isCumulative if Coupon is cumulative - * @param bool $isRemovingPostage if Coupon is removing postage + * @param CouponInterface $adapter Provides necessary value from Thelia + * @param string $code Coupon code (ex: XMAS) + * @param string $title Coupon title (ex: Coupon for XMAS) + * @param string $shortDescription Coupon short description + * @param string $description Coupon description + * @param float $percent Coupon percentage to deduce + * @param bool $isCumulative If Coupon is cumulative + * @param bool $isRemovingPostage If Coupon is removing postage + * @param bool $isAvailableOnSpecialOffers If available on Product already + * on special offer price + * @param bool $isEnabled False if Coupon is disabled by admin + * @param int $maxUsage How many usage left + * @param \Datetime $expirationDate When the Code is expiring */ - function __construct($code, $title, $shortDescription, $description, $percent, $isCumulative, $isRemovingPostage) + function __construct( + $adapter, + $code, + $title, + $shortDescription, + $description, + $percent, + $isCumulative, + $isRemovingPostage, + $isAvailableOnSpecialOffers, + $isEnabled, + $maxUsage, + \DateTime $expirationDate) { $this->code = $code; $this->title = $title; @@ -62,6 +80,12 @@ class RemoveXPercent extends CouponAbstract $this->isRemovingPostage = $isRemovingPostage; $this->percent = $percent; + + $this->isAvailableOnSpecialOffers = $isAvailableOnSpecialOffers; + $this->isEnabled = $isEnabled; + $this->maxUsage = $maxUsage; + $this->expirationDate = $expirationDate; + $this->adapter = $adapter; } /** @@ -83,10 +107,40 @@ class RemoveXPercent extends CouponAbstract ); } - $basePrice =$adapter - ->getCartTotalPrice(); + $basePrice = $adapter->getCartTotalPrice(); - return $basePrice * (( 100 - $this->percent ) / 100); + return $basePrice * (( $this->percent ) / 100); + } + + + /** + * Get I18n name + * + * @return string + */ + public function getName() + { + return $this->adapter + ->getTranslator() + ->trans('Remove X percent to total cart', null, 'constraint'); + } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + $toolTip = $this->adapter + ->getTranslator() + ->trans( + 'This coupon will remove the entered percentage to the customer total checkout. If the discount is superior to the total checkout price the customer will only pay the postage. Unless if the coupon is set to remove postage too.', + null, + 'constraint' + ); + + return $toolTip; } } \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Constraint/ConstraintManagerTest.php b/core/lib/Thelia/Tests/Constraint/ConstraintManagerTest.php new file mode 100644 index 000000000..770746ba1 --- /dev/null +++ b/core/lib/Thelia/Tests/Constraint/ConstraintManagerTest.php @@ -0,0 +1,142 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Constraint; + +use Thelia\Constraint\Validator\PriceParam; +use Thelia\Constraint\Validator\RuleValidator; +use Thelia\Constraint\Rule\AvailableForTotalAmount; +use Thelia\Constraint\Rule\Operators; +use Thelia\Coupon\CouponRuleCollection; +use Thelia\Coupon\Type\CouponInterface; +use Thelia\Coupon\Type\RemoveXAmount; +use Thelia\Tools\PhpUnitUtils; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Unit Test ConstraintManager Class + * + * @package Constraint + * @author Guillaume MOREL + * + */ +class ConstraintManagerTest extends \PHPUnit_Framework_TestCase +{ + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + } + + + + /** + * Generate valid CouponRuleInterfaces + * + * @return array Array of CouponRuleInterface + */ + public static function generateValidRules() + { + $rule1 = new AvailableForTotalAmount( + array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::SUPERIOR, + new PriceParam( + , 40.00, 'EUR' + ) + ) + ) + ); + $rule2 = new AvailableForTotalAmount( + array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + Operators::INFERIOR, + new PriceParam( + , 400.00, 'EUR' + ) + ) + ) + ); + $rules = new CouponRuleCollection(array($rule1, $rule2)); + + return $rules; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * Generate a fake Adapter + * + * @param array $coupons Coupons + * @param float $cartTotalPrice Cart total price + * @param float $checkoutTotalPrice Checkout total price + * @param float $postagePrice Checkout postage price + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ + public function generateFakeAdapter(array $coupons, $cartTotalPrice, $checkoutTotalPrice, $postagePrice = 6.00) + { + $stubCouponBaseAdapter = $this->getMock( + 'Thelia\Coupon\CouponBaseAdapter', + array( + 'getCurrentCoupons', + 'getCartTotalPrice', + 'getCheckoutTotalPrice', + 'getCheckoutPostagePrice' + ), + array() + ); + + $stubCouponBaseAdapter->expects($this->any()) + ->method('getCurrentCoupons') + ->will($this->returnValue(($coupons))); + + // Return Cart product amount = $cartTotalPrice euros + $stubCouponBaseAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue($cartTotalPrice)); + + // Return Checkout amount = $checkoutTotalPrice euros + $stubCouponBaseAdapter->expects($this->any()) + ->method('getCheckoutTotalPrice') + ->will($this->returnValue($checkoutTotalPrice)); + + $stubCouponBaseAdapter->expects($this->any()) + ->method('getCheckoutPostagePrice') + ->will($this->returnValue($postagePrice)); + + return $stubCouponBaseAdapter; + } +} diff --git a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php similarity index 94% rename from core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php rename to core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php index 63d78615f..05e507863 100644 --- a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForTotalAmountTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php @@ -23,10 +23,10 @@ namespace Thelia\Coupon; -use Thelia\Coupon\Validator\PriceParam; -use Thelia\Coupon\Validator\RuleValidator; -use Thelia\Coupon\Rule\AvailableForTotalAmount; -use Thelia\Coupon\Rule\Operators; +use Thelia\Constraint\Validator\PriceParam; +use Thelia\Constraint\Validator\RuleValidator; +use Thelia\Constraint\Rule\AvailableForTotalAmount; +use Thelia\Constraint\Rule\Operators; use Thelia\Exception\InvalidRuleOperatorException; use Thelia\Exception\InvalidRuleValueException; @@ -37,7 +37,7 @@ use Thelia\Exception\InvalidRuleValueException; * * Unit Test AvailableForTotalAmount Class * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -86,8 +86,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - 421.23, - 'EUR' + , 421.23, 'EUR' ) ) ); @@ -116,8 +115,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( 'X', new PriceParam( - 421.23, - 'EUR' + , 421.23, 'EUR' ) ) ); @@ -176,8 +174,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - 421.23, - 'EUR' + , 421.23, 'EUR' ) ) ); @@ -204,8 +201,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - 421.23, - 'EUR' + , 421.23, 'EUR' ) ) ); @@ -232,8 +228,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - 421.23, - 'EUR' + , 421.23, 'EUR' ) ) ); @@ -259,8 +254,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::INFERIOR, new PriceParam( - 421.23, - 'EUR' + , 421.23, 'EUR' ) ) ); @@ -286,8 +280,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::INFERIOR, new PriceParam( - 421.23, - 'EUR' + , 421.23, 'EUR' ) ) ); @@ -316,8 +309,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::EQUAL, new PriceParam( - 421.23, - 'EUR' + , 421.23, 'EUR' ) ) ); @@ -343,8 +335,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::EQUAL, new PriceParam( - 421.23, - 'EUR' + , 421.23, 'EUR' ) ) ); @@ -370,8 +361,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - 421.23, - 'EUR' + , 421.23, 'EUR' ) ) ); @@ -397,8 +387,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - 421.23, - 'EUR' + , 421.23, 'EUR' ) ) ); diff --git a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php similarity index 99% rename from core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php rename to core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php index 3579eacf3..69bfd13a6 100644 --- a/core/lib/Thelia/Tests/Coupon/Rule/AvailableForXArticlesTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php @@ -23,7 +23,7 @@ namespace Thelia\Coupon; -use Thelia\Coupon\Rule\AvailableForXArticles; +use Thelia\Constraint\Rule\AvailableForXArticles; /** * Created by JetBrains PhpStorm. @@ -32,7 +32,7 @@ use Thelia\Coupon\Rule\AvailableForXArticles; * * Unit Test AvailableForXArticles Class * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ diff --git a/core/lib/Thelia/Tests/Coupon/Rule/OperatorsTest.php b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php similarity index 92% rename from core/lib/Thelia/Tests/Coupon/Rule/OperatorsTest.php rename to core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php index 22a83dc8b..51d5d06f1 100644 --- a/core/lib/Thelia/Tests/Coupon/Rule/OperatorsTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php @@ -23,8 +23,8 @@ namespace Thelia\Coupon; -use Thelia\Coupon\Validator\QuantityParam; -use Thelia\Coupon\Rule\Operators; +use Thelia\Constraint\Validator\QuantityParam; +use Thelia\Constraint\Rule\Operators; /** * Created by JetBrains PhpStorm. @@ -33,7 +33,7 @@ use Thelia\Coupon\Rule\Operators; * * Unit Test Operators Class * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -58,7 +58,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 11; $operator = Operators::INFERIOR; - $b = new QuantityParam(12); + $b = new QuantityParam(, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -77,7 +77,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 12; $operator = Operators::INFERIOR; - $b = new QuantityParam(12); + $b = new QuantityParam(, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -96,7 +96,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 13; $operator = Operators::INFERIOR; - $b = new QuantityParam(12); + $b = new QuantityParam(, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -115,7 +115,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 11; $operator = Operators::INFERIOR_OR_EQUAL; - $b = new QuantityParam(11); + $b = new QuantityParam(, 11); // When $actual = Operators::isValid($a, $operator, $b); @@ -134,7 +134,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 10; $operator = Operators::INFERIOR_OR_EQUAL; - $b = new QuantityParam(11); + $b = new QuantityParam(, 11); // When $actual = Operators::isValid($a, $operator, $b); @@ -153,7 +153,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 12; $operator = Operators::INFERIOR_OR_EQUAL; - $b = new QuantityParam(11); + $b = new QuantityParam(, 11); // When $actual = Operators::isValid($a, $operator, $b); @@ -172,7 +172,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 12; $operator = Operators::EQUAL; - $b = new QuantityParam(12); + $b = new QuantityParam(, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -191,7 +191,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 11; $operator = Operators::EQUAL; - $b = new QuantityParam(12); + $b = new QuantityParam(, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -210,7 +210,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 13; $operator = Operators::EQUAL; - $b = new QuantityParam(12); + $b = new QuantityParam(, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -229,7 +229,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 13; $operator = Operators::SUPERIOR_OR_EQUAL; - $b = new QuantityParam(13); + $b = new QuantityParam(, 13); // When $actual = Operators::isValid($a, $operator, $b); @@ -248,7 +248,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 14; $operator = Operators::SUPERIOR_OR_EQUAL; - $b = new QuantityParam(13); + $b = new QuantityParam(, 13); // When $actual = Operators::isValid($a, $operator, $b); @@ -267,7 +267,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 12; $operator = Operators::SUPERIOR_OR_EQUAL; - $b = new QuantityParam(13); + $b = new QuantityParam(, 13); // When $actual = Operators::isValid($a, $operator, $b); @@ -286,7 +286,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 13; $operator = Operators::SUPERIOR; - $b = new QuantityParam(12); + $b = new QuantityParam(, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -305,7 +305,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 12; $operator = Operators::SUPERIOR; - $b = new QuantityParam(12); + $b = new QuantityParam(, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -324,7 +324,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 11; $operator = Operators::SUPERIOR; - $b = new QuantityParam(12); + $b = new QuantityParam(, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -343,7 +343,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 12; $operator = Operators::DIFFERENT; - $b = new QuantityParam(11); + $b = new QuantityParam(, 11); // When $actual = Operators::isValid($a, $operator, $b); @@ -362,7 +362,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 11; $operator = Operators::DIFFERENT; - $b = new QuantityParam(11); + $b = new QuantityParam(, 11); // When $actual = Operators::isValid($a, $operator, $b); @@ -381,7 +381,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // Given $a = 12; $operator = 'X'; - $b = new QuantityParam(11); + $b = new QuantityParam(, 11); // When $actual = Operators::isValid($a, $operator, $b); diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/DateParamTest.php similarity index 75% rename from core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php rename to core/lib/Thelia/Tests/Constraint/Validator/DateParamTest.php index bbfe4015a..1b3739c5c 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/DateParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/DateParamTest.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use InvalidArgumentException; -use Thelia\Coupon\Validator\DateParam; +use Thelia\Constraint\Validator\DateParam; /** * Created by JetBrains PhpStorm. @@ -33,7 +33,7 @@ use Thelia\Coupon\Validator\DateParam; * * Unit Test DateParam Class * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -55,10 +55,11 @@ class DateParamTest extends \PHPUnit_Framework_TestCase */ public function testInferiorDate() { + $adapter = new CouponBaseAdapter(); $dateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-07-07"); - $dateParam = new DateParam($dateValidator); + $dateParam = new DateParam($adapter, $dateValidator); $expected = 1; $actual = $dateParam->compareTo($dateToValidate); @@ -72,10 +73,11 @@ class DateParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDate() { + $adapter = new CouponBaseAdapter(); $dateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-07-08"); - $dateParam = new DateParam($dateValidator); + $dateParam = new DateParam($adapter, $dateValidator); $expected = 0; $actual = $dateParam->compareTo($dateToValidate); @@ -89,10 +91,11 @@ class DateParamTest extends \PHPUnit_Framework_TestCase */ public function testSuperiorDate() { + $adapter = new CouponBaseAdapter(); $dateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-07-09"); - $dateParam = new DateParam($dateValidator); + $dateParam = new DateParam($adapter, $dateValidator); $expected = -1; $actual = $dateParam->compareTo($dateToValidate); @@ -105,14 +108,36 @@ class DateParamTest extends \PHPUnit_Framework_TestCase */ public function testInvalidArgumentException() { + $adapter = new CouponBaseAdapter(); $dateValidator = new \DateTime("2012-07-08"); $dateToValidate = 1377012588; - $dateParam = new DateParam($dateValidator); + $dateParam = new DateParam($adapter, $dateValidator); $dateParam->compareTo($dateToValidate); } + /** + * Test is the object is serializable + * If no data is lost during the process + */ + protected function isSerializableTest() + { + $adapter = new CouponBaseAdapter(); + $dateValidator = new \DateTime("2012-07-08"); + + $param = new DateParam($adapter, $dateValidator); + + $serialized = base64_encode(serialize($param)); + /** @var DateParam $unserialized */ + $unserialized = base64_decode(serialize($serialized)); + + $this->assertEquals($param->getValue(), $unserialized->getValue()); + $this->assertEquals($param->getDateTime(), $unserialized->getDateTime()); + + $new = new DateParam($adapter, $unserialized->getDateTime()); + $this->assertEquals($param->getDateTime(), $new->getDateTime()); + } /** diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/IntegerParamTest.php similarity index 75% rename from core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php rename to core/lib/Thelia/Tests/Constraint/Validator/IntegerParamTest.php index b8938d102..c7b5b2ac0 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/IntegerParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/IntegerParamTest.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use InvalidArgumentException; -use Thelia\Coupon\Validator\IntegerParam; +use Thelia\Constraint\Validator\IntegerParam; /** * Created by JetBrains PhpStorm. @@ -33,7 +33,7 @@ use Thelia\Coupon\Validator\IntegerParam; * * Unit Test IntegerParam Class * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -55,10 +55,11 @@ class IntegerParamTest extends \PHPUnit_Framework_TestCase */ public function testInferiorInteger() { + $adapter = new CouponBaseAdapter(); $intValidator = 42; $intToValidate = 41; - $integerParam = new IntegerParam($intValidator); + $integerParam = new IntegerParam($adapter, $intValidator); $expected = 1; $actual = $integerParam->compareTo($intToValidate); @@ -72,10 +73,11 @@ class IntegerParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsInteger() { + $adapter = new CouponBaseAdapter(); $intValidator = 42; $intToValidate = 42; - $integerParam = new IntegerParam($intValidator); + $integerParam = new IntegerParam($adapter, $intValidator); $expected = 0; $actual = $integerParam->compareTo($intToValidate); @@ -89,10 +91,11 @@ class IntegerParamTest extends \PHPUnit_Framework_TestCase */ public function testSuperiorInteger() { + $adapter = new CouponBaseAdapter(); $intValidator = 42; $intToValidate = 43; - $integerParam = new IntegerParam($intValidator); + $integerParam = new IntegerParam($adapter, $intValidator); $expected = -1; $actual = $integerParam->compareTo($intToValidate); @@ -105,17 +108,38 @@ class IntegerParamTest extends \PHPUnit_Framework_TestCase */ public function testInvalidArgumentException() { + $adapter = new CouponBaseAdapter(); $intValidator = 42; $intToValidate = '42'; - $integerParam = new IntegerParam($intValidator); + $integerParam = new IntegerParam($adapter, $intValidator); $expected = 0; $actual = $integerParam->compareTo($intToValidate); $this->assertEquals($expected, $actual); } + /** + * Test is the object is serializable + * If no data is lost during the process + */ + protected function isSerializableTest() + { + $adapter = new CouponBaseAdapter(); + $intValidator = 42; + $param = new IntegerParam($adapter, $intValidator); + + $serialized = base64_encode(serialize($param)); + /** @var IntegerParam $unserialized */ + $unserialized = base64_decode(serialize($serialized)); + + $this->assertEquals($param->getValue(), $unserialized->getValue()); + $this->assertEquals($param->getInteger(), $unserialized->getInteger()); + + $new = new IntegerParam($adapter, $unserialized->getInteger()); + $this->assertEquals($param->getInteger(), $new->getInteger()); + } /** * Tears down the fixture, for example, closes a network connection. diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/IntervalParamTest.php similarity index 74% rename from core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php rename to core/lib/Thelia/Tests/Constraint/Validator/IntervalParamTest.php index c068dfc01..05dad2f0c 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/IntervalParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/IntervalParamTest.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use InvalidArgumentException; -use Thelia\Coupon\Validator\IntervalParam; +use Thelia\Constraint\Validator\IntervalParam; /** * Created by JetBrains PhpStorm. @@ -33,7 +33,7 @@ use Thelia\Coupon\Validator\IntervalParam; * * Unit Test IntervalParam Class * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -55,11 +55,12 @@ class IntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testInferiorDate() { + $adapter = new CouponBaseAdapter(); $dateValidatorStart = new \DateTime("2012-07-08"); $dateValidatorInterval = new \DateInterval("P1M"); //1month $dateToValidate = new \DateTime("2012-07-07"); - $dateParam = new IntervalParam($dateValidatorStart, $dateValidatorInterval); + $dateParam = new IntervalParam($adapter, $dateValidatorStart, $dateValidatorInterval); $expected = 1; $actual = $dateParam->compareTo($dateToValidate); @@ -73,6 +74,7 @@ class IntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDate() { + $adapter = new CouponBaseAdapter(); $dateValidatorStart = new \DateTime("2012-07-08"); $dateValidatorInterval = new \DateInterval("P1M"); //1month $dateToValidate = new \DateTime("2012-07-08"); @@ -80,7 +82,7 @@ class IntervalParamTest extends \PHPUnit_Framework_TestCase echo '1 ' . date_format($dateValidatorStart, 'g:ia \o\n l jS F Y') . "\n"; echo '2 ' . date_format($dateToValidate, 'g:ia \o\n l jS F Y') . "\n"; - $dateParam = new IntervalParam($dateValidatorStart, $dateValidatorInterval); + $dateParam = new IntervalParam($adapter, $dateValidatorStart, $dateValidatorInterval); $expected = 0; $actual = $dateParam->compareTo($dateToValidate); @@ -94,11 +96,12 @@ class IntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDate2() { + $adapter = new CouponBaseAdapter(); $dateValidatorStart = new \DateTime("2012-07-08"); $dateValidatorInterval = new \DateInterval("P1M"); //1month $dateToValidate = new \DateTime("2012-08-08"); - $dateParam = new IntervalParam($dateValidatorStart, $dateValidatorInterval); + $dateParam = new IntervalParam($adapter, $dateValidatorStart, $dateValidatorInterval); $expected = 0; $actual = $dateParam->compareTo($dateToValidate); @@ -112,11 +115,12 @@ class IntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testSuperiorDate() { + $adapter = new CouponBaseAdapter(); $dateValidatorStart = new \DateTime("2012-07-08"); $dateValidatorInterval = new \DateInterval("P1M"); //1month $dateToValidate = new \DateTime("2012-08-09"); - $dateParam = new IntervalParam($dateValidatorStart, $dateValidatorInterval); + $dateParam = new IntervalParam($adapter, $dateValidatorStart, $dateValidatorInterval); $expected = -1; $actual = $dateParam->compareTo($dateToValidate); @@ -129,16 +133,38 @@ class IntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testInvalidArgumentException() { + $adapter = new CouponBaseAdapter(); $dateValidatorStart = new \DateTime("2012-07-08"); $dateValidatorInterval = new \DateInterval("P1M"); //1month $dateToValidate = 1377012588; - $dateParam = new IntervalParam($dateValidatorStart, $dateValidatorInterval); + $dateParam = new IntervalParam($adapter, $dateValidatorStart, $dateValidatorInterval); $dateParam->compareTo($dateToValidate); } + /** + * Test is the object is serializable + * If no data is lost during the process + */ + protected function isSerializableTest() + { + $adapter = new CouponBaseAdapter(); + $dateValidatorStart = new \DateTime("2012-07-08"); + $dateValidatorInterval = new \DateInterval("P1M"); //1month + $param = new IntervalParam($adapter, $dateValidatorStart, $dateValidatorInterval); + + $serialized = base64_encode(serialize($param)); + /** @var IntervalParam $unserialized */ + $unserialized = base64_decode(serialize($serialized)); + + $this->assertEquals($param->getValue(), $unserialized->getValue()); + $this->assertEquals($param->getDatePeriod(), $unserialized->getDatePeriod()); + + $new = new IntervalParam($adapter, $unserialized->getStart(), $unserialized->getInterval()); + $this->assertEquals($param->getDatePeriod(), $new->getDatePeriod()); + } /** * Tears down the fixture, for example, closes a network connection. diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/PriceParamTest.php similarity index 73% rename from core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php rename to core/lib/Thelia/Tests/Constraint/Validator/PriceParamTest.php index 19f19fd4e..7ccc508aa 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/PriceParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/PriceParamTest.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use InvalidArgumentException; -use Thelia\Coupon\Validator\PriceParam; +use Thelia\Constraint\Validator\PriceParam; /** * Created by JetBrains PhpStorm. @@ -33,7 +33,7 @@ use Thelia\Coupon\Validator\PriceParam; * * Unit Test PriceParam Class * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -55,10 +55,12 @@ class PriceParamTest extends \PHPUnit_Framework_TestCase */ public function testInferiorPrice() { + $adapter = new CouponBaseAdapter(); + $priceValidator = 42.50; $priceToValidate = 1.00; - $integerParam = new PriceParam($priceValidator, 'EUR'); + $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); $expected = 1; $actual = $integerParam->compareTo($priceToValidate); @@ -72,10 +74,12 @@ class PriceParamTest extends \PHPUnit_Framework_TestCase */ public function testInferiorPrice2() { + $adapter = new CouponBaseAdapter(); + $priceValidator = 42.50; $priceToValidate = 42.49; - $integerParam = new PriceParam($priceValidator, 'EUR'); + $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); $expected = 1; $actual = $integerParam->compareTo($priceToValidate); @@ -89,10 +93,12 @@ class PriceParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsPrice() { + $adapter = new CouponBaseAdapter(); + $priceValidator = 42.50; $priceToValidate = 42.50; - $integerParam = new PriceParam($priceValidator, 'EUR'); + $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); $expected = 0; $actual = $integerParam->compareTo($priceToValidate); @@ -106,10 +112,12 @@ class PriceParamTest extends \PHPUnit_Framework_TestCase */ public function testSuperiorPrice() { + $adapter = new CouponBaseAdapter(); + $priceValidator = 42.50; $priceToValidate = 42.51; - $integerParam = new PriceParam($priceValidator, 'EUR'); + $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); $expected = -1; $actual = $integerParam->compareTo($priceToValidate); @@ -122,10 +130,12 @@ class PriceParamTest extends \PHPUnit_Framework_TestCase */ public function testInvalidArgumentException() { + $adapter = new CouponBaseAdapter(); + $priceValidator = 42.50; $priceToValidate = '42.50'; - $integerParam = new PriceParam($priceValidator, 'EUR'); + $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); $expected = 0; $actual = $integerParam->compareTo($priceToValidate); @@ -138,10 +148,12 @@ class PriceParamTest extends \PHPUnit_Framework_TestCase */ public function testInvalidArgumentException2() { + $adapter = new CouponBaseAdapter(); + $priceValidator = 42.50; $priceToValidate = -1; - $integerParam = new PriceParam($priceValidator, 'EUR'); + $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); $expected = 0; $actual = $integerParam->compareTo($priceToValidate); @@ -154,10 +166,12 @@ class PriceParamTest extends \PHPUnit_Framework_TestCase */ public function testInvalidArgumentException3() { + $adapter = new CouponBaseAdapter(); + $priceValidator = 42.50; $priceToValidate = 0; - $integerParam = new PriceParam($priceValidator, 'EUR'); + $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); $expected = 0; $actual = $integerParam->compareTo($priceToValidate); @@ -170,17 +184,40 @@ class PriceParamTest extends \PHPUnit_Framework_TestCase */ public function testInvalidArgumentException4() { + $adapter = new CouponBaseAdapter(); $priceValidator = 42.50; $priceToValidate = 1; - $integerParam = new PriceParam($priceValidator, 'EUR'); + $integerParam = new PriceParam($adapter, $priceValidator, 'GBP'); $expected = 0; $actual = $integerParam->compareTo($priceToValidate); $this->assertEquals($expected, $actual); } + /** + * Test is the object is serializable + * If no data is lost during the process + */ + protected function isSerializableTest() + { + $adapter = new CouponBaseAdapter(); + $priceValidator = 42.50; + $param = new PriceParam($adapter, $priceValidator, 'GBP'); + + $serialized = base64_encode(serialize($param)); + /** @var PriceParam $unserialized */ + $unserialized = base64_decode(serialize($serialized)); + + $this->assertEquals($param->getValue(), $unserialized->getValue()); + $this->assertEquals($param->getPrice(), $unserialized->getPrice()); + $this->assertEquals($param->getCurrency(), $unserialized->getCurrency()); + + $new = new PriceParam($adapter, $unserialized->getPrice(), $unserialized->getCurrency()); + $this->assertEquals($param->getPrice(), $new->getPrice()); + $this->assertEquals($param->getCurrency(), $new->getCurrency()); + } /** * Tears down the fixture, for example, closes a network connection. diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php similarity index 75% rename from core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php rename to core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php index 17343121c..9543388f6 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/QuantityParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use InvalidArgumentException; -use Thelia\Coupon\Validator\QuantityParam; +use Thelia\Constraint\Validator\QuantityParam; /** * Created by JetBrains PhpStorm. @@ -33,7 +33,7 @@ use Thelia\Coupon\Validator\QuantityParam; * * Unit Test QuantityParam Class * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -55,10 +55,11 @@ class QuantityParamTest extends \PHPUnit_Framework_TestCase */ public function testInferiorQuantity() { + $adapter = new CouponBaseAdapter(); $intValidator = 42; $intToValidate = 0; - $integerParam = new QuantityParam($intValidator); + $integerParam = new QuantityParam($adapter, $intValidator); $expected = 1; $actual = $integerParam->compareTo($intToValidate); @@ -72,10 +73,11 @@ class QuantityParamTest extends \PHPUnit_Framework_TestCase */ public function testInferiorQuantity2() { + $adapter = new CouponBaseAdapter(); $intValidator = 42; $intToValidate = 41; - $integerParam = new QuantityParam($intValidator); + $integerParam = new QuantityParam($adapter, $intValidator); $expected = 1; $actual = $integerParam->compareTo($intToValidate); @@ -89,10 +91,11 @@ class QuantityParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsQuantity() { + $adapter = new CouponBaseAdapter(); $intValidator = 42; $intToValidate = 42; - $integerParam = new QuantityParam($intValidator); + $integerParam = new QuantityParam($adapter, $intValidator); $expected = 0; $actual = $integerParam->compareTo($intToValidate); @@ -106,10 +109,11 @@ class QuantityParamTest extends \PHPUnit_Framework_TestCase */ public function testSuperiorQuantity() { + $adapter = new CouponBaseAdapter(); $intValidator = 42; $intToValidate = 43; - $integerParam = new QuantityParam($intValidator); + $integerParam = new QuantityParam($adapter, $intValidator); $expected = -1; $actual = $integerParam->compareTo($intToValidate); @@ -122,10 +126,11 @@ class QuantityParamTest extends \PHPUnit_Framework_TestCase */ public function testInvalidArgumentException() { + $adapter = new CouponBaseAdapter(); $intValidator = 42; $intToValidate = '42'; - $integerParam = new QuantityParam($intValidator); + $integerParam = new QuantityParam($adapter, $intValidator); $expected = 0; $actual = $integerParam->compareTo($intToValidate); @@ -138,17 +143,39 @@ class QuantityParamTest extends \PHPUnit_Framework_TestCase */ public function testInvalidArgumentException2() { + $adapter = new CouponBaseAdapter(); $intValidator = 42; $intToValidate = -1; - $integerParam = new QuantityParam($intValidator); + $integerParam = new QuantityParam($adapter, $intValidator); $expected = 0; $actual = $integerParam->compareTo($intToValidate); $this->assertEquals($expected, $actual); } + /** + * Test is the object is serializable + * If no data is lost during the process + */ + protected function isSerializableTest() + { + $adapter = new CouponBaseAdapter(); + $intValidator = 42; + $intToValidate = -1; + $param = new QuantityParam($adapter, $intValidator); + + $serialized = base64_encode(serialize($param)); + /** @var QuantityParam $unserialized */ + $unserialized = base64_decode(serialize($serialized)); + + $this->assertEquals($param->getValue(), $unserialized->getValue()); + $this->assertEquals($param->getInteger(), $unserialized->getInteger()); + + $new = new PriceParam($adapter, $unserialized->getInteger()); + $this->assertEquals($param->getInteger(), $new->getInteger()); + } /** * Tears down the fixture, for example, closes a network connection. diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php similarity index 78% rename from core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php rename to core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php index 66c970a4f..5766cb6b1 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedDateParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php @@ -25,7 +25,7 @@ namespace Thelia\Coupon; use InvalidArgumentException; use Symfony\Component\Intl\Exception\NotImplementedException; -use Thelia\Coupon\Validator\RepeatedDateParam; +use Thelia\Constraint\Validator\RepeatedDateParam; /** * Created by JetBrains PhpStorm. @@ -34,7 +34,7 @@ use Thelia\Coupon\Validator\RepeatedDateParam; * * Unit Test RepeatedDateParam Class * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -56,10 +56,11 @@ class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase */ public function testInferiorDate() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-07-07"); - $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam = new RepeatedDateParam($adapter); $repeatedDateParam->setFrom($startDateValidator); $repeatedDateParam->repeatEveryMonth(); @@ -75,10 +76,11 @@ class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriod() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-07-08"); - $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam = new RepeatedDateParam($adapter); $repeatedDateParam->setFrom($startDateValidator); $repeatedDateParam->repeatEveryMonth(); @@ -94,12 +96,13 @@ class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriod() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-08-08"); - $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam = new RepeatedDateParam($adapter); $repeatedDateParam->setFrom($startDateValidator); - $repeatedDateParam->repeatEveryMonth(); + $repeatedDateParam->repeatEveryMonth(1, 1); $expected = 0; $actual = $repeatedDateParam->compareTo($dateToValidate); @@ -113,10 +116,11 @@ class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryMonthTenTimesThirdPeriod() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-09-08"); - $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam = new RepeatedDateParam($adapter); $repeatedDateParam->setFrom($startDateValidator); $repeatedDateParam->repeatEveryMonth(1, 10); @@ -132,10 +136,11 @@ class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryMonthTenTimesTensPeriod() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2013-05-08"); - $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam = new RepeatedDateParam($adapter); $repeatedDateParam->setFrom($startDateValidator); $repeatedDateParam->repeatEveryMonth(1, 10); @@ -151,10 +156,11 @@ class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryFourMonthTwoTimesSecondPeriod() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-11-08"); - $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam = new RepeatedDateParam($adapter); $repeatedDateParam->setFrom($startDateValidator); $repeatedDateParam->repeatEveryMonth(4, 2); @@ -170,10 +176,11 @@ class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryFourMonthTwoTimesLastPeriod() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2013-03-08"); - $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam = new RepeatedDateParam($adapter); $repeatedDateParam->setFrom($startDateValidator); $repeatedDateParam->repeatEveryMonth(4, 2); @@ -189,10 +196,11 @@ class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase */ public function testNotEqualsDateRepeatEveryFourMonthTwoTimes1() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-08-08"); - $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam = new RepeatedDateParam($adapter); $repeatedDateParam->setFrom($startDateValidator); $repeatedDateParam->repeatEveryMonth(4, 2); @@ -208,10 +216,11 @@ class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase */ public function testNotEqualsDateRepeatEveryFourMonthTwoTimes2() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-12-08"); - $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam = new RepeatedDateParam($adapter); $repeatedDateParam->setFrom($startDateValidator); $repeatedDateParam->repeatEveryMonth(4, 2); @@ -227,10 +236,11 @@ class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase */ public function testSuperiorDateRepeatEveryFourMonthTwoTimes() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2013-03-09"); - $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam = new RepeatedDateParam($adapter); $repeatedDateParam->setFrom($startDateValidator); $repeatedDateParam->repeatEveryMonth(4, 2); @@ -245,17 +255,42 @@ class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase */ public function testInvalidArgumentException() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = 1377012588; - $repeatedDateParam = new RepeatedDateParam(); + $repeatedDateParam = new RepeatedDateParam($adapter); $repeatedDateParam->setFrom($startDateValidator); $repeatedDateParam->repeatEveryMonth(4, 2); $repeatedDateParam->compareTo($dateToValidate); } + /** + * Test is the object is serializable + * If no data is lost during the process + */ + protected function isSerializableTest() + { + $adapter = new CouponBaseAdapter(); + $startDateValidator = new \DateTime("2012-07-08"); + $param = new RepeatedDateParam($adapter); + $param->setFrom($startDateValidator); + $param->repeatEveryMonth(4, 2); + + $serialized = base64_encode(serialize($param)); + /** @var RepeatedDateParam $unserialized */ + $unserialized = base64_decode(serialize($serialized)); + + $this->assertEquals($param->getValue(), $unserialized->getValue()); + $this->assertEquals($param->getDatePeriod(), $unserialized->getDatePeriod()); + + $new = new RepeatedDateParam($adapter); + $new->setFrom($unserialized->getFrom()); + $new->repeatEveryMonth($unserialized->getFrequency(), $unserialized->getNbRepetition()); + $this->assertEquals($param->getDatePeriod(), $new->getDatePeriod()); + } /** * Tears down the fixture, for example, closes a network connection. diff --git a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php similarity index 80% rename from core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php rename to core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php index dc7a1335d..22a105ffb 100644 --- a/core/lib/Thelia/Tests/Coupon/Parameter/RepeatedIntervalParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use Symfony\Component\Intl\Exception\NotImplementedException; -use Thelia\Coupon\Validator\RepeatedIntervalParam; +use Thelia\Constraint\Validator\RepeatedIntervalParam; /** * Created by JetBrains PhpStorm. @@ -33,7 +33,7 @@ use Thelia\Coupon\Validator\RepeatedIntervalParam; * * Unit Test RepeatedIntervalParam Class * - * @package Coupon + * @package Constraint * @author Guillaume MOREL * */ @@ -55,11 +55,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testInferiorDate() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-07-07"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); @@ -77,11 +78,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriodBeginning() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-07-08"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(); @@ -98,11 +100,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriodMiddle() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-07-13"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(); @@ -119,11 +122,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriodEnding() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-07-18"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(); @@ -140,11 +144,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriodBeginning() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-08-08"); $dateToValidate = new \DateTime("2012-08-08"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(); @@ -161,11 +166,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriodMiddle() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-08-08"); $dateToValidate = new \DateTime("2012-08-13"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(); @@ -182,11 +188,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriodEnding() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-08-08"); $dateToValidate = new \DateTime("2012-08-18"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(); @@ -201,13 +208,14 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo * */ - public function testEqualsDateRepeatEveryMonthFourTimeLastPeriodBegining() + public function testEqualsDateRepeatEveryMonthFourTimeLastPeriodBeginning() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-10-08"); $dateToValidate = new \DateTime("2012-10-08"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(1, 4); @@ -224,11 +232,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryMonthFourTimeLastPeriodMiddle() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-10-08"); $dateToValidate = new \DateTime("2012-10-13"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(1, 4); @@ -245,11 +254,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testEqualsDateRepeatEveryMonthFourTimeLastPeriodEnding() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-10-08"); $dateToValidate = new \DateTime("2012-10-18"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(1, 4); @@ -266,11 +276,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testNotEqualsDateRepeatEveryMonthFourTimeInTheBeginning() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-10-08"); $dateToValidate = new \DateTime("2012-07-19"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(1, 4); @@ -287,11 +298,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testNotEqualsDateRepeatEveryMonthFourTimeInTheMiddle() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-10-08"); $dateToValidate = new \DateTime("2012-08-01"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(1, 4); @@ -309,11 +321,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testNotEqualsDateRepeatEveryMonthFourTimeInTheEnd() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-10-08"); $dateToValidate = new \DateTime("2012-08-07"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(1, 4); @@ -332,11 +345,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testSuperiorDateRepeatEveryMonthFourTime() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = new \DateTime("2012-10-19"); $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(1, 0); @@ -352,11 +366,12 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase */ public function testInvalidArgumentException() { + $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); $dateToValidate = 1377012588; $duration = 10; - $RepeatedIntervalParam = new RepeatedIntervalParam(); + $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); $RepeatedIntervalParam->setFrom($startDateValidator); $RepeatedIntervalParam->setDurationInDays($duration); $RepeatedIntervalParam->repeatEveryMonth(1, 4); @@ -364,6 +379,36 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase $RepeatedIntervalParam->compareTo($dateToValidate); } + /** + * Test is the object is serializable + * If no data is lost during the process + */ + protected function isSerializableTest() + { + $adapter = new CouponBaseAdapter(); + $startDateValidator = new \DateTime("2012-07-08"); + $dateToValidate = 1377012588; + $duration = 10; + + $param = new RepeatedIntervalParam($adapter); + $param->setFrom($startDateValidator); + $param->setDurationInDays($duration); + $param->repeatEveryMonth(1, 4); + + $serialized = base64_encode(serialize($param)); + /** @var RepeatedIntervalParam $unserialized */ + $unserialized = base64_decode(serialize($serialized)); + + $this->assertEquals($param->getValue(), $unserialized->getValue()); + $this->assertEquals($param->getDatePeriod(), $unserialized->getDatePeriod()); + + $new = new RepeatedIntervalParam($adapter); + $new->setFrom($unserialized->getFrom()); + $new->repeatEveryMonth($unserialized->getFrequency(), $unserialized->getNbRepetition()); + $new->setDurationInDays($unserialized->getDurationInDays()); + $this->assertEquals($param->getDatePeriod(), $new->getDatePeriod()); + } + /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index c33b2327a..f3cf99054 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -23,10 +23,10 @@ namespace Thelia\Coupon; -use Thelia\Coupon\Validator\PriceParam; -use Thelia\Coupon\Validator\RuleValidator; -use Thelia\Coupon\Rule\AvailableForTotalAmount; -use Thelia\Coupon\Rule\Operators; +use Thelia\Constraint\Validator\PriceParam; +use Thelia\Constraint\Validator\RuleValidator; +use Thelia\Constraint\Rule\AvailableForTotalAmount; +use Thelia\Constraint\Rule\Operators; use Thelia\Coupon\Type\CouponInterface; use Thelia\Exception\CouponExpiredException; use Thelia\Model\Coupon; @@ -208,8 +208,7 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - 40.00, - 'EUR' + , 40.00, 'EUR' ) ) ) @@ -219,8 +218,7 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::INFERIOR, new PriceParam( - 400.00, - 'EUR' + , 400.00, 'EUR' ) ) ) diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index b5b9cefbe..08673746e 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -23,10 +23,10 @@ namespace Thelia\Coupon; -use Thelia\Coupon\Validator\PriceParam; -use Thelia\Coupon\Validator\RuleValidator; -use Thelia\Coupon\Rule\AvailableForTotalAmount; -use Thelia\Coupon\Rule\Operators; +use Thelia\Constraint\Validator\PriceParam; +use Thelia\Constraint\Validator\RuleValidator; +use Thelia\Constraint\Rule\AvailableForTotalAmount; +use Thelia\Constraint\Rule\Operators; use Thelia\Coupon\Type\CouponInterface; use Thelia\Coupon\Type\RemoveXAmount; use Thelia\Tools\PhpUnitUtils; @@ -103,6 +103,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua */ public function testGetDiscountTwoCoupon() { + $adapter = new CouponBaseAdapter(); $cartTotalPrice = 100.00; $checkoutTotalPrice = 120.00; @@ -113,8 +114,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - 40.00, - 'EUR' + $adapter, 40.00, 'EUR' ) ) ) @@ -143,6 +143,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua */ public function testGetDiscountAlwaysInferiorToPrice() { + $adapter = new CouponBaseAdapter(); $cartTotalPrice = 21.00; $checkoutTotalPrice = 26.00; @@ -151,8 +152,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - 20.00, - 'EUR' + $adapter, 20.00, 'EUR' ) ) ) @@ -180,6 +180,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua */ public function testIsCouponRemovingPostage() { + $adapter = new CouponBaseAdapter(); $cartTotalPrice = 21.00; $checkoutTotalPrice = 27.00; @@ -188,8 +189,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - 20.00, - 'EUR' + $adapter, 20.00, 'EUR' ) ) ) @@ -640,13 +640,13 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua */ public static function generateValidRules() { + $adapter = new CouponBaseAdapter(); $rule1 = new AvailableForTotalAmount( array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - 40.00, - 'EUR' + $adapter, 40.00, 'EUR' ) ) ) @@ -656,8 +656,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::INFERIOR, new PriceParam( - 400.00, - 'EUR' + $adapter, 400.00, 'EUR' ) ) ) @@ -754,6 +753,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $isAvailableOnSpecialOffers = null, $maxUsage = null ) { + $adapter = new CouponBaseAdapter(); if ($code === null) { $code = self::VALID_CODE; } @@ -790,7 +790,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $expirationDate->setTimestamp(strtotime("today + 2 months")); } - $coupon = new RemoveXAmount($code, $title, $shortDescription, $description, $amount, $isCumulative, $isRemovingPostage, $isAvailableOnSpecialOffers, $isEnabled, $maxUsage, $expirationDate); + $coupon = new RemoveXAmount($adapter, $code, $title, $shortDescription, $description, $amount, $isCumulative, $isRemovingPostage, $isAvailableOnSpecialOffers, $isEnabled, $maxUsage, $expirationDate); if ($rules === null) { $rules = self::generateValidRules(); diff --git a/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php b/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php index e399b6f37..eab22758b 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php @@ -23,10 +23,10 @@ namespace Thelia\Coupon; -use Thelia\Coupon\Validator\PriceParam; -use Thelia\Coupon\Validator\RuleValidator; -use Thelia\Coupon\Rule\AvailableForTotalAmount; -use Thelia\Coupon\Rule\Operators; +use Thelia\Constraint\Validator\PriceParam; +use Thelia\Constraint\Validator\RuleValidator; +use Thelia\Constraint\Rule\AvailableForTotalAmount; +use Thelia\Constraint\Rule\Operators; /** * Created by JetBrains PhpStorm. @@ -51,8 +51,7 @@ class CouponRuleCollectionTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - 40.00, - 'EUR' + , 40.00, 'EUR' ) ) ) @@ -62,8 +61,7 @@ class CouponRuleCollectionTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::INFERIOR, new PriceParam( - 400.00, - 'EUR' + , 400.00, 'EUR' ) ) ) diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php index 72313f9ec..69e01549f 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php @@ -23,10 +23,10 @@ namespace Thelia\Coupon; -use Thelia\Coupon\Validator\PriceParam; -use Thelia\Coupon\Validator\RuleValidator; -use Thelia\Coupon\Rule\AvailableForTotalAmount; -use Thelia\Coupon\Rule\Operators; +use Thelia\Constraint\Validator\PriceParam; +use Thelia\Constraint\Validator\RuleValidator; +use Thelia\Constraint\Rule\AvailableForTotalAmount; +use Thelia\Constraint\Rule\Operators; use Thelia\Coupon\Type\RemoveXAmount; require_once '../CouponManagerTest.php'; @@ -54,6 +54,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase } /** + * Test if a Coupon is well displayed * * @covers Thelia\Coupon\type\RemoveXAmount::getCode * @covers Thelia\Coupon\type\RemoveXAmount::getTitle @@ -83,13 +84,13 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase } /** + * Test if a Coupon can be Cumulative * * @covers Thelia\Coupon\type\RemoveXAmount::isCumulative * */ public function testIsCumulative() { - $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, true, true); $actual = $coupon->isCumulative(); @@ -97,13 +98,13 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase } /** + * Test if a Coupon can be non cumulative * * @covers Thelia\Coupon\type\RemoveXAmount::isCumulative * */ public function testIsNotCumulative() { - $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); $actual = $coupon->isCumulative(); @@ -112,6 +113,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase /** + * Test if a Coupon can remove postage * * @covers Thelia\Coupon\type\RemoveXAmount::isRemovingPostage * @@ -125,13 +127,12 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase } /** + * Test if a Coupon won't remove postage if not set to * * @covers Thelia\Coupon\type\RemoveXAmount::isRemovingPostage - * */ public function testIsNotRemovingPostage() { - $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); $actual = $coupon->isRemovingPostage(); @@ -140,25 +141,25 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase /** + * Test if a Coupon has the effect expected (discount 10euros) * * @covers Thelia\Coupon\type\RemoveXAmount::getEffect - * */ public function testGetEffect() { - + $adapter = new CouponBaseAdapter(); $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); $expected = 10; - $actual = $coupon->getDiscount(); + $actual = $coupon->getDiscount($adapter); $this->assertEquals($expected, $actual); } /** + * Test Coupon rule setter * * @covers Thelia\Coupon\type\RemoveXAmount::setRules * @covers Thelia\Coupon\type\RemoveXAmount::getRules - * */ public function testSetRulesValid() { @@ -187,6 +188,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase } /** + * Test Coupon rule setter * * @covers Thelia\Coupon\type\RemoveXAmount::setRules * @expectedException \Thelia\Exception\InvalidRuleException @@ -212,6 +214,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase } /** + * Test Coupon effect for rule Total Amount < 400 * * @covers Thelia\Coupon\type\RemoveXAmount::getEffect * @@ -219,6 +222,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountInferiorTo400Valid() { // Given + $adapter = new CouponBaseAdapter(); $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::INFERIOR, 400.00 @@ -230,11 +234,12 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // Then $expected = 10.00; - $actual = $coupon->getDiscount(); + $actual = $coupon->getDiscount($adapter); $this->assertEquals($expected, $actual); } /** + * Test Coupon effect for rule Total Amount <= 400 * * @covers Thelia\Coupon\type\RemoveXAmount::getEffect * @@ -242,6 +247,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountInferiorOrEqualTo400Valid() { // Given + $adapter = new CouponBaseAdapter(); $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::INFERIOR_OR_EQUAL, 400.00 @@ -253,11 +259,12 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // Then $expected = 10.00; - $actual = $coupon->getDiscount(); + $actual = $coupon->getDiscount($adapter); $this->assertEquals($expected, $actual); } /** + * Test Coupon effect for rule Total Amount == 400 * * @covers Thelia\Coupon\type\RemoveXAmount::getEffect * @@ -265,6 +272,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountEqualTo400Valid() { // Given + $adapter = new CouponBaseAdapter(); $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::EQUAL, 400.00 @@ -276,11 +284,12 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // Then $expected = 10.00; - $actual = $coupon->getDiscount(); + $actual = $coupon->getDiscount($adapter); $this->assertEquals($expected, $actual); } /** + * Test Coupon effect for rule Total Amount >= 400 * * @covers Thelia\Coupon\type\RemoveXAmount::getEffect * @@ -288,6 +297,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountSuperiorOrEqualTo400Valid() { // Given + $adapter = new CouponBaseAdapter(); $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::SUPERIOR_OR_EQUAL, 400.00 @@ -299,11 +309,12 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // Then $expected = 10.00; - $actual = $coupon->getDiscount(); + $actual = $coupon->getDiscount($adapter); $this->assertEquals($expected, $actual); } /** + * Test Coupon effect for rule Total Amount > 400 * * @covers Thelia\Coupon\type\RemoveXAmount::getEffect * @@ -311,6 +322,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountSuperiorTo400Valid() { // Given + $adapter = new CouponBaseAdapter(); $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::SUPERIOR, 400.00 @@ -322,7 +334,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // Then $expected = 10.00; - $actual = $coupon->getDiscount(); + $actual = $coupon->getDiscount($adapter); $this->assertEquals($expected, $actual); } @@ -347,10 +359,12 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase */ protected function generateValidRuleAvailableForTotalAmountOperatorTo($operator, $amount) { + $adapter = new CouponBaseAdapter(); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( $operator, new PriceParam( + $adapter, $amount, 'EUR' ) diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php index 5d110d3df..5b80ac1a3 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php @@ -24,8 +24,15 @@ namespace Thelia\Coupon; use PHPUnit_Framework_TestCase; +use Thelia\Constraint\Rule\AvailableForTotalAmount; +use Thelia\Constraint\Rule\Operators; +use Thelia\Constraint\Validator\PriceParam; +use Thelia\Constraint\Validator\RuleValidator; +use Thelia\Coupon\Type\CouponInterface; use Thelia\Coupon\Type\RemoveXPercent; +require_once '../CouponManagerTest.php'; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -48,92 +55,29 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase { } - - protected function generateValidCumulativeRemovingPostageCoupon() - { - $coupon = new RemoveXPercent( - self::VALID_COUPON_CODE, - self::VALID_COUPON_TITLE, - self::VALID_COUPON_SHORT_DESCRIPTION, - self::VALID_COUPON_DESCRIPTION, - 30.00, - true, - true - ); - - return $coupon; - } - - protected function generateValidNonCumulativeNonRemovingPostageCoupon() - { - $coupon = new RemoveXPercent( - self::VALID_COUPON_CODE, - self::VALID_COUPON_TITLE, - self::VALID_COUPON_SHORT_DESCRIPTION, - self::VALID_COUPON_DESCRIPTION, - 30.00, - false, - false - ); - - return $coupon; - } - /** + * Test if a Coupon can be Cumulative * - * @covers Thelia\Coupon\Type\RemoveXPercent::getCode - * @covers Thelia\Coupon\Type\RemoveXPercent::getTitle - * @covers Thelia\Coupon\Type\RemoveXPercent::getShortDescription - * @covers Thelia\Coupon\Type\RemoveXPercent::getDescription - * - */ - public function testDisplay() - { - - $coupon = $this->generateValidCumulativeRemovingPostageCoupon(); - - $expected = self::VALID_COUPON_CODE; - $actual = $coupon->getCode(); - $this->assertEquals($expected, $actual); - - $expected = self::VALID_COUPON_TITLE; - $actual = $coupon->getTitle(); - $this->assertEquals($expected, $actual); - - $expected = self::VALID_COUPON_SHORT_DESCRIPTION; - $actual = $coupon->getShortDescription(); - $this->assertEquals($expected, $actual); - - $expected = self::VALID_COUPON_DESCRIPTION; - $actual = $coupon->getDescription(); - $this->assertEquals($expected, $actual); - - } - - - /** - * - * @covers Thelia\Coupon\Type\RemoveXPercent::isCumulative + * @covers Thelia\Coupon\type\RemoveXAmount::isCumulative * */ public function testIsCumulative() { - - $coupon = $this->generateValidCumulativeRemovingPostageCoupon(); + $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, true, true); $actual = $coupon->isCumulative(); $this->assertTrue($actual); } /** + * Test if a Coupon can be non cumulative * - * @covers Thelia\Coupon\Type\RemoveXPercent::isCumulative + * @covers Thelia\Coupon\type\RemoveXAmount::isCumulative * */ public function testIsNotCumulative() { - - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); $actual = $coupon->isCumulative(); $this->assertFalse($actual); @@ -141,28 +85,27 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase /** + * Test if a Coupon can remove postage * - * @covers Thelia\Coupon\Type\RemoveXPercent::isRemovingPostage + * @covers Thelia\Coupon\type\RemoveXAmount::isRemovingPostage * */ public function testIsRemovingPostage() { - - $coupon = $this->generateValidCumulativeRemovingPostageCoupon(); + $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, true, true); $actual = $coupon->isRemovingPostage(); $this->assertTrue($actual); } /** + * Test if a Coupon won't remove postage if not set to * - * @covers Thelia\Coupon\Type\RemoveXPercent::isRemovingPostage - * + * @covers Thelia\Coupon\type\RemoveXAmount::isRemovingPostage */ public function testIsNotRemovingPostage() { - - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); + $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); $actual = $coupon->isRemovingPostage(); $this->assertFalse($actual); @@ -170,20 +113,337 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase /** + * Test if a Coupon has the effect expected (discount 10euros) * - * @covers Thelia\Coupon\Type\RemoveXPercent::getDiscount - * + * @covers Thelia\Coupon\type\RemoveXAmount::getEffect */ public function testGetEffect() { + $adapter = $this->generateFakeAdapter(245); + $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); - $coupon = $this->generateValidNonCumulativeNonRemovingPostageCoupon(); - - $expected = -30.00; - $actual = $coupon->getDiscount(); + $expected = 24.50; + $actual = $coupon->getDiscount($adapter); $this->assertEquals($expected, $actual); } + /** + * Test Coupon rule setter + * + * @covers Thelia\Coupon\type\RemoveXAmount::setRules + * @covers Thelia\Coupon\type\RemoveXAmount::getRules + */ + public function testSetRulesValid() + { + // Given + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( + Operators::EQUAL, + 20.00 + ); + $rule1 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( + Operators::INFERIOR, + 100.23 + ); + $rule2 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( + Operators::SUPERIOR, + 421.23 + ); + + $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + + // When + $coupon->setRules(new CouponRuleCollection(array($rule0, $rule1, $rule2))); + + // Then + $expected = 3; + $this->assertCount($expected, $coupon->getRules()->getRules()); + } + + /** + * Test Coupon rule setter + * + * @covers Thelia\Coupon\type\RemoveXAmount::setRules + * @expectedException \Thelia\Exception\InvalidRuleException + * + */ + public function testSetRulesInvalid() + { + // Given + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( + Operators::EQUAL, + 20.00 + ); + $rule1 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( + Operators::INFERIOR, + 100.23 + ); + $rule2 = $this; + + $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + + // When + $coupon->setRules(new CouponRuleCollection(array($rule0, $rule1, $rule2))); + } + + /** + * Test Coupon effect for rule Total Amount < 400 + * + * @covers Thelia\Coupon\type\RemoveXAmount::getEffect + * + */ + public function testGetEffectIfTotalAmountInferiorTo400Valid() + { + // Given + $adapter = $this->generateFakeAdapter(245); + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( + Operators::INFERIOR, + 400.00 + ); + $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + + // When + $coupon->setRules(new CouponRuleCollection(array($rule0))); + + // Then + $expected = 24.50; + $actual = $coupon->getDiscount($adapter); + $this->assertEquals($expected, $actual); + } + + /** + * Test Coupon effect for rule Total Amount <= 400 + * + * @covers Thelia\Coupon\type\RemoveXAmount::getEffect + * + */ + public function testGetEffectIfTotalAmountInferiorOrEqualTo400Valid() + { + // Given + $adapter = $this->generateFakeAdapter(245); + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( + Operators::INFERIOR_OR_EQUAL, + 400.00 + ); + $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + + // When + $coupon->setRules(new CouponRuleCollection(array($rule0))); + + // Then + $expected = 24.50; + $actual = $coupon->getDiscount($adapter); + $this->assertEquals($expected, $actual); + } + + /** + * Test Coupon effect for rule Total Amount == 400 + * + * @covers Thelia\Coupon\type\RemoveXAmount::getEffect + * + */ + public function testGetEffectIfTotalAmountEqualTo400Valid() + { + // Given + $adapter = $this->generateFakeAdapter(245); + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( + Operators::EQUAL, + 400.00 + ); + $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + + // When + $coupon->setRules(new CouponRuleCollection(array($rule0))); + + // Then + $expected = 24.50; + $actual = $coupon->getDiscount($adapter); + $this->assertEquals($expected, $actual); + } + + /** + * Test Coupon effect for rule Total Amount >= 400 + * + * @covers Thelia\Coupon\type\RemoveXAmount::getEffect + * + */ + public function testGetEffectIfTotalAmountSuperiorOrEqualTo400Valid() + { + // Given + $adapter = $this->generateFakeAdapter(245); + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( + Operators::SUPERIOR_OR_EQUAL, + 400.00 + ); + $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + + // When + $coupon->setRules(new CouponRuleCollection(array($rule0))); + + // Then + $expected = 24.50; + $actual = $coupon->getDiscount($adapter); + $this->assertEquals($expected, $actual); + } + + /** + * Test Coupon effect for rule Total Amount > 400 + * + * @covers Thelia\Coupon\type\RemoveXAmount::getEffect + * + */ + public function testGetEffectIfTotalAmountSuperiorTo400Valid() + { + // Given + $adapter = $this->generateFakeAdapter(245); + $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( + Operators::SUPERIOR, + 400.00 + ); + $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + + // When + $coupon->setRules(new CouponRuleCollection(array($rule0))); + + // Then + $expected = 24.50; + $actual = $coupon->getDiscount($adapter); + $this->assertEquals($expected, $actual); + } + + /** + * Generate valid CouponInterface + * + * @param string $code Coupon Code + * @param string $title Coupon Title + * @param string $shortDescription Coupon short + * description + * @param string $description Coupon description + * @param float $amount Coupon discount + * @param bool $isEnabled Is Coupon enabled + * @param \DateTime $expirationDate Coupon expiration date + * @param CouponRuleCollection $rules Coupon rules + * @param bool $isCumulative If is cumulative + * @param bool $isRemovingPostage If is removing postage + * @param bool $isAvailableOnSpecialOffers If is available on + * special offers or not + * @param int $maxUsage How many time a Coupon + * can be used + * + * @return CouponInterface + */ + public static function generateValidCoupon( + $code = null, + $title = null, + $shortDescription = null, + $description = null, + $percent = null, + $isEnabled = null, + $expirationDate = null, + $rules = null, + $isCumulative = null, + $isRemovingPostage = null, + $isAvailableOnSpecialOffers = null, + $maxUsage = null + ) { + $adapter = new CouponBaseAdapter(); + if ($code === null) { + $code = CouponManagerTest::VALID_CODE; + } + if ($title === null) { + $title = CouponManagerTest::VALID_TITLE; + } + if ($shortDescription === null) { + $shortDescription = CouponManagerTest::VALID_SHORT_DESCRIPTION; + } + if ($description === null) { + $description = CouponManagerTest::VALID_DESCRIPTION; + } + if ($percent === null) { + $percent = 10.00; + } + if ($isEnabled === null) { + $isEnabled = true; + } + if ($isCumulative === null) { + $isCumulative = true; + } + if ($isRemovingPostage === null) { + $isRemovingPostage = false; + } + if ($isAvailableOnSpecialOffers === null) { + $isAvailableOnSpecialOffers = true; + } + if ($maxUsage === null) { + $maxUsage = 40; + } + + if ($expirationDate === null) { + $expirationDate = new \DateTime(); + $expirationDate->setTimestamp(strtotime("today + 2 months")); + } + + $coupon = new RemoveXPercent($adapter, $code, $title, $shortDescription, $description, $percent, $isCumulative, $isRemovingPostage, $isAvailableOnSpecialOffers, $isEnabled, $maxUsage, $expirationDate); + + if ($rules === null) { + $rules = CouponManagerTest::generateValidRules(); + } + + $coupon->setRules($rules); + + return $coupon; + } + + + /** + * Generate valid rule AvailableForTotalAmount + * according to given operator and amount + * + * @param string $operator Operators::CONST + * @param float $amount Amount with 2 decimals + * + * @return AvailableForTotalAmount + */ + protected function generateValidRuleAvailableForTotalAmountOperatorTo($operator, $amount) + { + $adapter = new CouponBaseAdapter(); + $validators = array( + AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( + $operator, + new PriceParam( + $adapter, + $amount, + 'EUR' + ) + ) + ); + + return new AvailableForTotalAmount($validators); + } + + /** + * Generate a fake Adapter + * + * @param float $cartTotalPrice Cart total price + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ + public function generateFakeAdapter($cartTotalPrice) + { + $stubCouponBaseAdapter = $this->getMock( + 'Thelia\Coupon\CouponBaseAdapter', + array( + 'getCartTotalPrice' + ), + array() + ); + + $stubCouponBaseAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(($cartTotalPrice))); + + return $stubCouponBaseAdapter; + } + /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. From 50d50d3b91ac7b7799192b63fe82b46ff65c150d Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 28 Aug 2013 09:33:33 +0200 Subject: [PATCH 037/268] WIP Coupon Refactor : creating dedicated reusable module for Constraints Adding ConstraintManager Secured : - Effects : RemoveXPercent + RemoveXAmount - Validators : all except ModelParam (need CustomerModelParam, AreaModelParam, CountryModelParam ?) - Conditions : AvailableForTotalAmount --- .../Rule/AvailableForTotalAmount.php | 24 ++- .../Constraint/Rule/AvailableForXArticles.php | 139 +++++++++++++++++- .../Constraint/Rule/CouponRuleAbstract.php | 26 ++-- .../Constraint/Rule/CouponRuleInterface.php | 5 +- .../lib/Thelia/Coupon/Type/CouponAbstract.php | 5 +- .../Thelia/Coupon/Type/CouponInterface.php | 7 +- .../lib/Thelia/Coupon/Type/RemoveXPercent.php | 7 +- .../Constraint/ConstraintManagerTest.php | 75 +--------- .../Rule/AvailableForTotalAmountTest.php | 91 +++++++----- .../Rule/AvailableForXArticlesTest.php | 87 ++++++----- .../Tests/Constraint/Rule/OperatorsTest.php | 54 ++++--- .../Validator/QuantityParamTest.php | 3 +- .../Thelia/Tests/Coupon/CouponFactoryTest.php | 4 +- .../Thelia/Tests/Coupon/CouponManagerTest.php | 10 +- .../Tests/Coupon/CouponRuleCollectionTest.php | 4 +- .../Type/RemoveXAmountForCategoryYTest.php | 7 + .../Tests/Coupon/Type/RemoveXAmountTest.php | 14 +- .../Type/RemoveXPercentForCategoryYTest.php | 7 + .../Tests/Coupon/Type/RemoveXPercentTest.php | 46 +++--- 19 files changed, 350 insertions(+), 265 deletions(-) diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmount.php b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmount.php index 704df073e..a6e5d60ee 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmount.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmount.php @@ -61,14 +61,16 @@ class AvailableForTotalAmount extends CouponRuleAbstract /** * Constructor * - * @param array $validators Array of RuleValidator - * validating $paramsToValidate against + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * @param array $validators Array of RuleValidator + * validating $paramsToValidate against * * @throws \Thelia\Exception\InvalidRuleException */ - public function __construct(array $validators) + public function __construct(CouponAdapterInterface $adapter, array $validators) { - parent::__construct($validators); + parent::__construct($adapter, $validators); if (isset($validators[self::PARAM1_PRICE]) && $validators[self::PARAM1_PRICE] instanceof RuleValidator @@ -77,7 +79,6 @@ class AvailableForTotalAmount extends CouponRuleAbstract } else { throw new InvalidRuleException(get_class()); } - } @@ -109,8 +110,6 @@ class AvailableForTotalAmount extends CouponRuleAbstract $this->checkBackOfficeInputsOperators(); - - return $this->isPriceValid($price->getPrice()); } @@ -129,9 +128,9 @@ class AvailableForTotalAmount extends CouponRuleAbstract throw new InvalidRuleValueException(get_class(), self::PARAM1_PRICE); } - $quantity = $this->paramsToValidate[self::PARAM1_PRICE]; + $price = $this->paramsToValidate[self::PARAM1_PRICE]; - return $this->isPriceValid($quantity); + return $this->isPriceValid($price); } /** @@ -157,15 +156,12 @@ class AvailableForTotalAmount extends CouponRuleAbstract /** * Generate current Rule param to be validated from adapter * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * * @return $this */ - protected function setParametersToValidate(CouponAdapterInterface $adapter) + protected function setParametersToValidate() { $this->paramsToValidate = array( - self::PARAM1_PRICE => $adapter->getCartTotalPrice() + self::PARAM1_PRICE => $this->adapter->getCartTotalPrice() ); return $this; diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php b/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php index b38a53ce4..1a8e17da2 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php @@ -23,6 +23,11 @@ namespace Thelia\Constraint\Rule; +use Thelia\Constraint\Validator\QuantityParam; +use Thelia\Constraint\Validator\RuleValidator; +use Thelia\Coupon\CouponAdapterInterface; +use Thelia\Exception\InvalidRuleValueException; + /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -36,15 +41,90 @@ namespace Thelia\Constraint\Rule; */ class AvailableForXArticles extends CouponRuleAbstract { + /** Rule 1st parameter : price */ + CONST PARAM1_QUANTITY = 'quantity'; + + /** @var array Available Operators (Operators::CONST) */ + protected $availableOperators = array( + Operators::INFERIOR, + Operators::EQUAL, + Operators::SUPERIOR, + ); + + /** @var RuleValidator Quantity Validator */ + protected $quantityValidator = null; + + /** + * Constructor + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * @param array $validators Array of RuleValidator + * validating $paramsToValidate against + * + * @throws InvalidRuleException + */ + public function __construct(CouponAdapterInterface $adapter, array $validators) + { + parent::__construct($adapter, $validators); + + if (isset($validators[self::PARAM1_QUANTITY]) + && $validators[self::PARAM1_QUANTITY] instanceof RuleValidator + ) { + $this->quantityValidator = $validators[self::PARAM1_QUANTITY]; + } else { + throw new InvalidRuleException(get_class()); + } + + $this->adapter = $adapter; + } /** * Check if backoffice inputs are relevant or not * + * @throws InvalidRuleOperatorException if Operator is not allowed + * @throws InvalidRuleValueException if Value is not allowed * @return bool */ public function checkBackOfficeInput() { - // TODO: Implement checkBackOfficeInput() method. + if (!isset($this->validators) + || empty($this->validators) + ||!isset($this->validators[self::PARAM1_QUANTITY]) + ||!isset($this->validators[self::PARAM1_QUANTITY]) + ) { + throw new InvalidRuleValueException(get_class(), self::PARAM1_QUANTITY); + } + + /** @var RuleValidator $ruleValidator */ + $ruleValidator = $this->validators[self::PARAM1_QUANTITY]; + /** @var QuantityParam $quantity */ + $quantity = $ruleValidator->getParam(); + + if (!$quantity instanceof QuantityParam) { + throw new InvalidRuleValueException(get_class(), self::PARAM1_QUANTITY); + } + + $this->checkBackOfficeInputsOperators(); + + return $this->isQuantityValid($quantity->getInteger()); + } + + /** + * Generate current Rule param to be validated from adapter + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * + * @return $this + */ + protected function setParametersToValidate() + { + $this->paramsToValidate = array( + self::PARAM1_QUANTITY => $this->adapter->getCartTotalPrice() + ); + + return $this; } /** @@ -57,4 +137,61 @@ class AvailableForXArticles extends CouponRuleAbstract // TODO: Implement checkCheckoutInput() method. } + /** + * Check if a quantity is valid + * + * @param float $quantity Quantity to check + * + * @throws InvalidRuleValueException if Value is not allowed + * @return bool + */ + protected function isQuantityValid($quantity) + { + $quantityValidator = $this->quantityValidator; + try { + $quantityValidator->getParam()->compareTo($quantity); + } catch(\InvalidArgumentException $e) { + throw new InvalidRuleValueException(get_class(), self::PARAM1_QUANTITY); + } + + return true; + } + + /** + * Get I18n name + * + * @return string + */ + public function getName() + { + return $this->adapter + ->getTranslator() + ->trans('Number of articles in cart', null, 'constraint'); + } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + $i18nOperator = Operators::getI18n( + $this->adapter, $this->priceValidator->getOperator() + ); + + $toolTip = $this->adapter + ->getTranslator() + ->trans( + 'If cart products quantity is %operator% %quantity%', + array( + '%operator%' => $i18nOperator, + '%quantity%' => $this->quantityValidator->getParam()->getInteger(), + ), + 'constraint' + ); + + return $toolTip; + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php b/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php index 9fbcc21fc..d7a966a13 100644 --- a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php +++ b/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php @@ -57,6 +57,9 @@ abstract class CouponRuleAbstract implements CouponRuleInterface /** @var array Parameters to be validated */ protected $paramsToValidate = array(); + /** @var CouponAdapterInterface Provide necessary value from Thelia */ + protected $adapter = null; + /** * Constructor * Ex: @@ -70,14 +73,16 @@ abstract class CouponRuleAbstract implements CouponRuleInterface * Param 2 : * $paramsToValidate[AvailableForTotalAmount::PARAM1_PRICE] = 9 * - * @param array $validators Array of RuleValidator - * validating $paramsToValidate against - * - * @throws InvalidRuleException + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * @param array $validators Array of RuleValidator + * validating $paramsToValidate against */ - public function __construct(array $validators) + public function __construct(CouponAdapterInterface $adapter, array $validators) { $this->setValidators($validators); + $this->adapter = $adapter; + $this->setParametersToValidate($this->adapter); } /** @@ -104,14 +109,10 @@ abstract class CouponRuleAbstract implements CouponRuleInterface /** * Check if the current Checkout matches this condition * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * * @return bool */ - public function isMatching(CouponAdapterInterface $adapter) + public function isMatching() { - $this->setParametersToValidate($adapter); $this->checkBackOfficeInput(); $this->checkCheckoutInput(); @@ -165,13 +166,10 @@ abstract class CouponRuleAbstract implements CouponRuleInterface /** * Generate current Rule param to be validated from adapter * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * * @throws \Thelia\Exception\NotImplementedException * @return $this */ - protected function setParametersToValidate(CouponAdapterInterface $adapter) + protected function setParametersToValidate() { throw new \Thelia\Exception\NotImplementedException(); } diff --git a/core/lib/Thelia/Constraint/Rule/CouponRuleInterface.php b/core/lib/Thelia/Constraint/Rule/CouponRuleInterface.php index 9e75c7fe1..ea0ba42d9 100644 --- a/core/lib/Thelia/Constraint/Rule/CouponRuleInterface.php +++ b/core/lib/Thelia/Constraint/Rule/CouponRuleInterface.php @@ -55,12 +55,9 @@ interface CouponRuleInterface /** * Check if the current Checkout matches this condition * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * * @return bool */ - public function isMatching(CouponAdapterInterface $adapter); + public function isMatching(); /** * Return all available Operators for this Rule diff --git a/core/lib/Thelia/Coupon/Type/CouponAbstract.php b/core/lib/Thelia/Coupon/Type/CouponAbstract.php index a5e82c83e..79e0b760c 100644 --- a/core/lib/Thelia/Coupon/Type/CouponAbstract.php +++ b/core/lib/Thelia/Coupon/Type/CouponAbstract.php @@ -168,12 +168,9 @@ abstract class CouponAbstract implements CouponInterface * Return effects generated by the coupon * A negative value * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * * @return float Amount removed from the Total Checkout */ - public function getDiscount(CouponAdapterInterface $adapter) + public function getDiscount() { return $this->amount; } diff --git a/core/lib/Thelia/Coupon/Type/CouponInterface.php b/core/lib/Thelia/Coupon/Type/CouponInterface.php index 334520104..116995496 100644 --- a/core/lib/Thelia/Coupon/Type/CouponInterface.php +++ b/core/lib/Thelia/Coupon/Type/CouponInterface.php @@ -88,16 +88,13 @@ interface CouponInterface * A positive value * * Effects could also affect something else than the final Checkout price - * CouponAdapter could be use to directly pass a Session value + * CouponAdapter $adapter could be use to directly pass a Session value * some would wish to modify * Hence affecting a wide variety of Thelia elements * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * * @return float Amount removed from the Total Checkout */ - public function getDiscount(CouponAdapterInterface $adapter); + public function getDiscount(); /** * Return condition to validate the Coupon or not diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php index 5d1d14b63..6279c3536 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php @@ -92,14 +92,11 @@ class RemoveXPercent extends CouponAbstract * Return effects generated by the coupon * A negative value * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables - * * @throws \Thelia\Exception\MissingAdapterException * @throws \InvalidArgumentException * @return float */ - public function getDiscount(CouponAdapterInterface $adapter) + public function getDiscount() { if ($this->percent >= 100) { throw new \InvalidArgumentException( @@ -107,7 +104,7 @@ class RemoveXPercent extends CouponAbstract ); } - $basePrice = $adapter->getCartTotalPrice(); + $basePrice = $this->adapter->getCartTotalPrice(); return $basePrice * (( $this->percent ) / 100); } diff --git a/core/lib/Thelia/Tests/Constraint/ConstraintManagerTest.php b/core/lib/Thelia/Tests/Constraint/ConstraintManagerTest.php index 770746ba1..08389ef9e 100644 --- a/core/lib/Thelia/Tests/Constraint/ConstraintManagerTest.php +++ b/core/lib/Thelia/Tests/Constraint/ConstraintManagerTest.php @@ -56,36 +56,11 @@ class ConstraintManagerTest extends \PHPUnit_Framework_TestCase - /** - * Generate valid CouponRuleInterfaces - * - * @return array Array of CouponRuleInterface - */ - public static function generateValidRules() + public function incompleteTest() { - $rule1 = new AvailableForTotalAmount( - array( - AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( - Operators::SUPERIOR, - new PriceParam( - , 40.00, 'EUR' - ) - ) - ) + $this->markTestIncomplete( + 'This test has not been implemented yet.' ); - $rule2 = new AvailableForTotalAmount( - array( - AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( - Operators::INFERIOR, - new PriceParam( - , 400.00, 'EUR' - ) - ) - ) - ); - $rules = new CouponRuleCollection(array($rule1, $rule2)); - - return $rules; } /** @@ -95,48 +70,4 @@ class ConstraintManagerTest extends \PHPUnit_Framework_TestCase protected function tearDown() { } - - /** - * Generate a fake Adapter - * - * @param array $coupons Coupons - * @param float $cartTotalPrice Cart total price - * @param float $checkoutTotalPrice Checkout total price - * @param float $postagePrice Checkout postage price - * - * @return \PHPUnit_Framework_MockObject_MockObject - */ - public function generateFakeAdapter(array $coupons, $cartTotalPrice, $checkoutTotalPrice, $postagePrice = 6.00) - { - $stubCouponBaseAdapter = $this->getMock( - 'Thelia\Coupon\CouponBaseAdapter', - array( - 'getCurrentCoupons', - 'getCartTotalPrice', - 'getCheckoutTotalPrice', - 'getCheckoutPostagePrice' - ), - array() - ); - - $stubCouponBaseAdapter->expects($this->any()) - ->method('getCurrentCoupons') - ->will($this->returnValue(($coupons))); - - // Return Cart product amount = $cartTotalPrice euros - $stubCouponBaseAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue($cartTotalPrice)); - - // Return Checkout amount = $checkoutTotalPrice euros - $stubCouponBaseAdapter->expects($this->any()) - ->method('getCheckoutTotalPrice') - ->will($this->returnValue($checkoutTotalPrice)); - - $stubCouponBaseAdapter->expects($this->any()) - ->method('getCheckoutPostagePrice') - ->will($this->returnValue($postagePrice)); - - return $stubCouponBaseAdapter; - } } diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php index 05e507863..303970e90 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php @@ -50,6 +50,8 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); } /** @@ -62,11 +64,11 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase /** @var CouponAdapterInterface $stubTheliaAdapter */ $stubTheliaAdapter = $this->getMock( 'CouponBaseAdapter', - array('getCheckoutTotalPrice'), + array('getCartTotalPrice'), array() ); $stubTheliaAdapter->expects($this->any()) - ->method('getCheckoutTotalPrice') + ->method('getCartTotalPrice') ->will($this->returnValue(421.23)); return $stubTheliaAdapter; @@ -79,21 +81,20 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testValidBackOfficeInput() { - /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + $adapter = new CouponBaseAdapter(); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - , 421.23, 'EUR' + $adapter, 421.23, 'EUR' ) ) ); $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => $stubTheliaAdapter->getCheckoutTotalPrice() + AvailableForTotalAmount::PARAM1_PRICE => $adapter->getCartTotalPrice() ); - $rule = new AvailableForTotalAmount($validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators, $validated); $expected = true; $actual = $rule->checkBackOfficeInput(); @@ -108,22 +109,21 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testInValidBackOfficeInputOperator() { - /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + $adapter = new CouponBaseAdapter(); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( 'X', new PriceParam( - , 421.23, 'EUR' + $adapter, 421.23, 'EUR' ) ) ); $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => $stubTheliaAdapter->getCheckoutTotalPrice() + AvailableForTotalAmount::PARAM1_PRICE => $adapter->getCartTotalPrice() ); - $rule = new AvailableForTotalAmount($validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators, $validated); $expected = false; $actual = $rule->checkBackOfficeInput(); @@ -138,8 +138,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testInValidBackOfficeInputValue() { - /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + $adapter = new CouponBaseAdapter(); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( @@ -149,9 +148,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase ); $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => $stubTheliaAdapter->getCheckoutTotalPrice() + AvailableForTotalAmount::PARAM1_PRICE => $adapter->getCartTotalPrice() ); - $rule = new AvailableForTotalAmount($validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators, $validated); $expected = false; $actual = $rule->checkBackOfficeInput(); @@ -167,22 +166,21 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testValidCheckoutInput() { - /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + $adapter = new CouponBaseAdapter(); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - , 421.23, 'EUR' + $adapter, 421.23, 'EUR' ) ) ); $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => $stubTheliaAdapter->getCheckoutTotalPrice() + AvailableForTotalAmount::PARAM1_PRICE => $adapter->getCartTotalPrice() ); - $rule = new AvailableForTotalAmount($validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators, $validated); $expected = true; $actual = $rule->checkCheckoutInput(); @@ -197,11 +195,13 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testInValidCheckoutInputValue() { + $adapter = new CouponBaseAdapter(); + $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - , 421.23, 'EUR' + $adapter, 421.23, 'EUR' ) ) ); @@ -209,7 +209,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $validated = array( AvailableForTotalAmount::PARAM1_PRICE => 421 ); - $rule = new AvailableForTotalAmount($validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators, $validated); $expected = false; $actual = $rule->checkCheckoutInput(); @@ -224,11 +224,13 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testInValidCheckoutInputType() { + $adapter = new CouponBaseAdapter(); + $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - , 421.23, 'EUR' + $adapter, 421.23, 'EUR' ) ) ); @@ -236,7 +238,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $validated = array( AvailableForTotalAmount::PARAM1_PRICE => 421 ); - $rule = new AvailableForTotalAmount($validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators, $validated); $expected = false; $actual = $rule->checkCheckoutInput(); @@ -250,11 +252,13 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleInferior() { + $adapter = new CouponBaseAdapter(); + $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::INFERIOR, new PriceParam( - , 421.23, 'EUR' + $adapter, 421.23, 'EUR' ) ) ); @@ -262,7 +266,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $validated = array( AvailableForTotalAmount::PARAM1_PRICE => 421.22 ); - $rule = new AvailableForTotalAmount($validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators, $validated); $expected = true; $actual = $rule->isMatching(); @@ -276,11 +280,13 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleInferior() { + $adapter = new CouponBaseAdapter(); + $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::INFERIOR, new PriceParam( - , 421.23, 'EUR' + $adapter, 421.23, 'EUR' ) ) ); @@ -288,7 +294,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $validated = array( AvailableForTotalAmount::PARAM1_PRICE => 421.23 ); - $rule = new AvailableForTotalAmount($validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators, $validated); $expected = false; $actual = $rule->isMatching(); @@ -302,22 +308,21 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleEqual() { - /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + $adapter = new CouponBaseAdapter(); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::EQUAL, new PriceParam( - , 421.23, 'EUR' + $adapter, 421.23, 'EUR' ) ) ); $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => $stubTheliaAdapter->getCheckoutTotalPrice() + AvailableForTotalAmount::PARAM1_PRICE => $adapter->getCartTotalPrice() ); - $rule = new AvailableForTotalAmount($validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators, $validated); $expected = true; $actual = $rule->isMatching(); @@ -331,11 +336,13 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleEqual() { + $adapter = new CouponBaseAdapter(); + $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::EQUAL, new PriceParam( - , 421.23, 'EUR' + $adapter, 421.23, 'EUR' ) ) ); @@ -343,7 +350,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $validated = array( AvailableForTotalAmount::PARAM1_PRICE => 421.22 ); - $rule = new AvailableForTotalAmount($validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators, $validated); $expected = false; $actual = $rule->isMatching(); @@ -357,11 +364,13 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleSuperior() { + $adapter = new CouponBaseAdapter(); + $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - , 421.23, 'EUR' + $adapter, 421.23, 'EUR' ) ) ); @@ -369,7 +378,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $validated = array( AvailableForTotalAmount::PARAM1_PRICE => 421.24 ); - $rule = new AvailableForTotalAmount($validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators, $validated); $expected = true; $actual = $rule->isMatching(); @@ -383,11 +392,13 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleSuperior() { + $adapter = new CouponBaseAdapter(); + $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( - , 421.23, 'EUR' + $adapter, 421.23, 'EUR' ) ) ); @@ -395,7 +406,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $validated = array( AvailableForTotalAmount::PARAM1_PRICE => 421.23 ); - $rule = new AvailableForTotalAmount($validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators, $validated); $expected = false; $actual = $rule->isMatching(); diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php index 69bfd13a6..9c5808010 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php @@ -45,16 +45,23 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); } + /** + * Return an Adapter Mock wick 4 products int the Cart + * + * @return CouponAdapterInterface + */ protected function generateValidCouponBaseAdapterMock() { /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->getMock( - 'CouponBaseAdapter', - array('getNbArticlesInCart'), - array() - ); + $stubTheliaAdapter = $this->getMock( + 'CouponBaseAdapter', + array('getNbArticlesInCart'), + array() + ); $stubTheliaAdapter->expects($this->any()) ->method('getNbArticlesInCart') ->will($this->returnValue(4)); @@ -69,12 +76,11 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ public function testValidBackOfficeInput() { - /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + $adapter = new CouponBaseAdapter(); $validators = array(4); - $validated = array($stubTheliaAdapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($validators, $validated); + $validated = array($adapter->getNbArticlesInCart()); + $rule = new AvailableForXArticles($adapter, $validators, $validated); $expected = true; $actual = $rule->checkBackOfficeInput(); @@ -88,28 +94,27 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ public function testInValidBackOfficeInput() { - /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + $adapter = new CouponBaseAdapter(); $validators = array(4.5); - $validated = array($stubTheliaAdapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($validators, $validated); + $validated = array($adapter->getNbArticlesInCart()); + $rule = new AvailableForXArticles($adapter, $validators, $validated); $expected = false; $actual = $rule->checkBackOfficeInput(); $this->assertEquals($expected, $actual); $validators = array(-1); - $validated = array($stubTheliaAdapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($validators, $validated); + $validated = array($adapter->getNbArticlesInCart()); + $rule = new AvailableForXArticles($adapter, $validators, $validated); $expected = false; $actual = $rule->checkBackOfficeInput(); $this->assertEquals($expected, $actual); $validators = array('bad'); - $validated = array($stubTheliaAdapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($validators, $validated); + $validated = array($adapter->getNbArticlesInCart()); + $rule = new AvailableForXArticles($adapter, $validators, $validated); $expected = false; $actual = $rule->checkBackOfficeInput(); @@ -125,12 +130,10 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ public function testValidCheckoutInput() { - /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); - + $adapter = new CouponBaseAdapter(); $validators = array(4); - $validated = array($stubTheliaAdapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($validators, $validated); + $validated = array($adapter->getNbArticlesInCart()); + $rule = new AvailableForXArticles($adapter, $validators, $validated); $expected = true; $actual = $rule->checkCheckoutInput(); @@ -144,28 +147,26 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ public function testInValidCheckoutInput() { - /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); - + $adapter = new CouponBaseAdapter(); $validators = array(4.5); - $validated = array($stubTheliaAdapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($validators, $validated); + $validated = array($adapter->getNbArticlesInCart()); + $rule = new AvailableForXArticles($adapter, $validators, $validated); $expected = false; $actual = $rule->checkCheckoutInput(); $this->assertEquals($expected, $actual); $validators = array(-1); - $validated = array($stubTheliaAdapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($validators, $validated); + $validated = array($adapter->getNbArticlesInCart()); + $rule = new AvailableForXArticles($adapter, $validators, $validated); $expected = false; $actual = $rule->checkCheckoutInput(); $this->assertEquals($expected, $actual); $validators = array('bad'); - $validated = array($stubTheliaAdapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($validators, $validated); + $validated = array($adapter->getNbArticlesInCart()); + $rule = new AvailableForXArticles($adapter, $validators, $validated); $expected = false; $actual = $rule->checkCheckoutInput(); @@ -179,12 +180,10 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleEqual() { - /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); - + $adapter = new CouponBaseAdapter(); $validators = array(4); - $validated = array($stubTheliaAdapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($validators, $validated); + $validated = array($adapter->getNbArticlesInCart()); + $rule = new AvailableForXArticles($adapter, $validators, $validated); $expected = true; $actual = $rule->isMatching(); @@ -198,12 +197,10 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleSuperior() { - /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); - + $adapter = new CouponBaseAdapter(); $validators = array(5); - $validated = array($stubTheliaAdapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($validators, $validated); + $validated = array($adapter->getNbArticlesInCart()); + $rule = new AvailableForXArticles($adapter, $validators, $validated); $expected = true; $actual = $rule->isMatching(); @@ -217,12 +214,10 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRule() { - /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); - + $adapter = new CouponBaseAdapter(); $validators = array(3); - $validated = array($stubTheliaAdapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($validators, $validated); + $validated = array($adapter->getNbArticlesInCart()); + $rule = new AvailableForXArticles($adapter, $validators, $validated); $expected = false; $actual = $rule->isMatching(); diff --git a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php index 51d5d06f1..aecd303b2 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php @@ -55,10 +55,11 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase */ public function testOperatorInferiorValidBefore() { + $adapter = new CouponBaseAdapter(); // Given $a = 11; $operator = Operators::INFERIOR; - $b = new QuantityParam(, 12); + $b = new QuantityParam($adapter, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -75,9 +76,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorInferiorInvalidEquals() { // Given + $adapter = new CouponBaseAdapter(); $a = 12; $operator = Operators::INFERIOR; - $b = new QuantityParam(, 12); + $b = new QuantityParam($adapter, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -94,9 +96,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorInferiorInvalidAfter() { // Given + $adapter = new CouponBaseAdapter(); $a = 13; $operator = Operators::INFERIOR; - $b = new QuantityParam(, 12); + $b = new QuantityParam($adapter, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -113,9 +116,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorInferiorOrEqualValidEqual() { // Given + $adapter = new CouponBaseAdapter(); $a = 11; $operator = Operators::INFERIOR_OR_EQUAL; - $b = new QuantityParam(, 11); + $b = new QuantityParam($adapter, 11); // When $actual = Operators::isValid($a, $operator, $b); @@ -132,9 +136,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorInferiorOrEqualValidBefore() { // Given + $adapter = new CouponBaseAdapter(); $a = 10; $operator = Operators::INFERIOR_OR_EQUAL; - $b = new QuantityParam(, 11); + $b = new QuantityParam($adapter, 11); // When $actual = Operators::isValid($a, $operator, $b); @@ -151,9 +156,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorInferiorOrEqualInValidAfter() { // Given + $adapter = new CouponBaseAdapter(); $a = 12; $operator = Operators::INFERIOR_OR_EQUAL; - $b = new QuantityParam(, 11); + $b = new QuantityParam($adapter, 11); // When $actual = Operators::isValid($a, $operator, $b); @@ -170,9 +176,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorEqualValidEqual() { // Given + $adapter = new CouponBaseAdapter(); $a = 12; $operator = Operators::EQUAL; - $b = new QuantityParam(, 12); + $b = new QuantityParam($adapter, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -189,9 +196,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorEqualInValidBefore() { // Given + $adapter = new CouponBaseAdapter(); $a = 11; $operator = Operators::EQUAL; - $b = new QuantityParam(, 12); + $b = new QuantityParam($adapter, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -208,9 +216,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorEqualInValidAfter() { // Given + $adapter = new CouponBaseAdapter(); $a = 13; $operator = Operators::EQUAL; - $b = new QuantityParam(, 12); + $b = new QuantityParam($adapter, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -227,9 +236,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorSuperiorOrEqualValidEqual() { // Given + $adapter = new CouponBaseAdapter(); $a = 13; $operator = Operators::SUPERIOR_OR_EQUAL; - $b = new QuantityParam(, 13); + $b = new QuantityParam($adapter, 13); // When $actual = Operators::isValid($a, $operator, $b); @@ -246,9 +256,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorSuperiorOrEqualAfter() { // Given + $adapter = new CouponBaseAdapter(); $a = 14; $operator = Operators::SUPERIOR_OR_EQUAL; - $b = new QuantityParam(, 13); + $b = new QuantityParam($adapter, 13); // When $actual = Operators::isValid($a, $operator, $b); @@ -265,9 +276,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorSuperiorOrEqualInvalidBefore() { // Given + $adapter = new CouponBaseAdapter(); $a = 12; $operator = Operators::SUPERIOR_OR_EQUAL; - $b = new QuantityParam(, 13); + $b = new QuantityParam($adapter, 13); // When $actual = Operators::isValid($a, $operator, $b); @@ -284,9 +296,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorSuperiorValidAfter() { // Given + $adapter = new CouponBaseAdapter(); $a = 13; $operator = Operators::SUPERIOR; - $b = new QuantityParam(, 12); + $b = new QuantityParam($adapter, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -303,9 +316,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorSuperiorInvalidEqual() { // Given + $adapter = new CouponBaseAdapter(); $a = 12; $operator = Operators::SUPERIOR; - $b = new QuantityParam(, 12); + $b = new QuantityParam($adapter, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -322,9 +336,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorSuperiorInvalidBefore() { // Given + $adapter = new CouponBaseAdapter(); $a = 11; $operator = Operators::SUPERIOR; - $b = new QuantityParam(, 12); + $b = new QuantityParam($adapter, 12); // When $actual = Operators::isValid($a, $operator, $b); @@ -341,9 +356,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorDifferentValid() { // Given + $adapter = new CouponBaseAdapter(); $a = 12; $operator = Operators::DIFFERENT; - $b = new QuantityParam(, 11); + $b = new QuantityParam($adapter, 11); // When $actual = Operators::isValid($a, $operator, $b); @@ -360,9 +376,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorDifferentInvalidEquals() { // Given + $adapter = new CouponBaseAdapter(); $a = 11; $operator = Operators::DIFFERENT; - $b = new QuantityParam(, 11); + $b = new QuantityParam($adapter, 11); // When $actual = Operators::isValid($a, $operator, $b); @@ -379,9 +396,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase public function testOperatorInValid() { // Given + $adapter = new CouponBaseAdapter(); $a = 12; $operator = 'X'; - $b = new QuantityParam(, 11); + $b = new QuantityParam($adapter, 11); // When $actual = Operators::isValid($a, $operator, $b); diff --git a/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php index 9543388f6..bd83d45db 100644 --- a/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php @@ -24,6 +24,7 @@ namespace Thelia\Coupon; use InvalidArgumentException; +use Thelia\Constraint\Validator\PriceParam; use Thelia\Constraint\Validator\QuantityParam; /** @@ -173,7 +174,7 @@ class QuantityParamTest extends \PHPUnit_Framework_TestCase $this->assertEquals($param->getValue(), $unserialized->getValue()); $this->assertEquals($param->getInteger(), $unserialized->getInteger()); - $new = new PriceParam($adapter, $unserialized->getInteger()); + $new = new QuantityParam($adapter, $unserialized->getInteger()); $this->assertEquals($param->getInteger(), $new->getInteger()); } diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index f3cf99054..c4006be0d 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -204,7 +204,7 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase protected function generateValidRules() { $rule1 = new AvailableForTotalAmount( - array( + , array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( @@ -214,7 +214,7 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase ) ); $rule2 = new AvailableForTotalAmount( - array( + , array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::INFERIOR, new PriceParam( diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index 08673746e..9d171a021 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -110,7 +110,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua /** @var CouponInterface $coupon1 */ $coupon1 = self::generateValidCoupon(); $rule1 = new AvailableForTotalAmount( - array( + $adapter, array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( @@ -148,7 +148,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $checkoutTotalPrice = 26.00; $rule1 = new AvailableForTotalAmount( - array( + $adapter, array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( @@ -185,7 +185,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $checkoutTotalPrice = 27.00; $rule1 = new AvailableForTotalAmount( - array( + $adapter, array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( @@ -642,7 +642,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua { $adapter = new CouponBaseAdapter(); $rule1 = new AvailableForTotalAmount( - array( + $adapter, array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( @@ -652,7 +652,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua ) ); $rule2 = new AvailableForTotalAmount( - array( + $adapter, array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::INFERIOR, new PriceParam( diff --git a/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php b/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php index eab22758b..e1ad4ecdd 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php @@ -47,7 +47,7 @@ class CouponRuleCollectionTest extends \PHPUnit_Framework_TestCase public function testRuleSerialisation() { $rule1 = new AvailableForTotalAmount( - array( + , array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::SUPERIOR, new PriceParam( @@ -57,7 +57,7 @@ class CouponRuleCollectionTest extends \PHPUnit_Framework_TestCase ) ); $rule2 = new AvailableForTotalAmount( - array( + , array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( Operators::INFERIOR, new PriceParam( diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php index 65bf2e344..896cc5feb 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountForCategoryYTest.php @@ -45,6 +45,13 @@ class RemoveXAmountForCategoryYTest extends \PHPUnit_Framework_TestCase { } + public function incompleteTest() + { + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php index 69e01549f..182594666 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php @@ -151,7 +151,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); $expected = 10; - $actual = $coupon->getDiscount($adapter); + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -234,7 +234,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // Then $expected = 10.00; - $actual = $coupon->getDiscount($adapter); + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -259,7 +259,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // Then $expected = 10.00; - $actual = $coupon->getDiscount($adapter); + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -284,7 +284,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // Then $expected = 10.00; - $actual = $coupon->getDiscount($adapter); + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -309,7 +309,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // Then $expected = 10.00; - $actual = $coupon->getDiscount($adapter); + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -334,7 +334,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // Then $expected = 10.00; - $actual = $coupon->getDiscount($adapter); + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -371,7 +371,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase ) ); - return new AvailableForTotalAmount($validators); + return new AvailableForTotalAmount($adapter, $validators); } } diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php index 24388104d..1ea0c67bb 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php @@ -45,6 +45,13 @@ class RemoveXPercentForCategoryYTest extends \PHPUnit_Framework_TestCase { } + public function incompleteTest() + { + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php index 5b80ac1a3..67d09341c 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php @@ -63,7 +63,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase */ public function testIsCumulative() { - $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, true, true); + $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, true, true); $actual = $coupon->isCumulative(); $this->assertTrue($actual); @@ -77,7 +77,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase */ public function testIsNotCumulative() { - $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); $actual = $coupon->isCumulative(); $this->assertFalse($actual); @@ -92,7 +92,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase */ public function testIsRemovingPostage() { - $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, true, true); + $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, true, true); $actual = $coupon->isRemovingPostage(); $this->assertTrue($actual); @@ -105,7 +105,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase */ public function testIsNotRemovingPostage() { - $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); $actual = $coupon->isRemovingPostage(); $this->assertFalse($actual); @@ -120,7 +120,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase public function testGetEffect() { $adapter = $this->generateFakeAdapter(245); - $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); $expected = 24.50; $actual = $coupon->getDiscount($adapter); @@ -149,7 +149,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase 421.23 ); - $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When $coupon->setRules(new CouponRuleCollection(array($rule0, $rule1, $rule2))); @@ -179,7 +179,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase ); $rule2 = $this; - $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When $coupon->setRules(new CouponRuleCollection(array($rule0, $rule1, $rule2))); @@ -194,19 +194,18 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountInferiorTo400Valid() { // Given - $adapter = $this->generateFakeAdapter(245); $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::INFERIOR, 400.00 ); - $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When $coupon->setRules(new CouponRuleCollection(array($rule0))); // Then $expected = 24.50; - $actual = $coupon->getDiscount($adapter); + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -219,19 +218,18 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountInferiorOrEqualTo400Valid() { // Given - $adapter = $this->generateFakeAdapter(245); $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::INFERIOR_OR_EQUAL, 400.00 ); - $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When $coupon->setRules(new CouponRuleCollection(array($rule0))); // Then $expected = 24.50; - $actual = $coupon->getDiscount($adapter); + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -244,19 +242,18 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountEqualTo400Valid() { // Given - $adapter = $this->generateFakeAdapter(245); $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::EQUAL, 400.00 ); - $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When $coupon->setRules(new CouponRuleCollection(array($rule0))); // Then $expected = 24.50; - $actual = $coupon->getDiscount($adapter); + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -269,19 +266,18 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountSuperiorOrEqualTo400Valid() { // Given - $adapter = $this->generateFakeAdapter(245); $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::SUPERIOR_OR_EQUAL, 400.00 ); - $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When $coupon->setRules(new CouponRuleCollection(array($rule0))); // Then $expected = 24.50; - $actual = $coupon->getDiscount($adapter); + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -294,19 +290,18 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase public function testGetEffectIfTotalAmountSuperiorTo400Valid() { // Given - $adapter = $this->generateFakeAdapter(245); $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( Operators::SUPERIOR, 400.00 ); - $coupon = self::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); + $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // When $coupon->setRules(new CouponRuleCollection(array($rule0))); // Then $expected = 24.50; - $actual = $coupon->getDiscount($adapter); + $actual = $coupon->getDiscount(); $this->assertEquals($expected, $actual); } @@ -331,7 +326,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase * * @return CouponInterface */ - public static function generateValidCoupon( + public function generateValidCoupon( $code = null, $title = null, $shortDescription = null, @@ -345,7 +340,8 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase $isAvailableOnSpecialOffers = null, $maxUsage = null ) { - $adapter = new CouponBaseAdapter(); + $adapter = $this->generateFakeAdapter(245); + if ($code === null) { $code = CouponManagerTest::VALID_CODE; } @@ -417,7 +413,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase ) ); - return new AvailableForTotalAmount($validators); + return new AvailableForTotalAmount($adapter, $validators); } /** From f1ed03a96a81d5a051f0da9d44a204933ada8c26 Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 28 Aug 2013 09:35:56 +0200 Subject: [PATCH 038/268] WIP Coupon Refactor : creating dedicated reusable module for Constraints Adding ConstraintManager Secured : - Effects : RemoveXPercent + RemoveXAmount - Validators : all except ModelParam (need CustomerModelParam, AreaModelParam, CountryModelParam ?) - Conditions : AvailableForTotalAmount --- .gitignore | 2 ++ composer.lock | 91 ++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 71 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index cad92f7a8..d0a538143 100755 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ web/cache/* web/.htaccess phpdoc*.log php-cs +xhprof +phpunit.phar diff --git a/composer.lock b/composer.lock index d84eeb977..c10b85655 100755 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "458aeccc06b7394d7653a9063b6fd981", + "hash": "6f8ad7a37d85013a8c8f99611c0f1b84", "packages": [ { "name": "ezyang/htmlpurifier", @@ -11,12 +11,12 @@ "source": { "type": "git", "url": "https://github.com/ezyang/htmlpurifier.git", - "reference": "19eee1489965d9bc6eded80f847ced2382127261" + "reference": "fac747bdbdba6aeaba4bed91ef49b2378c1798e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/19eee1489965d9bc6eded80f847ced2382127261", - "reference": "19eee1489965d9bc6eded80f847ced2382127261", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/fac747bdbdba6aeaba4bed91ef49b2378c1798e4", + "reference": "fac747bdbdba6aeaba4bed91ef49b2378c1798e4", "shasum": "" }, "require": { @@ -47,7 +47,7 @@ "keywords": [ "html" ], - "time": "2013-07-27 04:54:53" + "time": "2013-08-18 02:27:26" }, { "name": "imagine/imagine", @@ -55,12 +55,12 @@ "source": { "type": "git", "url": "https://github.com/avalanche123/Imagine.git", - "reference": "v0.5.0" + "reference": "f64ec666baaa800edcbf237db41121a569230709" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/avalanche123/Imagine/zipball/v0.5.0", - "reference": "v0.5.0", + "url": "https://api.github.com/repos/avalanche123/Imagine/zipball/f64ec666baaa800edcbf237db41121a569230709", + "reference": "f64ec666baaa800edcbf237db41121a569230709", "shasum": "" }, "require": { @@ -128,7 +128,7 @@ "authors": [ { "name": "Anthony Ferrara", - "email": "ircmaxell@php.net", + "email": "ircmaxell@ircmaxell.com", "homepage": "http://blog.ircmaxell.com" } ], @@ -356,12 +356,12 @@ "source": { "type": "git", "url": "https://github.com/krichprollsch/phpCssEmbed.git", - "reference": "v1.0.2" + "reference": "406c6d5b846cafa9186f9944a6210d0e6fed154b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/krichprollsch/phpCssEmbed/zipball/v1.0.2", - "reference": "v1.0.2", + "url": "https://api.github.com/repos/krichprollsch/phpCssEmbed/zipball/406c6d5b846cafa9186f9944a6210d0e6fed154b", + "reference": "406c6d5b846cafa9186f9944a6210d0e6fed154b", "shasum": "" }, "require": { @@ -798,12 +798,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "v2.2.5" + "reference": "fa16b9ab446b84371a63ab391133ff58134edff1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/fa16b9ab446b84371a63ab391133ff58134edff1", + "reference": "fa16b9ab446b84371a63ab391133ff58134edff1", "shasum": "" }, "require": { @@ -1071,18 +1071,18 @@ "source": { "type": "git", "url": "https://github.com/symfony/Icu.git", - "reference": "v1.2.0" + "reference": "7299cd3d8d6602103d1ebff5d0a9917b7bc6de72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Icu/zipball/v1.2.0", - "reference": "v1.2.0", + "url": "https://api.github.com/repos/symfony/Icu/zipball/7299cd3d8d6602103d1ebff5d0a9917b7bc6de72", + "reference": "7299cd3d8d6602103d1ebff5d0a9917b7bc6de72", "shasum": "" }, "require": { "lib-icu": ">=4.4", "php": ">=5.3.3", - "symfony/intl": ">=2.3,<3.0" + "symfony/intl": "~2.3" }, "type": "library", "autoload": { @@ -1452,6 +1452,53 @@ "homepage": "http://symfony.com", "time": "2013-07-30 11:22:46" }, + { + "name": "symfony/serializer", + "version": "v2.2.5", + "target-dir": "Symfony/Component/Serializer", + "source": { + "type": "git", + "url": "https://github.com/symfony/Serializer.git", + "reference": "v2.2.5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Serializer/zipball/v2.2.5", + "reference": "v2.2.5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Serializer\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Serializer Component", + "homepage": "http://symfony.com", + "time": "2013-05-08 08:39:40" + }, { "name": "symfony/translation", "version": "v2.2.5", @@ -1459,12 +1506,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/Translation.git", - "reference": "v2.2.5" + "reference": "32a1531e6298c037041ec82be95600e258938218" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/Translation/zipball/32a1531e6298c037041ec82be95600e258938218", + "reference": "32a1531e6298c037041ec82be95600e258938218", "shasum": "" }, "require": { From 3696ce4a4b7546819eb0f3bc9696d73efce6f790 Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 28 Aug 2013 11:22:49 +0200 Subject: [PATCH 039/268] WIP All Unit Test are green --- .../Constraint/Rule/AvailableForXArticles.php | 16 +- .../Constraint/Rule/CouponRuleAbstract.php | 6 + .../Constraint/Validator/QuantityParam.php | 3 - .../Rule/AvailableForTotalAmountTest.php | 112 +++---- .../Rule/AvailableForXArticlesTest.php | 284 ++++++++++++++---- 5 files changed, 289 insertions(+), 132 deletions(-) diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php b/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php index 1a8e17da2..9de10b2bb 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php @@ -41,7 +41,7 @@ use Thelia\Exception\InvalidRuleValueException; */ class AvailableForXArticles extends CouponRuleAbstract { - /** Rule 1st parameter : price */ + /** Rule 1st parameter : quantity */ CONST PARAM1_QUANTITY = 'quantity'; /** @var array Available Operators (Operators::CONST) */ @@ -121,7 +121,7 @@ class AvailableForXArticles extends CouponRuleAbstract protected function setParametersToValidate() { $this->paramsToValidate = array( - self::PARAM1_QUANTITY => $this->adapter->getCartTotalPrice() + self::PARAM1_QUANTITY => $this->adapter->getNbArticlesInCart() ); return $this; @@ -130,11 +130,21 @@ class AvailableForXArticles extends CouponRuleAbstract /** * Check if Checkout inputs are relevant or not * + * @throws \Thelia\Exception\InvalidRuleValueException * @return bool */ public function checkCheckoutInput() { - // TODO: Implement checkCheckoutInput() method. + if (!isset($this->paramsToValidate) + || empty($this->paramsToValidate) + ||!isset($this->paramsToValidate[self::PARAM1_QUANTITY]) + ) { + throw new InvalidRuleValueException(get_class(), self::PARAM1_QUANTITY); + } + + $price = $this->paramsToValidate[self::PARAM1_QUANTITY]; + + return $this->isQuantityValid($price); } /** diff --git a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php b/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php index d7a966a13..ff97ee3a0 100644 --- a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php +++ b/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php @@ -100,6 +100,12 @@ abstract class CouponRuleAbstract implements CouponRuleInterface if (!$validator instanceof RuleValidator) { throw new InvalidRuleException(get_class()); } + if (!in_array($validator->getOperator(), $this->availableOperators)) { + throw new InvalidRuleOperatorException( + get_class(), + $validator->getOperator() + ); + } } $this->validators = $validators; diff --git a/core/lib/Thelia/Constraint/Validator/QuantityParam.php b/core/lib/Thelia/Constraint/Validator/QuantityParam.php index 5d5132e5b..ac6fcf851 100644 --- a/core/lib/Thelia/Constraint/Validator/QuantityParam.php +++ b/core/lib/Thelia/Constraint/Validator/QuantityParam.php @@ -47,9 +47,6 @@ class QuantityParam extends IntegerParam */ public function __construct(CouponAdapterInterface $adapter, $integer) { - if ($integer < 0) { - $integer = 0; - } $this->integer = $integer; $this->adapter = $adapter; } diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php index 303970e90..f13e59238 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php @@ -43,6 +43,8 @@ use Thelia\Exception\InvalidRuleValueException; */ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase { + /** @var CouponAdapterInterface $stubTheliaAdapter */ + protected $stubTheliaAdapter = null; /** * Sets up the fixture, for example, opens a network connection. @@ -51,30 +53,33 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase protected function setUp() { /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + $this->stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); } /** * Generate valid CouponBaseAdapter * + * @param float $cartTotalPrice Total amount of the current Cart + * * @return CouponAdapterInterface */ - protected function generateValidCouponBaseAdapterMock() + protected function generateValidCouponBaseAdapterMock($cartTotalPrice = 421.23) { /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->getMock( - 'CouponBaseAdapter', - array('getCartTotalPrice'), - array() - ); + $stubTheliaAdapter = $this->getMock( + 'Thelia\Coupon\CouponBaseAdapter', + array('getCartTotalPrice'), + array() + ); $stubTheliaAdapter->expects($this->any()) ->method('getCartTotalPrice') - ->will($this->returnValue(421.23)); + ->will($this->returnValue($cartTotalPrice)); return $stubTheliaAdapter; } /** + * Check if validity test on BackOffice inputs are working * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput * @@ -91,10 +96,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase ) ) ); - $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => $adapter->getCartTotalPrice() - ); - $rule = new AvailableForTotalAmount($adapter, $validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators); $expected = true; $actual = $rule->checkBackOfficeInput(); @@ -102,6 +104,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase } /** + * Check if validity test on BackOffice inputs are working * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput * @expectedException \Thelia\Exception\InvalidRuleOperatorException @@ -120,10 +123,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase ) ); - $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => $adapter->getCartTotalPrice() - ); - $rule = new AvailableForTotalAmount($adapter, $validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators); $expected = false; $actual = $rule->checkBackOfficeInput(); @@ -131,6 +131,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase } /** + * Check if validity test on BackOffice inputs are working * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput * @expectedException \ErrorException @@ -138,7 +139,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testInValidBackOfficeInputValue() { - $adapter = new CouponBaseAdapter(); + $adapter = $this->generateValidCouponBaseAdapterMock(); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( @@ -147,10 +148,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase ) ); - $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => $adapter->getCartTotalPrice() - ); - $rule = new AvailableForTotalAmount($adapter, $validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators); $expected = false; $actual = $rule->checkBackOfficeInput(); @@ -160,13 +158,14 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase /** + * Check if validity test on FrontOffice inputs are working * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkCheckoutInput * */ public function testValidCheckoutInput() { - $adapter = new CouponBaseAdapter(); + $adapter = $this->stubTheliaAdapter; $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( @@ -177,10 +176,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase ) ); - $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => $adapter->getCartTotalPrice() - ); - $rule = new AvailableForTotalAmount($adapter, $validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators); $expected = true; $actual = $rule->checkCheckoutInput(); @@ -188,6 +184,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase } /** + * Check if validity test on FrontOffice inputs are working * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkCheckoutInput * @expectedException \Thelia\Exception\InvalidRuleValueException @@ -195,7 +192,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testInValidCheckoutInputValue() { - $adapter = new CouponBaseAdapter(); + $adapter = $this->generateValidCouponBaseAdapterMock(421); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( @@ -206,10 +203,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase ) ); - $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => 421 - ); - $rule = new AvailableForTotalAmount($adapter, $validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators); $expected = false; $actual = $rule->checkCheckoutInput(); @@ -217,6 +211,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase } /** + * Check if validity test on FrontOffice inputs are working * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkCheckoutInput * @expectedException \Thelia\Exception\InvalidRuleValueException @@ -224,7 +219,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ public function testInValidCheckoutInputType() { - $adapter = new CouponBaseAdapter(); + $adapter = $this->generateValidCouponBaseAdapterMock(421); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( @@ -235,10 +230,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase ) ); - $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => 421 - ); - $rule = new AvailableForTotalAmount($adapter, $validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators); $expected = false; $actual = $rule->checkCheckoutInput(); @@ -246,13 +238,14 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase } /** + * Check if test inferior operator is working * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::isMatching * */ public function testMatchingRuleInferior() { - $adapter = new CouponBaseAdapter(); + $adapter = $this->generateValidCouponBaseAdapterMock(421.22); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( @@ -263,10 +256,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase ) ); - $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => 421.22 - ); - $rule = new AvailableForTotalAmount($adapter, $validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators); $expected = true; $actual = $rule->isMatching(); @@ -274,13 +264,14 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase } /** + * Check if test inferior operator is working * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::isMatching * */ public function testNotMatchingRuleInferior() { - $adapter = new CouponBaseAdapter(); + $adapter = $this->generateValidCouponBaseAdapterMock(421.23); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( @@ -291,10 +282,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase ) ); - $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => 421.23 - ); - $rule = new AvailableForTotalAmount($adapter, $validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators); $expected = false; $actual = $rule->isMatching(); @@ -302,13 +290,14 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase } /** + * Check if test equals operator is working * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::isMatching * */ public function testMatchingRuleEqual() { - $adapter = new CouponBaseAdapter(); + $adapter = $this->stubTheliaAdapter; $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( @@ -319,10 +308,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase ) ); - $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => $adapter->getCartTotalPrice() - ); - $rule = new AvailableForTotalAmount($adapter, $validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators); $expected = true; $actual = $rule->isMatching(); @@ -330,13 +316,14 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase } /** + * Check if test equals operator is working * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::isMatching * */ public function testNotMatchingRuleEqual() { - $adapter = new CouponBaseAdapter(); + $adapter = $this->generateValidCouponBaseAdapterMock(421.22); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( @@ -347,10 +334,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase ) ); - $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => 421.22 - ); - $rule = new AvailableForTotalAmount($adapter, $validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators); $expected = false; $actual = $rule->isMatching(); @@ -358,13 +342,14 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase } /** + * Check if test superior operator is working * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::isMatching * */ public function testMatchingRuleSuperior() { - $adapter = new CouponBaseAdapter(); + $adapter = $this->generateValidCouponBaseAdapterMock(421.24); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( @@ -375,10 +360,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase ) ); - $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => 421.24 - ); - $rule = new AvailableForTotalAmount($adapter, $validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators); $expected = true; $actual = $rule->isMatching(); @@ -386,13 +368,14 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase } /** + * Check if test superior operator is working * * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::isMatching * */ public function testNotMatchingRuleSuperior() { - $adapter = new CouponBaseAdapter(); + $adapter = $this->generateValidCouponBaseAdapterMock(421.23); $validators = array( AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( @@ -403,10 +386,7 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase ) ); - $validated = array( - AvailableForTotalAmount::PARAM1_PRICE => 421.23 - ); - $rule = new AvailableForTotalAmount($adapter, $validators, $validated); + $rule = new AvailableForTotalAmount($adapter, $validators); $expected = false; $actual = $rule->isMatching(); diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php index 9c5808010..6b024ed9e 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php @@ -24,6 +24,10 @@ namespace Thelia\Coupon; use Thelia\Constraint\Rule\AvailableForXArticles; +use Thelia\Constraint\Rule\Operators; +use Thelia\Constraint\Validator\QuantityParam; +use Thelia\Constraint\Validator\RuleValidator; +use Thelia\Exception\InvalidRuleOperatorException; /** * Created by JetBrains PhpStorm. @@ -39,6 +43,9 @@ use Thelia\Constraint\Rule\AvailableForXArticles; class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase { + /** @var CouponAdapterInterface $stubTheliaAdapter */ + protected $stubTheliaAdapter = null; + /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -46,41 +53,51 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase protected function setUp() { /** @var CouponAdapterInterface $stubTheliaAdapter */ - $stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + $this->stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); } /** - * Return an Adapter Mock wick 4 products int the Cart + * Generate valid CouponBaseAdapter + * + * @param int $nbArticlesInCart Total articles in the current Cart * * @return CouponAdapterInterface */ - protected function generateValidCouponBaseAdapterMock() + protected function generateValidCouponBaseAdapterMock($nbArticlesInCart = 4) { /** @var CouponAdapterInterface $stubTheliaAdapter */ $stubTheliaAdapter = $this->getMock( - 'CouponBaseAdapter', + 'Thelia\Coupon\CouponBaseAdapter', array('getNbArticlesInCart'), array() ); $stubTheliaAdapter->expects($this->any()) ->method('getNbArticlesInCart') - ->will($this->returnValue(4)); + ->will($this->returnValue($nbArticlesInCart)); return $stubTheliaAdapter; } /** + * Check if validity test on BackOffice inputs are working * * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput * */ public function testValidBackOfficeInput() { - $adapter = new CouponBaseAdapter(); + $adapter = $this->stubTheliaAdapter; - $validators = array(4); - $validated = array($adapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($adapter, $validators, $validated); + $validators = array( + AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( + Operators::SUPERIOR, + new QuantityParam( + $adapter, + 4 + ) + ) + ); + $rule = new AvailableForXArticles($adapter, $validators); $expected = true; $actual = $rule->checkBackOfficeInput(); @@ -88,33 +105,77 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase } /** + * Check if validity test on BackOffice inputs are working * * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput - * + * @expectedException \Thelia\Exception\InvalidRuleValueException */ - public function testInValidBackOfficeInput() + public function testInValidBackOfficeInputFloat() { - $adapter = new CouponBaseAdapter(); + $adapter = $this->stubTheliaAdapter; - $validators = array(4.5); - $validated = array($adapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($adapter, $validators, $validated); + $validators = array( + AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( + Operators::SUPERIOR, + new QuantityParam( + $adapter, + 4.5 + ) + ) + ); + $rule = new AvailableForXArticles($adapter, $validators); $expected = false; $actual = $rule->checkBackOfficeInput(); $this->assertEquals($expected, $actual); + } - $validators = array(-1); - $validated = array($adapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($adapter, $validators, $validated); + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput + * @expectedException \Thelia\Exception\InvalidRuleValueException + */ + public function testInValidBackOfficeInputNegative() + { + $adapter = $this->stubTheliaAdapter; + + $validators = array( + AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( + Operators::SUPERIOR, + new QuantityParam( + $adapter, + -1 + ) + ) + ); + $rule = new AvailableForXArticles($adapter, $validators); $expected = false; $actual = $rule->checkBackOfficeInput(); $this->assertEquals($expected, $actual); + } - $validators = array('bad'); - $validated = array($adapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($adapter, $validators, $validated); + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput + * @expectedException \Thelia\Exception\InvalidRuleValueException + */ + public function testInValidBackOfficeInputString() + { + $adapter = $this->stubTheliaAdapter; + + $validators = array( + AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( + Operators::SUPERIOR, + new QuantityParam( + $adapter, + 'bad' + ) + ) + ); + $rule = new AvailableForXArticles($adapter, $validators); $expected = false; $actual = $rule->checkBackOfficeInput(); @@ -123,17 +184,26 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase + + /** + * Check if validity test on FrontOffice inputs are working * * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkCheckoutInput - * */ public function testValidCheckoutInput() { - $adapter = new CouponBaseAdapter(); - $validators = array(4); - $validated = array($adapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($adapter, $validators, $validated); + $adapter = $this->stubTheliaAdapter; + $validators = array( + AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( + Operators::SUPERIOR, + new QuantityParam( + $adapter, + 4 + ) + ) + ); + $rule = new AvailableForXArticles($adapter, $validators); $expected = true; $actual = $rule->checkCheckoutInput(); @@ -141,32 +211,24 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase } /** + * Check if validity test on FrontOffice inputs are working * * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkCheckoutInput - * + * @expectedException \Thelia\Exception\InvalidRuleValueException */ - public function testInValidCheckoutInput() + public function testInValidCheckoutInputFloat() { - $adapter = new CouponBaseAdapter(); - $validators = array(4.5); - $validated = array($adapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($adapter, $validators, $validated); - - $expected = false; - $actual = $rule->checkCheckoutInput(); - $this->assertEquals($expected, $actual); - - $validators = array(-1); - $validated = array($adapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($adapter, $validators, $validated); - - $expected = false; - $actual = $rule->checkCheckoutInput(); - $this->assertEquals($expected, $actual); - - $validators = array('bad'); - $validated = array($adapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($adapter, $validators, $validated); + $adapter = $this->generateValidCouponBaseAdapterMock(4.5); + $validators = array( + AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( + Operators::SUPERIOR, + new QuantityParam( + $adapter, + 4 + ) + ) + ); + $rule = new AvailableForXArticles($adapter, $validators); $expected = false; $actual = $rule->checkCheckoutInput(); @@ -174,16 +236,101 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase } /** + * Check if validity test on FrontOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkCheckoutInput + * @expectedException \Thelia\Exception\InvalidRuleValueException + */ + public function testInValidCheckoutInputNegative() + { + $adapter = $this->generateValidCouponBaseAdapterMock(-1); + + $validators = array( + AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( + Operators::SUPERIOR, + new QuantityParam( + $adapter, + 4 + ) + ) + ); + $rule = new AvailableForXArticles($adapter, $validators); + + $expected = false; + $actual = $rule->checkCheckoutInput(); + $this->assertEquals($expected, $actual); + } + + /** + * Check if validity test on FrontOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkCheckoutInput + * @expectedException \Thelia\Exception\InvalidRuleValueException + */ + public function testInValidCheckoutInputString() + { + $adapter = $this->generateValidCouponBaseAdapterMock('bad'); + + $validators = array( + AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( + Operators::SUPERIOR, + new QuantityParam( + $adapter, + 4 + ) + ) + ); + $rule = new AvailableForXArticles($adapter, $validators); + + $expected = false; + $actual = $rule->checkCheckoutInput(); + $this->assertEquals($expected, $actual); + } + + /** + * Check if test inferior operator is working + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::isMatching + * + */ + public function testMatchingRuleInferior() + { + $adapter = $this->stubTheliaAdapter; + $validators = array( + AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( + Operators::INFERIOR, + new QuantityParam( + $adapter, + 5 + ) + ) + ); + $rule = new AvailableForXArticles($adapter, $validators); + + $expected = true; + $actual = $rule->isMatching(); + $this->assertEquals($expected, $actual); + } + + /** + * Check if test equals operator is working * * @covers Thelia\Coupon\Rule\AvailableForXArticles::isMatching * */ public function testMatchingRuleEqual() { - $adapter = new CouponBaseAdapter(); - $validators = array(4); - $validated = array($adapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($adapter, $validators, $validated); + $adapter = $this->stubTheliaAdapter; + $validators = array( + AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( + Operators::EQUAL, + new QuantityParam( + $adapter, + 4 + ) + ) + ); + $rule = new AvailableForXArticles($adapter, $validators); $expected = true; $actual = $rule->isMatching(); @@ -191,16 +338,24 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase } /** + * Check if test superior operator is working * * @covers Thelia\Coupon\Rule\AvailableForXArticles::isMatching * */ public function testMatchingRuleSuperior() { - $adapter = new CouponBaseAdapter(); - $validators = array(5); - $validated = array($adapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($adapter, $validators, $validated); + $adapter = $this->stubTheliaAdapter; + $validators = array( + AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( + Operators::SUPERIOR, + new QuantityParam( + $adapter, + 3 + ) + ) + ); + $rule = new AvailableForXArticles($adapter, $validators); $expected = true; $actual = $rule->isMatching(); @@ -208,16 +363,25 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase } /** + * Check if test unavailable operator is working * * @covers Thelia\Coupon\Rule\AvailableForXArticles::isMatching + * @expectedException \Thelia\Exception\InvalidRuleOperatorException * */ public function testNotMatchingRule() { - $adapter = new CouponBaseAdapter(); - $validators = array(3); - $validated = array($adapter->getNbArticlesInCart()); - $rule = new AvailableForXArticles($adapter, $validators, $validated); + $adapter = $this->stubTheliaAdapter; + $validators = array( + AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( + Operators::DIFFERENT, + new QuantityParam( + $adapter, + 3 + ) + ) + ); + $rule = new AvailableForXArticles($adapter, $validators); $expected = false; $actual = $rule->isMatching(); From 07849aa614b7daeba4fbc120cef1d588b06eb3d3 Mon Sep 17 00:00:00 2001 From: franck Date: Wed, 28 Aug 2013 14:23:50 +0200 Subject: [PATCH 040/268] Added command for creating admin users on console --- core/lib/Thelia/Command/ClearImageCache.php | 1 - core/lib/Thelia/Command/CreateAdminUser.php | 119 ++++++++++++++++++++ core/lib/Thelia/Config/Resources/config.xml | 1 + core/lib/Thelia/Model/Admin.php | 2 +- core/lib/Thelia/Model/Category.php | 2 +- 5 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 core/lib/Thelia/Command/CreateAdminUser.php diff --git a/core/lib/Thelia/Command/ClearImageCache.php b/core/lib/Thelia/Command/ClearImageCache.php index 8f11770a3..babbdd619 100755 --- a/core/lib/Thelia/Command/ClearImageCache.php +++ b/core/lib/Thelia/Command/ClearImageCache.php @@ -24,7 +24,6 @@ namespace Thelia\Command; use Thelia\Command\ContainerAwareCommand; -use Thelia\Core\Event\TheliaEvents; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/core/lib/Thelia/Command/CreateAdminUser.php b/core/lib/Thelia/Command/CreateAdminUser.php new file mode 100644 index 000000000..dc7118399 --- /dev/null +++ b/core/lib/Thelia/Command/CreateAdminUser.php @@ -0,0 +1,119 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Command; + +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +use Thelia\Command\ContainerAwareCommand; +use Thelia\Model\Admin; + +class CreateAdminUser extends ContainerAwareCommand +{ + /** + * Configure the command + */ + protected function configure() + { + $this + ->setName("thelia:create-admin") + ->setDescription("Create a new adminsitration user") + ->setHelp("The thelia:create-admin command create a new administration user.") + ; + + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $output->writeln('Please enter the admin user information:'); + + $admin = $this->getAdminInfo($input, $output); // new Admin(); + + $admin->save(); + + $output->writeln(array( + "", + "User ".$admin->getLogin()." successfully created.", + "" + )); + } + + protected function enterData($dialog, $output, $label, $error_message) + { + return $dialog->askAndValidate( + $output, + $this->decorateInfo($label), + function ($answer) { + $answer = trim($answer); + if (empty($answer)) { + throw new \RuntimeException("This information is mandatory."); + } + + return $answer; + } + ); + } + + /** + * Ask to user all needed information + * + * @param InputInterface $input + * @param OutputInterface $output + * @return array + */ + protected function getAdminInfo(InputInterface $input, OutputInterface $output) + { + $dialog = $this->getHelperSet()->get('dialog'); + + $admin = new Admin(); + + $admin->setLogin($this->enterData($dialog, $output, "Admin login name : ", "Please enter a login name.")); + $admin->setFirstname($this->enterData($dialog, $output, "User first name : ", "Please enter user first name.")); + $admin->setLastname($this->enterData($dialog, $output, "User last name : ", "Please enter user last name.")); + + do { + $password = $this->enterData($dialog, $output, "Password : ", "Please enter a password."); + $password_again = $this->enterData($dialog, $output, "Password (again): ", "Please enter the password again."); + + if (! empty($password) && $password == $password_again) { + + $admin->setPassword($password); + + break; + } + + $output->writeln("Passwords are different, please try again."); + } + while (true); + + return $admin; + } + + protected function decorateInfo($text) + { + return sprintf("%s", $text); + } + +} diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 39d8bc905..a0d8db77b 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -54,6 +54,7 @@ + diff --git a/core/lib/Thelia/Model/Admin.php b/core/lib/Thelia/Model/Admin.php index 34dc7fbfd..a6deb7e60 100755 --- a/core/lib/Thelia/Model/Admin.php +++ b/core/lib/Thelia/Model/Admin.php @@ -26,7 +26,7 @@ class Admin extends BaseAdmin implements UserInterface \Thelia\Log\Tlog::getInstance()->debug($password); if ($this->isNew() && ($password === null || trim($password) == "")) { - throw new InvalidArgumentException("customer password is mandatory on creation"); + throw new \InvalidArgumentException("customer password is mandatory on creation"); } if($password !== null && trim($password) != "") { diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php index 35ac49e0e..a2ad5e52a 100755 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -16,8 +16,8 @@ class Category extends BaseCategory { public function getUrl() { - } + /** * Create a new category. * From 8b6cbb06214139500e4ce0492af094460eaf820f Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 28 Aug 2013 14:37:29 +0200 Subject: [PATCH 041/268] WIP - Beginning BackOffice Coupon implementation --- core/lib/Thelia/Action/Coupon.php | 79 +++++++ .../Thelia/Config/Resources/routing/admin.xml | 5 + .../Constraint/Rule/AvailableForCustomer.php | 203 ++++++++++++++++++ .../Constraint/Rule/AvailableForXArticles.php | 2 +- .../Constraint/Validator/CustomerParam.php | 158 ++++++++++++++ .../Controller/Admin/CouponController.php | 100 +++++++++ templates/default/coupon.html | 5 + 7 files changed, 551 insertions(+), 1 deletion(-) create mode 100755 core/lib/Thelia/Action/Coupon.php create mode 100644 core/lib/Thelia/Constraint/Rule/AvailableForCustomer.php create mode 100644 core/lib/Thelia/Constraint/Validator/CustomerParam.php create mode 100755 core/lib/Thelia/Controller/Admin/CouponController.php create mode 100755 templates/default/coupon.html diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php new file mode 100755 index 000000000..7b95d80fa --- /dev/null +++ b/core/lib/Thelia/Action/Coupon.php @@ -0,0 +1,79 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\ActionEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Model\Category as CategoryModel; +use Thelia\Form\CategoryCreationForm; +use Thelia\Core\Event\CategoryEvent; +use Thelia\Tools\Redirect; +use Thelia\Model\CategoryQuery; +use Thelia\Model\AdminLog; +use Thelia\Form\CategoryDeletionForm; +use Thelia\Action\Exception\FormValidationException; + +use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Propel; +use Thelia\Model\Map\CategoryTableMap; +use Propel\Runtime\Exception\PropelException; + +class Coupon extends BaseAction implements EventSubscriberInterface +{ + + /** + * Returns an array of event names this subscriber listens to. + * + * The array keys are event names and the value can be: + * + * * The method name to call (priority defaults to 0) + * * An array composed of the method name to call and the priority + * * An array of arrays composed of the method names to call and respective + * priorities, or 0 if unset + * + * For instance: + * + * * array('eventName' => 'methodName') + * * array('eventName' => array('methodName', $priority)) + * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) + * + * @return array The event names to listen to + * + * @api + */ + public static function getSubscribedEvents() + { + return array( +// "action.createCategory" => array("create", 128), +// "action.modifyCategory" => array("modify", 128), +// "action.deleteCategory" => array("delete", 128), +// +// "action.toggleCategoryVisibility" => array("toggleVisibility", 128), +// "action.changeCategoryPositionUp" => array("changePositionUp", 128), +// "action.changeCategoryPositionDown" => array("changePositionDown", 128), +// "action.changeCategoryPosition" => array("changePosition", 128), + ); + } +} diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index ece222c22..df1495953 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -35,6 +35,11 @@ Thelia\Controller\Admin\CategoryController::processAction + + + Thelia\Controller\Admin\CouponController::indexAction + + diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForCustomer.php b/core/lib/Thelia/Constraint/Rule/AvailableForCustomer.php new file mode 100644 index 000000000..299736d89 --- /dev/null +++ b/core/lib/Thelia/Constraint/Rule/AvailableForCustomer.php @@ -0,0 +1,203 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Constraint\Rule; + +use Thelia\Constraint\Validator\CustomerParam; +use Thelia\Constraint\Validator\RuleValidator; +use Thelia\Coupon\CouponAdapterInterface; +use Thelia\Exception\InvalidRuleException; +use Thelia\Exception\InvalidRuleOperatorException; +use Thelia\Exception\InvalidRuleValueException; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * @package Constraint + * @author Guillaume MOREL + * + */ +class AvailableForCustomer extends CouponRuleAbstract +{ + + /** Rule 1st parameter : customer id */ + CONST PARAM1 = 'customerId'; + + /** @var array Available Operators (Operators::CONST) */ + protected $availableOperators = array( + Operators::EQUAL, + ); + + /** @var RuleValidator Customer Validator */ + protected $customerValidator = null; + + /** + * Constructor + * + * @param CouponAdapterInterface $adapter allowing to gather + * all necessary Thelia variables + * @param array $validators Array of RuleValidator + * validating $paramsToValidate against + * + * @throws InvalidRuleException + */ + public function __construct(CouponAdapterInterface $adapter, array $validators) + { + parent::__construct($adapter, $validators); + + if (isset($validators[self::PARAM1]) + && $validators[self::PARAM1] instanceof RuleValidator + ) { + $this->customerValidator = $validators[self::PARAM1]; + } else { + throw new InvalidRuleException(get_class()); + } + + $this->adapter = $adapter; + } + + /** + * Check if backoffice inputs are relevant or not + * + * @throws InvalidRuleOperatorException if Operator is not allowed + * @throws InvalidRuleValueException if Value is not allowed + * @return bool + */ + public function checkBackOfficeInput() + { + if (!isset($this->validators) + || empty($this->validators) + ||!isset($this->validators[self::PARAM1]) + ||!isset($this->validators[self::PARAM1]) + ) { + throw new InvalidRuleValueException(get_class(), self::PARAM1); + } + + /** @var RuleValidator $ruleValidator */ + $ruleValidator = $this->validators[self::PARAM1]; + /** @var CustomerParam $customer */ + $customer = $ruleValidator->getParam(); + + if (!$customer instanceof CustomerParam) { + throw new InvalidRuleValueException(get_class(), self::PARAM1); + } + + $this->checkBackOfficeInputsOperators(); + + return $this->isCustomerValid($customer->getInteger()); + } + + /** + * Generate current Rule param to be validated from adapter + * + * @return $this + */ + protected function setParametersToValidate() + { + $this->paramsToValidate = array( + self::PARAM1 => $this->adapter->getCustomer()->getId() + ); + + return $this; + } + + /** + * Check if Checkout inputs are relevant or not + * + * @throws \Thelia\Exception\InvalidRuleValueException + * @return bool + */ + public function checkCheckoutInput() + { + if (!isset($this->paramsToValidate) + || empty($this->paramsToValidate) + ||!isset($this->paramsToValidate[self::PARAM1]) + ) { + throw new InvalidRuleValueException(get_class(), self::PARAM1); + } + + $customerId = $this->paramsToValidate[self::PARAM1]; + + return $this->isCustomerValid($customerId); + } + + /** + * Check if a Customer is valid + * + * @param int $customerId Customer to check + * + * @throws InvalidRuleValueException if Value is not allowed + * @return bool + */ + protected function isCustomerValid($customerId) + { + $customerValidator = $this->customerValidator; + try { + $customerValidator->getParam()->compareTo($customerId); + } catch(\InvalidArgumentException $e) { + throw new InvalidRuleValueException(get_class(), self::PARAM1); + } + + return true; + } + + /** + * Get I18n name + * + * @return string + */ + public function getName() + { + return $this->adapter + ->getTranslator() + ->trans('Customer', null, 'constraint'); + } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + /** @var CustomerParam $param */ + $param = $this->customerValidator->getParam(); + $toolTip = $this->adapter + ->getTranslator() + ->trans( + 'If customer is %fistname% %lastname% (%email%)', + array( + '%fistname%' => $param->getFirstName(), + '%lastname%' => $param->getLastName(), + '%email%' => $param->getEmail(), + ), + 'constraint' + ); + + return $toolTip; + } + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php b/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php index 9de10b2bb..d103f4f23 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForXArticles.php @@ -150,7 +150,7 @@ class AvailableForXArticles extends CouponRuleAbstract /** * Check if a quantity is valid * - * @param float $quantity Quantity to check + * @param int $quantity Quantity to check * * @throws InvalidRuleValueException if Value is not allowed * @return bool diff --git a/core/lib/Thelia/Constraint/Validator/CustomerParam.php b/core/lib/Thelia/Constraint/Validator/CustomerParam.php new file mode 100644 index 000000000..5b4390ddc --- /dev/null +++ b/core/lib/Thelia/Constraint/Validator/CustomerParam.php @@ -0,0 +1,158 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Constraint\Validator; + +use InvalidArgumentException; +use Propel\Runtime\ActiveQuery\ModelCriteria; +use Thelia\Coupon\CouponAdapterInterface; +use Thelia\Model\Customer; +use Thelia\Model\CustomerQuery; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Represent a Customer + * + * @package Constraint + * @author Guillaume MOREL + * + */ +class CustomerParam extends IntegerParam +{ + /** @var string Model Class name */ + protected $modelClass = '\Thelia\Model\Customer'; + + /** @var ModelCriteria */ + protected $queryBuilder = null; + + /** @var string Customer firstname */ + protected $firstName = null; + + /** @var string Customer lastname */ + protected $lastName = null; + + /** @var string Customer email */ + protected $email = null; + + /** + * Constructor + * + * @param CouponAdapterInterface $adapter Provide necessary value from Thelia + * @param int $integer Integer + * + * @throws InvalidArgumentException + */ + public function __construct(CouponAdapterInterface $adapter, $integer) + { + $this->integer = $integer; + $this->adapter = $adapter; + + $this->queryBuilder = CustomerQuery::create(); + /** @var Customer $customer */ + $customer = $this->queryBuilder->findById($integer); + if ($customer !== null) { + $this->firstName = $customer->getFirstname(); + $this->lastName = $customer->getLastname(); + $this->email = $customer->getEmail(); + } else { + throw new \InvalidArgumentException( + 'CustomerParam can compare only existing Customers' + ); + } + } + + /** + * Compare the current object to the passed $other. + * + * Returns 0 if they are semantically equal, 1 if the other object + * is less than the current one, or -1 if its more than the current one. + * + * This method should not check for identity using ===, only for semantically equality for example + * when two different DateTime instances point to the exact same Date + TZ. + * + * @param mixed $other Object + * + * @throws InvalidArgumentException + * @return int + */ + public function compareTo($other) + { + if (!is_integer($other) || $other < 0) { + throw new InvalidArgumentException( + 'IntegerParam can compare only positive int' + ); + } + + return parent::compareTo($other); + } + + /** + * Customer email + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * Customer first name + * + * @return string + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * Customer last name + * + * @return string + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + return $this->adapter + ->getTranslator() + ->trans( + 'A Customer', + null, + 'constraint' + ); + } + +} diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php new file mode 100755 index 000000000..67d1e451e --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -0,0 +1,100 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Security\Exception\AuthenticationException; +use Thelia\Core\Security\Exception\AuthorizationException; + +class CouponController extends BaseAdminController +{ + + protected function browseCoupon($args) + { + $this->checkAuth("ADMIN", "admin.coupon.view"); + + return $this->render('coupons', $args); + } + + public function indexAction() + { + return $this->processAction(); + } + + public function processAction() + { + // Get the current action + $action = $this->getRequest()->get('action', 'browse'); + + // Get the category ID + $id = $this->getRequest()->get('id', 0); + + $args = array( + 'action' => $action, + 'current_coupon_id' => $id + ); + + try { + switch ($action) { + case 'browse' : // Browse coupon + + return $this->browseCoupons($args); + + case 'create' : // Create a new category + +// return $this->createNewCategory($args); + + case 'edit' : // Edit an existing category + +// return $this->editCategory($args); + + case 'delete' : // Delete an existing category + +// return $this->deleteCategory($args); + + case 'visibilityToggle' : // Toggle visibility + +// return $this->visibilityToggle($id); + + case 'changePosition' : // Change position + +// return $this->changePosition($args); + + case 'positionUp' : // Move up category + +// return $this->positionUp($args); + + case 'positionDown' : // Move down category + +// return $this->positionDown($args); + } + } catch (AuthorizationException $ex) { + return $this->errorPage($ex->getMessage()); + } catch (AuthenticationException $ex) { + return $this->errorPage($ex->getMessage()); + } + + // We did not recognized the action -> return a 404 page + return $this->pageNotFound(); + } +} diff --git a/templates/default/coupon.html b/templates/default/coupon.html new file mode 100755 index 000000000..3fd478575 --- /dev/null +++ b/templates/default/coupon.html @@ -0,0 +1,5 @@ +

      Coupon page

      + +
      + +

      COUPON

      From 8b07b963661ca3785bd3a6ec046cdc0825fbe65c Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 28 Aug 2013 15:31:27 +0200 Subject: [PATCH 042/268] Working - Add error message when not in trusted IP list --- web/index_dev.php | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/web/index_dev.php b/web/index_dev.php index cb9a3d6f0..f02a625da 100755 --- a/web/index_dev.php +++ b/web/index_dev.php @@ -1,4 +1,28 @@ . */ +/* */ +/**********************************************************************************/ + + +use Symfony\Component\HttpFoundation\Response; use Thelia\Core\Thelia; use Thelia\Core\HttpFoundation\Request; @@ -7,20 +31,21 @@ use Thelia\Core\HttpFoundation\Request; $env = 'dev'; require __DIR__ . '/../core/bootstrap.php'; -$trustIp = array( +// List of allowed IP +$trustedIp = array( '::1', '127.0.0.1' ); $request = Request::createFromGlobals(); - -if ( false === in_array($request->getClientIp(), $trustIp)) { - //change request to send to a 404 error page - exit; -} - $thelia = new Thelia("dev", true); +if ( false === in_array($request->getClientIp(), $trustedIp)) { + // Redirect 403 Forbidden + $response = new Response('Forbidden', 404); + $thelia->terminate($request, $response); +} + $response = $thelia->handle($request)->prepare($request)->send(); $thelia->terminate($request, $response); From 61e13c416cd415da551b22df840636bd33f87824 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 28 Aug 2013 15:35:10 +0200 Subject: [PATCH 043/268] rewriting tables --- core/lib/Thelia/Model/Base/Coupon.php | 328 ++- core/lib/Thelia/Model/Base/CouponQuery.php | 200 +- core/lib/Thelia/Model/Base/CouponVersion.php | 316 ++- .../Thelia/Model/Base/CouponVersionQuery.php | 200 +- core/lib/Thelia/Model/Base/Rewriting.php | 1812 ----------------- core/lib/Thelia/Model/Base/RewritingQuery.php | 1044 ---------- core/lib/Thelia/Model/Map/CouponTableMap.php | 70 +- .../Model/Map/CouponVersionTableMap.php | 74 +- .../Thelia/Model/Map/RewritingTableMap.php | 470 ----- core/lib/Thelia/Model/Rewriting.php | 9 - core/lib/Thelia/Model/RewritingQuery.php | 20 - install/thelia.sql | 72 +- local/config/schema.xml | 66 +- 13 files changed, 1170 insertions(+), 3511 deletions(-) delete mode 100755 core/lib/Thelia/Model/Base/Rewriting.php delete mode 100755 core/lib/Thelia/Model/Base/RewritingQuery.php delete mode 100755 core/lib/Thelia/Model/Map/RewritingTableMap.php delete mode 100755 core/lib/Thelia/Model/Rewriting.php delete mode 100755 core/lib/Thelia/Model/RewritingQuery.php diff --git a/core/lib/Thelia/Model/Base/Coupon.php b/core/lib/Thelia/Model/Base/Coupon.php index 0a6ee2061..29477cc8b 100755 --- a/core/lib/Thelia/Model/Base/Coupon.php +++ b/core/lib/Thelia/Model/Base/Coupon.php @@ -99,10 +99,10 @@ abstract class Coupon implements ActiveRecordInterface protected $description; /** - * The value for the value field. + * The value for the amount field. * @var double */ - protected $value; + protected $amount; /** * The value for the is_used field. @@ -128,6 +128,30 @@ abstract class Coupon implements ActiveRecordInterface */ protected $serialized_rules; + /** + * The value for the is_cumulative field. + * @var int + */ + protected $is_cumulative; + + /** + * The value for the is_removing_postage field. + * @var int + */ + protected $is_removing_postage; + + /** + * The value for the max_usage field. + * @var int + */ + protected $max_usage; + + /** + * The value for the is_available_on_special_offers field. + * @var boolean + */ + protected $is_available_on_special_offers; + /** * The value for the created_at field. * @var string @@ -547,14 +571,14 @@ abstract class Coupon implements ActiveRecordInterface } /** - * Get the [value] column value. + * Get the [amount] column value. * * @return double */ - public function getValue() + public function getAmount() { - return $this->value; + return $this->amount; } /** @@ -610,6 +634,50 @@ abstract class Coupon implements ActiveRecordInterface return $this->serialized_rules; } + /** + * Get the [is_cumulative] column value. + * + * @return int + */ + public function getIsCumulative() + { + + return $this->is_cumulative; + } + + /** + * Get the [is_removing_postage] column value. + * + * @return int + */ + public function getIsRemovingPostage() + { + + return $this->is_removing_postage; + } + + /** + * Get the [max_usage] column value. + * + * @return int + */ + public function getMaxUsage() + { + + return $this->max_usage; + } + + /** + * Get the [is_available_on_special_offers] column value. + * + * @return boolean + */ + public function getIsAvailableOnSpecialOffers() + { + + return $this->is_available_on_special_offers; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -788,25 +856,25 @@ abstract class Coupon implements ActiveRecordInterface } // setDescription() /** - * Set the value of [value] column. + * Set the value of [amount] column. * * @param double $v new value * @return \Thelia\Model\Coupon The current object (for fluent API support) */ - public function setValue($v) + public function setAmount($v) { if ($v !== null) { $v = (double) $v; } - if ($this->value !== $v) { - $this->value = $v; - $this->modifiedColumns[] = CouponTableMap::VALUE; + if ($this->amount !== $v) { + $this->amount = $v; + $this->modifiedColumns[] = CouponTableMap::AMOUNT; } return $this; - } // setValue() + } // setAmount() /** * Set the value of [is_used] column. @@ -892,6 +960,98 @@ abstract class Coupon implements ActiveRecordInterface return $this; } // setSerializedRules() + /** + * Set the value of [is_cumulative] column. + * + * @param int $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setIsCumulative($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_cumulative !== $v) { + $this->is_cumulative = $v; + $this->modifiedColumns[] = CouponTableMap::IS_CUMULATIVE; + } + + + return $this; + } // setIsCumulative() + + /** + * Set the value of [is_removing_postage] column. + * + * @param int $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setIsRemovingPostage($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_removing_postage !== $v) { + $this->is_removing_postage = $v; + $this->modifiedColumns[] = CouponTableMap::IS_REMOVING_POSTAGE; + } + + + return $this; + } // setIsRemovingPostage() + + /** + * Set the value of [max_usage] column. + * + * @param int $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setMaxUsage($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->max_usage !== $v) { + $this->max_usage = $v; + $this->modifiedColumns[] = CouponTableMap::MAX_USAGE; + } + + + return $this; + } // setMaxUsage() + + /** + * Sets the value of the [is_available_on_special_offers] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setIsAvailableOnSpecialOffers($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_available_on_special_offers !== $v) { + $this->is_available_on_special_offers = $v; + $this->modifiedColumns[] = CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS; + } + + + return $this; + } // setIsAvailableOnSpecialOffers() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -1014,8 +1174,8 @@ abstract class Coupon implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; $this->description = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; - $this->value = (null !== $col) ? (double) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponTableMap::translateFieldName('Amount', TableMap::TYPE_PHPNAME, $indexType)]; + $this->amount = (null !== $col) ? (double) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponTableMap::translateFieldName('IsUsed', TableMap::TYPE_PHPNAME, $indexType)]; $this->is_used = (null !== $col) ? (int) $col : null; @@ -1032,19 +1192,31 @@ abstract class Coupon implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponTableMap::translateFieldName('SerializedRules', TableMap::TYPE_PHPNAME, $indexType)]; $this->serialized_rules = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_cumulative = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_removing_postage = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponTableMap::translateFieldName('MaxUsage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->max_usage = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CouponTableMap::translateFieldName('IsAvailableOnSpecialOffers', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_available_on_special_offers = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : CouponTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; $this->version = (null !== $col) ? (int) $col : null; $this->resetModified(); @@ -1054,7 +1226,7 @@ abstract class Coupon implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 14; // 14 = CouponTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 18; // 18 = CouponTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Coupon object", 0, $e); @@ -1358,8 +1530,8 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::DESCRIPTION)) { $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; } - if ($this->isColumnModified(CouponTableMap::VALUE)) { - $modifiedColumns[':p' . $index++] = 'VALUE'; + if ($this->isColumnModified(CouponTableMap::AMOUNT)) { + $modifiedColumns[':p' . $index++] = 'AMOUNT'; } if ($this->isColumnModified(CouponTableMap::IS_USED)) { $modifiedColumns[':p' . $index++] = 'IS_USED'; @@ -1373,6 +1545,18 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES)) { $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES'; } + if ($this->isColumnModified(CouponTableMap::IS_CUMULATIVE)) { + $modifiedColumns[':p' . $index++] = 'IS_CUMULATIVE'; + } + if ($this->isColumnModified(CouponTableMap::IS_REMOVING_POSTAGE)) { + $modifiedColumns[':p' . $index++] = 'IS_REMOVING_POSTAGE'; + } + if ($this->isColumnModified(CouponTableMap::MAX_USAGE)) { + $modifiedColumns[':p' . $index++] = 'MAX_USAGE'; + } + if ($this->isColumnModified(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) { + $modifiedColumns[':p' . $index++] = 'IS_AVAILABLE_ON_SPECIAL_OFFERS'; + } if ($this->isColumnModified(CouponTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1411,8 +1595,8 @@ abstract class Coupon implements ActiveRecordInterface case 'DESCRIPTION': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case 'VALUE': - $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); + case 'AMOUNT': + $stmt->bindValue($identifier, $this->amount, PDO::PARAM_STR); break; case 'IS_USED': $stmt->bindValue($identifier, $this->is_used, PDO::PARAM_INT); @@ -1426,6 +1610,18 @@ abstract class Coupon implements ActiveRecordInterface case 'SERIALIZED_RULES': $stmt->bindValue($identifier, $this->serialized_rules, PDO::PARAM_STR); break; + case 'IS_CUMULATIVE': + $stmt->bindValue($identifier, $this->is_cumulative, PDO::PARAM_INT); + break; + case 'IS_REMOVING_POSTAGE': + $stmt->bindValue($identifier, $this->is_removing_postage, PDO::PARAM_INT); + break; + case 'MAX_USAGE': + $stmt->bindValue($identifier, $this->max_usage, PDO::PARAM_INT); + break; + case 'IS_AVAILABLE_ON_SPECIAL_OFFERS': + $stmt->bindValue($identifier, (int) $this->is_available_on_special_offers, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1516,7 +1712,7 @@ abstract class Coupon implements ActiveRecordInterface return $this->getDescription(); break; case 6: - return $this->getValue(); + return $this->getAmount(); break; case 7: return $this->getIsUsed(); @@ -1531,12 +1727,24 @@ abstract class Coupon implements ActiveRecordInterface return $this->getSerializedRules(); break; case 11: - return $this->getCreatedAt(); + return $this->getIsCumulative(); break; case 12: - return $this->getUpdatedAt(); + return $this->getIsRemovingPostage(); break; case 13: + return $this->getMaxUsage(); + break; + case 14: + return $this->getIsAvailableOnSpecialOffers(); + break; + case 15: + return $this->getCreatedAt(); + break; + case 16: + return $this->getUpdatedAt(); + break; + case 17: return $this->getVersion(); break; default: @@ -1574,14 +1782,18 @@ abstract class Coupon implements ActiveRecordInterface $keys[3] => $this->getTitle(), $keys[4] => $this->getShortDescription(), $keys[5] => $this->getDescription(), - $keys[6] => $this->getValue(), + $keys[6] => $this->getAmount(), $keys[7] => $this->getIsUsed(), $keys[8] => $this->getIsEnabled(), $keys[9] => $this->getExpirationDate(), $keys[10] => $this->getSerializedRules(), - $keys[11] => $this->getCreatedAt(), - $keys[12] => $this->getUpdatedAt(), - $keys[13] => $this->getVersion(), + $keys[11] => $this->getIsCumulative(), + $keys[12] => $this->getIsRemovingPostage(), + $keys[13] => $this->getMaxUsage(), + $keys[14] => $this->getIsAvailableOnSpecialOffers(), + $keys[15] => $this->getCreatedAt(), + $keys[16] => $this->getUpdatedAt(), + $keys[17] => $this->getVersion(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1652,7 +1864,7 @@ abstract class Coupon implements ActiveRecordInterface $this->setDescription($value); break; case 6: - $this->setValue($value); + $this->setAmount($value); break; case 7: $this->setIsUsed($value); @@ -1667,12 +1879,24 @@ abstract class Coupon implements ActiveRecordInterface $this->setSerializedRules($value); break; case 11: - $this->setCreatedAt($value); + $this->setIsCumulative($value); break; case 12: - $this->setUpdatedAt($value); + $this->setIsRemovingPostage($value); break; case 13: + $this->setMaxUsage($value); + break; + case 14: + $this->setIsAvailableOnSpecialOffers($value); + break; + case 15: + $this->setCreatedAt($value); + break; + case 16: + $this->setUpdatedAt($value); + break; + case 17: $this->setVersion($value); break; } // switch() @@ -1705,14 +1929,18 @@ abstract class Coupon implements ActiveRecordInterface if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setShortDescription($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setDescription($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setValue($arr[$keys[6]]); + if (array_key_exists($keys[6], $arr)) $this->setAmount($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setIsUsed($arr[$keys[7]]); if (array_key_exists($keys[8], $arr)) $this->setIsEnabled($arr[$keys[8]]); if (array_key_exists($keys[9], $arr)) $this->setExpirationDate($arr[$keys[9]]); if (array_key_exists($keys[10], $arr)) $this->setSerializedRules($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setCreatedAt($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setUpdatedAt($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setVersion($arr[$keys[13]]); + if (array_key_exists($keys[11], $arr)) $this->setIsCumulative($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setIsRemovingPostage($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setMaxUsage($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setCreatedAt($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setUpdatedAt($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setVersion($arr[$keys[17]]); } /** @@ -1730,11 +1958,15 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::TITLE)) $criteria->add(CouponTableMap::TITLE, $this->title); if ($this->isColumnModified(CouponTableMap::SHORT_DESCRIPTION)) $criteria->add(CouponTableMap::SHORT_DESCRIPTION, $this->short_description); if ($this->isColumnModified(CouponTableMap::DESCRIPTION)) $criteria->add(CouponTableMap::DESCRIPTION, $this->description); - if ($this->isColumnModified(CouponTableMap::VALUE)) $criteria->add(CouponTableMap::VALUE, $this->value); + if ($this->isColumnModified(CouponTableMap::AMOUNT)) $criteria->add(CouponTableMap::AMOUNT, $this->amount); if ($this->isColumnModified(CouponTableMap::IS_USED)) $criteria->add(CouponTableMap::IS_USED, $this->is_used); if ($this->isColumnModified(CouponTableMap::IS_ENABLED)) $criteria->add(CouponTableMap::IS_ENABLED, $this->is_enabled); if ($this->isColumnModified(CouponTableMap::EXPIRATION_DATE)) $criteria->add(CouponTableMap::EXPIRATION_DATE, $this->expiration_date); if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES)) $criteria->add(CouponTableMap::SERIALIZED_RULES, $this->serialized_rules); + if ($this->isColumnModified(CouponTableMap::IS_CUMULATIVE)) $criteria->add(CouponTableMap::IS_CUMULATIVE, $this->is_cumulative); + if ($this->isColumnModified(CouponTableMap::IS_REMOVING_POSTAGE)) $criteria->add(CouponTableMap::IS_REMOVING_POSTAGE, $this->is_removing_postage); + if ($this->isColumnModified(CouponTableMap::MAX_USAGE)) $criteria->add(CouponTableMap::MAX_USAGE, $this->max_usage); + if ($this->isColumnModified(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) $criteria->add(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $this->is_available_on_special_offers); if ($this->isColumnModified(CouponTableMap::CREATED_AT)) $criteria->add(CouponTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) $criteria->add(CouponTableMap::UPDATED_AT, $this->updated_at); if ($this->isColumnModified(CouponTableMap::VERSION)) $criteria->add(CouponTableMap::VERSION, $this->version); @@ -1806,11 +2038,15 @@ abstract class Coupon implements ActiveRecordInterface $copyObj->setTitle($this->getTitle()); $copyObj->setShortDescription($this->getShortDescription()); $copyObj->setDescription($this->getDescription()); - $copyObj->setValue($this->getValue()); + $copyObj->setAmount($this->getAmount()); $copyObj->setIsUsed($this->getIsUsed()); $copyObj->setIsEnabled($this->getIsEnabled()); $copyObj->setExpirationDate($this->getExpirationDate()); $copyObj->setSerializedRules($this->getSerializedRules()); + $copyObj->setIsCumulative($this->getIsCumulative()); + $copyObj->setIsRemovingPostage($this->getIsRemovingPostage()); + $copyObj->setMaxUsage($this->getMaxUsage()); + $copyObj->setIsAvailableOnSpecialOffers($this->getIsAvailableOnSpecialOffers()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); $copyObj->setVersion($this->getVersion()); @@ -2590,11 +2826,15 @@ abstract class Coupon implements ActiveRecordInterface $this->title = null; $this->short_description = null; $this->description = null; - $this->value = null; + $this->amount = null; $this->is_used = null; $this->is_enabled = null; $this->expiration_date = null; $this->serialized_rules = null; + $this->is_cumulative = null; + $this->is_removing_postage = null; + $this->max_usage = null; + $this->is_available_on_special_offers = null; $this->created_at = null; $this->updated_at = null; $this->version = null; @@ -2830,11 +3070,15 @@ abstract class Coupon implements ActiveRecordInterface $version->setTitle($this->getTitle()); $version->setShortDescription($this->getShortDescription()); $version->setDescription($this->getDescription()); - $version->setValue($this->getValue()); + $version->setAmount($this->getAmount()); $version->setIsUsed($this->getIsUsed()); $version->setIsEnabled($this->getIsEnabled()); $version->setExpirationDate($this->getExpirationDate()); $version->setSerializedRules($this->getSerializedRules()); + $version->setIsCumulative($this->getIsCumulative()); + $version->setIsRemovingPostage($this->getIsRemovingPostage()); + $version->setMaxUsage($this->getMaxUsage()); + $version->setIsAvailableOnSpecialOffers($this->getIsAvailableOnSpecialOffers()); $version->setCreatedAt($this->getCreatedAt()); $version->setUpdatedAt($this->getUpdatedAt()); $version->setVersion($this->getVersion()); @@ -2881,11 +3125,15 @@ abstract class Coupon implements ActiveRecordInterface $this->setTitle($version->getTitle()); $this->setShortDescription($version->getShortDescription()); $this->setDescription($version->getDescription()); - $this->setValue($version->getValue()); + $this->setAmount($version->getAmount()); $this->setIsUsed($version->getIsUsed()); $this->setIsEnabled($version->getIsEnabled()); $this->setExpirationDate($version->getExpirationDate()); $this->setSerializedRules($version->getSerializedRules()); + $this->setIsCumulative($version->getIsCumulative()); + $this->setIsRemovingPostage($version->getIsRemovingPostage()); + $this->setMaxUsage($version->getMaxUsage()); + $this->setIsAvailableOnSpecialOffers($version->getIsAvailableOnSpecialOffers()); $this->setCreatedAt($version->getCreatedAt()); $this->setUpdatedAt($version->getUpdatedAt()); $this->setVersion($version->getVersion()); diff --git a/core/lib/Thelia/Model/Base/CouponQuery.php b/core/lib/Thelia/Model/Base/CouponQuery.php index fa5700786..c7ae0eabd 100755 --- a/core/lib/Thelia/Model/Base/CouponQuery.php +++ b/core/lib/Thelia/Model/Base/CouponQuery.php @@ -28,11 +28,15 @@ use Thelia\Model\Map\CouponTableMap; * @method ChildCouponQuery orderByTitle($order = Criteria::ASC) Order by the title column * @method ChildCouponQuery orderByShortDescription($order = Criteria::ASC) Order by the short_description column * @method ChildCouponQuery orderByDescription($order = Criteria::ASC) Order by the description column - * @method ChildCouponQuery orderByValue($order = Criteria::ASC) Order by the value column + * @method ChildCouponQuery orderByAmount($order = Criteria::ASC) Order by the amount column * @method ChildCouponQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column * @method ChildCouponQuery orderByIsEnabled($order = Criteria::ASC) Order by the is_enabled column * @method ChildCouponQuery orderByExpirationDate($order = Criteria::ASC) Order by the expiration_date column * @method ChildCouponQuery orderBySerializedRules($order = Criteria::ASC) Order by the serialized_rules column + * @method ChildCouponQuery orderByIsCumulative($order = Criteria::ASC) Order by the is_cumulative column + * @method ChildCouponQuery orderByIsRemovingPostage($order = Criteria::ASC) Order by the is_removing_postage column + * @method ChildCouponQuery orderByMaxUsage($order = Criteria::ASC) Order by the max_usage column + * @method ChildCouponQuery orderByIsAvailableOnSpecialOffers($order = Criteria::ASC) Order by the is_available_on_special_offers column * @method ChildCouponQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCouponQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @method ChildCouponQuery orderByVersion($order = Criteria::ASC) Order by the version column @@ -43,11 +47,15 @@ use Thelia\Model\Map\CouponTableMap; * @method ChildCouponQuery groupByTitle() Group by the title column * @method ChildCouponQuery groupByShortDescription() Group by the short_description column * @method ChildCouponQuery groupByDescription() Group by the description column - * @method ChildCouponQuery groupByValue() Group by the value column + * @method ChildCouponQuery groupByAmount() Group by the amount column * @method ChildCouponQuery groupByIsUsed() Group by the is_used column * @method ChildCouponQuery groupByIsEnabled() Group by the is_enabled column * @method ChildCouponQuery groupByExpirationDate() Group by the expiration_date column * @method ChildCouponQuery groupBySerializedRules() Group by the serialized_rules column + * @method ChildCouponQuery groupByIsCumulative() Group by the is_cumulative column + * @method ChildCouponQuery groupByIsRemovingPostage() Group by the is_removing_postage column + * @method ChildCouponQuery groupByMaxUsage() Group by the max_usage column + * @method ChildCouponQuery groupByIsAvailableOnSpecialOffers() Group by the is_available_on_special_offers column * @method ChildCouponQuery groupByCreatedAt() Group by the created_at column * @method ChildCouponQuery groupByUpdatedAt() Group by the updated_at column * @method ChildCouponQuery groupByVersion() Group by the version column @@ -77,11 +85,15 @@ use Thelia\Model\Map\CouponTableMap; * @method ChildCoupon findOneByTitle(string $title) Return the first ChildCoupon filtered by the title column * @method ChildCoupon findOneByShortDescription(string $short_description) Return the first ChildCoupon filtered by the short_description column * @method ChildCoupon findOneByDescription(string $description) Return the first ChildCoupon filtered by the description column - * @method ChildCoupon findOneByValue(double $value) Return the first ChildCoupon filtered by the value column + * @method ChildCoupon findOneByAmount(double $amount) Return the first ChildCoupon filtered by the amount column * @method ChildCoupon findOneByIsUsed(int $is_used) Return the first ChildCoupon filtered by the is_used column * @method ChildCoupon findOneByIsEnabled(int $is_enabled) Return the first ChildCoupon filtered by the is_enabled column * @method ChildCoupon findOneByExpirationDate(string $expiration_date) Return the first ChildCoupon filtered by the expiration_date column * @method ChildCoupon findOneBySerializedRules(string $serialized_rules) Return the first ChildCoupon filtered by the serialized_rules column + * @method ChildCoupon findOneByIsCumulative(int $is_cumulative) Return the first ChildCoupon filtered by the is_cumulative column + * @method ChildCoupon findOneByIsRemovingPostage(int $is_removing_postage) Return the first ChildCoupon filtered by the is_removing_postage column + * @method ChildCoupon findOneByMaxUsage(int $max_usage) Return the first ChildCoupon filtered by the max_usage column + * @method ChildCoupon findOneByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return the first ChildCoupon filtered by the is_available_on_special_offers column * @method ChildCoupon findOneByCreatedAt(string $created_at) Return the first ChildCoupon filtered by the created_at column * @method ChildCoupon findOneByUpdatedAt(string $updated_at) Return the first ChildCoupon filtered by the updated_at column * @method ChildCoupon findOneByVersion(int $version) Return the first ChildCoupon filtered by the version column @@ -92,11 +104,15 @@ use Thelia\Model\Map\CouponTableMap; * @method array findByTitle(string $title) Return ChildCoupon objects filtered by the title column * @method array findByShortDescription(string $short_description) Return ChildCoupon objects filtered by the short_description column * @method array findByDescription(string $description) Return ChildCoupon objects filtered by the description column - * @method array findByValue(double $value) Return ChildCoupon objects filtered by the value column + * @method array findByAmount(double $amount) Return ChildCoupon objects filtered by the amount column * @method array findByIsUsed(int $is_used) Return ChildCoupon objects filtered by the is_used column * @method array findByIsEnabled(int $is_enabled) Return ChildCoupon objects filtered by the is_enabled column * @method array findByExpirationDate(string $expiration_date) Return ChildCoupon objects filtered by the expiration_date column * @method array findBySerializedRules(string $serialized_rules) Return ChildCoupon objects filtered by the serialized_rules column + * @method array findByIsCumulative(int $is_cumulative) Return ChildCoupon objects filtered by the is_cumulative column + * @method array findByIsRemovingPostage(int $is_removing_postage) Return ChildCoupon objects filtered by the is_removing_postage column + * @method array findByMaxUsage(int $max_usage) Return ChildCoupon objects filtered by the max_usage column + * @method array findByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return ChildCoupon objects filtered by the is_available_on_special_offers column * @method array findByCreatedAt(string $created_at) Return ChildCoupon objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCoupon objects filtered by the updated_at column * @method array findByVersion(int $version) Return ChildCoupon objects filtered by the version column @@ -195,7 +211,7 @@ abstract class CouponQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, VALUE, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES, CREATED_AT, UPDATED_AT, VERSION FROM coupon WHERE ID = :p0'; + $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, AMOUNT, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES, IS_CUMULATIVE, IS_REMOVING_POSTAGE, MAX_USAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, CREATED_AT, UPDATED_AT, VERSION FROM coupon WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -471,16 +487,16 @@ abstract class CouponQuery extends ModelCriteria } /** - * Filter the query on the value column + * Filter the query on the amount column * * Example usage: * - * $query->filterByValue(1234); // WHERE value = 1234 - * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34) - * $query->filterByValue(array('min' => 12)); // WHERE value > 12 + * $query->filterByAmount(1234); // WHERE amount = 1234 + * $query->filterByAmount(array(12, 34)); // WHERE amount IN (12, 34) + * $query->filterByAmount(array('min' => 12)); // WHERE amount > 12 * * - * @param mixed $value The value to use as filter. + * @param mixed $amount The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -488,16 +504,16 @@ abstract class CouponQuery extends ModelCriteria * * @return ChildCouponQuery The current query, for fluid interface */ - public function filterByValue($value = null, $comparison = null) + public function filterByAmount($amount = null, $comparison = null) { - if (is_array($value)) { + if (is_array($amount)) { $useMinMax = false; - if (isset($value['min'])) { - $this->addUsingAlias(CouponTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL); + if (isset($amount['min'])) { + $this->addUsingAlias(CouponTableMap::AMOUNT, $amount['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($value['max'])) { - $this->addUsingAlias(CouponTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL); + if (isset($amount['max'])) { + $this->addUsingAlias(CouponTableMap::AMOUNT, $amount['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -508,7 +524,7 @@ abstract class CouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponTableMap::VALUE, $value, $comparison); + return $this->addUsingAlias(CouponTableMap::AMOUNT, $amount, $comparison); } /** @@ -665,6 +681,156 @@ abstract class CouponQuery extends ModelCriteria return $this->addUsingAlias(CouponTableMap::SERIALIZED_RULES, $serializedRules, $comparison); } + /** + * Filter the query on the is_cumulative column + * + * Example usage: + * + * $query->filterByIsCumulative(1234); // WHERE is_cumulative = 1234 + * $query->filterByIsCumulative(array(12, 34)); // WHERE is_cumulative IN (12, 34) + * $query->filterByIsCumulative(array('min' => 12)); // WHERE is_cumulative > 12 + * + * + * @param mixed $isCumulative The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByIsCumulative($isCumulative = null, $comparison = null) + { + if (is_array($isCumulative)) { + $useMinMax = false; + if (isset($isCumulative['min'])) { + $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isCumulative['max'])) { + $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative, $comparison); + } + + /** + * Filter the query on the is_removing_postage column + * + * Example usage: + * + * $query->filterByIsRemovingPostage(1234); // WHERE is_removing_postage = 1234 + * $query->filterByIsRemovingPostage(array(12, 34)); // WHERE is_removing_postage IN (12, 34) + * $query->filterByIsRemovingPostage(array('min' => 12)); // WHERE is_removing_postage > 12 + * + * + * @param mixed $isRemovingPostage The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByIsRemovingPostage($isRemovingPostage = null, $comparison = null) + { + if (is_array($isRemovingPostage)) { + $useMinMax = false; + if (isset($isRemovingPostage['min'])) { + $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isRemovingPostage['max'])) { + $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison); + } + + /** + * Filter the query on the max_usage column + * + * Example usage: + * + * $query->filterByMaxUsage(1234); // WHERE max_usage = 1234 + * $query->filterByMaxUsage(array(12, 34)); // WHERE max_usage IN (12, 34) + * $query->filterByMaxUsage(array('min' => 12)); // WHERE max_usage > 12 + * + * + * @param mixed $maxUsage The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByMaxUsage($maxUsage = null, $comparison = null) + { + if (is_array($maxUsage)) { + $useMinMax = false; + if (isset($maxUsage['min'])) { + $this->addUsingAlias(CouponTableMap::MAX_USAGE, $maxUsage['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($maxUsage['max'])) { + $this->addUsingAlias(CouponTableMap::MAX_USAGE, $maxUsage['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponTableMap::MAX_USAGE, $maxUsage, $comparison); + } + + /** + * Filter the query on the is_available_on_special_offers column + * + * Example usage: + * + * $query->filterByIsAvailableOnSpecialOffers(true); // WHERE is_available_on_special_offers = true + * $query->filterByIsAvailableOnSpecialOffers('yes'); // WHERE is_available_on_special_offers = true + * + * + * @param boolean|string $isAvailableOnSpecialOffers The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers = null, $comparison = null) + { + if (is_string($isAvailableOnSpecialOffers)) { + $is_available_on_special_offers = in_array(strtolower($isAvailableOnSpecialOffers), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $isAvailableOnSpecialOffers, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/CouponVersion.php b/core/lib/Thelia/Model/Base/CouponVersion.php index 34d525a7a..55edbe3ed 100644 --- a/core/lib/Thelia/Model/Base/CouponVersion.php +++ b/core/lib/Thelia/Model/Base/CouponVersion.php @@ -92,10 +92,10 @@ abstract class CouponVersion implements ActiveRecordInterface protected $description; /** - * The value for the value field. + * The value for the amount field. * @var double */ - protected $value; + protected $amount; /** * The value for the is_used field. @@ -121,6 +121,30 @@ abstract class CouponVersion implements ActiveRecordInterface */ protected $serialized_rules; + /** + * The value for the is_cumulative field. + * @var int + */ + protected $is_cumulative; + + /** + * The value for the is_removing_postage field. + * @var int + */ + protected $is_removing_postage; + + /** + * The value for the max_usage field. + * @var int + */ + protected $max_usage; + + /** + * The value for the is_available_on_special_offers field. + * @var boolean + */ + protected $is_available_on_special_offers; + /** * The value for the created_at field. * @var string @@ -487,14 +511,14 @@ abstract class CouponVersion implements ActiveRecordInterface } /** - * Get the [value] column value. + * Get the [amount] column value. * * @return double */ - public function getValue() + public function getAmount() { - return $this->value; + return $this->amount; } /** @@ -550,6 +574,50 @@ abstract class CouponVersion implements ActiveRecordInterface return $this->serialized_rules; } + /** + * Get the [is_cumulative] column value. + * + * @return int + */ + public function getIsCumulative() + { + + return $this->is_cumulative; + } + + /** + * Get the [is_removing_postage] column value. + * + * @return int + */ + public function getIsRemovingPostage() + { + + return $this->is_removing_postage; + } + + /** + * Get the [max_usage] column value. + * + * @return int + */ + public function getMaxUsage() + { + + return $this->max_usage; + } + + /** + * Get the [is_available_on_special_offers] column value. + * + * @return boolean + */ + public function getIsAvailableOnSpecialOffers() + { + + return $this->is_available_on_special_offers; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -732,25 +800,25 @@ abstract class CouponVersion implements ActiveRecordInterface } // setDescription() /** - * Set the value of [value] column. + * Set the value of [amount] column. * * @param double $v new value * @return \Thelia\Model\CouponVersion The current object (for fluent API support) */ - public function setValue($v) + public function setAmount($v) { if ($v !== null) { $v = (double) $v; } - if ($this->value !== $v) { - $this->value = $v; - $this->modifiedColumns[] = CouponVersionTableMap::VALUE; + if ($this->amount !== $v) { + $this->amount = $v; + $this->modifiedColumns[] = CouponVersionTableMap::AMOUNT; } return $this; - } // setValue() + } // setAmount() /** * Set the value of [is_used] column. @@ -836,6 +904,98 @@ abstract class CouponVersion implements ActiveRecordInterface return $this; } // setSerializedRules() + /** + * Set the value of [is_cumulative] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setIsCumulative($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_cumulative !== $v) { + $this->is_cumulative = $v; + $this->modifiedColumns[] = CouponVersionTableMap::IS_CUMULATIVE; + } + + + return $this; + } // setIsCumulative() + + /** + * Set the value of [is_removing_postage] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setIsRemovingPostage($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_removing_postage !== $v) { + $this->is_removing_postage = $v; + $this->modifiedColumns[] = CouponVersionTableMap::IS_REMOVING_POSTAGE; + } + + + return $this; + } // setIsRemovingPostage() + + /** + * Set the value of [max_usage] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setMaxUsage($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->max_usage !== $v) { + $this->max_usage = $v; + $this->modifiedColumns[] = CouponVersionTableMap::MAX_USAGE; + } + + + return $this; + } // setMaxUsage() + + /** + * Sets the value of the [is_available_on_special_offers] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setIsAvailableOnSpecialOffers($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_available_on_special_offers !== $v) { + $this->is_available_on_special_offers = $v; + $this->modifiedColumns[] = CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS; + } + + + return $this; + } // setIsAvailableOnSpecialOffers() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -958,8 +1118,8 @@ abstract class CouponVersion implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponVersionTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; $this->description = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponVersionTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; - $this->value = (null !== $col) ? (double) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponVersionTableMap::translateFieldName('Amount', TableMap::TYPE_PHPNAME, $indexType)]; + $this->amount = (null !== $col) ? (double) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponVersionTableMap::translateFieldName('IsUsed', TableMap::TYPE_PHPNAME, $indexType)]; $this->is_used = (null !== $col) ? (int) $col : null; @@ -976,19 +1136,31 @@ abstract class CouponVersion implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponVersionTableMap::translateFieldName('SerializedRules', TableMap::TYPE_PHPNAME, $indexType)]; $this->serialized_rules = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponVersionTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_cumulative = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponVersionTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_removing_postage = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponVersionTableMap::translateFieldName('MaxUsage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->max_usage = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CouponVersionTableMap::translateFieldName('IsAvailableOnSpecialOffers', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_available_on_special_offers = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CouponVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CouponVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : CouponVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; $this->version = (null !== $col) ? (int) $col : null; $this->resetModified(); @@ -998,7 +1170,7 @@ abstract class CouponVersion implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 14; // 14 = CouponVersionTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 18; // 18 = CouponVersionTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\CouponVersion object", 0, $e); @@ -1237,8 +1409,8 @@ abstract class CouponVersion implements ActiveRecordInterface if ($this->isColumnModified(CouponVersionTableMap::DESCRIPTION)) { $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; } - if ($this->isColumnModified(CouponVersionTableMap::VALUE)) { - $modifiedColumns[':p' . $index++] = 'VALUE'; + if ($this->isColumnModified(CouponVersionTableMap::AMOUNT)) { + $modifiedColumns[':p' . $index++] = 'AMOUNT'; } if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) { $modifiedColumns[':p' . $index++] = 'IS_USED'; @@ -1252,6 +1424,18 @@ abstract class CouponVersion implements ActiveRecordInterface if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES)) { $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES'; } + if ($this->isColumnModified(CouponVersionTableMap::IS_CUMULATIVE)) { + $modifiedColumns[':p' . $index++] = 'IS_CUMULATIVE'; + } + if ($this->isColumnModified(CouponVersionTableMap::IS_REMOVING_POSTAGE)) { + $modifiedColumns[':p' . $index++] = 'IS_REMOVING_POSTAGE'; + } + if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) { + $modifiedColumns[':p' . $index++] = 'MAX_USAGE'; + } + if ($this->isColumnModified(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) { + $modifiedColumns[':p' . $index++] = 'IS_AVAILABLE_ON_SPECIAL_OFFERS'; + } if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1290,8 +1474,8 @@ abstract class CouponVersion implements ActiveRecordInterface case 'DESCRIPTION': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case 'VALUE': - $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); + case 'AMOUNT': + $stmt->bindValue($identifier, $this->amount, PDO::PARAM_STR); break; case 'IS_USED': $stmt->bindValue($identifier, $this->is_used, PDO::PARAM_INT); @@ -1305,6 +1489,18 @@ abstract class CouponVersion implements ActiveRecordInterface case 'SERIALIZED_RULES': $stmt->bindValue($identifier, $this->serialized_rules, PDO::PARAM_STR); break; + case 'IS_CUMULATIVE': + $stmt->bindValue($identifier, $this->is_cumulative, PDO::PARAM_INT); + break; + case 'IS_REMOVING_POSTAGE': + $stmt->bindValue($identifier, $this->is_removing_postage, PDO::PARAM_INT); + break; + case 'MAX_USAGE': + $stmt->bindValue($identifier, $this->max_usage, PDO::PARAM_INT); + break; + case 'IS_AVAILABLE_ON_SPECIAL_OFFERS': + $stmt->bindValue($identifier, (int) $this->is_available_on_special_offers, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1388,7 +1584,7 @@ abstract class CouponVersion implements ActiveRecordInterface return $this->getDescription(); break; case 6: - return $this->getValue(); + return $this->getAmount(); break; case 7: return $this->getIsUsed(); @@ -1403,12 +1599,24 @@ abstract class CouponVersion implements ActiveRecordInterface return $this->getSerializedRules(); break; case 11: - return $this->getCreatedAt(); + return $this->getIsCumulative(); break; case 12: - return $this->getUpdatedAt(); + return $this->getIsRemovingPostage(); break; case 13: + return $this->getMaxUsage(); + break; + case 14: + return $this->getIsAvailableOnSpecialOffers(); + break; + case 15: + return $this->getCreatedAt(); + break; + case 16: + return $this->getUpdatedAt(); + break; + case 17: return $this->getVersion(); break; default: @@ -1446,14 +1654,18 @@ abstract class CouponVersion implements ActiveRecordInterface $keys[3] => $this->getTitle(), $keys[4] => $this->getShortDescription(), $keys[5] => $this->getDescription(), - $keys[6] => $this->getValue(), + $keys[6] => $this->getAmount(), $keys[7] => $this->getIsUsed(), $keys[8] => $this->getIsEnabled(), $keys[9] => $this->getExpirationDate(), $keys[10] => $this->getSerializedRules(), - $keys[11] => $this->getCreatedAt(), - $keys[12] => $this->getUpdatedAt(), - $keys[13] => $this->getVersion(), + $keys[11] => $this->getIsCumulative(), + $keys[12] => $this->getIsRemovingPostage(), + $keys[13] => $this->getMaxUsage(), + $keys[14] => $this->getIsAvailableOnSpecialOffers(), + $keys[15] => $this->getCreatedAt(), + $keys[16] => $this->getUpdatedAt(), + $keys[17] => $this->getVersion(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1518,7 +1730,7 @@ abstract class CouponVersion implements ActiveRecordInterface $this->setDescription($value); break; case 6: - $this->setValue($value); + $this->setAmount($value); break; case 7: $this->setIsUsed($value); @@ -1533,12 +1745,24 @@ abstract class CouponVersion implements ActiveRecordInterface $this->setSerializedRules($value); break; case 11: - $this->setCreatedAt($value); + $this->setIsCumulative($value); break; case 12: - $this->setUpdatedAt($value); + $this->setIsRemovingPostage($value); break; case 13: + $this->setMaxUsage($value); + break; + case 14: + $this->setIsAvailableOnSpecialOffers($value); + break; + case 15: + $this->setCreatedAt($value); + break; + case 16: + $this->setUpdatedAt($value); + break; + case 17: $this->setVersion($value); break; } // switch() @@ -1571,14 +1795,18 @@ abstract class CouponVersion implements ActiveRecordInterface if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setShortDescription($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setDescription($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setValue($arr[$keys[6]]); + if (array_key_exists($keys[6], $arr)) $this->setAmount($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setIsUsed($arr[$keys[7]]); if (array_key_exists($keys[8], $arr)) $this->setIsEnabled($arr[$keys[8]]); if (array_key_exists($keys[9], $arr)) $this->setExpirationDate($arr[$keys[9]]); if (array_key_exists($keys[10], $arr)) $this->setSerializedRules($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setCreatedAt($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setUpdatedAt($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setVersion($arr[$keys[13]]); + if (array_key_exists($keys[11], $arr)) $this->setIsCumulative($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setIsRemovingPostage($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setMaxUsage($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setCreatedAt($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setUpdatedAt($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setVersion($arr[$keys[17]]); } /** @@ -1596,11 +1824,15 @@ abstract class CouponVersion implements ActiveRecordInterface if ($this->isColumnModified(CouponVersionTableMap::TITLE)) $criteria->add(CouponVersionTableMap::TITLE, $this->title); if ($this->isColumnModified(CouponVersionTableMap::SHORT_DESCRIPTION)) $criteria->add(CouponVersionTableMap::SHORT_DESCRIPTION, $this->short_description); if ($this->isColumnModified(CouponVersionTableMap::DESCRIPTION)) $criteria->add(CouponVersionTableMap::DESCRIPTION, $this->description); - if ($this->isColumnModified(CouponVersionTableMap::VALUE)) $criteria->add(CouponVersionTableMap::VALUE, $this->value); + if ($this->isColumnModified(CouponVersionTableMap::AMOUNT)) $criteria->add(CouponVersionTableMap::AMOUNT, $this->amount); if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) $criteria->add(CouponVersionTableMap::IS_USED, $this->is_used); if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) $criteria->add(CouponVersionTableMap::IS_ENABLED, $this->is_enabled); if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) $criteria->add(CouponVersionTableMap::EXPIRATION_DATE, $this->expiration_date); if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES)) $criteria->add(CouponVersionTableMap::SERIALIZED_RULES, $this->serialized_rules); + if ($this->isColumnModified(CouponVersionTableMap::IS_CUMULATIVE)) $criteria->add(CouponVersionTableMap::IS_CUMULATIVE, $this->is_cumulative); + if ($this->isColumnModified(CouponVersionTableMap::IS_REMOVING_POSTAGE)) $criteria->add(CouponVersionTableMap::IS_REMOVING_POSTAGE, $this->is_removing_postage); + if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) $criteria->add(CouponVersionTableMap::MAX_USAGE, $this->max_usage); + if ($this->isColumnModified(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) $criteria->add(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $this->is_available_on_special_offers); if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) $criteria->add(CouponVersionTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CouponVersionTableMap::UPDATED_AT)) $criteria->add(CouponVersionTableMap::UPDATED_AT, $this->updated_at); if ($this->isColumnModified(CouponVersionTableMap::VERSION)) $criteria->add(CouponVersionTableMap::VERSION, $this->version); @@ -1680,11 +1912,15 @@ abstract class CouponVersion implements ActiveRecordInterface $copyObj->setTitle($this->getTitle()); $copyObj->setShortDescription($this->getShortDescription()); $copyObj->setDescription($this->getDescription()); - $copyObj->setValue($this->getValue()); + $copyObj->setAmount($this->getAmount()); $copyObj->setIsUsed($this->getIsUsed()); $copyObj->setIsEnabled($this->getIsEnabled()); $copyObj->setExpirationDate($this->getExpirationDate()); $copyObj->setSerializedRules($this->getSerializedRules()); + $copyObj->setIsCumulative($this->getIsCumulative()); + $copyObj->setIsRemovingPostage($this->getIsRemovingPostage()); + $copyObj->setMaxUsage($this->getMaxUsage()); + $copyObj->setIsAvailableOnSpecialOffers($this->getIsAvailableOnSpecialOffers()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); $copyObj->setVersion($this->getVersion()); @@ -1777,11 +2013,15 @@ abstract class CouponVersion implements ActiveRecordInterface $this->title = null; $this->short_description = null; $this->description = null; - $this->value = null; + $this->amount = null; $this->is_used = null; $this->is_enabled = null; $this->expiration_date = null; $this->serialized_rules = null; + $this->is_cumulative = null; + $this->is_removing_postage = null; + $this->max_usage = null; + $this->is_available_on_special_offers = null; $this->created_at = null; $this->updated_at = null; $this->version = null; diff --git a/core/lib/Thelia/Model/Base/CouponVersionQuery.php b/core/lib/Thelia/Model/Base/CouponVersionQuery.php index e1acec354..71ce72aee 100644 --- a/core/lib/Thelia/Model/Base/CouponVersionQuery.php +++ b/core/lib/Thelia/Model/Base/CouponVersionQuery.php @@ -27,11 +27,15 @@ use Thelia\Model\Map\CouponVersionTableMap; * @method ChildCouponVersionQuery orderByTitle($order = Criteria::ASC) Order by the title column * @method ChildCouponVersionQuery orderByShortDescription($order = Criteria::ASC) Order by the short_description column * @method ChildCouponVersionQuery orderByDescription($order = Criteria::ASC) Order by the description column - * @method ChildCouponVersionQuery orderByValue($order = Criteria::ASC) Order by the value column + * @method ChildCouponVersionQuery orderByAmount($order = Criteria::ASC) Order by the amount column * @method ChildCouponVersionQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column * @method ChildCouponVersionQuery orderByIsEnabled($order = Criteria::ASC) Order by the is_enabled column * @method ChildCouponVersionQuery orderByExpirationDate($order = Criteria::ASC) Order by the expiration_date column * @method ChildCouponVersionQuery orderBySerializedRules($order = Criteria::ASC) Order by the serialized_rules column + * @method ChildCouponVersionQuery orderByIsCumulative($order = Criteria::ASC) Order by the is_cumulative column + * @method ChildCouponVersionQuery orderByIsRemovingPostage($order = Criteria::ASC) Order by the is_removing_postage column + * @method ChildCouponVersionQuery orderByMaxUsage($order = Criteria::ASC) Order by the max_usage column + * @method ChildCouponVersionQuery orderByIsAvailableOnSpecialOffers($order = Criteria::ASC) Order by the is_available_on_special_offers column * @method ChildCouponVersionQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCouponVersionQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @method ChildCouponVersionQuery orderByVersion($order = Criteria::ASC) Order by the version column @@ -42,11 +46,15 @@ use Thelia\Model\Map\CouponVersionTableMap; * @method ChildCouponVersionQuery groupByTitle() Group by the title column * @method ChildCouponVersionQuery groupByShortDescription() Group by the short_description column * @method ChildCouponVersionQuery groupByDescription() Group by the description column - * @method ChildCouponVersionQuery groupByValue() Group by the value column + * @method ChildCouponVersionQuery groupByAmount() Group by the amount column * @method ChildCouponVersionQuery groupByIsUsed() Group by the is_used column * @method ChildCouponVersionQuery groupByIsEnabled() Group by the is_enabled column * @method ChildCouponVersionQuery groupByExpirationDate() Group by the expiration_date column * @method ChildCouponVersionQuery groupBySerializedRules() Group by the serialized_rules column + * @method ChildCouponVersionQuery groupByIsCumulative() Group by the is_cumulative column + * @method ChildCouponVersionQuery groupByIsRemovingPostage() Group by the is_removing_postage column + * @method ChildCouponVersionQuery groupByMaxUsage() Group by the max_usage column + * @method ChildCouponVersionQuery groupByIsAvailableOnSpecialOffers() Group by the is_available_on_special_offers column * @method ChildCouponVersionQuery groupByCreatedAt() Group by the created_at column * @method ChildCouponVersionQuery groupByUpdatedAt() Group by the updated_at column * @method ChildCouponVersionQuery groupByVersion() Group by the version column @@ -68,11 +76,15 @@ use Thelia\Model\Map\CouponVersionTableMap; * @method ChildCouponVersion findOneByTitle(string $title) Return the first ChildCouponVersion filtered by the title column * @method ChildCouponVersion findOneByShortDescription(string $short_description) Return the first ChildCouponVersion filtered by the short_description column * @method ChildCouponVersion findOneByDescription(string $description) Return the first ChildCouponVersion filtered by the description column - * @method ChildCouponVersion findOneByValue(double $value) Return the first ChildCouponVersion filtered by the value column + * @method ChildCouponVersion findOneByAmount(double $amount) Return the first ChildCouponVersion filtered by the amount column * @method ChildCouponVersion findOneByIsUsed(int $is_used) Return the first ChildCouponVersion filtered by the is_used column * @method ChildCouponVersion findOneByIsEnabled(int $is_enabled) Return the first ChildCouponVersion filtered by the is_enabled column * @method ChildCouponVersion findOneByExpirationDate(string $expiration_date) Return the first ChildCouponVersion filtered by the expiration_date column * @method ChildCouponVersion findOneBySerializedRules(string $serialized_rules) Return the first ChildCouponVersion filtered by the serialized_rules column + * @method ChildCouponVersion findOneByIsCumulative(int $is_cumulative) Return the first ChildCouponVersion filtered by the is_cumulative column + * @method ChildCouponVersion findOneByIsRemovingPostage(int $is_removing_postage) Return the first ChildCouponVersion filtered by the is_removing_postage column + * @method ChildCouponVersion findOneByMaxUsage(int $max_usage) Return the first ChildCouponVersion filtered by the max_usage column + * @method ChildCouponVersion findOneByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return the first ChildCouponVersion filtered by the is_available_on_special_offers column * @method ChildCouponVersion findOneByCreatedAt(string $created_at) Return the first ChildCouponVersion filtered by the created_at column * @method ChildCouponVersion findOneByUpdatedAt(string $updated_at) Return the first ChildCouponVersion filtered by the updated_at column * @method ChildCouponVersion findOneByVersion(int $version) Return the first ChildCouponVersion filtered by the version column @@ -83,11 +95,15 @@ use Thelia\Model\Map\CouponVersionTableMap; * @method array findByTitle(string $title) Return ChildCouponVersion objects filtered by the title column * @method array findByShortDescription(string $short_description) Return ChildCouponVersion objects filtered by the short_description column * @method array findByDescription(string $description) Return ChildCouponVersion objects filtered by the description column - * @method array findByValue(double $value) Return ChildCouponVersion objects filtered by the value column + * @method array findByAmount(double $amount) Return ChildCouponVersion objects filtered by the amount column * @method array findByIsUsed(int $is_used) Return ChildCouponVersion objects filtered by the is_used column * @method array findByIsEnabled(int $is_enabled) Return ChildCouponVersion objects filtered by the is_enabled column * @method array findByExpirationDate(string $expiration_date) Return ChildCouponVersion objects filtered by the expiration_date column * @method array findBySerializedRules(string $serialized_rules) Return ChildCouponVersion objects filtered by the serialized_rules column + * @method array findByIsCumulative(int $is_cumulative) Return ChildCouponVersion objects filtered by the is_cumulative column + * @method array findByIsRemovingPostage(int $is_removing_postage) Return ChildCouponVersion objects filtered by the is_removing_postage column + * @method array findByMaxUsage(int $max_usage) Return ChildCouponVersion objects filtered by the max_usage column + * @method array findByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return ChildCouponVersion objects filtered by the is_available_on_special_offers column * @method array findByCreatedAt(string $created_at) Return ChildCouponVersion objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCouponVersion objects filtered by the updated_at column * @method array findByVersion(int $version) Return ChildCouponVersion objects filtered by the version column @@ -179,7 +195,7 @@ abstract class CouponVersionQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, VALUE, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES, CREATED_AT, UPDATED_AT, VERSION FROM coupon_version WHERE ID = :p0 AND VERSION = :p1'; + $sql = 'SELECT ID, CODE, TYPE, TITLE, SHORT_DESCRIPTION, DESCRIPTION, AMOUNT, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES, IS_CUMULATIVE, IS_REMOVING_POSTAGE, MAX_USAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, CREATED_AT, UPDATED_AT, VERSION FROM coupon_version WHERE ID = :p0 AND VERSION = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -469,16 +485,16 @@ abstract class CouponVersionQuery extends ModelCriteria } /** - * Filter the query on the value column + * Filter the query on the amount column * * Example usage: * - * $query->filterByValue(1234); // WHERE value = 1234 - * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34) - * $query->filterByValue(array('min' => 12)); // WHERE value > 12 + * $query->filterByAmount(1234); // WHERE amount = 1234 + * $query->filterByAmount(array(12, 34)); // WHERE amount IN (12, 34) + * $query->filterByAmount(array('min' => 12)); // WHERE amount > 12 * * - * @param mixed $value The value to use as filter. + * @param mixed $amount The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -486,16 +502,16 @@ abstract class CouponVersionQuery extends ModelCriteria * * @return ChildCouponVersionQuery The current query, for fluid interface */ - public function filterByValue($value = null, $comparison = null) + public function filterByAmount($amount = null, $comparison = null) { - if (is_array($value)) { + if (is_array($amount)) { $useMinMax = false; - if (isset($value['min'])) { - $this->addUsingAlias(CouponVersionTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL); + if (isset($amount['min'])) { + $this->addUsingAlias(CouponVersionTableMap::AMOUNT, $amount['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($value['max'])) { - $this->addUsingAlias(CouponVersionTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL); + if (isset($amount['max'])) { + $this->addUsingAlias(CouponVersionTableMap::AMOUNT, $amount['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -506,7 +522,7 @@ abstract class CouponVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponVersionTableMap::VALUE, $value, $comparison); + return $this->addUsingAlias(CouponVersionTableMap::AMOUNT, $amount, $comparison); } /** @@ -663,6 +679,156 @@ abstract class CouponVersionQuery extends ModelCriteria return $this->addUsingAlias(CouponVersionTableMap::SERIALIZED_RULES, $serializedRules, $comparison); } + /** + * Filter the query on the is_cumulative column + * + * Example usage: + * + * $query->filterByIsCumulative(1234); // WHERE is_cumulative = 1234 + * $query->filterByIsCumulative(array(12, 34)); // WHERE is_cumulative IN (12, 34) + * $query->filterByIsCumulative(array('min' => 12)); // WHERE is_cumulative > 12 + * + * + * @param mixed $isCumulative The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByIsCumulative($isCumulative = null, $comparison = null) + { + if (is_array($isCumulative)) { + $useMinMax = false; + if (isset($isCumulative['min'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isCumulative['max'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative, $comparison); + } + + /** + * Filter the query on the is_removing_postage column + * + * Example usage: + * + * $query->filterByIsRemovingPostage(1234); // WHERE is_removing_postage = 1234 + * $query->filterByIsRemovingPostage(array(12, 34)); // WHERE is_removing_postage IN (12, 34) + * $query->filterByIsRemovingPostage(array('min' => 12)); // WHERE is_removing_postage > 12 + * + * + * @param mixed $isRemovingPostage The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByIsRemovingPostage($isRemovingPostage = null, $comparison = null) + { + if (is_array($isRemovingPostage)) { + $useMinMax = false; + if (isset($isRemovingPostage['min'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isRemovingPostage['max'])) { + $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison); + } + + /** + * Filter the query on the max_usage column + * + * Example usage: + * + * $query->filterByMaxUsage(1234); // WHERE max_usage = 1234 + * $query->filterByMaxUsage(array(12, 34)); // WHERE max_usage IN (12, 34) + * $query->filterByMaxUsage(array('min' => 12)); // WHERE max_usage > 12 + * + * + * @param mixed $maxUsage The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByMaxUsage($maxUsage = null, $comparison = null) + { + if (is_array($maxUsage)) { + $useMinMax = false; + if (isset($maxUsage['min'])) { + $this->addUsingAlias(CouponVersionTableMap::MAX_USAGE, $maxUsage['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($maxUsage['max'])) { + $this->addUsingAlias(CouponVersionTableMap::MAX_USAGE, $maxUsage['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::MAX_USAGE, $maxUsage, $comparison); + } + + /** + * Filter the query on the is_available_on_special_offers column + * + * Example usage: + * + * $query->filterByIsAvailableOnSpecialOffers(true); // WHERE is_available_on_special_offers = true + * $query->filterByIsAvailableOnSpecialOffers('yes'); // WHERE is_available_on_special_offers = true + * + * + * @param boolean|string $isAvailableOnSpecialOffers The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers = null, $comparison = null) + { + if (is_string($isAvailableOnSpecialOffers)) { + $is_available_on_special_offers = in_array(strtolower($isAvailableOnSpecialOffers), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $isAvailableOnSpecialOffers, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Rewriting.php b/core/lib/Thelia/Model/Base/Rewriting.php deleted file mode 100755 index c8109458d..000000000 --- a/core/lib/Thelia/Model/Base/Rewriting.php +++ /dev/null @@ -1,1812 +0,0 @@ -modifiedColumns); - } - - /** - * Has specified column been modified? - * - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID - * @return boolean True if $col has been modified. - */ - public function isColumnModified($col) - { - return in_array($col, $this->modifiedColumns); - } - - /** - * Get the columns that have been modified in this object. - * @return array A unique list of the modified column names for this object. - */ - public function getModifiedColumns() - { - return array_unique($this->modifiedColumns); - } - - /** - * Returns whether the object has ever been saved. This will - * be false, if the object was retrieved from storage or was created - * and then saved. - * - * @return true, if the object has never been persisted. - */ - public function isNew() - { - return $this->new; - } - - /** - * Setter for the isNew attribute. This method will be called - * by Propel-generated children and objects. - * - * @param boolean $b the state of the object. - */ - public function setNew($b) - { - $this->new = (Boolean) $b; - } - - /** - * Whether this object has been deleted. - * @return boolean The deleted state of this object. - */ - public function isDeleted() - { - return $this->deleted; - } - - /** - * Specify whether this object has been deleted. - * @param boolean $b The deleted state of this object. - * @return void - */ - public function setDeleted($b) - { - $this->deleted = (Boolean) $b; - } - - /** - * Sets the modified state for the object to be false. - * @param string $col If supplied, only the specified column is reset. - * @return void - */ - public function resetModified($col = null) - { - if (null !== $col) { - while (false !== ($offset = array_search($col, $this->modifiedColumns))) { - array_splice($this->modifiedColumns, $offset, 1); - } - } else { - $this->modifiedColumns = array(); - } - } - - /** - * Compares this with another Rewriting instance. If - * obj is an instance of Rewriting, delegates to - * equals(Rewriting). Otherwise, returns false. - * - * @param obj The object to compare to. - * @return Whether equal to the object specified. - */ - public function equals($obj) - { - $thisclazz = get_class($this); - if (!is_object($obj) || !($obj instanceof $thisclazz)) { - return false; - } - - if ($this === $obj) { - return true; - } - - if (null === $this->getPrimaryKey() - || null === $obj->getPrimaryKey()) { - return false; - } - - return $this->getPrimaryKey() === $obj->getPrimaryKey(); - } - - /** - * If the primary key is not null, return the hashcode of the - * primary key. Otherwise, return the hash code of the object. - * - * @return int Hashcode - */ - public function hashCode() - { - if (null !== $this->getPrimaryKey()) { - return crc32(serialize($this->getPrimaryKey())); - } - - return crc32(serialize(clone $this)); - } - - /** - * Get the associative array of the virtual columns in this object - * - * @param string $name The virtual column name - * - * @return array - */ - public function getVirtualColumns() - { - return $this->virtualColumns; - } - - /** - * Checks the existence of a virtual column in this object - * - * @return boolean - */ - public function hasVirtualColumn($name) - { - return array_key_exists($name, $this->virtualColumns); - } - - /** - * Get the value of a virtual column in this object - * - * @return mixed - */ - public function getVirtualColumn($name) - { - if (!$this->hasVirtualColumn($name)) { - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); - } - - return $this->virtualColumns[$name]; - } - - /** - * Set the value of a virtual column in this object - * - * @param string $name The virtual column name - * @param mixed $value The value to give to the virtual column - * - * @return Rewriting The current object, for fluid interface - */ - public function setVirtualColumn($name, $value) - { - $this->virtualColumns[$name] = $value; - - return $this; - } - - /** - * Logs a message using Propel::log(). - * - * @param string $msg - * @param int $priority One of the Propel::LOG_* logging levels - * @return boolean - */ - protected function log($msg, $priority = Propel::LOG_INFO) - { - return Propel::log(get_class($this) . ': ' . $msg, $priority); - } - - /** - * Populate the current object from a string, using a given parser format - * - * $book = new Book(); - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, - * or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param string $data The source data to import from - * - * @return Rewriting The current object, for fluid interface - */ - public function importFrom($parser, $data) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); - } - - /** - * Export the current object properties to a string, using a given parser format - * - * $book = BookQuery::create()->findPk(9012); - * echo $book->exportTo('JSON'); - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. - * @return string The exported data - */ - public function exportTo($parser, $includeLazyLoadColumns = true) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); - } - - /** - * Clean up internal collections prior to serializing - * Avoids recursive loops that turn into segmentation faults when serializing - */ - public function __sleep() - { - $this->clearAllReferences(); - - return array_keys(get_object_vars($this)); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - - return $this->id; - } - - /** - * Get the [url] column value. - * - * @return string - */ - public function getUrl() - { - - return $this->url; - } - - /** - * Get the [product_id] column value. - * - * @return int - */ - public function getProductId() - { - - return $this->product_id; - } - - /** - * Get the [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - - return $this->category_id; - } - - /** - * Get the [folder_id] column value. - * - * @return int - */ - public function getFolderId() - { - - return $this->folder_id; - } - - /** - * Get the [content_id] column value. - * - * @return int - */ - public function getContentId() - { - - return $this->content_id; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = NULL) - { - if ($format === null) { - return $this->created_at; - } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; - } - } - - /** - * Get the [optionally formatted] temporal [updated_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getUpdatedAt($format = NULL) - { - if ($format === null) { - return $this->updated_at; - } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; - } - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return \Thelia\Model\Rewriting The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = RewritingTableMap::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [url] column. - * - * @param string $v new value - * @return \Thelia\Model\Rewriting The current object (for fluent API support) - */ - public function setUrl($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->url !== $v) { - $this->url = $v; - $this->modifiedColumns[] = RewritingTableMap::URL; - } - - - return $this; - } // setUrl() - - /** - * Set the value of [product_id] column. - * - * @param int $v new value - * @return \Thelia\Model\Rewriting The current object (for fluent API support) - */ - public function setProductId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->product_id !== $v) { - $this->product_id = $v; - $this->modifiedColumns[] = RewritingTableMap::PRODUCT_ID; - } - - if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { - $this->aProduct = null; - } - - - return $this; - } // setProductId() - - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return \Thelia\Model\Rewriting The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = RewritingTableMap::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - - /** - * Set the value of [folder_id] column. - * - * @param int $v new value - * @return \Thelia\Model\Rewriting The current object (for fluent API support) - */ - public function setFolderId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->folder_id !== $v) { - $this->folder_id = $v; - $this->modifiedColumns[] = RewritingTableMap::FOLDER_ID; - } - - if ($this->aFolder !== null && $this->aFolder->getId() !== $v) { - $this->aFolder = null; - } - - - return $this; - } // setFolderId() - - /** - * Set the value of [content_id] column. - * - * @param int $v new value - * @return \Thelia\Model\Rewriting The current object (for fluent API support) - */ - public function setContentId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->content_id !== $v) { - $this->content_id = $v; - $this->modifiedColumns[] = RewritingTableMap::CONTENT_ID; - } - - if ($this->aContent !== null && $this->aContent->getId() !== $v) { - $this->aContent = null; - } - - - return $this; - } // setContentId() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\Rewriting The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->created_at !== null || $dt !== null) { - if ($dt !== $this->created_at) { - $this->created_at = $dt; - $this->modifiedColumns[] = RewritingTableMap::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\Rewriting The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->updated_at !== null || $dt !== null) { - if ($dt !== $this->updated_at) { - $this->updated_at = $dt; - $this->modifiedColumns[] = RewritingTableMap::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return TRUE - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by DataFetcher->fetch(). - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) - { - try { - - - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : RewritingTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - $this->id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : RewritingTableMap::translateFieldName('Url', TableMap::TYPE_PHPNAME, $indexType)]; - $this->url = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : RewritingTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->product_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : RewritingTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->category_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : RewritingTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->folder_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : RewritingTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->content_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : RewritingTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : RewritingTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 8; // 8 = RewritingTableMap::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\Rewriting object", 0, $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { - $this->aProduct = null; - } - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; - } - if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) { - $this->aFolder = null; - } - if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { - $this->aContent = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(RewritingTableMap::DATABASE_NAME); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $dataFetcher = ChildRewritingQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); - $row = $dataFetcher->fetch(); - $dataFetcher->close(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aProduct = null; - $this->aCategory = null; - $this->aFolder = null; - $this->aContent = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param ConnectionInterface $con - * @return void - * @throws PropelException - * @see Rewriting::setDeleted() - * @see Rewriting::isDeleted() - */ - public function delete(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - try { - $deleteQuery = ChildRewritingQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see doSave() - */ - public function save(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(RewritingTableMap::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(RewritingTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(RewritingTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - RewritingTableMap::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(ConnectionInterface $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their corresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aProduct !== null) { - if ($this->aProduct->isModified() || $this->aProduct->isNew()) { - $affectedRows += $this->aProduct->save($con); - } - $this->setProduct($this->aProduct); - } - - if ($this->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - - if ($this->aFolder !== null) { - if ($this->aFolder->isModified() || $this->aFolder->isNew()) { - $affectedRows += $this->aFolder->save($con); - } - $this->setFolder($this->aFolder); - } - - if ($this->aContent !== null) { - if ($this->aContent->isModified() || $this->aContent->isNew()) { - $affectedRows += $this->aContent->save($con); - } - $this->setContent($this->aContent); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param ConnectionInterface $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(ConnectionInterface $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(RewritingTableMap::ID)) { - $modifiedColumns[':p' . $index++] = 'ID'; - } - if ($this->isColumnModified(RewritingTableMap::URL)) { - $modifiedColumns[':p' . $index++] = 'URL'; - } - if ($this->isColumnModified(RewritingTableMap::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; - } - if ($this->isColumnModified(RewritingTableMap::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; - } - if ($this->isColumnModified(RewritingTableMap::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = 'FOLDER_ID'; - } - if ($this->isColumnModified(RewritingTableMap::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; - } - if ($this->isColumnModified(RewritingTableMap::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = 'CREATED_AT'; - } - if ($this->isColumnModified(RewritingTableMap::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; - } - - $sql = sprintf( - 'INSERT INTO rewriting (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case 'ID': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case 'URL': - $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR); - break; - case 'PRODUCT_ID': - $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); - break; - case 'CATEGORY_ID': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); - break; - case 'FOLDER_ID': - $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); - break; - case 'CONTENT_ID': - $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); - break; - case 'CREATED_AT': - $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - case 'UPDATED_AT': - $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); - } - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param ConnectionInterface $con - * - * @return Integer Number of updated rows - * @see doSave() - */ - protected function doUpdate(ConnectionInterface $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - - return $selectCriteria->doUpdate($valuesCriteria, $con); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return mixed Value of field. - */ - public function getByName($name, $type = TableMap::TYPE_PHPNAME) - { - $pos = RewritingTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getUrl(); - break; - case 2: - return $this->getProductId(); - break; - case 3: - return $this->getCategoryId(); - break; - case 4: - return $this->getFolderId(); - break; - case 5: - return $this->getContentId(); - break; - case 6: - return $this->getCreatedAt(); - break; - case 7: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Rewriting'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Rewriting'][$this->getPrimaryKey()] = true; - $keys = RewritingTableMap::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getUrl(), - $keys[2] => $this->getProductId(), - $keys[3] => $this->getCategoryId(), - $keys[4] => $this->getFolderId(), - $keys[5] => $this->getContentId(), - $keys[6] => $this->getCreatedAt(), - $keys[7] => $this->getUpdatedAt(), - ); - $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { - $result[$key] = $virtualColumn; - } - - if ($includeForeignObjects) { - if (null !== $this->aProduct) { - $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aFolder) { - $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aContent) { - $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return void - */ - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) - { - $pos = RewritingTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - - return $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setUrl($value); - break; - case 2: - $this->setProductId($value); - break; - case 3: - $this->setCategoryId($value); - break; - case 4: - $this->setFolderId($value); - break; - case 5: - $this->setContentId($value); - break; - case 6: - $this->setCreatedAt($value); - break; - case 7: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * The default key type is the column's TableMap::TYPE_PHPNAME. - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) - { - $keys = RewritingTableMap::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setUrl($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCategoryId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setFolderId($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setContentId($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(RewritingTableMap::DATABASE_NAME); - - if ($this->isColumnModified(RewritingTableMap::ID)) $criteria->add(RewritingTableMap::ID, $this->id); - if ($this->isColumnModified(RewritingTableMap::URL)) $criteria->add(RewritingTableMap::URL, $this->url); - if ($this->isColumnModified(RewritingTableMap::PRODUCT_ID)) $criteria->add(RewritingTableMap::PRODUCT_ID, $this->product_id); - if ($this->isColumnModified(RewritingTableMap::CATEGORY_ID)) $criteria->add(RewritingTableMap::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(RewritingTableMap::FOLDER_ID)) $criteria->add(RewritingTableMap::FOLDER_ID, $this->folder_id); - if ($this->isColumnModified(RewritingTableMap::CONTENT_ID)) $criteria->add(RewritingTableMap::CONTENT_ID, $this->content_id); - if ($this->isColumnModified(RewritingTableMap::CREATED_AT)) $criteria->add(RewritingTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(RewritingTableMap::UPDATED_AT)) $criteria->add(RewritingTableMap::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(RewritingTableMap::DATABASE_NAME); - $criteria->add(RewritingTableMap::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of \Thelia\Model\Rewriting (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setId($this->getId()); - $copyObj->setUrl($this->getUrl()); - $copyObj->setProductId($this->getProductId()); - $copyObj->setCategoryId($this->getCategoryId()); - $copyObj->setFolderId($this->getFolderId()); - $copyObj->setContentId($this->getContentId()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($makeNew) { - $copyObj->setNew(true); - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\Rewriting Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Declares an association between this object and a ChildProduct object. - * - * @param ChildProduct $v - * @return \Thelia\Model\Rewriting The current object (for fluent API support) - * @throws PropelException - */ - public function setProduct(ChildProduct $v = null) - { - if ($v === null) { - $this->setProductId(NULL); - } else { - $this->setProductId($v->getId()); - } - - $this->aProduct = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildProduct object, it will not be re-added. - if ($v !== null) { - $v->addRewriting($this); - } - - - return $this; - } - - - /** - * Get the associated ChildProduct object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildProduct The associated ChildProduct object. - * @throws PropelException - */ - public function getProduct(ConnectionInterface $con = null) - { - if ($this->aProduct === null && ($this->product_id !== null)) { - $this->aProduct = ChildProductQuery::create()->findPk($this->product_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aProduct->addRewritings($this); - */ - } - - return $this->aProduct; - } - - /** - * Declares an association between this object and a ChildCategory object. - * - * @param ChildCategory $v - * @return \Thelia\Model\Rewriting The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(ChildCategory $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildCategory object, it will not be re-added. - if ($v !== null) { - $v->addRewriting($this); - } - - - return $this; - } - - - /** - * Get the associated ChildCategory object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildCategory The associated ChildCategory object. - * @throws PropelException - */ - public function getCategory(ConnectionInterface $con = null) - { - if ($this->aCategory === null && ($this->category_id !== null)) { - $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCategory->addRewritings($this); - */ - } - - return $this->aCategory; - } - - /** - * Declares an association between this object and a ChildFolder object. - * - * @param ChildFolder $v - * @return \Thelia\Model\Rewriting The current object (for fluent API support) - * @throws PropelException - */ - public function setFolder(ChildFolder $v = null) - { - if ($v === null) { - $this->setFolderId(NULL); - } else { - $this->setFolderId($v->getId()); - } - - $this->aFolder = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildFolder object, it will not be re-added. - if ($v !== null) { - $v->addRewriting($this); - } - - - return $this; - } - - - /** - * Get the associated ChildFolder object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildFolder The associated ChildFolder object. - * @throws PropelException - */ - public function getFolder(ConnectionInterface $con = null) - { - if ($this->aFolder === null && ($this->folder_id !== null)) { - $this->aFolder = ChildFolderQuery::create()->findPk($this->folder_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aFolder->addRewritings($this); - */ - } - - return $this->aFolder; - } - - /** - * Declares an association between this object and a ChildContent object. - * - * @param ChildContent $v - * @return \Thelia\Model\Rewriting The current object (for fluent API support) - * @throws PropelException - */ - public function setContent(ChildContent $v = null) - { - if ($v === null) { - $this->setContentId(NULL); - } else { - $this->setContentId($v->getId()); - } - - $this->aContent = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildContent object, it will not be re-added. - if ($v !== null) { - $v->addRewriting($this); - } - - - return $this; - } - - - /** - * Get the associated ChildContent object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildContent The associated ChildContent object. - * @throws PropelException - */ - public function getContent(ConnectionInterface $con = null) - { - if ($this->aContent === null && ($this->content_id !== null)) { - $this->aContent = ChildContentQuery::create()->findPk($this->content_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aContent->addRewritings($this); - */ - } - - return $this->aContent; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->url = null; - $this->product_id = null; - $this->category_id = null; - $this->folder_id = null; - $this->content_id = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volume/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - } // if ($deep) - - $this->aProduct = null; - $this->aCategory = null; - $this->aFolder = null; - $this->aContent = null; - } - - /** - * Return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(RewritingTableMap::DEFAULT_STRING_FORMAT); - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return ChildRewriting The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = RewritingTableMap::UPDATED_AT; - - return $this; - } - - /** - * Code to be run before persisting the object - * @param ConnectionInterface $con - * @return boolean - */ - public function preSave(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after persisting the object - * @param ConnectionInterface $con - */ - public function postSave(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before inserting to database - * @param ConnectionInterface $con - * @return boolean - */ - public function preInsert(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after inserting to database - * @param ConnectionInterface $con - */ - public function postInsert(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before updating the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preUpdate(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after updating the object in database - * @param ConnectionInterface $con - */ - public function postUpdate(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before deleting the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preDelete(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after deleting the object in database - * @param ConnectionInterface $con - */ - public function postDelete(ConnectionInterface $con = null) - { - - } - - - /** - * Derived method to catches calls to undefined methods. - * - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). - * Allows to define default __call() behavior if you overwrite __call() - * - * @param string $name - * @param mixed $params - * - * @return array|string - */ - public function __call($name, $params) - { - if (0 === strpos($name, 'get')) { - $virtualColumn = substr($name, 3); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - - $virtualColumn = lcfirst($virtualColumn); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - } - - if (0 === strpos($name, 'from')) { - $format = substr($name, 4); - - return $this->importFrom($format, reset($params)); - } - - if (0 === strpos($name, 'to')) { - $format = substr($name, 2); - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; - - return $this->exportTo($format, $includeLazyLoadColumns); - } - - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); - } - -} diff --git a/core/lib/Thelia/Model/Base/RewritingQuery.php b/core/lib/Thelia/Model/Base/RewritingQuery.php deleted file mode 100755 index bf814cfd2..000000000 --- a/core/lib/Thelia/Model/Base/RewritingQuery.php +++ /dev/null @@ -1,1044 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ChildRewriting|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = RewritingTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(RewritingTableMap::DATABASE_NAME); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildRewriting A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, URL, PRODUCT_ID, CATEGORY_ID, FOLDER_ID, CONTENT_ID, CREATED_AT, UPDATED_AT FROM rewriting WHERE ID = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); - } - $obj = null; - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildRewriting(); - $obj->hydrate($row); - RewritingTableMap::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildRewriting|array|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(RewritingTableMap::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(RewritingTableMap::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(RewritingTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(RewritingTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the url column - * - * Example usage: - * - * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue' - * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%' - * - * - * @param string $url The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterByUrl($url = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($url)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $url)) { - $url = str_replace('*', '%', $url); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(RewritingTableMap::URL, $url, $comparison); - } - - /** - * Filter the query on the product_id column - * - * Example usage: - * - * $query->filterByProductId(1234); // WHERE product_id = 1234 - * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 - * - * - * @see filterByProduct() - * - * @param mixed $productId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterByProductId($productId = null, $comparison = null) - { - if (is_array($productId)) { - $useMinMax = false; - if (isset($productId['min'])) { - $this->addUsingAlias(RewritingTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($productId['max'])) { - $this->addUsingAlias(RewritingTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingTableMap::PRODUCT_ID, $productId, $comparison); - } - - /** - * Filter the query on the category_id column - * - * Example usage: - * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 - * - * - * @see filterByCategory() - * - * @param mixed $categoryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterByCategoryId($categoryId = null, $comparison = null) - { - if (is_array($categoryId)) { - $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(RewritingTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($categoryId['max'])) { - $this->addUsingAlias(RewritingTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingTableMap::CATEGORY_ID, $categoryId, $comparison); - } - - /** - * Filter the query on the folder_id column - * - * Example usage: - * - * $query->filterByFolderId(1234); // WHERE folder_id = 1234 - * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34) - * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12 - * - * - * @see filterByFolder() - * - * @param mixed $folderId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterByFolderId($folderId = null, $comparison = null) - { - if (is_array($folderId)) { - $useMinMax = false; - if (isset($folderId['min'])) { - $this->addUsingAlias(RewritingTableMap::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($folderId['max'])) { - $this->addUsingAlias(RewritingTableMap::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingTableMap::FOLDER_ID, $folderId, $comparison); - } - - /** - * Filter the query on the content_id column - * - * Example usage: - * - * $query->filterByContentId(1234); // WHERE content_id = 1234 - * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 - * - * - * @see filterByContent() - * - * @param mixed $contentId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterByContentId($contentId = null, $comparison = null) - { - if (is_array($contentId)) { - $useMinMax = false; - if (isset($contentId['min'])) { - $this->addUsingAlias(RewritingTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($contentId['max'])) { - $this->addUsingAlias(RewritingTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingTableMap::CONTENT_ID, $contentId, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(RewritingTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(RewritingTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingTableMap::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(RewritingTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(RewritingTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\Product object - * - * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterByProduct($product, $comparison = null) - { - if ($product instanceof \Thelia\Model\Product) { - return $this - ->addUsingAlias(RewritingTableMap::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(RewritingTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Product relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Product'); - } - - return $this; - } - - /** - * Use the Product relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Category object - * - * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof \Thelia\Model\Category) { - return $this - ->addUsingAlias(RewritingTableMap::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(RewritingTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Folder object - * - * @param \Thelia\Model\Folder|ObjectCollection $folder The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterByFolder($folder, $comparison = null) - { - if ($folder instanceof \Thelia\Model\Folder) { - return $this - ->addUsingAlias(RewritingTableMap::FOLDER_ID, $folder->getId(), $comparison); - } elseif ($folder instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(RewritingTableMap::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Folder relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Folder'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Folder'); - } - - return $this; - } - - /** - * Use the Folder relation Folder object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query - */ - public function useFolderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinFolder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Content object - * - * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function filterByContent($content, $comparison = null) - { - if ($content instanceof \Thelia\Model\Content) { - return $this - ->addUsingAlias(RewritingTableMap::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(RewritingTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Content relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Content'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Content'); - } - - return $this; - } - - /** - * Use the Content relation Content object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query - */ - public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContent($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); - } - - /** - * Exclude object from result - * - * @param ChildRewriting $rewriting Object to remove from the list of results - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function prune($rewriting = null) - { - if ($rewriting) { - $this->addUsingAlias(RewritingTableMap::ID, $rewriting->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - /** - * Deletes all rows from the rewriting table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public function doDeleteAll(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += parent::doDeleteAll($con); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - RewritingTableMap::clearInstancePool(); - RewritingTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildRewriting or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildRewriting object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public function delete(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(RewritingTableMap::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - - RewritingTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - RewritingTableMap::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(RewritingTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(RewritingTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(RewritingTableMap::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(RewritingTableMap::UPDATED_AT); - } - - /** - * Order by create date desc - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(RewritingTableMap::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ChildRewritingQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(RewritingTableMap::CREATED_AT); - } - -} // RewritingQuery diff --git a/core/lib/Thelia/Model/Map/CouponTableMap.php b/core/lib/Thelia/Model/Map/CouponTableMap.php index 7e576a585..d3ba620bf 100755 --- a/core/lib/Thelia/Model/Map/CouponTableMap.php +++ b/core/lib/Thelia/Model/Map/CouponTableMap.php @@ -57,7 +57,7 @@ class CouponTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 14; + const NUM_COLUMNS = 18; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CouponTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 14; + const NUM_HYDRATE_COLUMNS = 18; /** * the column name for the ID field @@ -100,9 +100,9 @@ class CouponTableMap extends TableMap const DESCRIPTION = 'coupon.DESCRIPTION'; /** - * the column name for the VALUE field + * the column name for the AMOUNT field */ - const VALUE = 'coupon.VALUE'; + const AMOUNT = 'coupon.AMOUNT'; /** * the column name for the IS_USED field @@ -124,6 +124,26 @@ class CouponTableMap extends TableMap */ const SERIALIZED_RULES = 'coupon.SERIALIZED_RULES'; + /** + * the column name for the IS_CUMULATIVE field + */ + const IS_CUMULATIVE = 'coupon.IS_CUMULATIVE'; + + /** + * the column name for the IS_REMOVING_POSTAGE field + */ + const IS_REMOVING_POSTAGE = 'coupon.IS_REMOVING_POSTAGE'; + + /** + * the column name for the MAX_USAGE field + */ + const MAX_USAGE = 'coupon.MAX_USAGE'; + + /** + * the column name for the IS_AVAILABLE_ON_SPECIAL_OFFERS field + */ + const IS_AVAILABLE_ON_SPECIAL_OFFERS = 'coupon.IS_AVAILABLE_ON_SPECIAL_OFFERS'; + /** * the column name for the CREATED_AT field */ @@ -160,12 +180,12 @@ class CouponTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Value', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'CreatedAt', 'UpdatedAt', 'Version', ), - self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'value', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'createdAt', 'updatedAt', 'version', ), - self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::TITLE, CouponTableMap::SHORT_DESCRIPTION, CouponTableMap::DESCRIPTION, CouponTableMap::VALUE, CouponTableMap::IS_USED, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::SERIALIZED_RULES, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ), - self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'VALUE', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), - self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'value', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'created_at', 'updated_at', 'version', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Amount', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'IsCumulative', 'IsRemovingPostage', 'MaxUsage', 'IsAvailableOnSpecialOffers', 'CreatedAt', 'UpdatedAt', 'Version', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'amount', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'isCumulative', 'isRemovingPostage', 'maxUsage', 'isAvailableOnSpecialOffers', 'createdAt', 'updatedAt', 'version', ), + self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::TITLE, CouponTableMap::SHORT_DESCRIPTION, CouponTableMap::DESCRIPTION, CouponTableMap::AMOUNT, CouponTableMap::IS_USED, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::SERIALIZED_RULES, CouponTableMap::IS_CUMULATIVE, CouponTableMap::IS_REMOVING_POSTAGE, CouponTableMap::MAX_USAGE, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'AMOUNT', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'MAX_USAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), + self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'amount', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'is_cumulative', 'is_removing_postage', 'max_usage', 'is_available_on_special_offers', 'created_at', 'updated_at', 'version', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); /** @@ -175,12 +195,12 @@ class CouponTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Value' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRules' => 10, 'CreatedAt' => 11, 'UpdatedAt' => 12, 'Version' => 13, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'value' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRules' => 10, 'createdAt' => 11, 'updatedAt' => 12, 'version' => 13, ), - self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::TITLE => 3, CouponTableMap::SHORT_DESCRIPTION => 4, CouponTableMap::DESCRIPTION => 5, CouponTableMap::VALUE => 6, CouponTableMap::IS_USED => 7, CouponTableMap::IS_ENABLED => 8, CouponTableMap::EXPIRATION_DATE => 9, CouponTableMap::SERIALIZED_RULES => 10, CouponTableMap::CREATED_AT => 11, CouponTableMap::UPDATED_AT => 12, CouponTableMap::VERSION => 13, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'VALUE' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES' => 10, 'CREATED_AT' => 11, 'UPDATED_AT' => 12, 'VERSION' => 13, ), - self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'value' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules' => 10, 'created_at' => 11, 'updated_at' => 12, 'version' => 13, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Amount' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRules' => 10, 'IsCumulative' => 11, 'IsRemovingPostage' => 12, 'MaxUsage' => 13, 'IsAvailableOnSpecialOffers' => 14, 'CreatedAt' => 15, 'UpdatedAt' => 16, 'Version' => 17, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'amount' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRules' => 10, 'isCumulative' => 11, 'isRemovingPostage' => 12, 'maxUsage' => 13, 'isAvailableOnSpecialOffers' => 14, 'createdAt' => 15, 'updatedAt' => 16, 'version' => 17, ), + self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::TITLE => 3, CouponTableMap::SHORT_DESCRIPTION => 4, CouponTableMap::DESCRIPTION => 5, CouponTableMap::AMOUNT => 6, CouponTableMap::IS_USED => 7, CouponTableMap::IS_ENABLED => 8, CouponTableMap::EXPIRATION_DATE => 9, CouponTableMap::SERIALIZED_RULES => 10, CouponTableMap::IS_CUMULATIVE => 11, CouponTableMap::IS_REMOVING_POSTAGE => 12, CouponTableMap::MAX_USAGE => 13, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 14, CouponTableMap::CREATED_AT => 15, CouponTableMap::UPDATED_AT => 16, CouponTableMap::VERSION => 17, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'AMOUNT' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES' => 10, 'IS_CUMULATIVE' => 11, 'IS_REMOVING_POSTAGE' => 12, 'MAX_USAGE' => 13, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 14, 'CREATED_AT' => 15, 'UPDATED_AT' => 16, 'VERSION' => 17, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'amount' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules' => 10, 'is_cumulative' => 11, 'is_removing_postage' => 12, 'max_usage' => 13, 'is_available_on_special_offers' => 14, 'created_at' => 15, 'updated_at' => 16, 'version' => 17, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); /** @@ -205,11 +225,15 @@ class CouponTableMap extends TableMap $this->addColumn('TITLE', 'Title', 'VARCHAR', true, 255, null); $this->addColumn('SHORT_DESCRIPTION', 'ShortDescription', 'LONGVARCHAR', true, null, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', true, null, null); - $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null); + $this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null); $this->addColumn('IS_USED', 'IsUsed', 'TINYINT', true, null, null); $this->addColumn('IS_ENABLED', 'IsEnabled', 'TINYINT', true, null, null); $this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null); $this->addColumn('SERIALIZED_RULES', 'SerializedRules', 'LONGVARCHAR', true, null, null); + $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'TINYINT', true, null, null); + $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'TINYINT', true, null, null); + $this->addColumn('MAX_USAGE', 'MaxUsage', 'INTEGER', true, null, null); + $this->addColumn('IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IsAvailableOnSpecialOffers', 'BOOLEAN', true, 1, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0); @@ -394,11 +418,15 @@ class CouponTableMap extends TableMap $criteria->addSelectColumn(CouponTableMap::TITLE); $criteria->addSelectColumn(CouponTableMap::SHORT_DESCRIPTION); $criteria->addSelectColumn(CouponTableMap::DESCRIPTION); - $criteria->addSelectColumn(CouponTableMap::VALUE); + $criteria->addSelectColumn(CouponTableMap::AMOUNT); $criteria->addSelectColumn(CouponTableMap::IS_USED); $criteria->addSelectColumn(CouponTableMap::IS_ENABLED); $criteria->addSelectColumn(CouponTableMap::EXPIRATION_DATE); $criteria->addSelectColumn(CouponTableMap::SERIALIZED_RULES); + $criteria->addSelectColumn(CouponTableMap::IS_CUMULATIVE); + $criteria->addSelectColumn(CouponTableMap::IS_REMOVING_POSTAGE); + $criteria->addSelectColumn(CouponTableMap::MAX_USAGE); + $criteria->addSelectColumn(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS); $criteria->addSelectColumn(CouponTableMap::CREATED_AT); $criteria->addSelectColumn(CouponTableMap::UPDATED_AT); $criteria->addSelectColumn(CouponTableMap::VERSION); @@ -409,11 +437,15 @@ class CouponTableMap extends TableMap $criteria->addSelectColumn($alias . '.TITLE'); $criteria->addSelectColumn($alias . '.SHORT_DESCRIPTION'); $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.VALUE'); + $criteria->addSelectColumn($alias . '.AMOUNT'); $criteria->addSelectColumn($alias . '.IS_USED'); $criteria->addSelectColumn($alias . '.IS_ENABLED'); $criteria->addSelectColumn($alias . '.EXPIRATION_DATE'); $criteria->addSelectColumn($alias . '.SERIALIZED_RULES'); + $criteria->addSelectColumn($alias . '.IS_CUMULATIVE'); + $criteria->addSelectColumn($alias . '.IS_REMOVING_POSTAGE'); + $criteria->addSelectColumn($alias . '.MAX_USAGE'); + $criteria->addSelectColumn($alias . '.IS_AVAILABLE_ON_SPECIAL_OFFERS'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); $criteria->addSelectColumn($alias . '.VERSION'); diff --git a/core/lib/Thelia/Model/Map/CouponVersionTableMap.php b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php index 6ce67d3f1..9db387a86 100644 --- a/core/lib/Thelia/Model/Map/CouponVersionTableMap.php +++ b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php @@ -57,7 +57,7 @@ class CouponVersionTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 14; + const NUM_COLUMNS = 18; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CouponVersionTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 14; + const NUM_HYDRATE_COLUMNS = 18; /** * the column name for the ID field @@ -100,9 +100,9 @@ class CouponVersionTableMap extends TableMap const DESCRIPTION = 'coupon_version.DESCRIPTION'; /** - * the column name for the VALUE field + * the column name for the AMOUNT field */ - const VALUE = 'coupon_version.VALUE'; + const AMOUNT = 'coupon_version.AMOUNT'; /** * the column name for the IS_USED field @@ -124,6 +124,26 @@ class CouponVersionTableMap extends TableMap */ const SERIALIZED_RULES = 'coupon_version.SERIALIZED_RULES'; + /** + * the column name for the IS_CUMULATIVE field + */ + const IS_CUMULATIVE = 'coupon_version.IS_CUMULATIVE'; + + /** + * the column name for the IS_REMOVING_POSTAGE field + */ + const IS_REMOVING_POSTAGE = 'coupon_version.IS_REMOVING_POSTAGE'; + + /** + * the column name for the MAX_USAGE field + */ + const MAX_USAGE = 'coupon_version.MAX_USAGE'; + + /** + * the column name for the IS_AVAILABLE_ON_SPECIAL_OFFERS field + */ + const IS_AVAILABLE_ON_SPECIAL_OFFERS = 'coupon_version.IS_AVAILABLE_ON_SPECIAL_OFFERS'; + /** * the column name for the CREATED_AT field */ @@ -151,12 +171,12 @@ class CouponVersionTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Value', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'CreatedAt', 'UpdatedAt', 'Version', ), - self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'value', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'createdAt', 'updatedAt', 'version', ), - self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::TITLE, CouponVersionTableMap::SHORT_DESCRIPTION, CouponVersionTableMap::DESCRIPTION, CouponVersionTableMap::VALUE, CouponVersionTableMap::IS_USED, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::SERIALIZED_RULES, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ), - self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'VALUE', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), - self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'value', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'created_at', 'updated_at', 'version', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Title', 'ShortDescription', 'Description', 'Amount', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'IsCumulative', 'IsRemovingPostage', 'MaxUsage', 'IsAvailableOnSpecialOffers', 'CreatedAt', 'UpdatedAt', 'Version', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'title', 'shortDescription', 'description', 'amount', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'isCumulative', 'isRemovingPostage', 'maxUsage', 'isAvailableOnSpecialOffers', 'createdAt', 'updatedAt', 'version', ), + self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::TITLE, CouponVersionTableMap::SHORT_DESCRIPTION, CouponVersionTableMap::DESCRIPTION, CouponVersionTableMap::AMOUNT, CouponVersionTableMap::IS_USED, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::SERIALIZED_RULES, CouponVersionTableMap::IS_CUMULATIVE, CouponVersionTableMap::IS_REMOVING_POSTAGE, CouponVersionTableMap::MAX_USAGE, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'AMOUNT', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'MAX_USAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), + self::TYPE_FIELDNAME => array('id', 'code', 'type', 'title', 'short_description', 'description', 'amount', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'is_cumulative', 'is_removing_postage', 'max_usage', 'is_available_on_special_offers', 'created_at', 'updated_at', 'version', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); /** @@ -166,12 +186,12 @@ class CouponVersionTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Value' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRules' => 10, 'CreatedAt' => 11, 'UpdatedAt' => 12, 'Version' => 13, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'value' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRules' => 10, 'createdAt' => 11, 'updatedAt' => 12, 'version' => 13, ), - self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::TITLE => 3, CouponVersionTableMap::SHORT_DESCRIPTION => 4, CouponVersionTableMap::DESCRIPTION => 5, CouponVersionTableMap::VALUE => 6, CouponVersionTableMap::IS_USED => 7, CouponVersionTableMap::IS_ENABLED => 8, CouponVersionTableMap::EXPIRATION_DATE => 9, CouponVersionTableMap::SERIALIZED_RULES => 10, CouponVersionTableMap::CREATED_AT => 11, CouponVersionTableMap::UPDATED_AT => 12, CouponVersionTableMap::VERSION => 13, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'VALUE' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES' => 10, 'CREATED_AT' => 11, 'UPDATED_AT' => 12, 'VERSION' => 13, ), - self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'value' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules' => 10, 'created_at' => 11, 'updated_at' => 12, 'version' => 13, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Title' => 3, 'ShortDescription' => 4, 'Description' => 5, 'Amount' => 6, 'IsUsed' => 7, 'IsEnabled' => 8, 'ExpirationDate' => 9, 'SerializedRules' => 10, 'IsCumulative' => 11, 'IsRemovingPostage' => 12, 'MaxUsage' => 13, 'IsAvailableOnSpecialOffers' => 14, 'CreatedAt' => 15, 'UpdatedAt' => 16, 'Version' => 17, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'shortDescription' => 4, 'description' => 5, 'amount' => 6, 'isUsed' => 7, 'isEnabled' => 8, 'expirationDate' => 9, 'serializedRules' => 10, 'isCumulative' => 11, 'isRemovingPostage' => 12, 'maxUsage' => 13, 'isAvailableOnSpecialOffers' => 14, 'createdAt' => 15, 'updatedAt' => 16, 'version' => 17, ), + self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::TITLE => 3, CouponVersionTableMap::SHORT_DESCRIPTION => 4, CouponVersionTableMap::DESCRIPTION => 5, CouponVersionTableMap::AMOUNT => 6, CouponVersionTableMap::IS_USED => 7, CouponVersionTableMap::IS_ENABLED => 8, CouponVersionTableMap::EXPIRATION_DATE => 9, CouponVersionTableMap::SERIALIZED_RULES => 10, CouponVersionTableMap::IS_CUMULATIVE => 11, CouponVersionTableMap::IS_REMOVING_POSTAGE => 12, CouponVersionTableMap::MAX_USAGE => 13, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 14, CouponVersionTableMap::CREATED_AT => 15, CouponVersionTableMap::UPDATED_AT => 16, CouponVersionTableMap::VERSION => 17, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'TITLE' => 3, 'SHORT_DESCRIPTION' => 4, 'DESCRIPTION' => 5, 'AMOUNT' => 6, 'IS_USED' => 7, 'IS_ENABLED' => 8, 'EXPIRATION_DATE' => 9, 'SERIALIZED_RULES' => 10, 'IS_CUMULATIVE' => 11, 'IS_REMOVING_POSTAGE' => 12, 'MAX_USAGE' => 13, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 14, 'CREATED_AT' => 15, 'UPDATED_AT' => 16, 'VERSION' => 17, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'title' => 3, 'short_description' => 4, 'description' => 5, 'amount' => 6, 'is_used' => 7, 'is_enabled' => 8, 'expiration_date' => 9, 'serialized_rules' => 10, 'is_cumulative' => 11, 'is_removing_postage' => 12, 'max_usage' => 13, 'is_available_on_special_offers' => 14, 'created_at' => 15, 'updated_at' => 16, 'version' => 17, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); /** @@ -196,11 +216,15 @@ class CouponVersionTableMap extends TableMap $this->addColumn('TITLE', 'Title', 'VARCHAR', true, 255, null); $this->addColumn('SHORT_DESCRIPTION', 'ShortDescription', 'LONGVARCHAR', true, null, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', true, null, null); - $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null); + $this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null); $this->addColumn('IS_USED', 'IsUsed', 'TINYINT', true, null, null); $this->addColumn('IS_ENABLED', 'IsEnabled', 'TINYINT', true, null, null); $this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null); $this->addColumn('SERIALIZED_RULES', 'SerializedRules', 'LONGVARCHAR', true, null, null); + $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'TINYINT', true, null, null); + $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'TINYINT', true, null, null); + $this->addColumn('MAX_USAGE', 'MaxUsage', 'INTEGER', true, null, null); + $this->addColumn('IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IsAvailableOnSpecialOffers', 'BOOLEAN', true, 1, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0); @@ -281,11 +305,11 @@ class CouponVersionTableMap extends TableMap public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { // If the PK cannot be derived from the row, return NULL. - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 13 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 17 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { return null; } - return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 13 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 17 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); } /** @@ -407,11 +431,15 @@ class CouponVersionTableMap extends TableMap $criteria->addSelectColumn(CouponVersionTableMap::TITLE); $criteria->addSelectColumn(CouponVersionTableMap::SHORT_DESCRIPTION); $criteria->addSelectColumn(CouponVersionTableMap::DESCRIPTION); - $criteria->addSelectColumn(CouponVersionTableMap::VALUE); + $criteria->addSelectColumn(CouponVersionTableMap::AMOUNT); $criteria->addSelectColumn(CouponVersionTableMap::IS_USED); $criteria->addSelectColumn(CouponVersionTableMap::IS_ENABLED); $criteria->addSelectColumn(CouponVersionTableMap::EXPIRATION_DATE); $criteria->addSelectColumn(CouponVersionTableMap::SERIALIZED_RULES); + $criteria->addSelectColumn(CouponVersionTableMap::IS_CUMULATIVE); + $criteria->addSelectColumn(CouponVersionTableMap::IS_REMOVING_POSTAGE); + $criteria->addSelectColumn(CouponVersionTableMap::MAX_USAGE); + $criteria->addSelectColumn(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS); $criteria->addSelectColumn(CouponVersionTableMap::CREATED_AT); $criteria->addSelectColumn(CouponVersionTableMap::UPDATED_AT); $criteria->addSelectColumn(CouponVersionTableMap::VERSION); @@ -422,11 +450,15 @@ class CouponVersionTableMap extends TableMap $criteria->addSelectColumn($alias . '.TITLE'); $criteria->addSelectColumn($alias . '.SHORT_DESCRIPTION'); $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.VALUE'); + $criteria->addSelectColumn($alias . '.AMOUNT'); $criteria->addSelectColumn($alias . '.IS_USED'); $criteria->addSelectColumn($alias . '.IS_ENABLED'); $criteria->addSelectColumn($alias . '.EXPIRATION_DATE'); $criteria->addSelectColumn($alias . '.SERIALIZED_RULES'); + $criteria->addSelectColumn($alias . '.IS_CUMULATIVE'); + $criteria->addSelectColumn($alias . '.IS_REMOVING_POSTAGE'); + $criteria->addSelectColumn($alias . '.MAX_USAGE'); + $criteria->addSelectColumn($alias . '.IS_AVAILABLE_ON_SPECIAL_OFFERS'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); $criteria->addSelectColumn($alias . '.VERSION'); diff --git a/core/lib/Thelia/Model/Map/RewritingTableMap.php b/core/lib/Thelia/Model/Map/RewritingTableMap.php deleted file mode 100755 index afce3e3c7..000000000 --- a/core/lib/Thelia/Model/Map/RewritingTableMap.php +++ /dev/null @@ -1,470 +0,0 @@ - array('Id', 'Url', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'url', 'productId', 'categoryId', 'folderId', 'contentId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(RewritingTableMap::ID, RewritingTableMap::URL, RewritingTableMap::PRODUCT_ID, RewritingTableMap::CATEGORY_ID, RewritingTableMap::FOLDER_ID, RewritingTableMap::CONTENT_ID, RewritingTableMap::CREATED_AT, RewritingTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'URL', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'url', 'product_id', 'category_id', 'folder_id', 'content_id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Url' => 1, 'ProductId' => 2, 'CategoryId' => 3, 'FolderId' => 4, 'ContentId' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'url' => 1, 'productId' => 2, 'categoryId' => 3, 'folderId' => 4, 'contentId' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), - self::TYPE_COLNAME => array(RewritingTableMap::ID => 0, RewritingTableMap::URL => 1, RewritingTableMap::PRODUCT_ID => 2, RewritingTableMap::CATEGORY_ID => 3, RewritingTableMap::FOLDER_ID => 4, RewritingTableMap::CONTENT_ID => 5, RewritingTableMap::CREATED_AT => 6, RewritingTableMap::UPDATED_AT => 7, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'URL' => 1, 'PRODUCT_ID' => 2, 'CATEGORY_ID' => 3, 'FOLDER_ID' => 4, 'CONTENT_ID' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), - self::TYPE_FIELDNAME => array('id' => 0, 'url' => 1, 'product_id' => 2, 'category_id' => 3, 'folder_id' => 4, 'content_id' => 5, 'created_at' => 6, 'updated_at' => 7, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * Initialize the table attributes and columns - * Relations are not initialized by this method since they are lazy loaded - * - * @return void - * @throws PropelException - */ - public function initialize() - { - // attributes - $this->setName('rewriting'); - $this->setPhpName('Rewriting'); - $this->setClassName('\\Thelia\\Model\\Rewriting'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('URL', 'Url', 'VARCHAR', true, 255, null); - $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null); - $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null); - $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), - ); - } // getBehaviors() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - */ - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - // If the PK cannot be derived from the row, return NULL. - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { - return null; - } - - return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - * - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - - return (int) $row[ - $indexType == TableMap::TYPE_NUM - ? 0 + $offset - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) - ]; - } - - /** - * The class that the tableMap will make instances of. - * - * If $withPrefix is true, the returned path - * uses a dot-path notation which is translated into a path - * relative to a location on the PHP include_path. - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') - * - * @param boolean $withPrefix Whether or not to return the path with the class name - * @return string path.to.ClassName - */ - public static function getOMClass($withPrefix = true) - { - return $withPrefix ? RewritingTableMap::CLASS_DEFAULT : RewritingTableMap::OM_CLASS; - } - - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row row returned by DataFetcher->fetch(). - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Rewriting object, last column rank) - */ - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - $key = RewritingTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = RewritingTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + RewritingTableMap::NUM_HYDRATE_COLUMNS; - } else { - $cls = RewritingTableMap::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $offset, false, $indexType); - RewritingTableMap::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @param DataFetcherInterface $dataFetcher - * @return array - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(DataFetcherInterface $dataFetcher) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = static::getOMClass(false); - // populate the object(s) - while ($row = $dataFetcher->fetch()) { - $key = RewritingTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = RewritingTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - RewritingTableMap::addInstanceToPool($obj, $key); - } // if key exists - } - - return $results; - } - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(RewritingTableMap::ID); - $criteria->addSelectColumn(RewritingTableMap::URL); - $criteria->addSelectColumn(RewritingTableMap::PRODUCT_ID); - $criteria->addSelectColumn(RewritingTableMap::CATEGORY_ID); - $criteria->addSelectColumn(RewritingTableMap::FOLDER_ID); - $criteria->addSelectColumn(RewritingTableMap::CONTENT_ID); - $criteria->addSelectColumn(RewritingTableMap::CREATED_AT); - $criteria->addSelectColumn(RewritingTableMap::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.URL'); - $criteria->addSelectColumn($alias . '.PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); - $criteria->addSelectColumn($alias . '.FOLDER_ID'); - $criteria->addSelectColumn($alias . '.CONTENT_ID'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - } - } - - /** - * Returns the TableMap related to this object. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getServiceContainer()->getDatabaseMap(RewritingTableMap::DATABASE_NAME)->getTable(RewritingTableMap::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this tableMap class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(RewritingTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(RewritingTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new RewritingTableMap()); - } - } - - /** - * Performs a DELETE on the database, given a Rewriting or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Rewriting object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - // rename for clarity - $criteria = $values; - } elseif ($values instanceof \Thelia\Model\Rewriting) { // it's a model object - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(RewritingTableMap::DATABASE_NAME); - $criteria->add(RewritingTableMap::ID, (array) $values, Criteria::IN); - } - - $query = RewritingQuery::create()->mergeWith($criteria); - - if ($values instanceof Criteria) { RewritingTableMap::clearInstancePool(); - } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { RewritingTableMap::removeInstanceFromPool($singleval); - } - } - - return $query->delete($con); - } - - /** - * Deletes all rows from the rewriting table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public static function doDeleteAll(ConnectionInterface $con = null) - { - return RewritingQuery::create()->doDeleteAll($con); - } - - /** - * Performs an INSERT on the database, given a Rewriting or Criteria object. - * - * @param mixed $criteria Criteria or Rewriting object containing data that is used to create the INSERT statement. - * @param ConnectionInterface $con the ConnectionInterface connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($criteria, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME); - } - - if ($criteria instanceof Criteria) { - $criteria = clone $criteria; // rename for clarity - } else { - $criteria = $criteria->buildCriteria(); // build Criteria from Rewriting object - } - - - // Set the correct dbName - $query = RewritingQuery::create()->mergeWith($criteria); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = $query->doInsert($con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - -} // RewritingTableMap -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -RewritingTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Rewriting.php b/core/lib/Thelia/Model/Rewriting.php deleted file mode 100755 index 8d6f75fab..000000000 --- a/core/lib/Thelia/Model/Rewriting.php +++ /dev/null @@ -1,9 +0,0 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1095,4 +1126,37 @@ + + + + + + + + + + + + + + + + + + + + +
      + + + + + + + + + + + +
      From 1de0e9f8a4525b2cf43c0dbe17ccc5f71c741ff2 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 28 Aug 2013 15:47:47 +0200 Subject: [PATCH 044/268] rewriting tables --- core/lib/Thelia/Model/Base/Category.php | 347 --- core/lib/Thelia/Model/Base/CategoryQuery.php | 77 - core/lib/Thelia/Model/Base/Content.php | 347 --- core/lib/Thelia/Model/Base/ContentQuery.php | 77 - core/lib/Thelia/Model/Base/Folder.php | 347 --- core/lib/Thelia/Model/Base/FolderQuery.php | 77 - core/lib/Thelia/Model/Base/Product.php | 347 --- core/lib/Thelia/Model/Base/ProductQuery.php | 77 - .../Thelia/Model/Base/RewritingArgument.php | 1417 +++++++++++ .../Model/Base/RewritingArgumentQuery.php | 673 ++++++ core/lib/Thelia/Model/Base/RewritingUrl.php | 2147 +++++++++++++++++ .../Thelia/Model/Base/RewritingUrlQuery.php | 919 +++++++ .../lib/Thelia/Model/Map/CategoryTableMap.php | 2 - core/lib/Thelia/Model/Map/ContentTableMap.php | 2 - core/lib/Thelia/Model/Map/FolderTableMap.php | 2 - core/lib/Thelia/Model/Map/ProductTableMap.php | 2 - .../Model/Map/RewritingArgumentTableMap.php | 503 ++++ .../Thelia/Model/Map/RewritingUrlTableMap.php | 478 ++++ core/lib/Thelia/Model/RewritingArgument.php | 9 + .../Thelia/Model/RewritingArgumentQuery.php | 20 + core/lib/Thelia/Model/RewritingUrl.php | 9 + core/lib/Thelia/Model/RewritingUrlQuery.php | 20 + install/thelia.sql | 2 +- local/config/schema.xml | 35 +- 24 files changed, 6197 insertions(+), 1739 deletions(-) create mode 100644 core/lib/Thelia/Model/Base/RewritingArgument.php create mode 100644 core/lib/Thelia/Model/Base/RewritingArgumentQuery.php create mode 100644 core/lib/Thelia/Model/Base/RewritingUrl.php create mode 100644 core/lib/Thelia/Model/Base/RewritingUrlQuery.php create mode 100644 core/lib/Thelia/Model/Map/RewritingArgumentTableMap.php create mode 100644 core/lib/Thelia/Model/Map/RewritingUrlTableMap.php create mode 100644 core/lib/Thelia/Model/RewritingArgument.php create mode 100644 core/lib/Thelia/Model/RewritingArgumentQuery.php create mode 100644 core/lib/Thelia/Model/RewritingUrl.php create mode 100644 core/lib/Thelia/Model/RewritingUrlQuery.php diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php index 1bafdae8c..46a8876ef 100755 --- a/core/lib/Thelia/Model/Base/Category.php +++ b/core/lib/Thelia/Model/Base/Category.php @@ -41,8 +41,6 @@ use Thelia\Model\Product as ChildProduct; use Thelia\Model\ProductCategory as ChildProductCategory; use Thelia\Model\ProductCategoryQuery as ChildProductCategoryQuery; use Thelia\Model\ProductQuery as ChildProductQuery; -use Thelia\Model\Rewriting as ChildRewriting; -use Thelia\Model\RewritingQuery as ChildRewritingQuery; use Thelia\Model\Map\CategoryTableMap; use Thelia\Model\Map\CategoryVersionTableMap; @@ -153,12 +151,6 @@ abstract class Category implements ActiveRecordInterface protected $collAttributeCategories; protected $collAttributeCategoriesPartial; - /** - * @var ObjectCollection|ChildRewriting[] Collection to store aggregation of ChildRewriting objects. - */ - protected $collRewritings; - protected $collRewritingsPartial; - /** * @var ObjectCollection|ChildCategoryImage[] Collection to store aggregation of ChildCategoryImage objects. */ @@ -270,12 +262,6 @@ abstract class Category implements ActiveRecordInterface */ protected $attributeCategoriesScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $rewritingsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -1039,8 +1025,6 @@ abstract class Category implements ActiveRecordInterface $this->collAttributeCategories = null; - $this->collRewritings = null; - $this->collCategoryImages = null; $this->collCategoryDocuments = null; @@ -1331,23 +1315,6 @@ abstract class Category implements ActiveRecordInterface } } - if ($this->rewritingsScheduledForDeletion !== null) { - if (!$this->rewritingsScheduledForDeletion->isEmpty()) { - \Thelia\Model\RewritingQuery::create() - ->filterByPrimaryKeys($this->rewritingsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->rewritingsScheduledForDeletion = null; - } - } - - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->categoryImagesScheduledForDeletion !== null) { if (!$this->categoryImagesScheduledForDeletion->isEmpty()) { \Thelia\Model\CategoryImageQuery::create() @@ -1668,9 +1635,6 @@ abstract class Category implements ActiveRecordInterface if (null !== $this->collAttributeCategories) { $result['AttributeCategories'] = $this->collAttributeCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collRewritings) { - $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collCategoryImages) { $result['CategoryImages'] = $this->collCategoryImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1895,12 +1859,6 @@ abstract class Category implements ActiveRecordInterface } } - foreach ($this->getRewritings() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addRewriting($relObj->copy($deepCopy)); - } - } - foreach ($this->getCategoryImages() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCategoryImage($relObj->copy($deepCopy)); @@ -1981,9 +1939,6 @@ abstract class Category implements ActiveRecordInterface if ('AttributeCategory' == $relationName) { return $this->initAttributeCategories(); } - if ('Rewriting' == $relationName) { - return $this->initRewritings(); - } if ('CategoryImage' == $relationName) { return $this->initCategoryImages(); } @@ -2733,299 +2688,6 @@ abstract class Category implements ActiveRecordInterface return $this->getAttributeCategories($query, $con); } - /** - * Clears out the collRewritings collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addRewritings() - */ - public function clearRewritings() - { - $this->collRewritings = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collRewritings collection loaded partially. - */ - public function resetPartialRewritings($v = true) - { - $this->collRewritingsPartial = $v; - } - - /** - * Initializes the collRewritings collection. - * - * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initRewritings($overrideExisting = true) - { - if (null !== $this->collRewritings && !$overrideExisting) { - return; - } - $this->collRewritings = new ObjectCollection(); - $this->collRewritings->setModel('\Thelia\Model\Rewriting'); - } - - /** - * Gets an array of ChildRewriting objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildCategory is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildRewriting[] List of ChildRewriting objects - * @throws PropelException - */ - public function getRewritings($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - // return empty collection - $this->initRewritings(); - } else { - $collRewritings = ChildRewritingQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collRewritingsPartial && count($collRewritings)) { - $this->initRewritings(false); - - foreach ($collRewritings as $obj) { - if (false == $this->collRewritings->contains($obj)) { - $this->collRewritings->append($obj); - } - } - - $this->collRewritingsPartial = true; - } - - $collRewritings->getInternalIterator()->rewind(); - - return $collRewritings; - } - - if ($partial && $this->collRewritings) { - foreach ($this->collRewritings as $obj) { - if ($obj->isNew()) { - $collRewritings[] = $obj; - } - } - } - - $this->collRewritings = $collRewritings; - $this->collRewritingsPartial = false; - } - } - - return $this->collRewritings; - } - - /** - * Sets a collection of Rewriting objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $rewritings A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildCategory The current object (for fluent API support) - */ - public function setRewritings(Collection $rewritings, ConnectionInterface $con = null) - { - $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - - - $this->rewritingsScheduledForDeletion = $rewritingsToDelete; - - foreach ($rewritingsToDelete as $rewritingRemoved) { - $rewritingRemoved->setCategory(null); - } - - $this->collRewritings = null; - foreach ($rewritings as $rewriting) { - $this->addRewriting($rewriting); - } - - $this->collRewritings = $rewritings; - $this->collRewritingsPartial = false; - - return $this; - } - - /** - * Returns the number of related Rewriting objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related Rewriting objects. - * @throws PropelException - */ - public function countRewritings(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getRewritings()); - } - - $query = ChildRewritingQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collRewritings); - } - - /** - * Method called to associate a ChildRewriting object to this object - * through the ChildRewriting foreign key attribute. - * - * @param ChildRewriting $l ChildRewriting - * @return \Thelia\Model\Category The current object (for fluent API support) - */ - public function addRewriting(ChildRewriting $l) - { - if ($this->collRewritings === null) { - $this->initRewritings(); - $this->collRewritingsPartial = true; - } - - if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddRewriting($l); - } - - return $this; - } - - /** - * @param Rewriting $rewriting The rewriting object to add. - */ - protected function doAddRewriting($rewriting) - { - $this->collRewritings[]= $rewriting; - $rewriting->setCategory($this); - } - - /** - * @param Rewriting $rewriting The rewriting object to remove. - * @return ChildCategory The current object (for fluent API support) - */ - public function removeRewriting($rewriting) - { - if ($this->getRewritings()->contains($rewriting)) { - $this->collRewritings->remove($this->collRewritings->search($rewriting)); - if (null === $this->rewritingsScheduledForDeletion) { - $this->rewritingsScheduledForDeletion = clone $this->collRewritings; - $this->rewritingsScheduledForDeletion->clear(); - } - $this->rewritingsScheduledForDeletion[]= $rewriting; - $rewriting->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildRewriting[] List of ChildRewriting objects - */ - public function getRewritingsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildRewritingQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildRewriting[] List of ChildRewriting objects - */ - public function getRewritingsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildRewritingQuery::create(null, $criteria); - $query->joinWith('Folder', $joinBehavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildRewriting[] List of ChildRewriting objects - */ - public function getRewritingsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildRewritingQuery::create(null, $criteria); - $query->joinWith('Content', $joinBehavior); - - return $this->getRewritings($query, $con); - } - /** * Clears out the collCategoryImages collection * @@ -4749,11 +4411,6 @@ abstract class Category implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collRewritings) { - foreach ($this->collRewritings as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collCategoryImages) { foreach ($this->collCategoryImages as $o) { $o->clearAllReferences($deep); @@ -4812,10 +4469,6 @@ abstract class Category implements ActiveRecordInterface $this->collAttributeCategories->clearIterator(); } $this->collAttributeCategories = null; - if ($this->collRewritings instanceof Collection) { - $this->collRewritings->clearIterator(); - } - $this->collRewritings = null; if ($this->collCategoryImages instanceof Collection) { $this->collCategoryImages->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/CategoryQuery.php b/core/lib/Thelia/Model/Base/CategoryQuery.php index 4c823a223..1fe81871b 100755 --- a/core/lib/Thelia/Model/Base/CategoryQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryQuery.php @@ -58,10 +58,6 @@ use Thelia\Model\Map\CategoryTableMap; * @method ChildCategoryQuery rightJoinAttributeCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCategory relation * @method ChildCategoryQuery innerJoinAttributeCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCategory relation * - * @method ChildCategoryQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation - * @method ChildCategoryQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation - * @method ChildCategoryQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation - * * @method ChildCategoryQuery leftJoinCategoryImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryImage relation * @method ChildCategoryQuery rightJoinCategoryImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryImage relation * @method ChildCategoryQuery innerJoinCategoryImage($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryImage relation @@ -870,79 +866,6 @@ abstract class CategoryQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery'); } - /** - * Filter the query by a related \Thelia\Model\Rewriting object - * - * @param \Thelia\Model\Rewriting|ObjectCollection $rewriting the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function filterByRewriting($rewriting, $comparison = null) - { - if ($rewriting instanceof \Thelia\Model\Rewriting) { - return $this - ->addUsingAlias(CategoryTableMap::ID, $rewriting->getCategoryId(), $comparison); - } elseif ($rewriting instanceof ObjectCollection) { - return $this - ->useRewritingQuery() - ->filterByPrimaryKeys($rewriting->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByRewriting() only accepts arguments of type \Thelia\Model\Rewriting or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Rewriting relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Rewriting'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Rewriting'); - } - - return $this; - } - - /** - * Use the Rewriting relation Rewriting object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query - */ - public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinRewriting($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery'); - } - /** * Filter the query by a related \Thelia\Model\CategoryImage object * diff --git a/core/lib/Thelia/Model/Base/Content.php b/core/lib/Thelia/Model/Base/Content.php index bd4d29046..64b99508b 100755 --- a/core/lib/Thelia/Model/Base/Content.php +++ b/core/lib/Thelia/Model/Base/Content.php @@ -35,8 +35,6 @@ use Thelia\Model\Folder as ChildFolder; use Thelia\Model\FolderQuery as ChildFolderQuery; use Thelia\Model\ProductAssociatedContent as ChildProductAssociatedContent; use Thelia\Model\ProductAssociatedContentQuery as ChildProductAssociatedContentQuery; -use Thelia\Model\Rewriting as ChildRewriting; -use Thelia\Model\RewritingQuery as ChildRewritingQuery; use Thelia\Model\Map\ContentTableMap; use Thelia\Model\Map\ContentVersionTableMap; @@ -123,12 +121,6 @@ abstract class Content implements ActiveRecordInterface */ protected $version_created_by; - /** - * @var ObjectCollection|ChildRewriting[] Collection to store aggregation of ChildRewriting objects. - */ - protected $collRewritings; - protected $collRewritingsPartial; - /** * @var ObjectCollection|ChildContentFolder[] Collection to store aggregation of ChildContentFolder objects. */ @@ -212,12 +204,6 @@ abstract class Content implements ActiveRecordInterface */ protected $foldersScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $rewritingsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -952,8 +938,6 @@ abstract class Content implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->collRewritings = null; - $this->collContentFolders = null; $this->collContentImages = null; @@ -1141,23 +1125,6 @@ abstract class Content implements ActiveRecordInterface } } - if ($this->rewritingsScheduledForDeletion !== null) { - if (!$this->rewritingsScheduledForDeletion->isEmpty()) { - \Thelia\Model\RewritingQuery::create() - ->filterByPrimaryKeys($this->rewritingsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->rewritingsScheduledForDeletion = null; - } - } - - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->contentFoldersScheduledForDeletion !== null) { if (!$this->contentFoldersScheduledForDeletion->isEmpty()) { \Thelia\Model\ContentFolderQuery::create() @@ -1493,9 +1460,6 @@ abstract class Content implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->collRewritings) { - $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collContentFolders) { $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1702,12 +1666,6 @@ abstract class Content implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getRewritings() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addRewriting($relObj->copy($deepCopy)); - } - } - foreach ($this->getContentFolders() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addContentFolder($relObj->copy($deepCopy)); @@ -1791,9 +1749,6 @@ abstract class Content implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('Rewriting' == $relationName) { - return $this->initRewritings(); - } if ('ContentFolder' == $relationName) { return $this->initContentFolders(); } @@ -1817,299 +1772,6 @@ abstract class Content implements ActiveRecordInterface } } - /** - * Clears out the collRewritings collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addRewritings() - */ - public function clearRewritings() - { - $this->collRewritings = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collRewritings collection loaded partially. - */ - public function resetPartialRewritings($v = true) - { - $this->collRewritingsPartial = $v; - } - - /** - * Initializes the collRewritings collection. - * - * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initRewritings($overrideExisting = true) - { - if (null !== $this->collRewritings && !$overrideExisting) { - return; - } - $this->collRewritings = new ObjectCollection(); - $this->collRewritings->setModel('\Thelia\Model\Rewriting'); - } - - /** - * Gets an array of ChildRewriting objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildContent is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildRewriting[] List of ChildRewriting objects - * @throws PropelException - */ - public function getRewritings($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - // return empty collection - $this->initRewritings(); - } else { - $collRewritings = ChildRewritingQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collRewritingsPartial && count($collRewritings)) { - $this->initRewritings(false); - - foreach ($collRewritings as $obj) { - if (false == $this->collRewritings->contains($obj)) { - $this->collRewritings->append($obj); - } - } - - $this->collRewritingsPartial = true; - } - - $collRewritings->getInternalIterator()->rewind(); - - return $collRewritings; - } - - if ($partial && $this->collRewritings) { - foreach ($this->collRewritings as $obj) { - if ($obj->isNew()) { - $collRewritings[] = $obj; - } - } - } - - $this->collRewritings = $collRewritings; - $this->collRewritingsPartial = false; - } - } - - return $this->collRewritings; - } - - /** - * Sets a collection of Rewriting objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $rewritings A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildContent The current object (for fluent API support) - */ - public function setRewritings(Collection $rewritings, ConnectionInterface $con = null) - { - $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - - - $this->rewritingsScheduledForDeletion = $rewritingsToDelete; - - foreach ($rewritingsToDelete as $rewritingRemoved) { - $rewritingRemoved->setContent(null); - } - - $this->collRewritings = null; - foreach ($rewritings as $rewriting) { - $this->addRewriting($rewriting); - } - - $this->collRewritings = $rewritings; - $this->collRewritingsPartial = false; - - return $this; - } - - /** - * Returns the number of related Rewriting objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related Rewriting objects. - * @throws PropelException - */ - public function countRewritings(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getRewritings()); - } - - $query = ChildRewritingQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - - return count($this->collRewritings); - } - - /** - * Method called to associate a ChildRewriting object to this object - * through the ChildRewriting foreign key attribute. - * - * @param ChildRewriting $l ChildRewriting - * @return \Thelia\Model\Content The current object (for fluent API support) - */ - public function addRewriting(ChildRewriting $l) - { - if ($this->collRewritings === null) { - $this->initRewritings(); - $this->collRewritingsPartial = true; - } - - if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddRewriting($l); - } - - return $this; - } - - /** - * @param Rewriting $rewriting The rewriting object to add. - */ - protected function doAddRewriting($rewriting) - { - $this->collRewritings[]= $rewriting; - $rewriting->setContent($this); - } - - /** - * @param Rewriting $rewriting The rewriting object to remove. - * @return ChildContent The current object (for fluent API support) - */ - public function removeRewriting($rewriting) - { - if ($this->getRewritings()->contains($rewriting)) { - $this->collRewritings->remove($this->collRewritings->search($rewriting)); - if (null === $this->rewritingsScheduledForDeletion) { - $this->rewritingsScheduledForDeletion = clone $this->collRewritings; - $this->rewritingsScheduledForDeletion->clear(); - } - $this->rewritingsScheduledForDeletion[]= $rewriting; - $rewriting->setContent(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildRewriting[] List of ChildRewriting objects - */ - public function getRewritingsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildRewritingQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildRewriting[] List of ChildRewriting objects - */ - public function getRewritingsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildRewritingQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildRewriting[] List of ChildRewriting objects - */ - public function getRewritingsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildRewritingQuery::create(null, $criteria); - $query->joinWith('Folder', $joinBehavior); - - return $this->getRewritings($query, $con); - } - /** * Clears out the collContentFolders collection * @@ -3940,11 +3602,6 @@ abstract class Content implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collRewritings) { - foreach ($this->collRewritings as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collContentFolders) { foreach ($this->collContentFolders as $o) { $o->clearAllReferences($deep); @@ -3991,10 +3648,6 @@ abstract class Content implements ActiveRecordInterface $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collRewritings instanceof Collection) { - $this->collRewritings->clearIterator(); - } - $this->collRewritings = null; if ($this->collContentFolders instanceof Collection) { $this->collContentFolders->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/ContentQuery.php b/core/lib/Thelia/Model/Base/ContentQuery.php index d4749ce46..11275cdc6 100755 --- a/core/lib/Thelia/Model/Base/ContentQuery.php +++ b/core/lib/Thelia/Model/Base/ContentQuery.php @@ -44,10 +44,6 @@ use Thelia\Model\Map\ContentTableMap; * @method ChildContentQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildContentQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildContentQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation - * @method ChildContentQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation - * @method ChildContentQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation - * * @method ChildContentQuery leftJoinContentFolder($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentFolder relation * @method ChildContentQuery rightJoinContentFolder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentFolder relation * @method ChildContentQuery innerJoinContentFolder($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentFolder relation @@ -602,79 +598,6 @@ abstract class ContentQuery extends ModelCriteria return $this->addUsingAlias(ContentTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } - /** - * Filter the query by a related \Thelia\Model\Rewriting object - * - * @param \Thelia\Model\Rewriting|ObjectCollection $rewriting the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentQuery The current query, for fluid interface - */ - public function filterByRewriting($rewriting, $comparison = null) - { - if ($rewriting instanceof \Thelia\Model\Rewriting) { - return $this - ->addUsingAlias(ContentTableMap::ID, $rewriting->getContentId(), $comparison); - } elseif ($rewriting instanceof ObjectCollection) { - return $this - ->useRewritingQuery() - ->filterByPrimaryKeys($rewriting->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByRewriting() only accepts arguments of type \Thelia\Model\Rewriting or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Rewriting relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildContentQuery The current query, for fluid interface - */ - public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Rewriting'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Rewriting'); - } - - return $this; - } - - /** - * Use the Rewriting relation Rewriting object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query - */ - public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinRewriting($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery'); - } - /** * Filter the query by a related \Thelia\Model\ContentFolder object * diff --git a/core/lib/Thelia/Model/Base/Folder.php b/core/lib/Thelia/Model/Base/Folder.php index 8899ae6be..a864711c0 100755 --- a/core/lib/Thelia/Model/Base/Folder.php +++ b/core/lib/Thelia/Model/Base/Folder.php @@ -31,8 +31,6 @@ use Thelia\Model\FolderImageQuery as ChildFolderImageQuery; use Thelia\Model\FolderQuery as ChildFolderQuery; use Thelia\Model\FolderVersion as ChildFolderVersion; use Thelia\Model\FolderVersionQuery as ChildFolderVersionQuery; -use Thelia\Model\Rewriting as ChildRewriting; -use Thelia\Model\RewritingQuery as ChildRewritingQuery; use Thelia\Model\Map\FolderTableMap; use Thelia\Model\Map\FolderVersionTableMap; @@ -125,12 +123,6 @@ abstract class Folder implements ActiveRecordInterface */ protected $version_created_by; - /** - * @var ObjectCollection|ChildRewriting[] Collection to store aggregation of ChildRewriting objects. - */ - protected $collRewritings; - protected $collRewritingsPartial; - /** * @var ObjectCollection|ChildContentFolder[] Collection to store aggregation of ChildContentFolder objects. */ @@ -202,12 +194,6 @@ abstract class Folder implements ActiveRecordInterface */ protected $contentsScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $rewritingsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -965,8 +951,6 @@ abstract class Folder implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->collRewritings = null; - $this->collContentFolders = null; $this->collFolderImages = null; @@ -1150,23 +1134,6 @@ abstract class Folder implements ActiveRecordInterface } } - if ($this->rewritingsScheduledForDeletion !== null) { - if (!$this->rewritingsScheduledForDeletion->isEmpty()) { - \Thelia\Model\RewritingQuery::create() - ->filterByPrimaryKeys($this->rewritingsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->rewritingsScheduledForDeletion = null; - } - } - - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->contentFoldersScheduledForDeletion !== null) { if (!$this->contentFoldersScheduledForDeletion->isEmpty()) { \Thelia\Model\ContentFolderQuery::create() @@ -1478,9 +1445,6 @@ abstract class Folder implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->collRewritings) { - $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collContentFolders) { $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1687,12 +1651,6 @@ abstract class Folder implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getRewritings() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addRewriting($relObj->copy($deepCopy)); - } - } - foreach ($this->getContentFolders() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addContentFolder($relObj->copy($deepCopy)); @@ -1764,9 +1722,6 @@ abstract class Folder implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('Rewriting' == $relationName) { - return $this->initRewritings(); - } if ('ContentFolder' == $relationName) { return $this->initContentFolders(); } @@ -1784,299 +1739,6 @@ abstract class Folder implements ActiveRecordInterface } } - /** - * Clears out the collRewritings collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addRewritings() - */ - public function clearRewritings() - { - $this->collRewritings = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collRewritings collection loaded partially. - */ - public function resetPartialRewritings($v = true) - { - $this->collRewritingsPartial = $v; - } - - /** - * Initializes the collRewritings collection. - * - * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initRewritings($overrideExisting = true) - { - if (null !== $this->collRewritings && !$overrideExisting) { - return; - } - $this->collRewritings = new ObjectCollection(); - $this->collRewritings->setModel('\Thelia\Model\Rewriting'); - } - - /** - * Gets an array of ChildRewriting objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildFolder is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildRewriting[] List of ChildRewriting objects - * @throws PropelException - */ - public function getRewritings($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - // return empty collection - $this->initRewritings(); - } else { - $collRewritings = ChildRewritingQuery::create(null, $criteria) - ->filterByFolder($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collRewritingsPartial && count($collRewritings)) { - $this->initRewritings(false); - - foreach ($collRewritings as $obj) { - if (false == $this->collRewritings->contains($obj)) { - $this->collRewritings->append($obj); - } - } - - $this->collRewritingsPartial = true; - } - - $collRewritings->getInternalIterator()->rewind(); - - return $collRewritings; - } - - if ($partial && $this->collRewritings) { - foreach ($this->collRewritings as $obj) { - if ($obj->isNew()) { - $collRewritings[] = $obj; - } - } - } - - $this->collRewritings = $collRewritings; - $this->collRewritingsPartial = false; - } - } - - return $this->collRewritings; - } - - /** - * Sets a collection of Rewriting objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $rewritings A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildFolder The current object (for fluent API support) - */ - public function setRewritings(Collection $rewritings, ConnectionInterface $con = null) - { - $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - - - $this->rewritingsScheduledForDeletion = $rewritingsToDelete; - - foreach ($rewritingsToDelete as $rewritingRemoved) { - $rewritingRemoved->setFolder(null); - } - - $this->collRewritings = null; - foreach ($rewritings as $rewriting) { - $this->addRewriting($rewriting); - } - - $this->collRewritings = $rewritings; - $this->collRewritingsPartial = false; - - return $this; - } - - /** - * Returns the number of related Rewriting objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related Rewriting objects. - * @throws PropelException - */ - public function countRewritings(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getRewritings()); - } - - $query = ChildRewritingQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); - } - - return count($this->collRewritings); - } - - /** - * Method called to associate a ChildRewriting object to this object - * through the ChildRewriting foreign key attribute. - * - * @param ChildRewriting $l ChildRewriting - * @return \Thelia\Model\Folder The current object (for fluent API support) - */ - public function addRewriting(ChildRewriting $l) - { - if ($this->collRewritings === null) { - $this->initRewritings(); - $this->collRewritingsPartial = true; - } - - if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddRewriting($l); - } - - return $this; - } - - /** - * @param Rewriting $rewriting The rewriting object to add. - */ - protected function doAddRewriting($rewriting) - { - $this->collRewritings[]= $rewriting; - $rewriting->setFolder($this); - } - - /** - * @param Rewriting $rewriting The rewriting object to remove. - * @return ChildFolder The current object (for fluent API support) - */ - public function removeRewriting($rewriting) - { - if ($this->getRewritings()->contains($rewriting)) { - $this->collRewritings->remove($this->collRewritings->search($rewriting)); - if (null === $this->rewritingsScheduledForDeletion) { - $this->rewritingsScheduledForDeletion = clone $this->collRewritings; - $this->rewritingsScheduledForDeletion->clear(); - } - $this->rewritingsScheduledForDeletion[]= $rewriting; - $rewriting->setFolder(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildRewriting[] List of ChildRewriting objects - */ - public function getRewritingsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildRewritingQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildRewriting[] List of ChildRewriting objects - */ - public function getRewritingsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildRewritingQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildRewriting[] List of ChildRewriting objects - */ - public function getRewritingsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildRewritingQuery::create(null, $criteria); - $query->joinWith('Content', $joinBehavior); - - return $this->getRewritings($query, $con); - } - /** * Clears out the collContentFolders collection * @@ -3422,11 +3084,6 @@ abstract class Folder implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collRewritings) { - foreach ($this->collRewritings as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collContentFolders) { foreach ($this->collContentFolders as $o) { $o->clearAllReferences($deep); @@ -3463,10 +3120,6 @@ abstract class Folder implements ActiveRecordInterface $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collRewritings instanceof Collection) { - $this->collRewritings->clearIterator(); - } - $this->collRewritings = null; if ($this->collContentFolders instanceof Collection) { $this->collContentFolders->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/FolderQuery.php b/core/lib/Thelia/Model/Base/FolderQuery.php index 22d2f3735..28f9bc8a3 100755 --- a/core/lib/Thelia/Model/Base/FolderQuery.php +++ b/core/lib/Thelia/Model/Base/FolderQuery.php @@ -46,10 +46,6 @@ use Thelia\Model\Map\FolderTableMap; * @method ChildFolderQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildFolderQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildFolderQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation - * @method ChildFolderQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation - * @method ChildFolderQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation - * * @method ChildFolderQuery leftJoinContentFolder($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentFolder relation * @method ChildFolderQuery rightJoinContentFolder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentFolder relation * @method ChildFolderQuery innerJoinContentFolder($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentFolder relation @@ -639,79 +635,6 @@ abstract class FolderQuery extends ModelCriteria return $this->addUsingAlias(FolderTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } - /** - * Filter the query by a related \Thelia\Model\Rewriting object - * - * @param \Thelia\Model\Rewriting|ObjectCollection $rewriting the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildFolderQuery The current query, for fluid interface - */ - public function filterByRewriting($rewriting, $comparison = null) - { - if ($rewriting instanceof \Thelia\Model\Rewriting) { - return $this - ->addUsingAlias(FolderTableMap::ID, $rewriting->getFolderId(), $comparison); - } elseif ($rewriting instanceof ObjectCollection) { - return $this - ->useRewritingQuery() - ->filterByPrimaryKeys($rewriting->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByRewriting() only accepts arguments of type \Thelia\Model\Rewriting or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Rewriting relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildFolderQuery The current query, for fluid interface - */ - public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Rewriting'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Rewriting'); - } - - return $this; - } - - /** - * Use the Rewriting relation Rewriting object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query - */ - public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinRewriting($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery'); - } - /** * Filter the query by a related \Thelia\Model\ContentFolder object * diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php index e66c2fe17..af5b7319d 100755 --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -41,8 +41,6 @@ use Thelia\Model\ProductSaleElements as ChildProductSaleElements; use Thelia\Model\ProductSaleElementsQuery as ChildProductSaleElementsQuery; use Thelia\Model\ProductVersion as ChildProductVersion; use Thelia\Model\ProductVersionQuery as ChildProductVersionQuery; -use Thelia\Model\Rewriting as ChildRewriting; -use Thelia\Model\RewritingQuery as ChildRewritingQuery; use Thelia\Model\TaxRule as ChildTaxRule; use Thelia\Model\TaxRuleQuery as ChildTaxRuleQuery; use Thelia\Model\Map\ProductTableMap; @@ -191,12 +189,6 @@ abstract class Product implements ActiveRecordInterface protected $collAccessoriesRelatedByAccessory; protected $collAccessoriesRelatedByAccessoryPartial; - /** - * @var ObjectCollection|ChildRewriting[] Collection to store aggregation of ChildRewriting objects. - */ - protected $collRewritings; - protected $collRewritingsPartial; - /** * @var ObjectCollection|ChildCartItem[] Collection to store aggregation of ChildCartItem objects. */ @@ -326,12 +318,6 @@ abstract class Product implements ActiveRecordInterface */ protected $accessoriesRelatedByAccessoryScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $rewritingsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -1145,8 +1131,6 @@ abstract class Product implements ActiveRecordInterface $this->collAccessoriesRelatedByAccessory = null; - $this->collRewritings = null; - $this->collCartItems = null; $this->collProductAssociatedContents = null; @@ -1515,23 +1499,6 @@ abstract class Product implements ActiveRecordInterface } } - if ($this->rewritingsScheduledForDeletion !== null) { - if (!$this->rewritingsScheduledForDeletion->isEmpty()) { - \Thelia\Model\RewritingQuery::create() - ->filterByPrimaryKeys($this->rewritingsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->rewritingsScheduledForDeletion = null; - } - } - - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->cartItemsScheduledForDeletion !== null) { if (!$this->cartItemsScheduledForDeletion->isEmpty()) { \Thelia\Model\CartItemQuery::create() @@ -1860,9 +1827,6 @@ abstract class Product implements ActiveRecordInterface if (null !== $this->collAccessoriesRelatedByAccessory) { $result['AccessoriesRelatedByAccessory'] = $this->collAccessoriesRelatedByAccessory->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collRewritings) { - $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collCartItems) { $result['CartItems'] = $this->collCartItems->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -2114,12 +2078,6 @@ abstract class Product implements ActiveRecordInterface } } - foreach ($this->getRewritings() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addRewriting($relObj->copy($deepCopy)); - } - } - foreach ($this->getCartItems() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCartItem($relObj->copy($deepCopy)); @@ -2257,9 +2215,6 @@ abstract class Product implements ActiveRecordInterface if ('AccessoryRelatedByAccessory' == $relationName) { return $this->initAccessoriesRelatedByAccessory(); } - if ('Rewriting' == $relationName) { - return $this->initRewritings(); - } if ('CartItem' == $relationName) { return $this->initCartItems(); } @@ -3878,299 +3833,6 @@ abstract class Product implements ActiveRecordInterface return $this; } - /** - * Clears out the collRewritings collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addRewritings() - */ - public function clearRewritings() - { - $this->collRewritings = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collRewritings collection loaded partially. - */ - public function resetPartialRewritings($v = true) - { - $this->collRewritingsPartial = $v; - } - - /** - * Initializes the collRewritings collection. - * - * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initRewritings($overrideExisting = true) - { - if (null !== $this->collRewritings && !$overrideExisting) { - return; - } - $this->collRewritings = new ObjectCollection(); - $this->collRewritings->setModel('\Thelia\Model\Rewriting'); - } - - /** - * Gets an array of ChildRewriting objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildProduct is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildRewriting[] List of ChildRewriting objects - * @throws PropelException - */ - public function getRewritings($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - // return empty collection - $this->initRewritings(); - } else { - $collRewritings = ChildRewritingQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collRewritingsPartial && count($collRewritings)) { - $this->initRewritings(false); - - foreach ($collRewritings as $obj) { - if (false == $this->collRewritings->contains($obj)) { - $this->collRewritings->append($obj); - } - } - - $this->collRewritingsPartial = true; - } - - $collRewritings->getInternalIterator()->rewind(); - - return $collRewritings; - } - - if ($partial && $this->collRewritings) { - foreach ($this->collRewritings as $obj) { - if ($obj->isNew()) { - $collRewritings[] = $obj; - } - } - } - - $this->collRewritings = $collRewritings; - $this->collRewritingsPartial = false; - } - } - - return $this->collRewritings; - } - - /** - * Sets a collection of Rewriting objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $rewritings A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildProduct The current object (for fluent API support) - */ - public function setRewritings(Collection $rewritings, ConnectionInterface $con = null) - { - $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - - - $this->rewritingsScheduledForDeletion = $rewritingsToDelete; - - foreach ($rewritingsToDelete as $rewritingRemoved) { - $rewritingRemoved->setProduct(null); - } - - $this->collRewritings = null; - foreach ($rewritings as $rewriting) { - $this->addRewriting($rewriting); - } - - $this->collRewritings = $rewritings; - $this->collRewritingsPartial = false; - - return $this; - } - - /** - * Returns the number of related Rewriting objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related Rewriting objects. - * @throws PropelException - */ - public function countRewritings(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getRewritings()); - } - - $query = ChildRewritingQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - - return count($this->collRewritings); - } - - /** - * Method called to associate a ChildRewriting object to this object - * through the ChildRewriting foreign key attribute. - * - * @param ChildRewriting $l ChildRewriting - * @return \Thelia\Model\Product The current object (for fluent API support) - */ - public function addRewriting(ChildRewriting $l) - { - if ($this->collRewritings === null) { - $this->initRewritings(); - $this->collRewritingsPartial = true; - } - - if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddRewriting($l); - } - - return $this; - } - - /** - * @param Rewriting $rewriting The rewriting object to add. - */ - protected function doAddRewriting($rewriting) - { - $this->collRewritings[]= $rewriting; - $rewriting->setProduct($this); - } - - /** - * @param Rewriting $rewriting The rewriting object to remove. - * @return ChildProduct The current object (for fluent API support) - */ - public function removeRewriting($rewriting) - { - if ($this->getRewritings()->contains($rewriting)) { - $this->collRewritings->remove($this->collRewritings->search($rewriting)); - if (null === $this->rewritingsScheduledForDeletion) { - $this->rewritingsScheduledForDeletion = clone $this->collRewritings; - $this->rewritingsScheduledForDeletion->clear(); - } - $this->rewritingsScheduledForDeletion[]= $rewriting; - $rewriting->setProduct(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildRewriting[] List of ChildRewriting objects - */ - public function getRewritingsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildRewritingQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildRewriting[] List of ChildRewriting objects - */ - public function getRewritingsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildRewritingQuery::create(null, $criteria); - $query->joinWith('Folder', $joinBehavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildRewriting[] List of ChildRewriting objects - */ - public function getRewritingsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildRewritingQuery::create(null, $criteria); - $query->joinWith('Content', $joinBehavior); - - return $this->getRewritings($query, $con); - } - /** * Clears out the collCartItems collection * @@ -5747,11 +5409,6 @@ abstract class Product implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collRewritings) { - foreach ($this->collRewritings as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collCartItems) { foreach ($this->collCartItems as $o) { $o->clearAllReferences($deep); @@ -5821,10 +5478,6 @@ abstract class Product implements ActiveRecordInterface $this->collAccessoriesRelatedByAccessory->clearIterator(); } $this->collAccessoriesRelatedByAccessory = null; - if ($this->collRewritings instanceof Collection) { - $this->collRewritings->clearIterator(); - } - $this->collRewritings = null; if ($this->collCartItems instanceof Collection) { $this->collCartItems->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/ProductQuery.php b/core/lib/Thelia/Model/Base/ProductQuery.php index 8a4d4ed18..3254bb08b 100755 --- a/core/lib/Thelia/Model/Base/ProductQuery.php +++ b/core/lib/Thelia/Model/Base/ProductQuery.php @@ -80,10 +80,6 @@ use Thelia\Model\Map\ProductTableMap; * @method ChildProductQuery rightJoinAccessoryRelatedByAccessory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AccessoryRelatedByAccessory relation * @method ChildProductQuery innerJoinAccessoryRelatedByAccessory($relationAlias = null) Adds a INNER JOIN clause to the query using the AccessoryRelatedByAccessory relation * - * @method ChildProductQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation - * @method ChildProductQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation - * @method ChildProductQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation - * * @method ChildProductQuery leftJoinCartItem($relationAlias = null) Adds a LEFT JOIN clause to the query using the CartItem relation * @method ChildProductQuery rightJoinCartItem($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CartItem relation * @method ChildProductQuery innerJoinCartItem($relationAlias = null) Adds a INNER JOIN clause to the query using the CartItem relation @@ -1288,79 +1284,6 @@ abstract class ProductQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'AccessoryRelatedByAccessory', '\Thelia\Model\AccessoryQuery'); } - /** - * Filter the query by a related \Thelia\Model\Rewriting object - * - * @param \Thelia\Model\Rewriting|ObjectCollection $rewriting the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildProductQuery The current query, for fluid interface - */ - public function filterByRewriting($rewriting, $comparison = null) - { - if ($rewriting instanceof \Thelia\Model\Rewriting) { - return $this - ->addUsingAlias(ProductTableMap::ID, $rewriting->getProductId(), $comparison); - } elseif ($rewriting instanceof ObjectCollection) { - return $this - ->useRewritingQuery() - ->filterByPrimaryKeys($rewriting->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByRewriting() only accepts arguments of type \Thelia\Model\Rewriting or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Rewriting relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildProductQuery The current query, for fluid interface - */ - public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Rewriting'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Rewriting'); - } - - return $this; - } - - /** - * Use the Rewriting relation Rewriting object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query - */ - public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinRewriting($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery'); - } - /** * Filter the query by a related \Thelia\Model\CartItem object * diff --git a/core/lib/Thelia/Model/Base/RewritingArgument.php b/core/lib/Thelia/Model/Base/RewritingArgument.php new file mode 100644 index 000000000..45f26c24f --- /dev/null +++ b/core/lib/Thelia/Model/Base/RewritingArgument.php @@ -0,0 +1,1417 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another RewritingArgument instance. If + * obj is an instance of RewritingArgument, delegates to + * equals(RewritingArgument). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return RewritingArgument The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return RewritingArgument The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [rewriting_url_id] column value. + * + * @return int + */ + public function getRewritingUrlId() + { + + return $this->rewriting_url_id; + } + + /** + * Get the [parameter] column value. + * + * @return string + */ + public function getParameter() + { + + return $this->parameter; + } + + /** + * Get the [value] column value. + * + * @return string + */ + public function getValue() + { + + return $this->value; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [rewriting_url_id] column. + * + * @param int $v new value + * @return \Thelia\Model\RewritingArgument The current object (for fluent API support) + */ + public function setRewritingUrlId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->rewriting_url_id !== $v) { + $this->rewriting_url_id = $v; + $this->modifiedColumns[] = RewritingArgumentTableMap::REWRITING_URL_ID; + } + + if ($this->aRewritingUrl !== null && $this->aRewritingUrl->getId() !== $v) { + $this->aRewritingUrl = null; + } + + + return $this; + } // setRewritingUrlId() + + /** + * Set the value of [parameter] column. + * + * @param string $v new value + * @return \Thelia\Model\RewritingArgument The current object (for fluent API support) + */ + public function setParameter($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->parameter !== $v) { + $this->parameter = $v; + $this->modifiedColumns[] = RewritingArgumentTableMap::PARAMETER; + } + + + return $this; + } // setParameter() + + /** + * Set the value of [value] column. + * + * @param string $v new value + * @return \Thelia\Model\RewritingArgument The current object (for fluent API support) + */ + public function setValue($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->value !== $v) { + $this->value = $v; + $this->modifiedColumns[] = RewritingArgumentTableMap::VALUE; + } + + + return $this; + } // setValue() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\RewritingArgument The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = RewritingArgumentTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\RewritingArgument The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = RewritingArgumentTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : RewritingArgumentTableMap::translateFieldName('RewritingUrlId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->rewriting_url_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : RewritingArgumentTableMap::translateFieldName('Parameter', TableMap::TYPE_PHPNAME, $indexType)]; + $this->parameter = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : RewritingArgumentTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; + $this->value = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : RewritingArgumentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : RewritingArgumentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = RewritingArgumentTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\RewritingArgument object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aRewritingUrl !== null && $this->rewriting_url_id !== $this->aRewritingUrl->getId()) { + $this->aRewritingUrl = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(RewritingArgumentTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildRewritingArgumentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aRewritingUrl = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see RewritingArgument::setDeleted() + * @see RewritingArgument::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingArgumentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildRewritingArgumentQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingArgumentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(RewritingArgumentTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(RewritingArgumentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(RewritingArgumentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + RewritingArgumentTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aRewritingUrl !== null) { + if ($this->aRewritingUrl->isModified() || $this->aRewritingUrl->isNew()) { + $affectedRows += $this->aRewritingUrl->save($con); + } + $this->setRewritingUrl($this->aRewritingUrl); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(RewritingArgumentTableMap::REWRITING_URL_ID)) { + $modifiedColumns[':p' . $index++] = 'REWRITING_URL_ID'; + } + if ($this->isColumnModified(RewritingArgumentTableMap::PARAMETER)) { + $modifiedColumns[':p' . $index++] = 'PARAMETER'; + } + if ($this->isColumnModified(RewritingArgumentTableMap::VALUE)) { + $modifiedColumns[':p' . $index++] = 'VALUE'; + } + if ($this->isColumnModified(RewritingArgumentTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(RewritingArgumentTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO rewriting_argument (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'REWRITING_URL_ID': + $stmt->bindValue($identifier, $this->rewriting_url_id, PDO::PARAM_INT); + break; + case 'PARAMETER': + $stmt->bindValue($identifier, $this->parameter, PDO::PARAM_STR); + break; + case 'VALUE': + $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = RewritingArgumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getRewritingUrlId(); + break; + case 1: + return $this->getParameter(); + break; + case 2: + return $this->getValue(); + break; + case 3: + return $this->getCreatedAt(); + break; + case 4: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['RewritingArgument'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['RewritingArgument'][serialize($this->getPrimaryKey())] = true; + $keys = RewritingArgumentTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getRewritingUrlId(), + $keys[1] => $this->getParameter(), + $keys[2] => $this->getValue(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aRewritingUrl) { + $result['RewritingUrl'] = $this->aRewritingUrl->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = RewritingArgumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setRewritingUrlId($value); + break; + case 1: + $this->setParameter($value); + break; + case 2: + $this->setValue($value); + break; + case 3: + $this->setCreatedAt($value); + break; + case 4: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = RewritingArgumentTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setRewritingUrlId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setParameter($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setValue($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(RewritingArgumentTableMap::DATABASE_NAME); + + if ($this->isColumnModified(RewritingArgumentTableMap::REWRITING_URL_ID)) $criteria->add(RewritingArgumentTableMap::REWRITING_URL_ID, $this->rewriting_url_id); + if ($this->isColumnModified(RewritingArgumentTableMap::PARAMETER)) $criteria->add(RewritingArgumentTableMap::PARAMETER, $this->parameter); + if ($this->isColumnModified(RewritingArgumentTableMap::VALUE)) $criteria->add(RewritingArgumentTableMap::VALUE, $this->value); + if ($this->isColumnModified(RewritingArgumentTableMap::CREATED_AT)) $criteria->add(RewritingArgumentTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(RewritingArgumentTableMap::UPDATED_AT)) $criteria->add(RewritingArgumentTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(RewritingArgumentTableMap::DATABASE_NAME); + $criteria->add(RewritingArgumentTableMap::REWRITING_URL_ID, $this->rewriting_url_id); + $criteria->add(RewritingArgumentTableMap::PARAMETER, $this->parameter); + $criteria->add(RewritingArgumentTableMap::VALUE, $this->value); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getRewritingUrlId(); + $pks[1] = $this->getParameter(); + $pks[2] = $this->getValue(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setRewritingUrlId($keys[0]); + $this->setParameter($keys[1]); + $this->setValue($keys[2]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getRewritingUrlId()) && (null === $this->getParameter()) && (null === $this->getValue()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\RewritingArgument (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setRewritingUrlId($this->getRewritingUrlId()); + $copyObj->setParameter($this->getParameter()); + $copyObj->setValue($this->getValue()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\RewritingArgument Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildRewritingUrl object. + * + * @param ChildRewritingUrl $v + * @return \Thelia\Model\RewritingArgument The current object (for fluent API support) + * @throws PropelException + */ + public function setRewritingUrl(ChildRewritingUrl $v = null) + { + if ($v === null) { + $this->setRewritingUrlId(NULL); + } else { + $this->setRewritingUrlId($v->getId()); + } + + $this->aRewritingUrl = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildRewritingUrl object, it will not be re-added. + if ($v !== null) { + $v->addRewritingArgument($this); + } + + + return $this; + } + + + /** + * Get the associated ChildRewritingUrl object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildRewritingUrl The associated ChildRewritingUrl object. + * @throws PropelException + */ + public function getRewritingUrl(ConnectionInterface $con = null) + { + if ($this->aRewritingUrl === null && ($this->rewriting_url_id !== null)) { + $this->aRewritingUrl = ChildRewritingUrlQuery::create()->findPk($this->rewriting_url_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aRewritingUrl->addRewritingArguments($this); + */ + } + + return $this->aRewritingUrl; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->rewriting_url_id = null; + $this->parameter = null; + $this->value = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aRewritingUrl = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(RewritingArgumentTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildRewritingArgument The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = RewritingArgumentTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/RewritingArgumentQuery.php b/core/lib/Thelia/Model/Base/RewritingArgumentQuery.php new file mode 100644 index 000000000..cd9ca4fd3 --- /dev/null +++ b/core/lib/Thelia/Model/Base/RewritingArgumentQuery.php @@ -0,0 +1,673 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34, 56), $con); + * + * + * @param array[$rewriting_url_id, $parameter, $value] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildRewritingArgument|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = RewritingArgumentTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(RewritingArgumentTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildRewritingArgument A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT REWRITING_URL_ID, PARAMETER, VALUE, CREATED_AT, UPDATED_AT FROM rewriting_argument WHERE REWRITING_URL_ID = :p0 AND PARAMETER = :p1 AND VALUE = :p2'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->bindValue(':p2', $key[2], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildRewritingArgument(); + $obj->hydrate($row); + RewritingArgumentTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildRewritingArgument|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(RewritingArgumentTableMap::REWRITING_URL_ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(RewritingArgumentTableMap::PARAMETER, $key[1], Criteria::EQUAL); + $this->addUsingAlias(RewritingArgumentTableMap::VALUE, $key[2], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(RewritingArgumentTableMap::REWRITING_URL_ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(RewritingArgumentTableMap::PARAMETER, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $cton2 = $this->getNewCriterion(RewritingArgumentTableMap::VALUE, $key[2], Criteria::EQUAL); + $cton0->addAnd($cton2); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the rewriting_url_id column + * + * Example usage: + * + * $query->filterByRewritingUrlId(1234); // WHERE rewriting_url_id = 1234 + * $query->filterByRewritingUrlId(array(12, 34)); // WHERE rewriting_url_id IN (12, 34) + * $query->filterByRewritingUrlId(array('min' => 12)); // WHERE rewriting_url_id > 12 + * + * + * @see filterByRewritingUrl() + * + * @param mixed $rewritingUrlId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function filterByRewritingUrlId($rewritingUrlId = null, $comparison = null) + { + if (is_array($rewritingUrlId)) { + $useMinMax = false; + if (isset($rewritingUrlId['min'])) { + $this->addUsingAlias(RewritingArgumentTableMap::REWRITING_URL_ID, $rewritingUrlId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($rewritingUrlId['max'])) { + $this->addUsingAlias(RewritingArgumentTableMap::REWRITING_URL_ID, $rewritingUrlId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(RewritingArgumentTableMap::REWRITING_URL_ID, $rewritingUrlId, $comparison); + } + + /** + * Filter the query on the parameter column + * + * Example usage: + * + * $query->filterByParameter('fooValue'); // WHERE parameter = 'fooValue' + * $query->filterByParameter('%fooValue%'); // WHERE parameter LIKE '%fooValue%' + * + * + * @param string $parameter The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function filterByParameter($parameter = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($parameter)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $parameter)) { + $parameter = str_replace('*', '%', $parameter); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(RewritingArgumentTableMap::PARAMETER, $parameter, $comparison); + } + + /** + * Filter the query on the value column + * + * Example usage: + * + * $query->filterByValue('fooValue'); // WHERE value = 'fooValue' + * $query->filterByValue('%fooValue%'); // WHERE value LIKE '%fooValue%' + * + * + * @param string $value The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function filterByValue($value = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($value)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $value)) { + $value = str_replace('*', '%', $value); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(RewritingArgumentTableMap::VALUE, $value, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(RewritingArgumentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(RewritingArgumentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(RewritingArgumentTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(RewritingArgumentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(RewritingArgumentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(RewritingArgumentTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\RewritingUrl object + * + * @param \Thelia\Model\RewritingUrl|ObjectCollection $rewritingUrl The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function filterByRewritingUrl($rewritingUrl, $comparison = null) + { + if ($rewritingUrl instanceof \Thelia\Model\RewritingUrl) { + return $this + ->addUsingAlias(RewritingArgumentTableMap::REWRITING_URL_ID, $rewritingUrl->getId(), $comparison); + } elseif ($rewritingUrl instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(RewritingArgumentTableMap::REWRITING_URL_ID, $rewritingUrl->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByRewritingUrl() only accepts arguments of type \Thelia\Model\RewritingUrl or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the RewritingUrl relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function joinRewritingUrl($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('RewritingUrl'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'RewritingUrl'); + } + + return $this; + } + + /** + * Use the RewritingUrl relation RewritingUrl object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\RewritingUrlQuery A secondary query class using the current class as primary query + */ + public function useRewritingUrlQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinRewritingUrl($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'RewritingUrl', '\Thelia\Model\RewritingUrlQuery'); + } + + /** + * Exclude object from result + * + * @param ChildRewritingArgument $rewritingArgument Object to remove from the list of results + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function prune($rewritingArgument = null) + { + if ($rewritingArgument) { + $this->addCond('pruneCond0', $this->getAliasedColName(RewritingArgumentTableMap::REWRITING_URL_ID), $rewritingArgument->getRewritingUrlId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(RewritingArgumentTableMap::PARAMETER), $rewritingArgument->getParameter(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond2', $this->getAliasedColName(RewritingArgumentTableMap::VALUE), $rewritingArgument->getValue(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the rewriting_argument table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingArgumentTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + RewritingArgumentTableMap::clearInstancePool(); + RewritingArgumentTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildRewritingArgument or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildRewritingArgument object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingArgumentTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(RewritingArgumentTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + RewritingArgumentTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + RewritingArgumentTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(RewritingArgumentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(RewritingArgumentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(RewritingArgumentTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(RewritingArgumentTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(RewritingArgumentTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildRewritingArgumentQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(RewritingArgumentTableMap::CREATED_AT); + } + +} // RewritingArgumentQuery diff --git a/core/lib/Thelia/Model/Base/RewritingUrl.php b/core/lib/Thelia/Model/Base/RewritingUrl.php new file mode 100644 index 000000000..2833e80ec --- /dev/null +++ b/core/lib/Thelia/Model/Base/RewritingUrl.php @@ -0,0 +1,2147 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another RewritingUrl instance. If + * obj is an instance of RewritingUrl, delegates to + * equals(RewritingUrl). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return RewritingUrl The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return RewritingUrl The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [url] column value. + * + * @return string + */ + public function getUrl() + { + + return $this->url; + } + + /** + * Get the [view] column value. + * + * @return string + */ + public function getView() + { + + return $this->view; + } + + /** + * Get the [view_id] column value. + * + * @return string + */ + public function getViewId() + { + + return $this->view_id; + } + + /** + * Get the [view_locale] column value. + * + * @return string + */ + public function getViewLocale() + { + + return $this->view_locale; + } + + /** + * Get the [redirected] column value. + * + * @return int + */ + public function getRedirected() + { + + return $this->redirected; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\RewritingUrl The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = RewritingUrlTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [url] column. + * + * @param string $v new value + * @return \Thelia\Model\RewritingUrl The current object (for fluent API support) + */ + public function setUrl($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->url !== $v) { + $this->url = $v; + $this->modifiedColumns[] = RewritingUrlTableMap::URL; + } + + + return $this; + } // setUrl() + + /** + * Set the value of [view] column. + * + * @param string $v new value + * @return \Thelia\Model\RewritingUrl The current object (for fluent API support) + */ + public function setView($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->view !== $v) { + $this->view = $v; + $this->modifiedColumns[] = RewritingUrlTableMap::VIEW; + } + + + return $this; + } // setView() + + /** + * Set the value of [view_id] column. + * + * @param string $v new value + * @return \Thelia\Model\RewritingUrl The current object (for fluent API support) + */ + public function setViewId($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->view_id !== $v) { + $this->view_id = $v; + $this->modifiedColumns[] = RewritingUrlTableMap::VIEW_ID; + } + + + return $this; + } // setViewId() + + /** + * Set the value of [view_locale] column. + * + * @param string $v new value + * @return \Thelia\Model\RewritingUrl The current object (for fluent API support) + */ + public function setViewLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->view_locale !== $v) { + $this->view_locale = $v; + $this->modifiedColumns[] = RewritingUrlTableMap::VIEW_LOCALE; + } + + + return $this; + } // setViewLocale() + + /** + * Set the value of [redirected] column. + * + * @param int $v new value + * @return \Thelia\Model\RewritingUrl The current object (for fluent API support) + */ + public function setRedirected($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->redirected !== $v) { + $this->redirected = $v; + $this->modifiedColumns[] = RewritingUrlTableMap::REDIRECTED; + } + + if ($this->aRewritingUrlRelatedByRedirected !== null && $this->aRewritingUrlRelatedByRedirected->getId() !== $v) { + $this->aRewritingUrlRelatedByRedirected = null; + } + + + return $this; + } // setRedirected() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\RewritingUrl The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = RewritingUrlTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\RewritingUrl The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = RewritingUrlTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : RewritingUrlTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : RewritingUrlTableMap::translateFieldName('Url', TableMap::TYPE_PHPNAME, $indexType)]; + $this->url = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : RewritingUrlTableMap::translateFieldName('View', TableMap::TYPE_PHPNAME, $indexType)]; + $this->view = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : RewritingUrlTableMap::translateFieldName('ViewId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->view_id = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : RewritingUrlTableMap::translateFieldName('ViewLocale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->view_locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : RewritingUrlTableMap::translateFieldName('Redirected', TableMap::TYPE_PHPNAME, $indexType)]; + $this->redirected = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : RewritingUrlTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : RewritingUrlTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 8; // 8 = RewritingUrlTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\RewritingUrl object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aRewritingUrlRelatedByRedirected !== null && $this->redirected !== $this->aRewritingUrlRelatedByRedirected->getId()) { + $this->aRewritingUrlRelatedByRedirected = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(RewritingUrlTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildRewritingUrlQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aRewritingUrlRelatedByRedirected = null; + $this->collRewritingUrlsRelatedById = null; + + $this->collRewritingArguments = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see RewritingUrl::setDeleted() + * @see RewritingUrl::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingUrlTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildRewritingUrlQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingUrlTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(RewritingUrlTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(RewritingUrlTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(RewritingUrlTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + RewritingUrlTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aRewritingUrlRelatedByRedirected !== null) { + if ($this->aRewritingUrlRelatedByRedirected->isModified() || $this->aRewritingUrlRelatedByRedirected->isNew()) { + $affectedRows += $this->aRewritingUrlRelatedByRedirected->save($con); + } + $this->setRewritingUrlRelatedByRedirected($this->aRewritingUrlRelatedByRedirected); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->rewritingUrlsRelatedByIdScheduledForDeletion !== null) { + if (!$this->rewritingUrlsRelatedByIdScheduledForDeletion->isEmpty()) { + foreach ($this->rewritingUrlsRelatedByIdScheduledForDeletion as $rewritingUrlRelatedById) { + // need to save related object because we set the relation to null + $rewritingUrlRelatedById->save($con); + } + $this->rewritingUrlsRelatedByIdScheduledForDeletion = null; + } + } + + if ($this->collRewritingUrlsRelatedById !== null) { + foreach ($this->collRewritingUrlsRelatedById as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->rewritingArgumentsScheduledForDeletion !== null) { + if (!$this->rewritingArgumentsScheduledForDeletion->isEmpty()) { + \Thelia\Model\RewritingArgumentQuery::create() + ->filterByPrimaryKeys($this->rewritingArgumentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->rewritingArgumentsScheduledForDeletion = null; + } + } + + if ($this->collRewritingArguments !== null) { + foreach ($this->collRewritingArguments as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(RewritingUrlTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(RewritingUrlTableMap::URL)) { + $modifiedColumns[':p' . $index++] = 'URL'; + } + if ($this->isColumnModified(RewritingUrlTableMap::VIEW)) { + $modifiedColumns[':p' . $index++] = 'VIEW'; + } + if ($this->isColumnModified(RewritingUrlTableMap::VIEW_ID)) { + $modifiedColumns[':p' . $index++] = 'VIEW_ID'; + } + if ($this->isColumnModified(RewritingUrlTableMap::VIEW_LOCALE)) { + $modifiedColumns[':p' . $index++] = 'VIEW_LOCALE'; + } + if ($this->isColumnModified(RewritingUrlTableMap::REDIRECTED)) { + $modifiedColumns[':p' . $index++] = 'REDIRECTED'; + } + if ($this->isColumnModified(RewritingUrlTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(RewritingUrlTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO rewriting_url (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'URL': + $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR); + break; + case 'VIEW': + $stmt->bindValue($identifier, $this->view, PDO::PARAM_STR); + break; + case 'VIEW_ID': + $stmt->bindValue($identifier, $this->view_id, PDO::PARAM_STR); + break; + case 'VIEW_LOCALE': + $stmt->bindValue($identifier, $this->view_locale, PDO::PARAM_STR); + break; + case 'REDIRECTED': + $stmt->bindValue($identifier, $this->redirected, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = RewritingUrlTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getUrl(); + break; + case 2: + return $this->getView(); + break; + case 3: + return $this->getViewId(); + break; + case 4: + return $this->getViewLocale(); + break; + case 5: + return $this->getRedirected(); + break; + case 6: + return $this->getCreatedAt(); + break; + case 7: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['RewritingUrl'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['RewritingUrl'][$this->getPrimaryKey()] = true; + $keys = RewritingUrlTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getUrl(), + $keys[2] => $this->getView(), + $keys[3] => $this->getViewId(), + $keys[4] => $this->getViewLocale(), + $keys[5] => $this->getRedirected(), + $keys[6] => $this->getCreatedAt(), + $keys[7] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aRewritingUrlRelatedByRedirected) { + $result['RewritingUrlRelatedByRedirected'] = $this->aRewritingUrlRelatedByRedirected->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collRewritingUrlsRelatedById) { + $result['RewritingUrlsRelatedById'] = $this->collRewritingUrlsRelatedById->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collRewritingArguments) { + $result['RewritingArguments'] = $this->collRewritingArguments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = RewritingUrlTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setUrl($value); + break; + case 2: + $this->setView($value); + break; + case 3: + $this->setViewId($value); + break; + case 4: + $this->setViewLocale($value); + break; + case 5: + $this->setRedirected($value); + break; + case 6: + $this->setCreatedAt($value); + break; + case 7: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = RewritingUrlTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setUrl($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setView($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setViewId($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setViewLocale($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setRedirected($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(RewritingUrlTableMap::DATABASE_NAME); + + if ($this->isColumnModified(RewritingUrlTableMap::ID)) $criteria->add(RewritingUrlTableMap::ID, $this->id); + if ($this->isColumnModified(RewritingUrlTableMap::URL)) $criteria->add(RewritingUrlTableMap::URL, $this->url); + if ($this->isColumnModified(RewritingUrlTableMap::VIEW)) $criteria->add(RewritingUrlTableMap::VIEW, $this->view); + if ($this->isColumnModified(RewritingUrlTableMap::VIEW_ID)) $criteria->add(RewritingUrlTableMap::VIEW_ID, $this->view_id); + if ($this->isColumnModified(RewritingUrlTableMap::VIEW_LOCALE)) $criteria->add(RewritingUrlTableMap::VIEW_LOCALE, $this->view_locale); + if ($this->isColumnModified(RewritingUrlTableMap::REDIRECTED)) $criteria->add(RewritingUrlTableMap::REDIRECTED, $this->redirected); + if ($this->isColumnModified(RewritingUrlTableMap::CREATED_AT)) $criteria->add(RewritingUrlTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(RewritingUrlTableMap::UPDATED_AT)) $criteria->add(RewritingUrlTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(RewritingUrlTableMap::DATABASE_NAME); + $criteria->add(RewritingUrlTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\RewritingUrl (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setUrl($this->getUrl()); + $copyObj->setView($this->getView()); + $copyObj->setViewId($this->getViewId()); + $copyObj->setViewLocale($this->getViewLocale()); + $copyObj->setRedirected($this->getRedirected()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getRewritingUrlsRelatedById() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addRewritingUrlRelatedById($relObj->copy($deepCopy)); + } + } + + foreach ($this->getRewritingArguments() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addRewritingArgument($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\RewritingUrl Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildRewritingUrl object. + * + * @param ChildRewritingUrl $v + * @return \Thelia\Model\RewritingUrl The current object (for fluent API support) + * @throws PropelException + */ + public function setRewritingUrlRelatedByRedirected(ChildRewritingUrl $v = null) + { + if ($v === null) { + $this->setRedirected(NULL); + } else { + $this->setRedirected($v->getId()); + } + + $this->aRewritingUrlRelatedByRedirected = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildRewritingUrl object, it will not be re-added. + if ($v !== null) { + $v->addRewritingUrlRelatedById($this); + } + + + return $this; + } + + + /** + * Get the associated ChildRewritingUrl object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildRewritingUrl The associated ChildRewritingUrl object. + * @throws PropelException + */ + public function getRewritingUrlRelatedByRedirected(ConnectionInterface $con = null) + { + if ($this->aRewritingUrlRelatedByRedirected === null && ($this->redirected !== null)) { + $this->aRewritingUrlRelatedByRedirected = ChildRewritingUrlQuery::create()->findPk($this->redirected, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aRewritingUrlRelatedByRedirected->addRewritingUrlsRelatedById($this); + */ + } + + return $this->aRewritingUrlRelatedByRedirected; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('RewritingUrlRelatedById' == $relationName) { + return $this->initRewritingUrlsRelatedById(); + } + if ('RewritingArgument' == $relationName) { + return $this->initRewritingArguments(); + } + } + + /** + * Clears out the collRewritingUrlsRelatedById collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addRewritingUrlsRelatedById() + */ + public function clearRewritingUrlsRelatedById() + { + $this->collRewritingUrlsRelatedById = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collRewritingUrlsRelatedById collection loaded partially. + */ + public function resetPartialRewritingUrlsRelatedById($v = true) + { + $this->collRewritingUrlsRelatedByIdPartial = $v; + } + + /** + * Initializes the collRewritingUrlsRelatedById collection. + * + * By default this just sets the collRewritingUrlsRelatedById collection to an empty array (like clearcollRewritingUrlsRelatedById()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initRewritingUrlsRelatedById($overrideExisting = true) + { + if (null !== $this->collRewritingUrlsRelatedById && !$overrideExisting) { + return; + } + $this->collRewritingUrlsRelatedById = new ObjectCollection(); + $this->collRewritingUrlsRelatedById->setModel('\Thelia\Model\RewritingUrl'); + } + + /** + * Gets an array of ChildRewritingUrl objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildRewritingUrl is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildRewritingUrl[] List of ChildRewritingUrl objects + * @throws PropelException + */ + public function getRewritingUrlsRelatedById($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collRewritingUrlsRelatedByIdPartial && !$this->isNew(); + if (null === $this->collRewritingUrlsRelatedById || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collRewritingUrlsRelatedById) { + // return empty collection + $this->initRewritingUrlsRelatedById(); + } else { + $collRewritingUrlsRelatedById = ChildRewritingUrlQuery::create(null, $criteria) + ->filterByRewritingUrlRelatedByRedirected($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collRewritingUrlsRelatedByIdPartial && count($collRewritingUrlsRelatedById)) { + $this->initRewritingUrlsRelatedById(false); + + foreach ($collRewritingUrlsRelatedById as $obj) { + if (false == $this->collRewritingUrlsRelatedById->contains($obj)) { + $this->collRewritingUrlsRelatedById->append($obj); + } + } + + $this->collRewritingUrlsRelatedByIdPartial = true; + } + + $collRewritingUrlsRelatedById->getInternalIterator()->rewind(); + + return $collRewritingUrlsRelatedById; + } + + if ($partial && $this->collRewritingUrlsRelatedById) { + foreach ($this->collRewritingUrlsRelatedById as $obj) { + if ($obj->isNew()) { + $collRewritingUrlsRelatedById[] = $obj; + } + } + } + + $this->collRewritingUrlsRelatedById = $collRewritingUrlsRelatedById; + $this->collRewritingUrlsRelatedByIdPartial = false; + } + } + + return $this->collRewritingUrlsRelatedById; + } + + /** + * Sets a collection of RewritingUrlRelatedById objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $rewritingUrlsRelatedById A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildRewritingUrl The current object (for fluent API support) + */ + public function setRewritingUrlsRelatedById(Collection $rewritingUrlsRelatedById, ConnectionInterface $con = null) + { + $rewritingUrlsRelatedByIdToDelete = $this->getRewritingUrlsRelatedById(new Criteria(), $con)->diff($rewritingUrlsRelatedById); + + + $this->rewritingUrlsRelatedByIdScheduledForDeletion = $rewritingUrlsRelatedByIdToDelete; + + foreach ($rewritingUrlsRelatedByIdToDelete as $rewritingUrlRelatedByIdRemoved) { + $rewritingUrlRelatedByIdRemoved->setRewritingUrlRelatedByRedirected(null); + } + + $this->collRewritingUrlsRelatedById = null; + foreach ($rewritingUrlsRelatedById as $rewritingUrlRelatedById) { + $this->addRewritingUrlRelatedById($rewritingUrlRelatedById); + } + + $this->collRewritingUrlsRelatedById = $rewritingUrlsRelatedById; + $this->collRewritingUrlsRelatedByIdPartial = false; + + return $this; + } + + /** + * Returns the number of related RewritingUrl objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related RewritingUrl objects. + * @throws PropelException + */ + public function countRewritingUrlsRelatedById(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collRewritingUrlsRelatedByIdPartial && !$this->isNew(); + if (null === $this->collRewritingUrlsRelatedById || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collRewritingUrlsRelatedById) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getRewritingUrlsRelatedById()); + } + + $query = ChildRewritingUrlQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByRewritingUrlRelatedByRedirected($this) + ->count($con); + } + + return count($this->collRewritingUrlsRelatedById); + } + + /** + * Method called to associate a ChildRewritingUrl object to this object + * through the ChildRewritingUrl foreign key attribute. + * + * @param ChildRewritingUrl $l ChildRewritingUrl + * @return \Thelia\Model\RewritingUrl The current object (for fluent API support) + */ + public function addRewritingUrlRelatedById(ChildRewritingUrl $l) + { + if ($this->collRewritingUrlsRelatedById === null) { + $this->initRewritingUrlsRelatedById(); + $this->collRewritingUrlsRelatedByIdPartial = true; + } + + if (!in_array($l, $this->collRewritingUrlsRelatedById->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddRewritingUrlRelatedById($l); + } + + return $this; + } + + /** + * @param RewritingUrlRelatedById $rewritingUrlRelatedById The rewritingUrlRelatedById object to add. + */ + protected function doAddRewritingUrlRelatedById($rewritingUrlRelatedById) + { + $this->collRewritingUrlsRelatedById[]= $rewritingUrlRelatedById; + $rewritingUrlRelatedById->setRewritingUrlRelatedByRedirected($this); + } + + /** + * @param RewritingUrlRelatedById $rewritingUrlRelatedById The rewritingUrlRelatedById object to remove. + * @return ChildRewritingUrl The current object (for fluent API support) + */ + public function removeRewritingUrlRelatedById($rewritingUrlRelatedById) + { + if ($this->getRewritingUrlsRelatedById()->contains($rewritingUrlRelatedById)) { + $this->collRewritingUrlsRelatedById->remove($this->collRewritingUrlsRelatedById->search($rewritingUrlRelatedById)); + if (null === $this->rewritingUrlsRelatedByIdScheduledForDeletion) { + $this->rewritingUrlsRelatedByIdScheduledForDeletion = clone $this->collRewritingUrlsRelatedById; + $this->rewritingUrlsRelatedByIdScheduledForDeletion->clear(); + } + $this->rewritingUrlsRelatedByIdScheduledForDeletion[]= $rewritingUrlRelatedById; + $rewritingUrlRelatedById->setRewritingUrlRelatedByRedirected(null); + } + + return $this; + } + + /** + * Clears out the collRewritingArguments collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addRewritingArguments() + */ + public function clearRewritingArguments() + { + $this->collRewritingArguments = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collRewritingArguments collection loaded partially. + */ + public function resetPartialRewritingArguments($v = true) + { + $this->collRewritingArgumentsPartial = $v; + } + + /** + * Initializes the collRewritingArguments collection. + * + * By default this just sets the collRewritingArguments collection to an empty array (like clearcollRewritingArguments()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initRewritingArguments($overrideExisting = true) + { + if (null !== $this->collRewritingArguments && !$overrideExisting) { + return; + } + $this->collRewritingArguments = new ObjectCollection(); + $this->collRewritingArguments->setModel('\Thelia\Model\RewritingArgument'); + } + + /** + * Gets an array of ChildRewritingArgument objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildRewritingUrl is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildRewritingArgument[] List of ChildRewritingArgument objects + * @throws PropelException + */ + public function getRewritingArguments($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collRewritingArgumentsPartial && !$this->isNew(); + if (null === $this->collRewritingArguments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collRewritingArguments) { + // return empty collection + $this->initRewritingArguments(); + } else { + $collRewritingArguments = ChildRewritingArgumentQuery::create(null, $criteria) + ->filterByRewritingUrl($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collRewritingArgumentsPartial && count($collRewritingArguments)) { + $this->initRewritingArguments(false); + + foreach ($collRewritingArguments as $obj) { + if (false == $this->collRewritingArguments->contains($obj)) { + $this->collRewritingArguments->append($obj); + } + } + + $this->collRewritingArgumentsPartial = true; + } + + $collRewritingArguments->getInternalIterator()->rewind(); + + return $collRewritingArguments; + } + + if ($partial && $this->collRewritingArguments) { + foreach ($this->collRewritingArguments as $obj) { + if ($obj->isNew()) { + $collRewritingArguments[] = $obj; + } + } + } + + $this->collRewritingArguments = $collRewritingArguments; + $this->collRewritingArgumentsPartial = false; + } + } + + return $this->collRewritingArguments; + } + + /** + * Sets a collection of RewritingArgument objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $rewritingArguments A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildRewritingUrl The current object (for fluent API support) + */ + public function setRewritingArguments(Collection $rewritingArguments, ConnectionInterface $con = null) + { + $rewritingArgumentsToDelete = $this->getRewritingArguments(new Criteria(), $con)->diff($rewritingArguments); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->rewritingArgumentsScheduledForDeletion = clone $rewritingArgumentsToDelete; + + foreach ($rewritingArgumentsToDelete as $rewritingArgumentRemoved) { + $rewritingArgumentRemoved->setRewritingUrl(null); + } + + $this->collRewritingArguments = null; + foreach ($rewritingArguments as $rewritingArgument) { + $this->addRewritingArgument($rewritingArgument); + } + + $this->collRewritingArguments = $rewritingArguments; + $this->collRewritingArgumentsPartial = false; + + return $this; + } + + /** + * Returns the number of related RewritingArgument objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related RewritingArgument objects. + * @throws PropelException + */ + public function countRewritingArguments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collRewritingArgumentsPartial && !$this->isNew(); + if (null === $this->collRewritingArguments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collRewritingArguments) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getRewritingArguments()); + } + + $query = ChildRewritingArgumentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByRewritingUrl($this) + ->count($con); + } + + return count($this->collRewritingArguments); + } + + /** + * Method called to associate a ChildRewritingArgument object to this object + * through the ChildRewritingArgument foreign key attribute. + * + * @param ChildRewritingArgument $l ChildRewritingArgument + * @return \Thelia\Model\RewritingUrl The current object (for fluent API support) + */ + public function addRewritingArgument(ChildRewritingArgument $l) + { + if ($this->collRewritingArguments === null) { + $this->initRewritingArguments(); + $this->collRewritingArgumentsPartial = true; + } + + if (!in_array($l, $this->collRewritingArguments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddRewritingArgument($l); + } + + return $this; + } + + /** + * @param RewritingArgument $rewritingArgument The rewritingArgument object to add. + */ + protected function doAddRewritingArgument($rewritingArgument) + { + $this->collRewritingArguments[]= $rewritingArgument; + $rewritingArgument->setRewritingUrl($this); + } + + /** + * @param RewritingArgument $rewritingArgument The rewritingArgument object to remove. + * @return ChildRewritingUrl The current object (for fluent API support) + */ + public function removeRewritingArgument($rewritingArgument) + { + if ($this->getRewritingArguments()->contains($rewritingArgument)) { + $this->collRewritingArguments->remove($this->collRewritingArguments->search($rewritingArgument)); + if (null === $this->rewritingArgumentsScheduledForDeletion) { + $this->rewritingArgumentsScheduledForDeletion = clone $this->collRewritingArguments; + $this->rewritingArgumentsScheduledForDeletion->clear(); + } + $this->rewritingArgumentsScheduledForDeletion[]= clone $rewritingArgument; + $rewritingArgument->setRewritingUrl(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->url = null; + $this->view = null; + $this->view_id = null; + $this->view_locale = null; + $this->redirected = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collRewritingUrlsRelatedById) { + foreach ($this->collRewritingUrlsRelatedById as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collRewritingArguments) { + foreach ($this->collRewritingArguments as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + if ($this->collRewritingUrlsRelatedById instanceof Collection) { + $this->collRewritingUrlsRelatedById->clearIterator(); + } + $this->collRewritingUrlsRelatedById = null; + if ($this->collRewritingArguments instanceof Collection) { + $this->collRewritingArguments->clearIterator(); + } + $this->collRewritingArguments = null; + $this->aRewritingUrlRelatedByRedirected = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(RewritingUrlTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildRewritingUrl The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = RewritingUrlTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/RewritingUrlQuery.php b/core/lib/Thelia/Model/Base/RewritingUrlQuery.php new file mode 100644 index 000000000..c3c73b923 --- /dev/null +++ b/core/lib/Thelia/Model/Base/RewritingUrlQuery.php @@ -0,0 +1,919 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildRewritingUrl|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = RewritingUrlTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(RewritingUrlTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildRewritingUrl A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, URL, VIEW, VIEW_ID, VIEW_LOCALE, REDIRECTED, CREATED_AT, UPDATED_AT FROM rewriting_url WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildRewritingUrl(); + $obj->hydrate($row); + RewritingUrlTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildRewritingUrl|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(RewritingUrlTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(RewritingUrlTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(RewritingUrlTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(RewritingUrlTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(RewritingUrlTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the url column + * + * Example usage: + * + * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue' + * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%' + * + * + * @param string $url The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function filterByUrl($url = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($url)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $url)) { + $url = str_replace('*', '%', $url); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(RewritingUrlTableMap::URL, $url, $comparison); + } + + /** + * Filter the query on the view column + * + * Example usage: + * + * $query->filterByView('fooValue'); // WHERE view = 'fooValue' + * $query->filterByView('%fooValue%'); // WHERE view LIKE '%fooValue%' + * + * + * @param string $view The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function filterByView($view = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($view)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $view)) { + $view = str_replace('*', '%', $view); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(RewritingUrlTableMap::VIEW, $view, $comparison); + } + + /** + * Filter the query on the view_id column + * + * Example usage: + * + * $query->filterByViewId('fooValue'); // WHERE view_id = 'fooValue' + * $query->filterByViewId('%fooValue%'); // WHERE view_id LIKE '%fooValue%' + * + * + * @param string $viewId The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function filterByViewId($viewId = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($viewId)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $viewId)) { + $viewId = str_replace('*', '%', $viewId); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(RewritingUrlTableMap::VIEW_ID, $viewId, $comparison); + } + + /** + * Filter the query on the view_locale column + * + * Example usage: + * + * $query->filterByViewLocale('fooValue'); // WHERE view_locale = 'fooValue' + * $query->filterByViewLocale('%fooValue%'); // WHERE view_locale LIKE '%fooValue%' + * + * + * @param string $viewLocale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function filterByViewLocale($viewLocale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($viewLocale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $viewLocale)) { + $viewLocale = str_replace('*', '%', $viewLocale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(RewritingUrlTableMap::VIEW_LOCALE, $viewLocale, $comparison); + } + + /** + * Filter the query on the redirected column + * + * Example usage: + * + * $query->filterByRedirected(1234); // WHERE redirected = 1234 + * $query->filterByRedirected(array(12, 34)); // WHERE redirected IN (12, 34) + * $query->filterByRedirected(array('min' => 12)); // WHERE redirected > 12 + * + * + * @see filterByRewritingUrlRelatedByRedirected() + * + * @param mixed $redirected The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function filterByRedirected($redirected = null, $comparison = null) + { + if (is_array($redirected)) { + $useMinMax = false; + if (isset($redirected['min'])) { + $this->addUsingAlias(RewritingUrlTableMap::REDIRECTED, $redirected['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($redirected['max'])) { + $this->addUsingAlias(RewritingUrlTableMap::REDIRECTED, $redirected['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(RewritingUrlTableMap::REDIRECTED, $redirected, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(RewritingUrlTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(RewritingUrlTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(RewritingUrlTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(RewritingUrlTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(RewritingUrlTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(RewritingUrlTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\RewritingUrl object + * + * @param \Thelia\Model\RewritingUrl|ObjectCollection $rewritingUrl The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function filterByRewritingUrlRelatedByRedirected($rewritingUrl, $comparison = null) + { + if ($rewritingUrl instanceof \Thelia\Model\RewritingUrl) { + return $this + ->addUsingAlias(RewritingUrlTableMap::REDIRECTED, $rewritingUrl->getId(), $comparison); + } elseif ($rewritingUrl instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(RewritingUrlTableMap::REDIRECTED, $rewritingUrl->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByRewritingUrlRelatedByRedirected() only accepts arguments of type \Thelia\Model\RewritingUrl or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the RewritingUrlRelatedByRedirected relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function joinRewritingUrlRelatedByRedirected($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('RewritingUrlRelatedByRedirected'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'RewritingUrlRelatedByRedirected'); + } + + return $this; + } + + /** + * Use the RewritingUrlRelatedByRedirected relation RewritingUrl object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\RewritingUrlQuery A secondary query class using the current class as primary query + */ + public function useRewritingUrlRelatedByRedirectedQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinRewritingUrlRelatedByRedirected($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'RewritingUrlRelatedByRedirected', '\Thelia\Model\RewritingUrlQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\RewritingUrl object + * + * @param \Thelia\Model\RewritingUrl|ObjectCollection $rewritingUrl the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function filterByRewritingUrlRelatedById($rewritingUrl, $comparison = null) + { + if ($rewritingUrl instanceof \Thelia\Model\RewritingUrl) { + return $this + ->addUsingAlias(RewritingUrlTableMap::ID, $rewritingUrl->getRedirected(), $comparison); + } elseif ($rewritingUrl instanceof ObjectCollection) { + return $this + ->useRewritingUrlRelatedByIdQuery() + ->filterByPrimaryKeys($rewritingUrl->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByRewritingUrlRelatedById() only accepts arguments of type \Thelia\Model\RewritingUrl or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the RewritingUrlRelatedById relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function joinRewritingUrlRelatedById($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('RewritingUrlRelatedById'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'RewritingUrlRelatedById'); + } + + return $this; + } + + /** + * Use the RewritingUrlRelatedById relation RewritingUrl object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\RewritingUrlQuery A secondary query class using the current class as primary query + */ + public function useRewritingUrlRelatedByIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinRewritingUrlRelatedById($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'RewritingUrlRelatedById', '\Thelia\Model\RewritingUrlQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\RewritingArgument object + * + * @param \Thelia\Model\RewritingArgument|ObjectCollection $rewritingArgument the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function filterByRewritingArgument($rewritingArgument, $comparison = null) + { + if ($rewritingArgument instanceof \Thelia\Model\RewritingArgument) { + return $this + ->addUsingAlias(RewritingUrlTableMap::ID, $rewritingArgument->getRewritingUrlId(), $comparison); + } elseif ($rewritingArgument instanceof ObjectCollection) { + return $this + ->useRewritingArgumentQuery() + ->filterByPrimaryKeys($rewritingArgument->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByRewritingArgument() only accepts arguments of type \Thelia\Model\RewritingArgument or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the RewritingArgument relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function joinRewritingArgument($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('RewritingArgument'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'RewritingArgument'); + } + + return $this; + } + + /** + * Use the RewritingArgument relation RewritingArgument object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\RewritingArgumentQuery A secondary query class using the current class as primary query + */ + public function useRewritingArgumentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinRewritingArgument($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'RewritingArgument', '\Thelia\Model\RewritingArgumentQuery'); + } + + /** + * Exclude object from result + * + * @param ChildRewritingUrl $rewritingUrl Object to remove from the list of results + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function prune($rewritingUrl = null) + { + if ($rewritingUrl) { + $this->addUsingAlias(RewritingUrlTableMap::ID, $rewritingUrl->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the rewriting_url table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingUrlTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + RewritingUrlTableMap::clearInstancePool(); + RewritingUrlTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildRewritingUrl or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildRewritingUrl object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingUrlTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(RewritingUrlTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + RewritingUrlTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + RewritingUrlTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(RewritingUrlTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(RewritingUrlTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(RewritingUrlTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(RewritingUrlTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(RewritingUrlTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildRewritingUrlQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(RewritingUrlTableMap::CREATED_AT); + } + +} // RewritingUrlQuery diff --git a/core/lib/Thelia/Model/Map/CategoryTableMap.php b/core/lib/Thelia/Model/Map/CategoryTableMap.php index f94b14e5f..5e692c00f 100755 --- a/core/lib/Thelia/Model/Map/CategoryTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryTableMap.php @@ -193,7 +193,6 @@ class CategoryTableMap extends TableMap $this->addRelation('ProductCategory', '\\Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'ProductCategories'); $this->addRelation('FeatureCategory', '\\Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'FeatureCategories'); $this->addRelation('AttributeCategory', '\\Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'AttributeCategories'); - $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); $this->addRelation('CategoryImage', '\\Thelia\\Model\\CategoryImage', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryImages'); $this->addRelation('CategoryDocument', '\\Thelia\\Model\\CategoryDocument', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryDocuments'); $this->addRelation('CategoryAssociatedContent', '\\Thelia\\Model\\CategoryAssociatedContent', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryAssociatedContents'); @@ -228,7 +227,6 @@ class CategoryTableMap extends TableMap ProductCategoryTableMap::clearInstancePool(); FeatureCategoryTableMap::clearInstancePool(); AttributeCategoryTableMap::clearInstancePool(); - RewritingTableMap::clearInstancePool(); CategoryImageTableMap::clearInstancePool(); CategoryDocumentTableMap::clearInstancePool(); CategoryAssociatedContentTableMap::clearInstancePool(); diff --git a/core/lib/Thelia/Model/Map/ContentTableMap.php b/core/lib/Thelia/Model/Map/ContentTableMap.php index 5b6787a28..f89e7fd20 100755 --- a/core/lib/Thelia/Model/Map/ContentTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentTableMap.php @@ -184,7 +184,6 @@ class ContentTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); $this->addRelation('ContentFolder', '\\Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders'); $this->addRelation('ContentImage', '\\Thelia\\Model\\ContentImage', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentImages'); $this->addRelation('ContentDocument', '\\Thelia\\Model\\ContentDocument', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentDocuments'); @@ -216,7 +215,6 @@ class ContentTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - RewritingTableMap::clearInstancePool(); ContentFolderTableMap::clearInstancePool(); ContentImageTableMap::clearInstancePool(); ContentDocumentTableMap::clearInstancePool(); diff --git a/core/lib/Thelia/Model/Map/FolderTableMap.php b/core/lib/Thelia/Model/Map/FolderTableMap.php index 08871715b..7f4dde6d0 100755 --- a/core/lib/Thelia/Model/Map/FolderTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderTableMap.php @@ -190,7 +190,6 @@ class FolderTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); $this->addRelation('ContentFolder', '\\Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders'); $this->addRelation('FolderImage', '\\Thelia\\Model\\FolderImage', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'FolderImages'); $this->addRelation('FolderDocument', '\\Thelia\\Model\\FolderDocument', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'FolderDocuments'); @@ -220,7 +219,6 @@ class FolderTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - RewritingTableMap::clearInstancePool(); ContentFolderTableMap::clearInstancePool(); FolderImageTableMap::clearInstancePool(); FolderDocumentTableMap::clearInstancePool(); diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php index 81badfba0..1d46d483e 100755 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -204,7 +204,6 @@ class ProductTableMap extends TableMap $this->addRelation('ProductDocument', '\\Thelia\\Model\\ProductDocument', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductDocuments'); $this->addRelation('AccessoryRelatedByProductId', '\\Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'AccessoriesRelatedByProductId'); $this->addRelation('AccessoryRelatedByAccessory', '\\Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'accessory', ), 'CASCADE', 'RESTRICT', 'AccessoriesRelatedByAccessory'); - $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); $this->addRelation('CartItem', '\\Thelia\\Model\\CartItem', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), null, null, 'CartItems'); $this->addRelation('ProductAssociatedContent', '\\Thelia\\Model\\ProductAssociatedContent', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductAssociatedContents'); $this->addRelation('ProductI18n', '\\Thelia\\Model\\ProductI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProductI18ns'); @@ -241,7 +240,6 @@ class ProductTableMap extends TableMap ProductImageTableMap::clearInstancePool(); ProductDocumentTableMap::clearInstancePool(); AccessoryTableMap::clearInstancePool(); - RewritingTableMap::clearInstancePool(); ProductAssociatedContentTableMap::clearInstancePool(); ProductI18nTableMap::clearInstancePool(); ProductVersionTableMap::clearInstancePool(); diff --git a/core/lib/Thelia/Model/Map/RewritingArgumentTableMap.php b/core/lib/Thelia/Model/Map/RewritingArgumentTableMap.php new file mode 100644 index 000000000..45c75c983 --- /dev/null +++ b/core/lib/Thelia/Model/Map/RewritingArgumentTableMap.php @@ -0,0 +1,503 @@ + array('RewritingUrlId', 'Parameter', 'Value', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('rewritingUrlId', 'parameter', 'value', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(RewritingArgumentTableMap::REWRITING_URL_ID, RewritingArgumentTableMap::PARAMETER, RewritingArgumentTableMap::VALUE, RewritingArgumentTableMap::CREATED_AT, RewritingArgumentTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('REWRITING_URL_ID', 'PARAMETER', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('rewriting_url_id', 'parameter', 'value', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('RewritingUrlId' => 0, 'Parameter' => 1, 'Value' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('rewritingUrlId' => 0, 'parameter' => 1, 'value' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(RewritingArgumentTableMap::REWRITING_URL_ID => 0, RewritingArgumentTableMap::PARAMETER => 1, RewritingArgumentTableMap::VALUE => 2, RewritingArgumentTableMap::CREATED_AT => 3, RewritingArgumentTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('REWRITING_URL_ID' => 0, 'PARAMETER' => 1, 'VALUE' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('rewriting_url_id' => 0, 'parameter' => 1, 'value' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('rewriting_argument'); + $this->setPhpName('RewritingArgument'); + $this->setClassName('\\Thelia\\Model\\RewritingArgument'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('REWRITING_URL_ID', 'RewritingUrlId', 'INTEGER' , 'rewriting_url', 'ID', true, null, null); + $this->addPrimaryKey('PARAMETER', 'Parameter', 'VARCHAR', true, 255, null); + $this->addPrimaryKey('VALUE', 'Value', 'VARCHAR', true, 255, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('RewritingUrl', '\\Thelia\\Model\\RewritingUrl', RelationMap::MANY_TO_ONE, array('rewriting_url_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\RewritingArgument $obj A \Thelia\Model\RewritingArgument object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getRewritingUrlId(), (string) $obj->getParameter(), (string) $obj->getValue())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\RewritingArgument object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\RewritingArgument) { + $key = serialize(array((string) $value->getRewritingUrlId(), (string) $value->getParameter(), (string) $value->getValue())); + + } elseif (is_array($value) && count($value) === 3) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1], (string) $value[2])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\RewritingArgument object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('RewritingUrlId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Parameter', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('RewritingUrlId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Parameter', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? RewritingArgumentTableMap::CLASS_DEFAULT : RewritingArgumentTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (RewritingArgument object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = RewritingArgumentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = RewritingArgumentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + RewritingArgumentTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = RewritingArgumentTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + RewritingArgumentTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = RewritingArgumentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = RewritingArgumentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + RewritingArgumentTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(RewritingArgumentTableMap::REWRITING_URL_ID); + $criteria->addSelectColumn(RewritingArgumentTableMap::PARAMETER); + $criteria->addSelectColumn(RewritingArgumentTableMap::VALUE); + $criteria->addSelectColumn(RewritingArgumentTableMap::CREATED_AT); + $criteria->addSelectColumn(RewritingArgumentTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.REWRITING_URL_ID'); + $criteria->addSelectColumn($alias . '.PARAMETER'); + $criteria->addSelectColumn($alias . '.VALUE'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(RewritingArgumentTableMap::DATABASE_NAME)->getTable(RewritingArgumentTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(RewritingArgumentTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(RewritingArgumentTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new RewritingArgumentTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a RewritingArgument or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or RewritingArgument object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingArgumentTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\RewritingArgument) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(RewritingArgumentTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(RewritingArgumentTableMap::REWRITING_URL_ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(RewritingArgumentTableMap::PARAMETER, $value[1])); + $criterion->addAnd($criteria->getNewCriterion(RewritingArgumentTableMap::VALUE, $value[2])); + $criteria->addOr($criterion); + } + } + + $query = RewritingArgumentQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { RewritingArgumentTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { RewritingArgumentTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the rewriting_argument table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return RewritingArgumentQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a RewritingArgument or Criteria object. + * + * @param mixed $criteria Criteria or RewritingArgument object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingArgumentTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from RewritingArgument object + } + + + // Set the correct dbName + $query = RewritingArgumentQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // RewritingArgumentTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +RewritingArgumentTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/RewritingUrlTableMap.php b/core/lib/Thelia/Model/Map/RewritingUrlTableMap.php new file mode 100644 index 000000000..e21a99a9d --- /dev/null +++ b/core/lib/Thelia/Model/Map/RewritingUrlTableMap.php @@ -0,0 +1,478 @@ + array('Id', 'Url', 'View', 'ViewId', 'ViewLocale', 'Redirected', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'url', 'view', 'viewId', 'viewLocale', 'redirected', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(RewritingUrlTableMap::ID, RewritingUrlTableMap::URL, RewritingUrlTableMap::VIEW, RewritingUrlTableMap::VIEW_ID, RewritingUrlTableMap::VIEW_LOCALE, RewritingUrlTableMap::REDIRECTED, RewritingUrlTableMap::CREATED_AT, RewritingUrlTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'URL', 'VIEW', 'VIEW_ID', 'VIEW_LOCALE', 'REDIRECTED', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'url', 'view', 'view_id', 'view_locale', 'redirected', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Url' => 1, 'View' => 2, 'ViewId' => 3, 'ViewLocale' => 4, 'Redirected' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'url' => 1, 'view' => 2, 'viewId' => 3, 'viewLocale' => 4, 'redirected' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + self::TYPE_COLNAME => array(RewritingUrlTableMap::ID => 0, RewritingUrlTableMap::URL => 1, RewritingUrlTableMap::VIEW => 2, RewritingUrlTableMap::VIEW_ID => 3, RewritingUrlTableMap::VIEW_LOCALE => 4, RewritingUrlTableMap::REDIRECTED => 5, RewritingUrlTableMap::CREATED_AT => 6, RewritingUrlTableMap::UPDATED_AT => 7, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'URL' => 1, 'VIEW' => 2, 'VIEW_ID' => 3, 'VIEW_LOCALE' => 4, 'REDIRECTED' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), + self::TYPE_FIELDNAME => array('id' => 0, 'url' => 1, 'view' => 2, 'view_id' => 3, 'view_locale' => 4, 'redirected' => 5, 'created_at' => 6, 'updated_at' => 7, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('rewriting_url'); + $this->setPhpName('RewritingUrl'); + $this->setClassName('\\Thelia\\Model\\RewritingUrl'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('URL', 'Url', 'VARCHAR', true, 255, null); + $this->addColumn('VIEW', 'View', 'VARCHAR', false, 255, null); + $this->addColumn('VIEW_ID', 'ViewId', 'VARCHAR', false, 255, null); + $this->addColumn('VIEW_LOCALE', 'ViewLocale', 'VARCHAR', false, 255, null); + $this->addForeignKey('REDIRECTED', 'Redirected', 'INTEGER', 'rewriting_url', 'ID', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('RewritingUrlRelatedByRedirected', '\\Thelia\\Model\\RewritingUrl', RelationMap::MANY_TO_ONE, array('redirected' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('RewritingUrlRelatedById', '\\Thelia\\Model\\RewritingUrl', RelationMap::ONE_TO_MANY, array('id' => 'redirected', ), 'RESTRICT', 'RESTRICT', 'RewritingUrlsRelatedById'); + $this->addRelation('RewritingArgument', '\\Thelia\\Model\\RewritingArgument', RelationMap::ONE_TO_MANY, array('id' => 'rewriting_url_id', ), 'CASCADE', 'RESTRICT', 'RewritingArguments'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to rewriting_url * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + RewritingArgumentTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? RewritingUrlTableMap::CLASS_DEFAULT : RewritingUrlTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (RewritingUrl object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = RewritingUrlTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = RewritingUrlTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + RewritingUrlTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = RewritingUrlTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + RewritingUrlTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = RewritingUrlTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = RewritingUrlTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + RewritingUrlTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(RewritingUrlTableMap::ID); + $criteria->addSelectColumn(RewritingUrlTableMap::URL); + $criteria->addSelectColumn(RewritingUrlTableMap::VIEW); + $criteria->addSelectColumn(RewritingUrlTableMap::VIEW_ID); + $criteria->addSelectColumn(RewritingUrlTableMap::VIEW_LOCALE); + $criteria->addSelectColumn(RewritingUrlTableMap::REDIRECTED); + $criteria->addSelectColumn(RewritingUrlTableMap::CREATED_AT); + $criteria->addSelectColumn(RewritingUrlTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.URL'); + $criteria->addSelectColumn($alias . '.VIEW'); + $criteria->addSelectColumn($alias . '.VIEW_ID'); + $criteria->addSelectColumn($alias . '.VIEW_LOCALE'); + $criteria->addSelectColumn($alias . '.REDIRECTED'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(RewritingUrlTableMap::DATABASE_NAME)->getTable(RewritingUrlTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(RewritingUrlTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(RewritingUrlTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new RewritingUrlTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a RewritingUrl or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or RewritingUrl object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingUrlTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\RewritingUrl) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(RewritingUrlTableMap::DATABASE_NAME); + $criteria->add(RewritingUrlTableMap::ID, (array) $values, Criteria::IN); + } + + $query = RewritingUrlQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { RewritingUrlTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { RewritingUrlTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the rewriting_url table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return RewritingUrlQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a RewritingUrl or Criteria object. + * + * @param mixed $criteria Criteria or RewritingUrl object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingUrlTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from RewritingUrl object + } + + + // Set the correct dbName + $query = RewritingUrlQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // RewritingUrlTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +RewritingUrlTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/RewritingArgument.php b/core/lib/Thelia/Model/RewritingArgument.php new file mode 100644 index 000000000..79ab92a54 --- /dev/null +++ b/core/lib/Thelia/Model/RewritingArgument.php @@ -0,0 +1,9 @@ +
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      @@ -1128,7 +1095,7 @@
      - + From 2d370bf9b8cbfb2319dafba54eaf31ff50c9a36b Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 28 Aug 2013 15:48:19 +0200 Subject: [PATCH 045/268] rewriting tables --- install/thelia.sql | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/install/thelia.sql b/install/thelia.sql index 501d6f358..308e52b75 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -1028,49 +1028,6 @@ CREATE TABLE `message` PRIMARY KEY (`id`) ) ENGINE=InnoDB; --- --------------------------------------------------------------------- --- rewriting --- --------------------------------------------------------------------- - -DROP TABLE IF EXISTS `rewriting`; - -CREATE TABLE `rewriting` -( - `id` INTEGER NOT NULL, - `url` VARCHAR(255) NOT NULL, - `product_id` INTEGER, - `category_id` INTEGER, - `folder_id` INTEGER, - `content_id` INTEGER, - `created_at` DATETIME, - `updated_at` DATETIME, - PRIMARY KEY (`id`), - INDEX `idx_rewriting_product_id` (`product_id`), - INDEX `idx_rewriting_category_id` (`category_id`), - INDEX `idx_rewriting_folder_id` (`folder_id`), - INDEX `idx_rewriting_content_id` (`content_id`), - CONSTRAINT `fk_rewriting_product_id` - FOREIGN KEY (`product_id`) - REFERENCES `product` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE, - CONSTRAINT `fk_rewriting_category_id` - FOREIGN KEY (`category_id`) - REFERENCES `category` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE, - CONSTRAINT `fk_rewriting_folder_id` - FOREIGN KEY (`folder_id`) - REFERENCES `folder` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE, - CONSTRAINT `fk_rewriting_content_id` - FOREIGN KEY (`content_id`) - REFERENCES `content` (`id`) - ON UPDATE RESTRICT - ON DELETE CASCADE -) ENGINE=InnoDB; - -- --------------------------------------------------------------------- -- coupon -- --------------------------------------------------------------------- From 844e142abbc25b81e0272359bb0ac241b1788fa2 Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 28 Aug 2013 15:49:55 +0200 Subject: [PATCH 046/268] Working - Add error message when not in trusted IP list --- web/index_dev.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/index_dev.php b/web/index_dev.php index dae84059f..4d0063268 100755 --- a/web/index_dev.php +++ b/web/index_dev.php @@ -41,8 +41,8 @@ $request = Request::createFromGlobals(); $thelia = new Thelia("dev", true); if ( false === in_array($request->getClientIp(), $trustedIp)) { - // Redirect 403 Forbidden - $response = new Response('Forbidden', 404); + // Redirect 401 Unauthorized + $response = new Response('Unauthorized', 401); $thelia->terminate($request, $response); } From 253a0b76d8d4bccecc9b6b8fcc566be00ddc0aa3 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 28 Aug 2013 15:55:38 +0200 Subject: [PATCH 047/268] rewriting tables --- core/lib/Thelia/Model/Base/RewritingUrl.php | 13 ++++++++++++- core/lib/Thelia/Model/Map/RewritingUrlTableMap.php | 6 +++++- install/insert.sql | 2 +- install/thelia.sql | 2 +- local/config/schema.xml | 2 +- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/core/lib/Thelia/Model/Base/RewritingUrl.php b/core/lib/Thelia/Model/Base/RewritingUrl.php index 2833e80ec..75ee97e79 100644 --- a/core/lib/Thelia/Model/Base/RewritingUrl.php +++ b/core/lib/Thelia/Model/Base/RewritingUrl.php @@ -1017,6 +1017,10 @@ abstract class RewritingUrl implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; + $this->modifiedColumns[] = RewritingUrlTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . RewritingUrlTableMap::ID . ')'); + } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(RewritingUrlTableMap::ID)) { @@ -1086,6 +1090,13 @@ abstract class RewritingUrl implements ActiveRecordInterface throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + $this->setNew(false); } @@ -1383,7 +1394,6 @@ abstract class RewritingUrl implements ActiveRecordInterface */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { - $copyObj->setId($this->getId()); $copyObj->setUrl($this->getUrl()); $copyObj->setView($this->getView()); $copyObj->setViewId($this->getViewId()); @@ -1413,6 +1423,7 @@ abstract class RewritingUrl implements ActiveRecordInterface if ($makeNew) { $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value } } diff --git a/core/lib/Thelia/Model/Map/RewritingUrlTableMap.php b/core/lib/Thelia/Model/Map/RewritingUrlTableMap.php index e21a99a9d..c6d5e5473 100644 --- a/core/lib/Thelia/Model/Map/RewritingUrlTableMap.php +++ b/core/lib/Thelia/Model/Map/RewritingUrlTableMap.php @@ -158,7 +158,7 @@ class RewritingUrlTableMap extends TableMap $this->setPhpName('RewritingUrl'); $this->setClassName('\\Thelia\\Model\\RewritingUrl'); $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); + $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('URL', 'Url', 'VARCHAR', true, 255, null); @@ -454,6 +454,10 @@ class RewritingUrlTableMap extends TableMap $criteria = $criteria->buildCriteria(); // build Criteria from RewritingUrl object } + if ($criteria->containsKey(RewritingUrlTableMap::ID) && $criteria->keyContainsValue(RewritingUrlTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.RewritingUrlTableMap::ID.')'); + } + // Set the correct dbName $query = RewritingUrlQuery::create()->mergeWith($criteria); diff --git a/install/insert.sql b/install/insert.sql index f5e5d6fdb..cbb6725f3 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -40,7 +40,7 @@ VALUES (1, 'en_EN', 'euro'), (2, 'fr_FR', 'dollar'), (2, 'en_EN', 'dollar'), -(3, 'fr_FR', 'livre'); +(3, 'fr_FR', 'livre'), (3, 'en_EN', 'pound'); diff --git a/install/thelia.sql b/install/thelia.sql index 308e52b75..1993ee084 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -1441,7 +1441,7 @@ DROP TABLE IF EXISTS `rewriting_url`; CREATE TABLE `rewriting_url` ( - `id` INTEGER NOT NULL, + `id` INTEGER NOT NULL AUTO_INCREMENT, `url` VARCHAR(255) NOT NULL, `view` VARCHAR(255), `view_id` VARCHAR(255), diff --git a/local/config/schema.xml b/local/config/schema.xml index 090280287..0e20f2562 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1094,7 +1094,7 @@
      - + From 059317c26667177ecc7f524fea2e249faf4f460e Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 28 Aug 2013 16:35:14 +0200 Subject: [PATCH 048/268] Working - Add reset_instal.sh reseting Model/SQL/DB creation/Insert/Admin creation Usage : chmod +x reset_install.sh ./ reset_install.sh --- reset_install.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 reset_install.sh diff --git a/reset_install.sh b/reset_install.sh new file mode 100755 index 000000000..f3a635a9b --- /dev/null +++ b/reset_install.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# @author Guillaume MOREL +# v0.1 + +echo -e "\033[47m\033[1;31m\n[WARN] This script will reset this Thelia2 install\n\033[0m" + +if [ ! -f local/config/database.yml ]; then + cp local/config/database.yml.sample local/config/database.yml + echo "[FAILED] Please add your database informations in local/config/database.yml and start this script again." +else + echo -e "\n\e[01;34m[INFO] Downloading vendors\e[00m\n" + php composer install --prefer-dist --no-dev + + cd local/config/ + + echo -e "\n\e[01;34m[INFO] Building Models file\e[00m\n" + ../../bin/propel build -v --output-dir=../../core/lib/ + + echo -e "\n\e[01;34m[INFO] Building SQL CREATE file\e[00m\n" + ../../bin/propel sql:build -v --output-dir=../../install/ + + # Not working : insert manually + # echo -e "\n\e[01;34m[INFO] Inserting SQL\e[00m\n" + # ../../bin/propel insert-sql -v --output-dir=../../install/ + # install/thelia.sql + # install/insert.sql + echo -e "\n\e[01;34m[INFO] Reinstalling Thelia2\e[00m\n" + cd ../.. + php Thelia thelia:install + + echo -e "\n\e[01;34m[INFO] Installing fixtures\e[00m\n" + php install/faker.php + + echo -e "\n\e[01;34m[INFO] Adding admin\e[00m\n" + php Thelia thelia:create-admin + + echo -e "\n\e[00;32m[SUCCESS] Reset done\e[00m\n" +fi From 0361cd1ff242b42ea6ee1347e09e133de01f4b6d Mon Sep 17 00:00:00 2001 From: franck Date: Wed, 28 Aug 2013 17:52:32 +0200 Subject: [PATCH 049/268] Removed InternalEvent, simplified SecurityContext --- composer.lock | 235 ++++++++--------- core/lib/Thelia/Action/BaseAction.php | 77 +++--- core/lib/Thelia/Action/Category.php | 249 +++++------------- core/lib/Thelia/Action/Customer.php | 6 +- core/lib/Thelia/Cart/CartTrait.php | 19 +- core/lib/Thelia/Config/Resources/action.xml | 10 +- core/lib/Thelia/Config/Resources/config.xml | 2 - .../Controller/Admin/BaseAdminController.php | 11 + .../Controller/Admin/CategoryController.php | 106 +++++++- .../Controller/Admin/SessionController.php | 4 +- core/lib/Thelia/Controller/BaseController.php | 39 +-- .../Controller/Front/CustomerController.php | 13 +- core/lib/Thelia/Core/Event/ActionEvent.php | 47 +--- core/lib/Thelia/Core/Event/CartItemEvent.php | 2 +- .../CategoryChangePositionEvent.php} | 68 +++-- ...ernalEvent.php => CategoryCreateEvent.php} | 64 ++++- .../CartEvent.php => CategoryDeleteEvent.php} | 33 ++- ....php => CategoryToggleVisibilityEvent.php} | 30 ++- .../Event/{Internal => }/CustomerEvent.php | 5 +- core/lib/Thelia/Core/Event/TheliaEvents.php | 24 +- .../Thelia/Core/Security/SecurityContext.php | 177 ++++++------- core/lib/Thelia/Core/Template/Loop/Auth.php | 3 - .../Smarty/Plugins/DataAccessFunctions.php | 7 +- .../Core/Template/Smarty/Plugins/Security.php | 5 - core/lib/Thelia/Model/CartItem.php | 2 +- core/lib/Thelia/Model/Customer.php | 2 +- 26 files changed, 630 insertions(+), 610 deletions(-) rename core/lib/Thelia/Core/{Context.php => Event/CategoryChangePositionEvent.php} (64%) mode change 100755 => 100644 rename core/lib/Thelia/Core/Event/{Internal/InternalEvent.php => CategoryCreateEvent.php} (62%) mode change 100755 => 100644 rename core/lib/Thelia/Core/Event/{Internal/CartEvent.php => CategoryDeleteEvent.php} (76%) mode change 100755 => 100644 rename core/lib/Thelia/Core/Event/{CategoryEvent.php => CategoryToggleVisibilityEvent.php} (81%) mode change 100755 => 100644 rename core/lib/Thelia/Core/Event/{Internal => }/CustomerEvent.php (95%) diff --git a/composer.lock b/composer.lock index d84eeb977..efa62a9f2 100755 --- a/composer.lock +++ b/composer.lock @@ -11,12 +11,12 @@ "source": { "type": "git", "url": "https://github.com/ezyang/htmlpurifier.git", - "reference": "19eee1489965d9bc6eded80f847ced2382127261" + "reference": "fac747bdbdba6aeaba4bed91ef49b2378c1798e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/19eee1489965d9bc6eded80f847ced2382127261", - "reference": "19eee1489965d9bc6eded80f847ced2382127261", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/fac747bdbdba6aeaba4bed91ef49b2378c1798e4", + "reference": "fac747bdbdba6aeaba4bed91ef49b2378c1798e4", "shasum": "" }, "require": { @@ -47,7 +47,7 @@ "keywords": [ "html" ], - "time": "2013-07-27 04:54:53" + "time": "2013-08-18 02:27:26" }, { "name": "imagine/imagine", @@ -55,12 +55,12 @@ "source": { "type": "git", "url": "https://github.com/avalanche123/Imagine.git", - "reference": "v0.5.0" + "reference": "f64ec666baaa800edcbf237db41121a569230709" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/avalanche123/Imagine/zipball/v0.5.0", - "reference": "v0.5.0", + "url": "https://api.github.com/repos/avalanche123/Imagine/zipball/f64ec666baaa800edcbf237db41121a569230709", + "reference": "f64ec666baaa800edcbf237db41121a569230709", "shasum": "" }, "require": { @@ -217,12 +217,12 @@ "source": { "type": "git", "url": "https://github.com/leafo/lessphp.git", - "reference": "v0.4.0" + "reference": "51f3f06f0fe78a722dabfd14578444bdd078d9de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/leafo/lessphp/zipball/v0.4.0", - "reference": "v0.4.0", + "url": "https://api.github.com/repos/leafo/lessphp/zipball/51f3f06f0fe78a722dabfd14578444bdd078d9de", + "reference": "51f3f06f0fe78a722dabfd14578444bdd078d9de", "shasum": "" }, "type": "library", @@ -258,26 +258,26 @@ "source": { "type": "git", "url": "https://github.com/propelorm/Propel2.git", - "reference": "2.0.0-alpha1" + "reference": "3b9ea45a6e1b9fb3903cb910a31fbbac4a66c184" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/propelorm/Propel2/zipball/2.0.0-alpha1", - "reference": "2.0.0-alpha1", + "url": "https://api.github.com/repos/propelorm/Propel2/zipball/3b9ea45a6e1b9fb3903cb910a31fbbac4a66c184", + "reference": "3b9ea45a6e1b9fb3903cb910a31fbbac4a66c184", "shasum": "" }, "require": { "php": ">=5.4", - "psr/log": ">=1.0,<2.0", - "symfony/console": ">=2.2,<3.0", - "symfony/filesystem": ">=2.2,<3.0", - "symfony/finder": ">=2.2,<3.0", - "symfony/validator": ">=2.2,<3.0", - "symfony/yaml": ">=2.2,<3.0" + "psr/log": "~1.0", + "symfony/console": "~2.2", + "symfony/filesystem": "~2.2", + "symfony/finder": "~2.2", + "symfony/validator": "~2.2", + "symfony/yaml": "~2.2" }, "require-dev": { - "behat/behat": ">=2.4,<3.0", - "monolog/monolog": ">=1.3,<2.0", + "behat/behat": "~2.4", + "monolog/monolog": "~1.3", "phpunit/phpunit": "3.7.*" }, "suggest": { @@ -356,12 +356,12 @@ "source": { "type": "git", "url": "https://github.com/krichprollsch/phpCssEmbed.git", - "reference": "v1.0.2" + "reference": "406c6d5b846cafa9186f9944a6210d0e6fed154b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/krichprollsch/phpCssEmbed/zipball/v1.0.2", - "reference": "v1.0.2", + "url": "https://api.github.com/repos/krichprollsch/phpCssEmbed/zipball/406c6d5b846cafa9186f9944a6210d0e6fed154b", + "reference": "406c6d5b846cafa9186f9944a6210d0e6fed154b", "shasum": "" }, "require": { @@ -540,17 +540,17 @@ }, { "name": "symfony/class-loader", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/ClassLoader", "source": { "type": "git", "url": "https://github.com/symfony/ClassLoader.git", - "reference": "v2.2.5" + "reference": "827c54ee9827f6de5afe53324cdbe47f017c0cba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/827c54ee9827f6de5afe53324cdbe47f017c0cba", + "reference": "827c54ee9827f6de5afe53324cdbe47f017c0cba", "shasum": "" }, "require": { @@ -586,21 +586,21 @@ ], "description": "Symfony ClassLoader Component", "homepage": "http://symfony.com", - "time": "2013-05-06 20:02:13" + "time": "2013-08-09 07:16:43" }, { "name": "symfony/config", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/Config", "source": { "type": "git", "url": "https://github.com/symfony/Config.git", - "reference": "v2.2.5" + "reference": "4ab8ad0c0f4bb52b0e7fb12d63b81892fb7f697a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/Config/zipball/4ab8ad0c0f4bb52b0e7fb12d63b81892fb7f697a", + "reference": "4ab8ad0c0f4bb52b0e7fb12d63b81892fb7f697a", "shasum": "" }, "require": { @@ -637,17 +637,17 @@ }, { "name": "symfony/console", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "v2.2.5" + "reference": "b9ed9d61ff84296c9ace5ac333c15e6f35062eeb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/Console/zipball/b9ed9d61ff84296c9ace5ac333c15e6f35062eeb", + "reference": "b9ed9d61ff84296c9ace5ac333c15e6f35062eeb", "shasum": "" }, "require": { @@ -680,21 +680,21 @@ ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2013-07-08 14:34:53" + "time": "2013-08-17 16:29:09" }, { "name": "symfony/dependency-injection", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "v2.2.5" + "reference": "434b31fe8548e0354d5f93b455d8927481ddfc6f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/434b31fe8548e0354d5f93b455d8927481ddfc6f", + "reference": "434b31fe8548e0354d5f93b455d8927481ddfc6f", "shasum": "" }, "require": { @@ -739,17 +739,17 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "v2.2.5" + "reference": "45c43ffa186a0473c71a947981e43e025cd93c87" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/45c43ffa186a0473c71a947981e43e025cd93c87", + "reference": "45c43ffa186a0473c71a947981e43e025cd93c87", "shasum": "" }, "require": { @@ -793,17 +793,17 @@ }, { "name": "symfony/filesystem", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/Filesystem", "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "v2.2.5" + "reference": "fa16b9ab446b84371a63ab391133ff58134edff1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/fa16b9ab446b84371a63ab391133ff58134edff1", + "reference": "fa16b9ab446b84371a63ab391133ff58134edff1", "shasum": "" }, "require": { @@ -840,17 +840,17 @@ }, { "name": "symfony/finder", - "version": "v2.3.3", + "version": "v2.3.4", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "v2.3.3" + "reference": "4a0fee5b86f5bbd9dfdc11ec124eba2915737ce1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/v2.3.3", - "reference": "v2.3.3", + "url": "https://api.github.com/repos/symfony/Finder/zipball/4a0fee5b86f5bbd9dfdc11ec124eba2915737ce1", + "reference": "4a0fee5b86f5bbd9dfdc11ec124eba2915737ce1", "shasum": "" }, "require": { @@ -883,21 +883,21 @@ ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2013-07-21 12:12:18" + "time": "2013-08-13 20:18:00" }, { "name": "symfony/form", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/Form", "source": { "type": "git", "url": "https://github.com/symfony/Form.git", - "reference": "v2.2.5" + "reference": "33e3fcb6ca3cefe43ab22dcb8bee5ea039033a88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Form/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/Form/zipball/33e3fcb6ca3cefe43ab22dcb8bee5ea039033a88", + "reference": "33e3fcb6ca3cefe43ab22dcb8bee5ea039033a88", "shasum": "" }, "require": { @@ -942,21 +942,21 @@ ], "description": "Symfony Form Component", "homepage": "http://symfony.com", - "time": "2013-08-02 13:12:51" + "time": "2013-08-25 11:59:08" }, { "name": "symfony/http-foundation", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "v2.2.5" + "reference": "9402ff009d4f1ee63e83e8f2262993a7c2a3beea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/9402ff009d4f1ee63e83e8f2262993a7c2a3beea", + "reference": "9402ff009d4f1ee63e83e8f2262993a7c2a3beea", "shasum": "" }, "require": { @@ -992,21 +992,21 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com", - "time": "2013-08-07 14:00:53" + "time": "2013-08-25 18:21:55" }, { "name": "symfony/http-kernel", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel.git", - "reference": "v2.2.5" + "reference": "080dea28df16aed1fbc7aeb08a1dcb10d7ab5299" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/080dea28df16aed1fbc7aeb08a1dcb10d7ab5299", + "reference": "080dea28df16aed1fbc7aeb08a1dcb10d7ab5299", "shasum": "" }, "require": { @@ -1062,25 +1062,24 @@ ], "description": "Symfony HttpKernel Component", "homepage": "http://symfony.com", - "time": "2013-08-07 15:57:43" + "time": "2013-08-26 19:27:24" }, { "name": "symfony/icu", - "version": "v1.2.0", + "version": "v1.0.0", "target-dir": "Symfony/Component/Icu", "source": { "type": "git", "url": "https://github.com/symfony/Icu.git", - "reference": "v1.2.0" + "reference": "v1.0.0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Icu/zipball/v1.2.0", - "reference": "v1.2.0", + "url": "https://api.github.com/repos/symfony/Icu/zipball/v1.0.0", + "reference": "v1.0.0", "shasum": "" }, "require": { - "lib-icu": ">=4.4", "php": ">=5.3.3", "symfony/intl": ">=2.3,<3.0" }, @@ -1110,21 +1109,21 @@ "icu", "intl" ], - "time": "2013-06-03 18:32:58" + "time": "2013-06-03 18:32:07" }, { "name": "symfony/intl", - "version": "v2.3.3", + "version": "v2.3.4", "target-dir": "Symfony/Component/Intl", "source": { "type": "git", "url": "https://github.com/symfony/Intl.git", - "reference": "v2.3.3" + "reference": "ebbcf7e3dab5185b4b24c961431e302a0ffb66ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Intl/zipball/v2.3.3", - "reference": "v2.3.3", + "url": "https://api.github.com/repos/symfony/Intl/zipball/ebbcf7e3dab5185b4b24c961431e302a0ffb66ec", + "reference": "ebbcf7e3dab5185b4b24c961431e302a0ffb66ec", "shasum": "" }, "require": { @@ -1187,21 +1186,21 @@ "l10n", "localization" ], - "time": "2013-08-01 12:40:45" + "time": "2013-08-24 14:32:55" }, { "name": "symfony/locale", - "version": "v2.3.3", + "version": "v2.3.4", "target-dir": "Symfony/Component/Locale", "source": { "type": "git", "url": "https://github.com/symfony/Locale.git", - "reference": "v2.3.3" + "reference": "490825116712881a351b9a13ad6dddd4a39b8bb0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Locale/zipball/v2.3.3", - "reference": "v2.3.3", + "url": "https://api.github.com/repos/symfony/Locale/zipball/490825116712881a351b9a13ad6dddd4a39b8bb0", + "reference": "490825116712881a351b9a13ad6dddd4a39b8bb0", "shasum": "" }, "require": { @@ -1239,17 +1238,17 @@ }, { "name": "symfony/options-resolver", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/OptionsResolver", "source": { "type": "git", "url": "https://github.com/symfony/OptionsResolver.git", - "reference": "v2.2.5" + "reference": "b36671093db40feacce2d489298f0782a0a61cfd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/OptionsResolver/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/OptionsResolver/zipball/b36671093db40feacce2d489298f0782a0a61cfd", + "reference": "b36671093db40feacce2d489298f0782a0a61cfd", "shasum": "" }, "require": { @@ -1291,17 +1290,17 @@ }, { "name": "symfony/process", - "version": "v2.3.3", + "version": "v2.3.4", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "v2.3.3" + "reference": "1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/v2.3.3", - "reference": "v2.3.3", + "url": "https://api.github.com/repos/symfony/Process/zipball/1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b", + "reference": "1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b", "shasum": "" }, "require": { @@ -1334,21 +1333,21 @@ ], "description": "Symfony Process Component", "homepage": "http://symfony.com", - "time": "2013-08-02 21:51:01" + "time": "2013-08-22 06:42:25" }, { "name": "symfony/property-access", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/PropertyAccess", "source": { "type": "git", "url": "https://github.com/symfony/PropertyAccess.git", - "reference": "v2.2.5" + "reference": "2452dd5d49c1602876d9eeb4de15425d5f9a6342" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/PropertyAccess/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/PropertyAccess/zipball/2452dd5d49c1602876d9eeb4de15425d5f9a6342", + "reference": "2452dd5d49c1602876d9eeb4de15425d5f9a6342", "shasum": "" }, "require": { @@ -1392,21 +1391,21 @@ "property path", "reflection" ], - "time": "2013-07-28 18:26:16" + "time": "2013-08-22 04:15:06" }, { "name": "symfony/routing", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony/Routing.git", - "reference": "v2.2.5" + "reference": "2704242137edc19cc61e71027a7a04eef28f42c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Routing/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/Routing/zipball/2704242137edc19cc61e71027a7a04eef28f42c6", + "reference": "2704242137edc19cc61e71027a7a04eef28f42c6", "shasum": "" }, "require": { @@ -1450,21 +1449,21 @@ ], "description": "Symfony Routing Component", "homepage": "http://symfony.com", - "time": "2013-07-30 11:22:46" + "time": "2013-08-23 14:06:02" }, { "name": "symfony/translation", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/Translation", "source": { "type": "git", "url": "https://github.com/symfony/Translation.git", - "reference": "v2.2.5" + "reference": "37a11fe823c28f9235548d253b215f07cec9a0de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/Translation/zipball/37a11fe823c28f9235548d253b215f07cec9a0de", + "reference": "37a11fe823c28f9235548d253b215f07cec9a0de", "shasum": "" }, "require": { @@ -1505,7 +1504,7 @@ ], "description": "Symfony Translation Component", "homepage": "http://symfony.com", - "time": "2013-07-28 18:26:16" + "time": "2013-08-24 12:29:44" }, { "name": "symfony/validator", @@ -1514,12 +1513,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/Validator.git", - "reference": "55808a75bf373a8edb6400239268d315f0a326c7" + "reference": "8f6f6be47fb8e1179cd225b1f949630e26221e42" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Validator/zipball/55808a75bf373a8edb6400239268d315f0a326c7", - "reference": "55808a75bf373a8edb6400239268d315f0a326c7", + "url": "https://api.github.com/repos/symfony/Validator/zipball/8f6f6be47fb8e1179cd225b1f949630e26221e42", + "reference": "8f6f6be47fb8e1179cd225b1f949630e26221e42", "shasum": "" }, "require": { @@ -1566,21 +1565,21 @@ ], "description": "Symfony Validator Component", "homepage": "http://symfony.com", - "time": "2013-08-13 20:18:00" + "time": "2013-08-24 15:26:22" }, { "name": "symfony/yaml", - "version": "v2.2.5", + "version": "v2.2.6", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "v2.2.5" + "reference": "d135717c1a42cb566cc09433658e7e8dbbe30b0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.2.5", - "reference": "v2.2.5", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/d135717c1a42cb566cc09433658e7e8dbbe30b0a", + "reference": "d135717c1a42cb566cc09433658e7e8dbbe30b0a", "shasum": "" }, "require": { @@ -1613,7 +1612,7 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2013-07-11 09:28:01" + "time": "2013-08-24 06:36:00" } ], "packages-dev": [ diff --git a/core/lib/Thelia/Action/BaseAction.php b/core/lib/Thelia/Action/BaseAction.php index bef57b30d..ab8f4abb8 100755 --- a/core/lib/Thelia/Action/BaseAction.php +++ b/core/lib/Thelia/Action/BaseAction.php @@ -40,52 +40,6 @@ class BaseAction $this->container = $container; } - /** - * Validate a BaseForm - * - * @param BaseForm $aBaseForm the form - * @param string $expectedMethod the expected method, POST or GET, or null for any of them - * @throws FormValidationException is the form contains error, or the method is not the right one - * @return \Symfony\Component\Form\Form Form the symfony form object - */ - protected function validateForm(BaseForm $aBaseForm, $expectedMethod = null) - { - $form = $aBaseForm->getForm(); - - if ($expectedMethod == null || $aBaseForm->getRequest()->isMethod($expectedMethod)) { - - $form->bind($aBaseForm->getRequest()); - - if ($form->isValid()) { - return $form; - } else { - throw new FormValidationException("Missing or invalid data"); - } - } else { - throw new FormValidationException(sprintf("Wrong form method, %s expected.", $expectedMethod)); - } - } - - /** - * Propagate a form error in the action event - * - * @param BaseForm $aBaseForm the form - * @param string $error_message an error message that may be displayed to the customer - * @param ActionEvent $event the action event - */ - protected function propagateFormError(BaseForm $aBaseForm, $error_message, ActionEvent $event) - { - // The form has an error - $aBaseForm->setError(true); - $aBaseForm->setErrorMessage($error_message); - - // Store the form in the parser context - $event->setErrorForm($aBaseForm); - - // Stop event propagation - $event->stopPropagation(); - } - /** * Return the event dispatcher, * @@ -96,4 +50,33 @@ class BaseAction return $this->container->get('event_dispatcher'); } -} + /** + * Check current user authorisations. + * + * @param mixed $roles a single role or an array of roles. + * @param mixed $permissions a single permission or an array of permissions. + * + * @throws AuthenticationException if permissions are not granted to the current user. + */ + protected function checkAuth($roles, $permissions) { + + if (! $this->getSecurityContext()->isGranted( + is_array($roles) ? $roles : array($roles), + is_array($permissions) ? $permissions : array($permissions)) ) { + + Tlog::getInstance()->addAlert("Authorization roles:", $roles, " permissions:", $permissions, " refused."); + + throw new AuthorizationException("Sorry, you're not allowed to perform this action"); + } + } + + /** + * Return the security context + * + * @return Thelia\Core\Security\SecurityContext + */ + protected function getSecurityContext() + { + return $this->container->get('thelia.securityContext'); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Action/Category.php b/core/lib/Thelia/Action/Category.php index 6e5b7ba00..d411d2a51 100755 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -24,134 +24,46 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Category as CategoryModel; -use Thelia\Form\CategoryCreationForm; -use Thelia\Core\Event\CategoryEvent; -use Thelia\Tools\Redirect; use Thelia\Model\CategoryQuery; -use Thelia\Model\AdminLog; -use Thelia\Form\CategoryDeletionForm; -use Thelia\Action\Exception\FormValidationException; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Propel; use Thelia\Model\Map\CategoryTableMap; use Propel\Runtime\Exception\PropelException; +use Thelia\Core\Event\CategoryCreateEvent; +use Thelia\Core\Event\CategoryDeleteEvent; +use Thelia\Core\Event\CategoryToggleVisibilityEvent; +use Thelia\Core\Event\CategoryChangePositionEvent; + class Category extends BaseAction implements EventSubscriberInterface { - public function create(ActionEvent $event) + public function create(CategoryCreateEvent $event) { - $this->checkAuth("ADMIN", "admin.category.create"); - $request = $event->getRequest(); + $category = new CategoryModel(); - try { - $categoryCreationForm = new CategoryCreationForm($request); + $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CREATECATEGORY, $event); - $form = $this->validateForm($categoryCreationForm, "POST"); + $category->create( + $event->getTitle(), + $event->getParent(), + $event->getLocale() + ); - $data = $form->getData(); + $event->setCreatedCategory($category); - $category = new CategoryModel(); - - $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CREATECATEGORY, $event); - - $category->create( - $data["title"], - $data["parent"], - $data["locale"] - ); - - AdminLog::append(sprintf("Category %s (ID %s) created", $category->getTitle(), $category->getId()), $request, $request->getSession()->getAdminUser()); - - $categoryEvent = new CategoryEvent($category); - - $event->getDispatcher()->dispatch(TheliaEvents::AFTER_CREATECATEGORY, $categoryEvent); - - // Substitute _ID_ in the URL with the ID of the created category - $successUrl = str_replace('_ID_', $category->getId(), $categoryCreationForm->getSuccessUrl()); - - // Redirect to the success URL - $this->redirect($successUrl); - - } catch (PropelException $e) { - Tlog::getInstance()->error(sprintf('error during creating category with message "%s"', $e->getMessage())); - - $message = "Failed to create this category, please try again."; - } - - // The form has errors, propagate it. - $this->propagateFormError($categoryCreationForm, $message, $event); + $event->getDispatcher()->dispatch(TheliaEvents::AFTER_CREATECATEGORY, $event); } - public function modify(ActionEvent $event) + public function modify(CategoryChangeEvent $event) { + $this->checkAuth("ADMIN", "admin.category.change"); - $this->checkAuth("ADMIN", "admin.category.delete"); - - $request = $event->getRequest(); - - $customerModification = new CustomerModification($request); - - $form = $customerModification->getForm(); - - if ($request->isMethod("post")) { - - $form->bind($request); - - if ($form->isValid()) { - $data = $form->getData(); - - $customer = CustomerQuery::create()->findPk(1); - try { - $customerEvent = new CustomerEvent($customer); - $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CHANGECUSTOMER, $customerEvent); - - $data = $form->getData(); - - $customer->createOrUpdate( - $data["title"], - $data["firstname"], - $data["lastname"], - $data["address1"], - $data["address2"], - $data["address3"], - $data["phone"], - $data["cellphone"], - $data["zipcode"], - $data["country"] - ); - - $customerEvent->customer = $customer; - $event->getDispatcher()->dispatch(TheliaEvents::AFTER_CHANGECUSTOMER, $customerEvent); - - // Update the logged-in user, and redirect to the success URL (exits) - // We don-t send the login event, as the customer si already logged. - $this->processSuccessfullLogin($event, $customer, $customerModification); - } catch (PropelException $e) { - - Tlog::getInstance()->error(sprintf('error during modifying customer on action/modifyCustomer with message "%s"', $e->getMessage())); - - $message = "Failed to change your account, please try again."; - } - } else { - $message = "Missing or invalid data"; - } - } else { - $message = "Wrong form method !"; - } - - // The form has an error - $customerModification->setError(true); - $customerModification->setErrorMessage($message); - - // Dispatch the errored form - $event->setErrorForm($customerModification); - + // TODO !! } /** @@ -159,50 +71,22 @@ class Category extends BaseAction implements EventSubscriberInterface * * @param ActionEvent $event */ - public function delete(ActionEvent $event) + public function delete(CategoryDeleteEvent $event) { - $this->checkAuth("ADMIN", "admin.category.delete"); - $request = $event->getRequest(); + $category = CategoryQuery::create()->findPk($event->getId()); - try { - $categoryDeletionForm = new CategoryDeletionForm($request); + if ($category !== null) { - $form = $this->validateForm($categoryDeletionForm, "POST"); + $event->setDeletedCategory($category); - $data = $form->getData(); - - $category = CategoryQuery::create()->findPk($data['id']); - - $categoryEvent = new CategoryEvent($category); - - $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_DELETECATEGORY, $categoryEvent); + $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_DELETECATEGORY, $event); $category->delete(); - AdminLog::append(sprintf("Category %s (ID %s) deleted", $category->getTitle(), $category->getId()), $request, $request->getSession()->getAdminUser()); - - $categoryEvent->category = $category; - - $event->getDispatcher()->dispatch(TheliaEvents::AFTER_DELETECATEGORY, $categoryEvent); - - // Substitute _ID_ in the URL with the ID of the created category - $successUrl = str_replace('_ID_', $category->getParent(), $categoryDeletionForm->getSuccessUrl()); - - // Redirect to the success URL - Redirect::exec($successUrl); - } catch (PropelException $e) { - - \Thelia\Log\Tlog::getInstance()->error(sprintf('error during deleting category ID=%s on action/modifyCustomer with message "%s"', $data['id'], $e->getMessage())); - - $message = "Failed to change your account, please try again."; - } catch (FormValidationException $e) { - - $message = $e->getMessage(); + $event->getDispatcher()->dispatch(TheliaEvents::AFTER_DELETECATEGORY, $event); } - - $this->propagateFormError($categoryDeletionForm, $message, $event); } /** @@ -210,63 +94,55 @@ class Category extends BaseAction implements EventSubscriberInterface * * @param ActionEvent $event */ - public function toggleVisibility(ActionEvent $event) + public function toggleVisibility(CategoryToggleVisibilityEvent $event) { - $this->checkAuth("ADMIN", "admin.category.edit"); - $request = $event->getRequest(); - - $category = CategoryQuery::create()->findPk($request->get('category_id', 0)); + $category = CategoryQuery::create()->findPk($event->getId()); if ($category !== null) { + $event->setCategory($category); + $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CHANGECATEGORY, $event); + $category->setVisible($category->getVisible() ? false : true); $category->save(); - $categoryEvent = new CategoryEvent($category); - - $event->getDispatcher()->dispatch(TheliaEvents::AFTER_CHANGECATEGORY, $categoryEvent); + $event->setCategory($category); + $event->getDispatcher()->dispatch(TheliaEvents::AFTER_CHANGECATEGORY, $event); } } /** - * Move category up + * Changes category position, selecting absolute ou relative change. * - * @param ActionEvent $event + * @param CategoryChangePositionEvent $event */ - public function changePositionUp(ActionEvent $event) + public function changePosition(CategoryChangePositionEvent $event) { - return $this->exchangePosition($event, 'up'); - } + $this->checkAuth("ADMIN", "admin.category.edit"); - /** - * Move category down - * - * @param ActionEvent $event - */ - public function changePositionDown(ActionEvent $event) - { - return $this->exchangePosition($event, 'down'); + if ($event->getMode() == CategoryChangePositionEvent::POSITION_ABSOLUTE) + return $this->changeAbsolutePosition($event); + else + return $this->exchangePosition($event); } /** * Move up or down a category * - * @param ActionEvent $event - * @param string $direction up to move up, down to move down + * @param CategoryChangePositionEvent $event */ - protected function exchangePosition(ActionEvent $event, $direction) + protected function exchangePosition(CategoryChangePositionEvent $event) { - $this->checkAuth("ADMIN", "admin.category.edit"); - - $request = $event->getRequest(); - - $category = CategoryQuery::create()->findPk($request->get('category_id', 0)); + $category = CategoryQuery::create()->findPk($event->getId()); if ($category !== null) { + $event->setCategory($category); + $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CHANGECATEGORY, $event); + // The current position of the category $my_position = $category->getPosition(); @@ -275,10 +151,10 @@ class Category extends BaseAction implements EventSubscriberInterface ->filterByParent($category->getParent()); // Up or down ? - if ($direction == 'up') { + if ($event->getMode() == CategoryChangePositionEvent::POSITION_UP) { // Find the category immediately before me $search->filterByPosition(array('max' => $my_position-1))->orderByPosition(Criteria::DESC); - } elseif ($direction == 'down') { + } elseif ($event->getMode() == CategoryChangePositionEvent::POSITION_DOWN) { // Find the category immediately after me $search->filterByPosition(array('min' => $my_position+1))->orderByPosition(Criteria::ASC); } else @@ -304,26 +180,30 @@ class Category extends BaseAction implements EventSubscriberInterface $cnx->rollback(); } } + + $event->setCategory($category); + $event->getDispatcher()->dispatch(TheliaEvents::AFTER_CHANGECATEGORY, $event); } } /** * Changes category position * - * @param ActionEvent $event + * @param CategoryChangePositionEvent $event */ - public function changePosition(ActionEvent $event) + protected function changeAbsolutePosition(CategoryChangePositionEvent $event) { $this->checkAuth("ADMIN", "admin.category.edit"); - $request = $event->getRequest(); - - $category = CategoryQuery::create()->findPk($request->get('category_id', 0)); + $category = CategoryQuery::create()->findPk($event->getId()); if ($category !== null) { + $event->setCategory($category); + $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CHANGECATEGORY, $event); + // The required position - $new_position = $request->get('position', null); + $new_position = $event->getPosition(); // The current position $current_position = $category->getPosition(); @@ -363,6 +243,9 @@ class Category extends BaseAction implements EventSubscriberInterface $cnx->rollback(); } } + + $event->setCategory($category); + $event->getDispatcher()->dispatch(TheliaEvents::AFTER_CHANGECATEGORY, $event); } } @@ -389,12 +272,14 @@ class Category extends BaseAction implements EventSubscriberInterface public static function getSubscribedEvents() { return array( - "action.createCategory" => array("create", 128), - "action.modifyCategory" => array("modify", 128), - "action.deleteCategory" => array("delete", 128), + TheliaEvents::CATEGORY_CREATE => array("create", 128), + TheliaEvents::CATEGORY_MODIFY => array("modify", 128), + TheliaEvents::CATEGORY_DELETE => array("delete", 128), - "action.toggleCategoryVisibility" => array("toggleVisibility", 128), - "action.changeCategoryPositionUp" => array("changePositionUp", 128), + TheliaEvents::CATEGORY_TOGGLE_VISIBILITY => array("toggleVisibility", 128), + TheliaEvents::CATEGORY_CHANGE_POSITION => array("changePosition", 128), + + "action.changeCategoryPositionU" => array("changePositionUp", 128), "action.changeCategoryPositionDown" => array("changePositionDown", 128), "action.changeCategoryPosition" => array("changePosition", 128), ); diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 785ee8f48..4c7a71d5e 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -96,7 +96,7 @@ class Customer extends BaseAction implements EventSubscriberInterface { $event->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_LOGOUT, $event); - $this->getFrontSecurityContext()->clear(); + $this->getSecurityContext()->clearCustomerUser(); } public function changePassword(ActionEvent $event) @@ -127,8 +127,8 @@ class Customer extends BaseAction implements EventSubscriberInterface public static function getSubscribedEvents() { return array( - "action.createCustomer" => array("create", 128), - "action.modifyCustomer" => array("modify", 128), + TheliaEvents::CUSTOMER_CREATEACCOUNT => array("create", 128), + TheliaEvents::CUSTOMER_UPDATEACCOUNT => array("modify", 128), ); } } diff --git a/core/lib/Thelia/Cart/CartTrait.php b/core/lib/Thelia/Cart/CartTrait.php index ed4f70374..901263a32 100755 --- a/core/lib/Thelia/Cart/CartTrait.php +++ b/core/lib/Thelia/Cart/CartTrait.php @@ -28,8 +28,8 @@ use Thelia\Model\ConfigQuery; use Thelia\Model\Customer; use Symfony\Component\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Session\Session; -use Thelia\Core\Event\Internal\CartEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\CartEvent; trait CartTrait { @@ -42,8 +42,9 @@ trait CartTrait */ public function getCart(Request $request) { + $session = $request->getSession(); - if (null !== $cart = $request->getSession()->getCart()) { + if (null !== $cart = $session->getCart()) { return $cart; } @@ -55,26 +56,26 @@ trait CartTrait if ($cart) { //le panier existe en base - $customer = $request->getSession()->getCustomerUser(); + $customer = $session->getCustomerUser(); if ($customer) { if ($cart->getCustomerId() != $customer->getId()) { //le customer du panier n'est pas le mm que celui connecté, il faut cloner le panier sans le customer_id - $cart = $this->duplicateCart($cart, $request->getSession(), $customer); + $cart = $this->duplicateCart($cart, $session, $customer); } } else { if ($cart->getCustomerId() != null) { //il faut dupliquer le panier sans le customer_id - $cart = $this->duplicateCart($cart, $request->getSession()); + $cart = $this->duplicateCart($cart, $session); } } } else { - $cart = $this->createCart($request->getSession()); + $cart = $this->createCart($session); } } else { //le cookie de panier n'existe pas, il va falloir le créer et faire un enregistrement en base. - $cart = $this->createCart($request->getSession()); + $cart = $this->createCart($session); } return $cart; @@ -116,7 +117,7 @@ trait CartTrait $cartEvent = new CartEvent($newCart); $this->getDispatcher()->dispatch(TheliaEvents::CART_DUPLICATE, $cartEvent); - return $cartEvent->cart; + return $cartEvent->getCart(); } protected function generateCookie() @@ -131,4 +132,4 @@ trait CartTrait return $id; } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index f773b4cd7..2bd31ce3e 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -22,16 +22,16 @@ - - - - - + + + + + diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 60105ad32..45c763830 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -85,8 +85,6 @@ - - diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 67cecd302..271ce3c05 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -30,11 +30,22 @@ use Symfony\Component\HttpKernel\HttpKernelInterface; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Tools\URL; use Thelia\Tools\Redirect; +use Thelia\Core\Security\SecurityContext; +use Thelia\Model\AdminLog; class BaseAdminController extends BaseController { const TEMPLATE_404 = "404"; + /** + * Helper to append a message to the admin log. + * + * @param unknown $message + */ + public function adminLogAppend($message) { + AdminLog::append($message, $this->getRequest(), $this->getSecurityContext()->getAdminUser()); + } + public function processTemplateAction($template) { try { diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 0c92d24dc..fda94191c 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -25,12 +25,52 @@ namespace Thelia\Controller\Admin; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\AuthorizationException; +use Thelia\Log\Tlog; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\CategoryCreateEvent; +use Thelia\Form\CategoryCreationForm; +use Thelia\Core\Event\CategoryDeleteEvent; +use Thelia\Core\Event\CategoryToggleVisibilityEvent; +use Thelia\Core\Event\CategoryChangePositionEvent; +use Thelia\Form\CategoryDeletionForm; class CategoryController extends BaseAdminController { protected function createNewCategory($args) { - $this->dispatchEvent("createCategory"); + try { + $categoryCreationForm = new CategoryCreationForm($this->getRequest()); + + $form = $this->validateForm($categoryCreationForm, "POST"); + + $data = $form->getData(); + + $categoryCreateEvent = new CategoryCreateEvent( + $data["title"], + $data["parent"], + $data["locale"] + ); + + $this->dispatch(TheliaEvents::CATEGORY_CREATE, $categoryCreateEvent); + + $category = $categoryCreateEvent->getCreatedCategory(); + + $this->adminLogAppend(sprintf("Category %s (ID %s) created", $category->getTitle(), $category->getId())); + + // Substitute _ID_ in the URL with the ID of the created category + $successUrl = str_replace('_ID_', $category->getId(), $categoryCreationForm->getSuccessUrl()); + + // Redirect to the success URL + $this->redirect($successUrl); + } + catch (FormValidationException $e) { + $categoryCreationForm->setErrorMessage($e->getMessage()); + $this->getParserContext()->setErrorForm($categoryCreationForm); + } + catch (Exception $e) { + Tlog::getInstance()->error(sprintf("Failed to create category: %s", $e->getMessage())); + $this->getParserContext()->setGeneralError($e->getMessage()); + } // At this point, the form has error, and should be redisplayed. return $this->render('categories', $args); @@ -45,9 +85,35 @@ class CategoryController extends BaseAdminController protected function deleteCategory($args) { - $this->dispatchEvent("deleteCategory"); + try { + $categoryDeletionForm = new CategoryDeletionForm($this->getRequest()); - // Something was wrong, category was not deleted. Display parent category list + $data = $this->validateForm($categoryDeletionForm, "POST")->getData(); +var_dump($data); + $categoryDeleteEvent = new CategoryDeleteEvent($data['category_id']); + + $this->dispatch(TheliaEvents::CATEGORY_DELETE, $categoryDeleteEvent); + + $category = $categoryDeleteEvent->getDeletedCategory(); + + $this->adminLogAppend(sprintf("Category %s (ID %s) deleted", $category->getTitle(), $category->getId())); + + // Substitute _ID_ in the URL with the ID of the created category + $successUrl = str_replace('_ID_', $categoryDeleteEvent->getDeletedCategory()->getId(), $categoryDeletionForm->getSuccessUrl()); + + // Redirect to the success URL + $this->redirect($successUrl); + } + catch (FormValidationException $e) { + $categoryDeletionForm->setErrorMessage($e->getMessage()); + $this->getParserContext()->setErrorForm($categoryDeletionForm); + } + catch (Exception $e) { + Tlog::getInstance()->error(sprintf("Failed to delete category: %s", $e->getMessage())); + $this->getParserContext()->setGeneralError($e->getMessage()); + } + + // At this point, something was wrong, category was not deleted. Display parent category list return $this->render('categories', $args); } @@ -60,28 +126,48 @@ class CategoryController extends BaseAdminController protected function visibilityToggle($args) { - $this->dispatchEvent("toggleCategoryVisibility"); + $event = new CategoryToggleVisibilityEvent($this->getRequest()->get('category_id', 0)); + + $this->dispatch(TheliaEvents::CATEGORY_TOGGLE_VISIBILITY, $event); return $this->nullResponse(); } protected function changePosition($args) { - $this->dispatchEvent("changeCategoryPosition"); + $request = $this->getRequest(); + + $event = new CategoryChangePositionEvent( + $request->get('category_id', 0), + CategoryChangePositionEvent::POSITION_ABSOLUTE, + $request->get('position', null) + ); + + $this->dispatch(TheliaEvents::CATEGORY_CHANGE_POSITION, $event); return $this->render('categories', $args); } protected function positionDown($args) { - $this->dispatchEvent("changeCategoryPositionDown"); + $event = new CategoryChangePositionEvent( + $this->getRequest()->get('category_id', 0), + CategoryChangePositionEvent::POSITION_DOWN + ); + + $this->dispatch(TheliaEvents::CATEGORY_CHANGE_POSITION, $event); return $this->render('categories', $args); } protected function positionUp($args) { - $this->dispatchEvent("changeCategoryPositionUp"); + $event = new CategoryChangePositionEvent( + $this->getRequest()->get('category_id', 0), + CategoryChangePositionEvent::POSITION_UP + ); + + $this->dispatch(TheliaEvents::CATEGORY_CHANGE_POSITION, $event); return $this->render('categories', $args); } @@ -138,9 +224,11 @@ class CategoryController extends BaseAdminController return $this->positionDown($args); } - } catch (AuthorizationException $ex) { + } + catch (AuthorizationException $ex) { return $this->errorPage($ex->getMessage()); - } catch (AuthenticationException $ex) { + } + catch (AuthenticationException $ex) { return $this->errorPage($ex->getMessage()); } diff --git a/core/lib/Thelia/Controller/Admin/SessionController.php b/core/lib/Thelia/Controller/Admin/SessionController.php index 5299253e0..39dbc1205 100755 --- a/core/lib/Thelia/Controller/Admin/SessionController.php +++ b/core/lib/Thelia/Controller/Admin/SessionController.php @@ -43,7 +43,7 @@ class SessionController extends BaseAdminController { $this->dispatch(TheliaEvents::ADMIN_LOGOUT); - $this->getSecurityContext()->clear(); + $this->getSecurityContext()->clearAdminUser(); // Go back to login page. return Redirect::exec(URL::absoluteUrl('/admin/login')); // FIXME - should be a parameter @@ -61,7 +61,7 @@ class SessionController extends BaseAdminController $user = $authenticator->getAuthentifiedUser(); // Success -> store user in security context - $this->getSecurityContext()->setUser($user); + $this->getSecurityContext()->setAdminUser($user); // Log authentication success AdminLog::append("Authentication successful", $request, $user); diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 5c6e3eb5e..1a610768d 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -34,6 +34,7 @@ use Symfony\Component\EventDispatcher\EventDispatcher; use Thelia\Core\Factory\ActionEventFactory; use Thelia\Form\BaseForm; use Thelia\Form\Exception\FormValidationException; +use Symfony\Component\EventDispatcher\Event; /** * @@ -56,34 +57,12 @@ class BaseController extends ContainerAware } /** - * Create an action event + * Dispatch a Thelia event * - * @param string $action - * @return EventDispatcher + * @param string $eventName a TheliaEvent name, as defined in TheliaEvents class + * @param Event $event the event */ - protected function dispatchEvent($action) - { - // Create the - $eventFactory = new ActionEventFactory($this->getRequest(), $action, $this->container->getParameter("thelia.actionEvent")); - - $actionEvent = $eventFactory->createActionEvent(); - - $this->dispatch("action.$action", $actionEvent); - - if ($actionEvent->hasErrorForm()) { - $this->getParserContext()->setErrorForm($actionEvent->getErrorForm()); - } - - return $actionEvent; - } - - /** - * Dispatch a Thelia event to modules - * - * @param string $eventName a TheliaEvent name, as defined in TheliaEvents class - * @param ActionEvent $event the event - */ - protected function dispatch($eventName, ActionEvent $event = null) + protected function dispatch($eventName, Event $event = null) { $this->getDispatcher()->dispatch($eventName, $event); } @@ -113,13 +92,9 @@ class BaseController extends ContainerAware * * @return \Thelia\Core\Security\SecurityContext */ - protected function getSecurityContext($context = false) + protected function getSecurityContext() { - $securityContext = $this->container->get('thelia.securityContext'); - - $securityContext->setContext($context === false ? SecurityContext::CONTEXT_BACK_OFFICE : $context); - - return $securityContext; + return $this->container->get('thelia.securityContext'); } /** diff --git a/core/lib/Thelia/Controller/Front/CustomerController.php b/core/lib/Thelia/Controller/Front/CustomerController.php index 07f9eb4c8..698c69d70 100755 --- a/core/lib/Thelia/Controller/Front/CustomerController.php +++ b/core/lib/Thelia/Controller/Front/CustomerController.php @@ -36,6 +36,7 @@ use Thelia\Form\CustomerModification; use Thelia\Form\Exception\FormValidationException; use Thelia\Model\Customer; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\CustomerEvent; class CustomerController extends BaseFrontController { @@ -76,7 +77,7 @@ class CustomerController extends BaseFrontController try { - $customer = $this->getSecurityContext(SecurityContext::CONTEXT_FRONT_OFFICE)->getUser(); + $customer = $this->getSecurityContext()->getCustomerUser(); $form = $this->validateForm($customerModification, "post"); @@ -116,9 +117,7 @@ class CustomerController extends BaseFrontController try { $customer = $authenticator->getAuthentifiedUser(); - $customerLoginEvent = new CustomerLoginEvent($customer); - - $this->processLogin($customer, $customerLoginEvent); + $this->processLogin($customer); $this->redirectSuccess(); } catch (ValidatorException $e) { @@ -132,11 +131,11 @@ class CustomerController extends BaseFrontController } } - public function processLogin(Customer $customer,$event = null) + public function processLogin(Customer $customer) { - $this->getSecurityContext(SecurityContext::CONTEXT_FRONT_OFFICE)->setUser($customer); + $this->getSecurityContext()->setCustomerUser($customer); - if($event) $this->dispatch(TheliaEvents::CUSTOMER_LOGIN, $event); + if($event) $this->dispatch(TheliaEvents::CUSTOMER_LOGIN, new CustomerLoginEvent($customer)); } /** diff --git a/core/lib/Thelia/Core/Event/ActionEvent.php b/core/lib/Thelia/Core/Event/ActionEvent.php index c5c188235..5040be7f5 100755 --- a/core/lib/Thelia/Core/Event/ActionEvent.php +++ b/core/lib/Thelia/Core/Event/ActionEvent.php @@ -35,27 +35,8 @@ use Thelia\Form\BaseForm; */ abstract class ActionEvent extends Event { - - /** - * - * @var Symfony\Component\HttpFoundation\Request - */ - protected $request; - - protected $errorForm = null; - protected $parameters = array(); - /** - * - * @param \Symfony\Component\HttpFoundation\Request $request - * @param string $action - */ - public function __construct(Request $request) - { - $this->request = $request; - } - public function __set($name, $value) { $this->parameters[$name] = $value; @@ -69,30 +50,4 @@ abstract class ActionEvent extends Event return null; } - - /** - * - * @return \Symfony\Component\HttpFoundation\Request - */ - public function getRequest() - { - return $this->request; - } - - public function setErrorForm(BaseForm $form) - { - $this->errorForm = $form; - - if ($form != null) $this->stopPropagation(); - } - - public function getErrorForm() - { - return $this->errorForm; - } - - public function hasErrorForm() - { - return $this->errorForm != null ? true : false; - } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/CartItemEvent.php b/core/lib/Thelia/Core/Event/CartItemEvent.php index 59deffb37..6718b63ff 100755 --- a/core/lib/Thelia/Core/Event/CartItemEvent.php +++ b/core/lib/Thelia/Core/Event/CartItemEvent.php @@ -25,7 +25,7 @@ namespace Thelia\Core\Event; use Thelia\Model\CartItem; -class CartItemEvent extends InternalEvent +class CartItemEvent extends ActionEvent { protected $cartItem; diff --git a/core/lib/Thelia/Core/Context.php b/core/lib/Thelia/Core/Event/CategoryChangePositionEvent.php old mode 100755 new mode 100644 similarity index 64% rename from core/lib/Thelia/Core/Context.php rename to core/lib/Thelia/Core/Event/CategoryChangePositionEvent.php index 6fa5a638b..141fc8182 --- a/core/lib/Thelia/Core/Context.php +++ b/core/lib/Thelia/Core/Event/CategoryChangePositionEvent.php @@ -21,34 +21,64 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core; +namespace Thelia\Core\Event; +use Thelia\Model\Category; -class Context +class CategoryChangePositionEvent extends ActionEvent { - const CONTEXT_FRONT_OFFICE = 'front'; - const CONTEXT_BACK_OFFICE = 'admin'; + const POSITION_UP = 1; + const POSITION_DOWN = 2; + const POSITION_ABSOLUTE = 3; - protected $defineContext = array( - self::CONTEXT_BACK_OFFICE, - self::CONTEXT_FRONT_OFFICE - ); + protected $id; + protected $mode; + protected $position; + protected $category; - protected $currentContext = self::CONTEXT_FRONT_OFFICE; - - public function isValidContext($context) + public function __construct($id, $mode, $position = null) { - return in_array($context, $this->defineContext); + $this->id = $id; + $this->mode = $mode; + $this->position = $position; } - public function setContext($context) + public function getId() { - if ($this->isValidContext($context)) { - $this->currentContext = $context; - } + return $this->id; } - public function getContext() + public function setId($id) { - return $this->currentContext; + $this->id = $id; } -} + + public function getMode() + { + return $this->mode; + } + + public function setMode($mode) + { + $this->mode = $mode; + } + + public function getPosition() + { + return $this->position; + } + + public function setPosition($position) + { + $this->position = $position; + } + + public function getCategory() + { + return $this->category; + } + + public function setCategory($category) + { + $this->category = $category; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Internal/InternalEvent.php b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php old mode 100755 new mode 100644 similarity index 62% rename from core/lib/Thelia/Core/Event/Internal/InternalEvent.php rename to core/lib/Thelia/Core/Event/CategoryCreateEvent.php index 49273769f..558b04277 --- a/core/lib/Thelia/Core/Event/Internal/InternalEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php @@ -21,16 +21,62 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event\Internal; +namespace Thelia\Core\Event; -use Symfony\Component\EventDispatcher\Event; +use Thelia\Model\Category; -/** - * Base class used for internal event like creating new Customer, adding item to cart, etc - * - * Class InternalEvent - * @package Thelia\Core\Event - */ -abstract class InternalEvent extends Event +class CategoryCreateEvent extends ActionEvent { + protected $title; + protected $parent; + protected $locale; + protected $created_category; + + public function __construct($title, $parent, $locale) + { + $this->title = $title; + $this->parent = $parent; + $this->locale = $locale; + } + + public function getTitle() + { + return $this->title; + } + + public function setTitle($title) + { + $this->title = $title; + } + + public function getParent() + { + return $this->parent; + } + + public function setParent($parent) + { + $this->parent = $parent; + } + + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + } + + public function getCreatedCategory() + { + return $this->created_category; + } + + public function setCreatedCategory(Category $created_category) + { + $this->created_category = $created_category; +var_dump($this->created_category); + } } diff --git a/core/lib/Thelia/Core/Event/Internal/CartEvent.php b/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php old mode 100755 new mode 100644 similarity index 76% rename from core/lib/Thelia/Core/Event/Internal/CartEvent.php rename to core/lib/Thelia/Core/Event/CategoryDeleteEvent.php index 7d35bea55..c53cb7e10 --- a/core/lib/Thelia/Core/Event/Internal/CartEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php @@ -21,17 +21,36 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event\Internal; +namespace Thelia\Core\Event; +use Thelia\Model\Category; -use Thelia\Model\Cart; - -class CartEvent extends InternalEvent +class CategoryDeleteEvent extends ActionEvent { - public $cart; + protected $id; + protected $deleted_category; - public function __construct(Cart $cart) + public function __construct($id) { - $this->cart = $cart; + $this->id = $id; } + public function getId() + { + return $this->id; + } + + public function setId($id) + { + $this->id = $id; + } + + public function getDeletedCategory() + { + return $this->deleted_category; + } + + public function setDeletedCategory(Category $deleted_category) + { + $this->deleted_category = $deleted_category; + } } diff --git a/core/lib/Thelia/Core/Event/CategoryEvent.php b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php old mode 100755 new mode 100644 similarity index 81% rename from core/lib/Thelia/Core/Event/CategoryEvent.php rename to core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php index 44986e8b9..b7237924e --- a/core/lib/Thelia/Core/Event/CategoryEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php @@ -22,15 +22,35 @@ /*************************************************************************************/ namespace Thelia\Core\Event; - use Thelia\Model\Category; -class CategoryEvent extends InternalEvent +class CategoryToggleVisibilityEvent extends ActionEvent { - public $category; + protected $id; + protected $category; - public function __construct(Category $category) + public function __construct($id) + { + $this->id = $id; + } + + public function getId() + { + return $this->id; + } + + public function setId($id) + { + $this->id = $id; + } + + public function getCategory() + { + return $this->category; + } + + public function setCategory(Category $category) { $this->category = $category; } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Internal/CustomerEvent.php b/core/lib/Thelia/Core/Event/CustomerEvent.php similarity index 95% rename from core/lib/Thelia/Core/Event/Internal/CustomerEvent.php rename to core/lib/Thelia/Core/Event/CustomerEvent.php index 46c9278cb..656f023c9 100755 --- a/core/lib/Thelia/Core/Event/Internal/CustomerEvent.php +++ b/core/lib/Thelia/Core/Event/CustomerEvent.php @@ -21,11 +21,12 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event\Internal; +namespace Thelia\Core\Event; use Thelia\Model\Customer; +use Thelia\Core\Event\ActionEvent; -class CustomerEvent extends InternalEvent +class CustomerEvent extends ActionEvent { public $customer; diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 81fc34097..2dd85905d 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -94,11 +94,29 @@ final class TheliaEvents */ const AFTER_CHANGECUSTOMER = "action.after_changecustomer"; + /** * Sent once the category creation form has been successfully validated, and before category insertion in the database. */ const BEFORE_CREATECATEGORY = "action.before_createcategory"; + /** + * Create, change or delete a category + */ + const CATEGORY_CREATE = "action.createCategory"; + const CATEGORY_MODIFY = "action.modifyCategory"; + const CATEGORY_DELETE = "action.deleteCategory"; + + /** + * Toggle category visibility + */ + const CATEGORY_TOGGLE_VISIBILITY = "action.toggleCategoryVisibility"; + + /** + * Change category position + */ + const CATEGORY_CHANGE_POSITION = "action.changeCategoryPosition"; + /** * Sent just after a successful insert of a new category in the database. */ @@ -113,6 +131,11 @@ final class TheliaEvents */ const AFTER_DELETECATEGORY = "action.after_deletecategory"; + /** + * Sent just before a successful change of a category in the database. + */ + const BEFORE_CHANGECATEGORY = "action.before_changecategory"; + /** * Sent just after a successful change of a category in the database. */ @@ -154,5 +177,4 @@ final class TheliaEvents * Sent on cimage cache clear request */ const IMAGE_CLEAR_CACHE = "action.clearImageCache"; - } diff --git a/core/lib/Thelia/Core/Security/SecurityContext.php b/core/lib/Thelia/Core/Security/SecurityContext.php index 9df25de9e..c09945f61 100755 --- a/core/lib/Thelia/Core/Security/SecurityContext.php +++ b/core/lib/Thelia/Core/Security/SecurityContext.php @@ -33,36 +33,11 @@ use Thelia\Core\HttpFoundation\Request; */ class SecurityContext { - const CONTEXT_FRONT_OFFICE = 'front'; - const CONTEXT_BACK_OFFICE = 'admin'; - private $request; - private $context; public function __construct(Request $request) { $this->request = $request; - - $this->context = null; - } - - public function setContext($context) - { - if ($context !== self::CONTEXT_FRONT_OFFICE && $context !== self::CONTEXT_BACK_OFFICE) { - throw new \InvalidArgumentException(sprintf("Invalid or empty context identifier '%s'", $context)); - } - - $this->context = $context; - - return $this; - } - - public function getContext($exception_if_context_undefined = false) - { - if (null === $this->context && $exception_if_context_undefined === true) - throw new \LogicException("No context defined. Please use setContext() first."); - - return $this->context; } private function getSession() @@ -76,28 +51,47 @@ class SecurityContext } /** - * Gets the currently authenticated user in the current context, or null if none is defined + * Gets the currently authenticated user in the admin, or null if none is defined * * @return UserInterface|null A UserInterface instance or null if no user is available */ - public function getUser() + public function getAdminUser() { - $context = $this->getContext(true); - - if ($context === self::CONTEXT_FRONT_OFFICE) - $user = $this->getSession()->getCustomerUser(); - else if ($context == self::CONTEXT_BACK_OFFICE) - $user = $this->getSession()->getAdminUser(); - else - $user = null; - - return $user; + return $this->getSession()->getAdminUser(); } - final public function isAuthenticated() + /** + * Gets the currently authenticated customer, or null if none is defined + * + * @return UserInterface|null A UserInterface instance or null if no user is available + */ + public function getCustomerUser() { - if (null !== $this->getUser()) { - return true; + return $this->getSession()->getCustomerUser(); + } + + /** + * Check if a user has at least one of the required roles + * + * @param UserInterface $user the user + * @param array $roles the roles + * @return boolean true if the user has the required role, false otherwise + */ + final public function hasRequiredRole($user, array $roles) { + + if ($user != null) { + // Check if user's roles matches required roles + $userRoles = $user->getRoles(); + + $roleFound = false; + + foreach ($userRoles as $role) { + if (in_array($role, $roles)) { + $roleFound = true; + + return true; + } + } } return false; @@ -110,85 +104,88 @@ class SecurityContext */ final public function isGranted(array $roles, array $permissions) { - if ($this->isAuthenticated() === true) { + // Find a user which matches the required roles. + $user = $this->getCustomerUser(); - $user = $this->getUser(); + if (! $this->hasRequiredRole($user, $roles)) { + $user = $this->getAdminUser(); - // Check if user's roles matches required roles - $userRoles = $user->getRoles(); + if (! $this->hasRequiredRole($user, $roles)) { + $user = null; + } + } - $roleFound = false; + if ($user != null) { - foreach ($userRoles as $role) { - if (in_array($role, $roles)) { - $roleFound = true; - - break; - } + if (empty($permissions)) { + return true; } - if ($roleFound) { + // Get permissions from profile + // $userPermissions = $user->getPermissions(); FIXME - if (empty($permissions)) { - return true; - } + // TODO: Finalize permissions system !; - // Get permissions from profile - // $userPermissions = $user->getPermissions(); FIXME + $userPermissions = array('*'); // FIXME ! - // TODO: Finalize permissions system !; + $permissionsFound = true; - $userPermissions = array('*'); // FIXME ! + // User have all permissions ? + if (in_array('*', $userPermissions)) + return true; - $permissionsFound = true; + // Check that user's permissions matches required permissions + foreach ($permissions as $permission) { + if (! in_array($permission, $userPermissions)) { + $permissionsFound = false; - // User have all permissions ? - if (in_array('*', $userPermissions)) - return true; - - // Check that user's permissions matches required permissions - foreach ($permissions as $permission) { - if (! in_array($permission, $userPermissions)) { - $permissionsFound = false; - - break; - } - } - - return $permissionsFound; + break; + } } + + return $permissionsFound; } return false; } /** - * Sets the authenticated user. + * Sets the authenticated admin user. * * @param UserInterface $user A UserInterface, or null if no further user should be stored */ - public function setUser(UserInterface $user) + public function setAdminUser(UserInterface $user) { - $context = $this->getContext(true); - $user->eraseCredentials(); - if ($context === self::CONTEXT_FRONT_OFFICE) - $this->getSession()->setCustomerUser($user); - else if ($context == self::CONTEXT_BACK_OFFICE) - $this->getSession()->setAdminUser($user); + $this->getSession()->setAdminUser($user); } /** - * Clear the user from the security context + * Sets the authenticated customer user. + * + * @param UserInterface $user A UserInterface, or null if no further user should be stored */ - public function clear() + public function setCustomerUser(UserInterface $user) { - $context = $this->getContext(true); + $user->eraseCredentials(); - if ($context === self::CONTEXT_FRONT_OFFICE) - $this->getSession()->clearCustomerUser(); - else if ($context == self::CONTEXT_BACK_OFFICE) - $this->getSession()->clearAdminUser(); + $this->getSession()->setCustomerUser($user); } -} + + /** + * Clear the customer from the security context + */ + public function clearCustomerUser() + { + $this->getSession()->clearCustomerUser(); + } + + /** + * Clear the admin from the security context + */ + public function clearAdminUser() + { + $this->getSession()->clearAdminUser(); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Loop/Auth.php b/core/lib/Thelia/Core/Template/Loop/Auth.php index b645a0f95..ff9f3cfd3 100755 --- a/core/lib/Thelia/Core/Template/Loop/Auth.php +++ b/core/lib/Thelia/Core/Template/Loop/Auth.php @@ -68,15 +68,12 @@ class Auth extends BaseLoop */ public function exec(&$pagination) { - $context = $this->getContext(); $roles = $this->_explode($this->getRoles()); $permissions = $this->_explode($this->getPermissions()); $loopResult = new LoopResult(); try { - $this->securityContext->setContext($context); - if (true === $this->securityContext->isGranted($roles, $permissions == null ? array() : $permissions)) { // Create an empty row: loop is no longer empty :) diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php index d9f08bbdf..ee65f34b3 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php @@ -52,7 +52,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin */ public function adminDataAccess($params, &$smarty) { - return $this->userDataAccess("Admin User", SecurityContext::CONTEXT_BACK_OFFICE, $params); + return $this->userDataAccess("Admin User", $this->securityContext->getAdminUser(), $params); } /** @@ -64,7 +64,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin */ public function customerDataAccess($params, &$smarty) { - return $this->userDataAccess("Customer User", SecurityContext::CONTEXT_FRONT_OFFICE, $params); + return $this->userDataAccess("Customer User", $this->securityContext->getCustomerUser(), $params); } /** @@ -75,12 +75,11 @@ class DataAccessFunctions extends AbstractSmartyPlugin * @return string the value of the requested attribute * @throws InvalidArgumentException if the object does not have the requested attribute. */ - protected function userDataAccess($objectLabel, $context, $params) + protected function userDataAccess($objectLabel, $user, $params) { $attribute = $this->getNormalizedParam($params, array('attribute', 'attrib', 'attr')); if (! empty($attribute)) { - $user = $this->securityContext->setContext($context)->getUser(); if (null != $user) { $getter = sprintf("get%s", ucfirst($attribute)); diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php index eb19d97f5..24d2c29ee 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php @@ -46,11 +46,6 @@ class Security extends AbstractSmartyPlugin */ public function checkAuthFunction($params, &$smarty) { - // Context: 'front' or 'admin' - $context = $this->getNormalizedParam($params, 'context'); - - $this->securityContext->setContext($context); - $roles = $this->_explode($this->getParam($params, 'roles')); $permissions = $this->_explode($this->getParam($params, 'permissions')); diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php index 39408763e..fbfbee32c 100755 --- a/core/lib/Thelia/Model/CartItem.php +++ b/core/lib/Thelia/Model/CartItem.php @@ -4,10 +4,10 @@ namespace Thelia\Model; use Propel\Runtime\Connection\ConnectionInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Thelia\Core\Event\Internal\CartEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\CartItem as BaseCartItem; use Thelia\Model\ConfigQuery; +use Thelia\Core\Event\CartEvent; class CartItem extends BaseCartItem { diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index a6a4927b2..d7418a4ea 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -3,7 +3,6 @@ namespace Thelia\Model; use Symfony\Component\Config\Definition\Exception\Exception; -use Thelia\Core\Event\Internal\CustomerEvent; use Thelia\Model\Base\Customer as BaseCustomer; use Thelia\Model\Exception\InvalidArgumentException; @@ -17,6 +16,7 @@ use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Propel; use Thelia\Model\Map\CustomerTableMap; use Thelia\Core\Security\Role\Role; +use Thelia\Core\Event\CustomerEvent; /** * Skeleton subclass for representing a row from the 'customer' table. From 84a23141087eefcf8ad5985a5c3d2f119370053a Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 28 Aug 2013 18:06:22 +0200 Subject: [PATCH 050/268] WIP - Add Coupon BackOffice controller - Add Coupon BackOffice template skeleton - Add Coupon BackOffice routes --- .../Thelia/Config/Resources/routing/admin.xml | 11 +- .../Controller/Admin/CouponController.php | 202 ++++++++++++------ templates/admin/default/coupon/edit.html | 30 +++ templates/admin/default/coupon/list.html | 29 +++ templates/admin/default/coupon/read.html | 29 +++ .../default/includes/coupon_breadcrumb.html | 8 + templates/default/coupon.html | 5 - 7 files changed, 246 insertions(+), 68 deletions(-) create mode 100755 templates/admin/default/coupon/edit.html create mode 100755 templates/admin/default/coupon/list.html create mode 100755 templates/admin/default/coupon/read.html create mode 100755 templates/admin/default/includes/coupon_breadcrumb.html delete mode 100755 templates/default/coupon.html diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index df1495953..2561dcc99 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -36,9 +36,18 @@ - + Thelia\Controller\Admin\CouponController::indexAction + + Thelia\Controller\Admin\CouponController::createAction + + + Thelia\Controller\Admin\CouponController::editAction + + + Thelia\Controller\Admin\CouponController::readAction + diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index 67d1e451e..e6159c9ac 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -1,92 +1,170 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* 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 . */ +/* */ +/**********************************************************************************/ namespace Thelia\Controller\Admin; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\AuthorizationException; +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Control View and Action (Model) via Events + * + * @package Coupon + * @author Guillaume MOREL + * + */ class CouponController extends BaseAdminController { - - protected function browseCoupon($args) - { - $this->checkAuth("ADMIN", "admin.coupon.view"); - - return $this->render('coupons', $args); - } - + /** + * List all Coupons Action + * + * @return \Symfony\Component\HttpFoundation\Response + */ public function indexAction() { return $this->processAction(); } - public function processAction() + /** + * Create a Coupon Action + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function createAction() + { + return $this->processAction('create'); + } + + /** + * Edit a Coupon Action + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function editAction() + { + return $this->processAction('edit'); + } + + /** + * Read a Coupon Action + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function readAction() + { + return $this->processAction('read'); + } + + /** + * Manage Coupons list display + * + * @param array $args GET arguments + * + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function browseCoupons($args) + { + $this->checkAuth("ADMIN", "admin.coupon.view"); + + return $this->render('coupon/list', $args); + } + + /** + * Manage Coupons creation display + * + * @param array $args GET arguments + * + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function createCoupon($args) + { + $this->checkAuth("ADMIN", "admin.coupon.view"); + + return $this->render('coupon/edit', $args); + } + + /** + * Manage Coupons edition display + * + * @param array $args GET arguments + * + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function editCoupon($args) + { + $this->checkAuth("ADMIN", "admin.coupon.view"); + + return $this->render('coupon/edit', $args); + } + + /** + * Manage Coupons read display + * + * @param array $args GET arguments + * + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function readCoupon($args) + { + $this->checkAuth("ADMIN", "admin.coupon.view"); + + return $this->render('coupon/read', $args); + } + + /** + * Process all Actions + * + * @param string $action Action to process + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function processAction($action = 'browse') { // Get the current action - $action = $this->getRequest()->get('action', 'browse'); +// $action = $this->getRequest()->get('action', 'browse'); // Get the category ID - $id = $this->getRequest()->get('id', 0); +// $id = $this->getRequest()->get('id', 0); $args = array( 'action' => $action, - 'current_coupon_id' => $id +// 'current_coupon_id' => $id ); try { switch ($action) { case 'browse' : // Browse coupon - return $this->browseCoupons($args); - - case 'create' : // Create a new category - -// return $this->createNewCategory($args); - - case 'edit' : // Edit an existing category - -// return $this->editCategory($args); - - case 'delete' : // Delete an existing category - -// return $this->deleteCategory($args); - - case 'visibilityToggle' : // Toggle visibility - -// return $this->visibilityToggle($id); - - case 'changePosition' : // Change position - -// return $this->changePosition($args); - - case 'positionUp' : // Move up category - -// return $this->positionUp($args); - - case 'positionDown' : // Move down category - -// return $this->positionDown($args); + case 'create' : // Create a new coupon + return $this->createCoupon($args); + case 'edit' : // Edit an existing coupon + return $this->editCoupon($args); + case 'read' : // Read an existing coupon + return $this->readCoupon($args); } } catch (AuthorizationException $ex) { return $this->errorPage($ex->getMessage()); diff --git a/templates/admin/default/coupon/edit.html b/templates/admin/default/coupon/edit.html new file mode 100755 index 000000000..017414ec4 --- /dev/null +++ b/templates/admin/default/coupon/edit.html @@ -0,0 +1,30 @@ +{check_auth context="admin" roles="ADMIN" permissions="admin.coupon.view" login_tpl="/admin/login"} + +{$page_title={intl l='Coupon'}} + +{$thelia_page_css_file = "assets/bootstrap-editable/css/bootstrap-editable.css"} + +{include file='includes/header.inc.html'} + +
      +
      + + + +

      EDIT

      +
      +
      + + +{include file='includes/js.inc.html'} + +{javascripts file='../assets/bootstrap-editable/js/bootstrap-editable.js'} + +{/javascripts} + + + +{include file='includes/footer.inc.html'} diff --git a/templates/admin/default/coupon/list.html b/templates/admin/default/coupon/list.html new file mode 100755 index 000000000..95b2da098 --- /dev/null +++ b/templates/admin/default/coupon/list.html @@ -0,0 +1,29 @@ +{check_auth context="admin" roles="ADMIN" permissions="admin.coupon.view" login_tpl="/admin/login"} + +{$page_title={intl l='Coupon'}} + +{$thelia_page_css_file = "assets/bootstrap-editable/css/bootstrap-editable.css"} + +{include file='includes/header.inc.html'} + +
      +
      + + +

      List

      +
      +
      + + +{include file='includes/js.inc.html'} + +{javascripts file='../assets/bootstrap-editable/js/bootstrap-editable.js'} + +{/javascripts} + + + +{include file='includes/footer.inc.html'} diff --git a/templates/admin/default/coupon/read.html b/templates/admin/default/coupon/read.html new file mode 100755 index 000000000..d29c7d927 --- /dev/null +++ b/templates/admin/default/coupon/read.html @@ -0,0 +1,29 @@ +{check_auth context="admin" roles="ADMIN" permissions="admin.coupon.view" login_tpl="/admin/login"} + +{$page_title={intl l='Coupon'}} + +{$thelia_page_css_file = "assets/bootstrap-editable/css/bootstrap-editable.css"} + +{include file='includes/header.inc.html'} + +
      +
      + + +

      Read

      +
      +
      + + +{include file='includes/js.inc.html'} + +{javascripts file='../assets/bootstrap-editable/js/bootstrap-editable.js'} + +{/javascripts} + + + +{include file='includes/footer.inc.html'} diff --git a/templates/admin/default/includes/coupon_breadcrumb.html b/templates/admin/default/includes/coupon_breadcrumb.html new file mode 100755 index 000000000..bcec6d0d3 --- /dev/null +++ b/templates/admin/default/includes/coupon_breadcrumb.html @@ -0,0 +1,8 @@ +{* Breadcrumb for coupon browsing and editing *} + +
    • Home /
    • +
    • Coupon
    • + +
    • /
    • +
    • Browse /
    • + diff --git a/templates/default/coupon.html b/templates/default/coupon.html deleted file mode 100755 index 3fd478575..000000000 --- a/templates/default/coupon.html +++ /dev/null @@ -1,5 +0,0 @@ -

      Coupon page

      - -
      - -

      COUPON

      From 6c2dbb0152cb8e9e8abfd8b2203c10a1d60c706a Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 28 Aug 2013 18:09:17 +0200 Subject: [PATCH 051/268] Working - Add regenerated Model classes --- core/lib/Thelia/Model/Base/Accessory.php | 2 +- core/lib/Thelia/Model/Base/Address.php | 2 +- core/lib/Thelia/Model/Base/Admin.php | 2 +- core/lib/Thelia/Model/Base/AdminGroup.php | 2 +- core/lib/Thelia/Model/Base/AdminLog.php | 2 +- core/lib/Thelia/Model/Base/Area.php | 2 +- core/lib/Thelia/Model/Base/Attribute.php | 2 +- core/lib/Thelia/Model/Base/AttributeAv.php | 2 +- core/lib/Thelia/Model/Base/AttributeAvI18n.php | 2 +- core/lib/Thelia/Model/Base/AttributeCategory.php | 2 +- core/lib/Thelia/Model/Base/AttributeCombination.php | 2 +- core/lib/Thelia/Model/Base/AttributeI18n.php | 2 +- core/lib/Thelia/Model/Base/Cart.php | 2 +- core/lib/Thelia/Model/Base/CartItem.php | 2 +- core/lib/Thelia/Model/Base/Category.php | 2 +- core/lib/Thelia/Model/Base/CategoryAssociatedContent.php | 2 +- core/lib/Thelia/Model/Base/CategoryDocument.php | 2 +- core/lib/Thelia/Model/Base/CategoryDocumentI18n.php | 2 +- core/lib/Thelia/Model/Base/CategoryI18n.php | 2 +- core/lib/Thelia/Model/Base/CategoryImage.php | 2 +- core/lib/Thelia/Model/Base/CategoryImageI18n.php | 2 +- core/lib/Thelia/Model/Base/CategoryVersion.php | 2 +- core/lib/Thelia/Model/Base/Config.php | 2 +- core/lib/Thelia/Model/Base/ConfigI18n.php | 2 +- core/lib/Thelia/Model/Base/Content.php | 2 +- core/lib/Thelia/Model/Base/ContentDocument.php | 2 +- core/lib/Thelia/Model/Base/ContentDocumentI18n.php | 2 +- core/lib/Thelia/Model/Base/ContentFolder.php | 2 +- core/lib/Thelia/Model/Base/ContentI18n.php | 2 +- core/lib/Thelia/Model/Base/ContentImage.php | 2 +- core/lib/Thelia/Model/Base/ContentImageI18n.php | 2 +- core/lib/Thelia/Model/Base/ContentVersion.php | 2 +- core/lib/Thelia/Model/Base/Country.php | 2 +- core/lib/Thelia/Model/Base/CountryI18n.php | 2 +- core/lib/Thelia/Model/Base/CouponOrder.php | 2 +- core/lib/Thelia/Model/Base/Currency.php | 2 +- core/lib/Thelia/Model/Base/CurrencyI18n.php | 2 +- core/lib/Thelia/Model/Base/Customer.php | 2 +- core/lib/Thelia/Model/Base/CustomerTitle.php | 2 +- core/lib/Thelia/Model/Base/CustomerTitleI18n.php | 2 +- core/lib/Thelia/Model/Base/Delivzone.php | 2 +- core/lib/Thelia/Model/Base/Feature.php | 2 +- core/lib/Thelia/Model/Base/FeatureAv.php | 2 +- core/lib/Thelia/Model/Base/FeatureAvI18n.php | 2 +- core/lib/Thelia/Model/Base/FeatureCategory.php | 2 +- core/lib/Thelia/Model/Base/FeatureI18n.php | 2 +- core/lib/Thelia/Model/Base/FeatureProduct.php | 2 +- core/lib/Thelia/Model/Base/Folder.php | 2 +- core/lib/Thelia/Model/Base/FolderDocument.php | 2 +- core/lib/Thelia/Model/Base/FolderDocumentI18n.php | 2 +- core/lib/Thelia/Model/Base/FolderI18n.php | 2 +- core/lib/Thelia/Model/Base/FolderImage.php | 2 +- core/lib/Thelia/Model/Base/FolderImageI18n.php | 2 +- core/lib/Thelia/Model/Base/FolderVersion.php | 2 +- core/lib/Thelia/Model/Base/Group.php | 2 +- core/lib/Thelia/Model/Base/GroupI18n.php | 2 +- core/lib/Thelia/Model/Base/GroupModule.php | 2 +- core/lib/Thelia/Model/Base/GroupResource.php | 2 +- core/lib/Thelia/Model/Base/Lang.php | 2 +- core/lib/Thelia/Model/Base/Message.php | 2 +- core/lib/Thelia/Model/Base/MessageI18n.php | 2 +- core/lib/Thelia/Model/Base/MessageVersion.php | 2 +- core/lib/Thelia/Model/Base/Module.php | 2 +- core/lib/Thelia/Model/Base/ModuleI18n.php | 2 +- core/lib/Thelia/Model/Base/Order.php | 2 +- core/lib/Thelia/Model/Base/OrderAddress.php | 2 +- core/lib/Thelia/Model/Base/OrderFeature.php | 2 +- core/lib/Thelia/Model/Base/OrderProduct.php | 2 +- core/lib/Thelia/Model/Base/OrderStatus.php | 2 +- core/lib/Thelia/Model/Base/OrderStatusI18n.php | 2 +- core/lib/Thelia/Model/Base/Product.php | 2 +- core/lib/Thelia/Model/Base/ProductCategory.php | 2 +- core/lib/Thelia/Model/Base/ProductDocument.php | 2 +- core/lib/Thelia/Model/Base/ProductDocumentI18n.php | 2 +- core/lib/Thelia/Model/Base/ProductI18n.php | 2 +- core/lib/Thelia/Model/Base/ProductImage.php | 2 +- core/lib/Thelia/Model/Base/ProductImageI18n.php | 2 +- core/lib/Thelia/Model/Base/ProductPrice.php | 2 +- core/lib/Thelia/Model/Base/ProductSaleElements.php | 2 +- core/lib/Thelia/Model/Base/ProductVersion.php | 2 +- core/lib/Thelia/Model/Base/Resource.php | 2 +- core/lib/Thelia/Model/Base/ResourceI18n.php | 2 +- core/lib/Thelia/Model/Base/Rewriting.php | 2 +- core/lib/Thelia/Model/Base/Tax.php | 2 +- core/lib/Thelia/Model/Base/TaxI18n.php | 2 +- core/lib/Thelia/Model/Base/TaxRule.php | 2 +- core/lib/Thelia/Model/Base/TaxRuleCountry.php | 2 +- core/lib/Thelia/Model/Base/TaxRuleI18n.php | 2 +- 88 files changed, 88 insertions(+), 88 deletions(-) diff --git a/core/lib/Thelia/Model/Base/Accessory.php b/core/lib/Thelia/Model/Base/Accessory.php index 183f59947..f4110b19e 100755 --- a/core/lib/Thelia/Model/Base/Accessory.php +++ b/core/lib/Thelia/Model/Base/Accessory.php @@ -266,7 +266,7 @@ abstract class Accessory implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Address.php b/core/lib/Thelia/Model/Base/Address.php index a6ab068d1..45cad61aa 100755 --- a/core/lib/Thelia/Model/Base/Address.php +++ b/core/lib/Thelia/Model/Base/Address.php @@ -388,7 +388,7 @@ abstract class Address implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Admin.php b/core/lib/Thelia/Model/Base/Admin.php index 6110aee7a..b1241473e 100755 --- a/core/lib/Thelia/Model/Base/Admin.php +++ b/core/lib/Thelia/Model/Base/Admin.php @@ -300,7 +300,7 @@ abstract class Admin implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/AdminGroup.php b/core/lib/Thelia/Model/Base/AdminGroup.php index 9eadbb107..60141e3f8 100755 --- a/core/lib/Thelia/Model/Base/AdminGroup.php +++ b/core/lib/Thelia/Model/Base/AdminGroup.php @@ -262,7 +262,7 @@ abstract class AdminGroup implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/AdminLog.php b/core/lib/Thelia/Model/Base/AdminLog.php index ae828e4bb..c83be20ee 100755 --- a/core/lib/Thelia/Model/Base/AdminLog.php +++ b/core/lib/Thelia/Model/Base/AdminLog.php @@ -266,7 +266,7 @@ abstract class AdminLog implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Area.php b/core/lib/Thelia/Model/Base/Area.php index 08fc8be42..fbd3199f4 100755 --- a/core/lib/Thelia/Model/Base/Area.php +++ b/core/lib/Thelia/Model/Base/Area.php @@ -277,7 +277,7 @@ abstract class Area implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Attribute.php b/core/lib/Thelia/Model/Base/Attribute.php index 21fb3389a..2f04404d4 100755 --- a/core/lib/Thelia/Model/Base/Attribute.php +++ b/core/lib/Thelia/Model/Base/Attribute.php @@ -326,7 +326,7 @@ abstract class Attribute implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/AttributeAv.php b/core/lib/Thelia/Model/Base/AttributeAv.php index 817c9738d..ab39577bd 100755 --- a/core/lib/Thelia/Model/Base/AttributeAv.php +++ b/core/lib/Thelia/Model/Base/AttributeAv.php @@ -298,7 +298,7 @@ abstract class AttributeAv implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/AttributeAvI18n.php b/core/lib/Thelia/Model/Base/AttributeAvI18n.php index 8b2b14a32..bcd1c7453 100755 --- a/core/lib/Thelia/Model/Base/AttributeAvI18n.php +++ b/core/lib/Thelia/Model/Base/AttributeAvI18n.php @@ -272,7 +272,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/AttributeCategory.php b/core/lib/Thelia/Model/Base/AttributeCategory.php index da702559a..691fa43ad 100755 --- a/core/lib/Thelia/Model/Base/AttributeCategory.php +++ b/core/lib/Thelia/Model/Base/AttributeCategory.php @@ -262,7 +262,7 @@ abstract class AttributeCategory implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/AttributeCombination.php b/core/lib/Thelia/Model/Base/AttributeCombination.php index ef840a5a1..ea2ade03c 100755 --- a/core/lib/Thelia/Model/Base/AttributeCombination.php +++ b/core/lib/Thelia/Model/Base/AttributeCombination.php @@ -269,7 +269,7 @@ abstract class AttributeCombination implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/AttributeI18n.php b/core/lib/Thelia/Model/Base/AttributeI18n.php index 8a0456192..b8865769c 100755 --- a/core/lib/Thelia/Model/Base/AttributeI18n.php +++ b/core/lib/Thelia/Model/Base/AttributeI18n.php @@ -272,7 +272,7 @@ abstract class AttributeI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Cart.php b/core/lib/Thelia/Model/Base/Cart.php index 20a2d9a5c..910bdf0e0 100755 --- a/core/lib/Thelia/Model/Base/Cart.php +++ b/core/lib/Thelia/Model/Base/Cart.php @@ -307,7 +307,7 @@ abstract class Cart implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/CartItem.php b/core/lib/Thelia/Model/Base/CartItem.php index 827a4c5ec..3c5711022 100755 --- a/core/lib/Thelia/Model/Base/CartItem.php +++ b/core/lib/Thelia/Model/Base/CartItem.php @@ -313,7 +313,7 @@ abstract class CartItem implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php index 1bafdae8c..810283e44 100755 --- a/core/lib/Thelia/Model/Base/Category.php +++ b/core/lib/Thelia/Model/Base/Category.php @@ -475,7 +475,7 @@ abstract class Category implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php b/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php index 142ab543f..a731ec971 100644 --- a/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php +++ b/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php @@ -268,7 +268,7 @@ abstract class CategoryAssociatedContent implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/CategoryDocument.php b/core/lib/Thelia/Model/Base/CategoryDocument.php index a5493815d..7225ac46f 100755 --- a/core/lib/Thelia/Model/Base/CategoryDocument.php +++ b/core/lib/Thelia/Model/Base/CategoryDocument.php @@ -290,7 +290,7 @@ abstract class CategoryDocument implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php b/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php index 2d5f76fcf..f361b3184 100755 --- a/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php @@ -272,7 +272,7 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/CategoryI18n.php b/core/lib/Thelia/Model/Base/CategoryI18n.php index 3e3d36521..65fa17063 100755 --- a/core/lib/Thelia/Model/Base/CategoryI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryI18n.php @@ -272,7 +272,7 @@ abstract class CategoryI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/CategoryImage.php b/core/lib/Thelia/Model/Base/CategoryImage.php index 6fd905453..17c2007f9 100755 --- a/core/lib/Thelia/Model/Base/CategoryImage.php +++ b/core/lib/Thelia/Model/Base/CategoryImage.php @@ -290,7 +290,7 @@ abstract class CategoryImage implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/CategoryImageI18n.php b/core/lib/Thelia/Model/Base/CategoryImageI18n.php index 0c65b8036..e59c4caca 100755 --- a/core/lib/Thelia/Model/Base/CategoryImageI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryImageI18n.php @@ -272,7 +272,7 @@ abstract class CategoryImageI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/CategoryVersion.php b/core/lib/Thelia/Model/Base/CategoryVersion.php index 416ad95d5..d8dfe76e0 100755 --- a/core/lib/Thelia/Model/Base/CategoryVersion.php +++ b/core/lib/Thelia/Model/Base/CategoryVersion.php @@ -292,7 +292,7 @@ abstract class CategoryVersion implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Config.php b/core/lib/Thelia/Model/Base/Config.php index b4d909de4..140cdb82d 100755 --- a/core/lib/Thelia/Model/Base/Config.php +++ b/core/lib/Thelia/Model/Base/Config.php @@ -305,7 +305,7 @@ abstract class Config implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ConfigI18n.php b/core/lib/Thelia/Model/Base/ConfigI18n.php index 57c72ace8..e73e27514 100755 --- a/core/lib/Thelia/Model/Base/ConfigI18n.php +++ b/core/lib/Thelia/Model/Base/ConfigI18n.php @@ -272,7 +272,7 @@ abstract class ConfigI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Content.php b/core/lib/Thelia/Model/Base/Content.php index bd4d29046..e46d82ac4 100755 --- a/core/lib/Thelia/Model/Base/Content.php +++ b/core/lib/Thelia/Model/Base/Content.php @@ -429,7 +429,7 @@ abstract class Content implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ContentDocument.php b/core/lib/Thelia/Model/Base/ContentDocument.php index 01f631208..7c974c839 100755 --- a/core/lib/Thelia/Model/Base/ContentDocument.php +++ b/core/lib/Thelia/Model/Base/ContentDocument.php @@ -290,7 +290,7 @@ abstract class ContentDocument implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ContentDocumentI18n.php b/core/lib/Thelia/Model/Base/ContentDocumentI18n.php index f11cd8a08..e275926c5 100755 --- a/core/lib/Thelia/Model/Base/ContentDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/ContentDocumentI18n.php @@ -272,7 +272,7 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ContentFolder.php b/core/lib/Thelia/Model/Base/ContentFolder.php index 51d72b974..52f5fa88a 100755 --- a/core/lib/Thelia/Model/Base/ContentFolder.php +++ b/core/lib/Thelia/Model/Base/ContentFolder.php @@ -256,7 +256,7 @@ abstract class ContentFolder implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ContentI18n.php b/core/lib/Thelia/Model/Base/ContentI18n.php index 244862800..14ff02b39 100755 --- a/core/lib/Thelia/Model/Base/ContentI18n.php +++ b/core/lib/Thelia/Model/Base/ContentI18n.php @@ -272,7 +272,7 @@ abstract class ContentI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ContentImage.php b/core/lib/Thelia/Model/Base/ContentImage.php index 33e1eca09..884c20c1e 100755 --- a/core/lib/Thelia/Model/Base/ContentImage.php +++ b/core/lib/Thelia/Model/Base/ContentImage.php @@ -290,7 +290,7 @@ abstract class ContentImage implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ContentImageI18n.php b/core/lib/Thelia/Model/Base/ContentImageI18n.php index cba4fba17..9fe9b4147 100755 --- a/core/lib/Thelia/Model/Base/ContentImageI18n.php +++ b/core/lib/Thelia/Model/Base/ContentImageI18n.php @@ -272,7 +272,7 @@ abstract class ContentImageI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ContentVersion.php b/core/lib/Thelia/Model/Base/ContentVersion.php index ef2897030..ca9189608 100755 --- a/core/lib/Thelia/Model/Base/ContentVersion.php +++ b/core/lib/Thelia/Model/Base/ContentVersion.php @@ -286,7 +286,7 @@ abstract class ContentVersion implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Country.php b/core/lib/Thelia/Model/Base/Country.php index 3794bff3c..3c4247896 100755 --- a/core/lib/Thelia/Model/Base/Country.php +++ b/core/lib/Thelia/Model/Base/Country.php @@ -324,7 +324,7 @@ abstract class Country implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/CountryI18n.php b/core/lib/Thelia/Model/Base/CountryI18n.php index fbba979a1..270a9d3f7 100755 --- a/core/lib/Thelia/Model/Base/CountryI18n.php +++ b/core/lib/Thelia/Model/Base/CountryI18n.php @@ -272,7 +272,7 @@ abstract class CountryI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/CouponOrder.php b/core/lib/Thelia/Model/Base/CouponOrder.php index a183f262e..7d3c413b6 100755 --- a/core/lib/Thelia/Model/Base/CouponOrder.php +++ b/core/lib/Thelia/Model/Base/CouponOrder.php @@ -268,7 +268,7 @@ abstract class CouponOrder implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Currency.php b/core/lib/Thelia/Model/Base/Currency.php index f99288679..a5ada0790 100755 --- a/core/lib/Thelia/Model/Base/Currency.php +++ b/core/lib/Thelia/Model/Base/Currency.php @@ -337,7 +337,7 @@ abstract class Currency implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/CurrencyI18n.php b/core/lib/Thelia/Model/Base/CurrencyI18n.php index 931c3acbf..52cd7fc5b 100755 --- a/core/lib/Thelia/Model/Base/CurrencyI18n.php +++ b/core/lib/Thelia/Model/Base/CurrencyI18n.php @@ -254,7 +254,7 @@ abstract class CurrencyI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Customer.php b/core/lib/Thelia/Model/Base/Customer.php index 3d87f3e28..c3315ac6f 100755 --- a/core/lib/Thelia/Model/Base/Customer.php +++ b/core/lib/Thelia/Model/Base/Customer.php @@ -352,7 +352,7 @@ abstract class Customer implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/CustomerTitle.php b/core/lib/Thelia/Model/Base/CustomerTitle.php index dcf271206..7f4c30d09 100755 --- a/core/lib/Thelia/Model/Base/CustomerTitle.php +++ b/core/lib/Thelia/Model/Base/CustomerTitle.php @@ -319,7 +319,7 @@ abstract class CustomerTitle implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/CustomerTitleI18n.php b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php index 4ea186061..38e47ecda 100755 --- a/core/lib/Thelia/Model/Base/CustomerTitleI18n.php +++ b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php @@ -260,7 +260,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Delivzone.php b/core/lib/Thelia/Model/Base/Delivzone.php index deb21997e..08125044e 100755 --- a/core/lib/Thelia/Model/Base/Delivzone.php +++ b/core/lib/Thelia/Model/Base/Delivzone.php @@ -255,7 +255,7 @@ abstract class Delivzone implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Feature.php b/core/lib/Thelia/Model/Base/Feature.php index 070bac50b..826de003f 100755 --- a/core/lib/Thelia/Model/Base/Feature.php +++ b/core/lib/Thelia/Model/Base/Feature.php @@ -346,7 +346,7 @@ abstract class Feature implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/FeatureAv.php b/core/lib/Thelia/Model/Base/FeatureAv.php index 14e6cd35c..818f352a0 100755 --- a/core/lib/Thelia/Model/Base/FeatureAv.php +++ b/core/lib/Thelia/Model/Base/FeatureAv.php @@ -298,7 +298,7 @@ abstract class FeatureAv implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/FeatureAvI18n.php b/core/lib/Thelia/Model/Base/FeatureAvI18n.php index a508d6075..aa524c430 100755 --- a/core/lib/Thelia/Model/Base/FeatureAvI18n.php +++ b/core/lib/Thelia/Model/Base/FeatureAvI18n.php @@ -272,7 +272,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/FeatureCategory.php b/core/lib/Thelia/Model/Base/FeatureCategory.php index 035e077d2..f3ce14349 100755 --- a/core/lib/Thelia/Model/Base/FeatureCategory.php +++ b/core/lib/Thelia/Model/Base/FeatureCategory.php @@ -262,7 +262,7 @@ abstract class FeatureCategory implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/FeatureI18n.php b/core/lib/Thelia/Model/Base/FeatureI18n.php index 06964ee19..b6070932e 100755 --- a/core/lib/Thelia/Model/Base/FeatureI18n.php +++ b/core/lib/Thelia/Model/Base/FeatureI18n.php @@ -272,7 +272,7 @@ abstract class FeatureI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/FeatureProduct.php b/core/lib/Thelia/Model/Base/FeatureProduct.php index 4af200d51..b68f4acd2 100755 --- a/core/lib/Thelia/Model/Base/FeatureProduct.php +++ b/core/lib/Thelia/Model/Base/FeatureProduct.php @@ -287,7 +287,7 @@ abstract class FeatureProduct implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Folder.php b/core/lib/Thelia/Model/Base/Folder.php index 8899ae6be..1b0c80d94 100755 --- a/core/lib/Thelia/Model/Base/Folder.php +++ b/core/lib/Thelia/Model/Base/Folder.php @@ -407,7 +407,7 @@ abstract class Folder implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/FolderDocument.php b/core/lib/Thelia/Model/Base/FolderDocument.php index fbe0c91b1..25b68a842 100755 --- a/core/lib/Thelia/Model/Base/FolderDocument.php +++ b/core/lib/Thelia/Model/Base/FolderDocument.php @@ -290,7 +290,7 @@ abstract class FolderDocument implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/FolderDocumentI18n.php b/core/lib/Thelia/Model/Base/FolderDocumentI18n.php index 57a38034f..520160758 100755 --- a/core/lib/Thelia/Model/Base/FolderDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/FolderDocumentI18n.php @@ -272,7 +272,7 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/FolderI18n.php b/core/lib/Thelia/Model/Base/FolderI18n.php index 12d627cac..35e69d6a6 100755 --- a/core/lib/Thelia/Model/Base/FolderI18n.php +++ b/core/lib/Thelia/Model/Base/FolderI18n.php @@ -272,7 +272,7 @@ abstract class FolderI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/FolderImage.php b/core/lib/Thelia/Model/Base/FolderImage.php index f1eb8a5ab..73bfd11b8 100755 --- a/core/lib/Thelia/Model/Base/FolderImage.php +++ b/core/lib/Thelia/Model/Base/FolderImage.php @@ -290,7 +290,7 @@ abstract class FolderImage implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/FolderImageI18n.php b/core/lib/Thelia/Model/Base/FolderImageI18n.php index 894b6ec0f..9096c8542 100755 --- a/core/lib/Thelia/Model/Base/FolderImageI18n.php +++ b/core/lib/Thelia/Model/Base/FolderImageI18n.php @@ -272,7 +272,7 @@ abstract class FolderImageI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/FolderVersion.php b/core/lib/Thelia/Model/Base/FolderVersion.php index ec588dcbd..4f6305b7e 100755 --- a/core/lib/Thelia/Model/Base/FolderVersion.php +++ b/core/lib/Thelia/Model/Base/FolderVersion.php @@ -292,7 +292,7 @@ abstract class FolderVersion implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Group.php b/core/lib/Thelia/Model/Base/Group.php index eed65d778..6b66d5f39 100755 --- a/core/lib/Thelia/Model/Base/Group.php +++ b/core/lib/Thelia/Model/Base/Group.php @@ -339,7 +339,7 @@ abstract class Group implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/GroupI18n.php b/core/lib/Thelia/Model/Base/GroupI18n.php index 4ba0aac29..de90d8863 100755 --- a/core/lib/Thelia/Model/Base/GroupI18n.php +++ b/core/lib/Thelia/Model/Base/GroupI18n.php @@ -272,7 +272,7 @@ abstract class GroupI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/GroupModule.php b/core/lib/Thelia/Model/Base/GroupModule.php index 82d6056f2..620ca9c91 100755 --- a/core/lib/Thelia/Model/Base/GroupModule.php +++ b/core/lib/Thelia/Model/Base/GroupModule.php @@ -282,7 +282,7 @@ abstract class GroupModule implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/GroupResource.php b/core/lib/Thelia/Model/Base/GroupResource.php index ea6c0ff47..84d6006b0 100755 --- a/core/lib/Thelia/Model/Base/GroupResource.php +++ b/core/lib/Thelia/Model/Base/GroupResource.php @@ -290,7 +290,7 @@ abstract class GroupResource implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Lang.php b/core/lib/Thelia/Model/Base/Lang.php index 293b0f3a7..3379594ef 100755 --- a/core/lib/Thelia/Model/Base/Lang.php +++ b/core/lib/Thelia/Model/Base/Lang.php @@ -272,7 +272,7 @@ abstract class Lang implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Message.php b/core/lib/Thelia/Model/Base/Message.php index 5245c3765..f39e4ecbe 100755 --- a/core/lib/Thelia/Model/Base/Message.php +++ b/core/lib/Thelia/Model/Base/Message.php @@ -338,7 +338,7 @@ abstract class Message implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/MessageI18n.php b/core/lib/Thelia/Model/Base/MessageI18n.php index 575e22907..545e75244 100755 --- a/core/lib/Thelia/Model/Base/MessageI18n.php +++ b/core/lib/Thelia/Model/Base/MessageI18n.php @@ -266,7 +266,7 @@ abstract class MessageI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/MessageVersion.php b/core/lib/Thelia/Model/Base/MessageVersion.php index e425b5c50..0781a503a 100755 --- a/core/lib/Thelia/Model/Base/MessageVersion.php +++ b/core/lib/Thelia/Model/Base/MessageVersion.php @@ -292,7 +292,7 @@ abstract class MessageVersion implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Module.php b/core/lib/Thelia/Model/Base/Module.php index 76c391207..ebe4b4c18 100755 --- a/core/lib/Thelia/Model/Base/Module.php +++ b/core/lib/Thelia/Model/Base/Module.php @@ -303,7 +303,7 @@ abstract class Module implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ModuleI18n.php b/core/lib/Thelia/Model/Base/ModuleI18n.php index d31dda0ba..54cf305e4 100755 --- a/core/lib/Thelia/Model/Base/ModuleI18n.php +++ b/core/lib/Thelia/Model/Base/ModuleI18n.php @@ -272,7 +272,7 @@ abstract class ModuleI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Order.php b/core/lib/Thelia/Model/Base/Order.php index 3c47ce415..ccf7922f3 100755 --- a/core/lib/Thelia/Model/Base/Order.php +++ b/core/lib/Thelia/Model/Base/Order.php @@ -388,7 +388,7 @@ abstract class Order implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/OrderAddress.php b/core/lib/Thelia/Model/Base/OrderAddress.php index d0220d4e0..b5ff32951 100755 --- a/core/lib/Thelia/Model/Base/OrderAddress.php +++ b/core/lib/Thelia/Model/Base/OrderAddress.php @@ -329,7 +329,7 @@ abstract class OrderAddress implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/OrderFeature.php b/core/lib/Thelia/Model/Base/OrderFeature.php index e2b52e6b1..49c1a0911 100755 --- a/core/lib/Thelia/Model/Base/OrderFeature.php +++ b/core/lib/Thelia/Model/Base/OrderFeature.php @@ -261,7 +261,7 @@ abstract class OrderFeature implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/OrderProduct.php b/core/lib/Thelia/Model/Base/OrderProduct.php index 2bf9c7ace..b448e4e0c 100755 --- a/core/lib/Thelia/Model/Base/OrderProduct.php +++ b/core/lib/Thelia/Model/Base/OrderProduct.php @@ -312,7 +312,7 @@ abstract class OrderProduct implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/OrderStatus.php b/core/lib/Thelia/Model/Base/OrderStatus.php index 99bb87879..15ce7fbf7 100755 --- a/core/lib/Thelia/Model/Base/OrderStatus.php +++ b/core/lib/Thelia/Model/Base/OrderStatus.php @@ -285,7 +285,7 @@ abstract class OrderStatus implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/OrderStatusI18n.php b/core/lib/Thelia/Model/Base/OrderStatusI18n.php index 249944854..1f98739f0 100755 --- a/core/lib/Thelia/Model/Base/OrderStatusI18n.php +++ b/core/lib/Thelia/Model/Base/OrderStatusI18n.php @@ -272,7 +272,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php index e66c2fe17..707bd0904 100755 --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -526,7 +526,7 @@ abstract class Product implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ProductCategory.php b/core/lib/Thelia/Model/Base/ProductCategory.php index 62a6ea425..74affb0c0 100755 --- a/core/lib/Thelia/Model/Base/ProductCategory.php +++ b/core/lib/Thelia/Model/Base/ProductCategory.php @@ -256,7 +256,7 @@ abstract class ProductCategory implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ProductDocument.php b/core/lib/Thelia/Model/Base/ProductDocument.php index 96a584dab..16503b9fb 100755 --- a/core/lib/Thelia/Model/Base/ProductDocument.php +++ b/core/lib/Thelia/Model/Base/ProductDocument.php @@ -290,7 +290,7 @@ abstract class ProductDocument implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ProductDocumentI18n.php b/core/lib/Thelia/Model/Base/ProductDocumentI18n.php index ba04b5ccc..f6c8436f8 100755 --- a/core/lib/Thelia/Model/Base/ProductDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/ProductDocumentI18n.php @@ -272,7 +272,7 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ProductI18n.php b/core/lib/Thelia/Model/Base/ProductI18n.php index ee7514fd4..7b6e65976 100755 --- a/core/lib/Thelia/Model/Base/ProductI18n.php +++ b/core/lib/Thelia/Model/Base/ProductI18n.php @@ -272,7 +272,7 @@ abstract class ProductI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ProductImage.php b/core/lib/Thelia/Model/Base/ProductImage.php index 152a298a5..364e6f00b 100755 --- a/core/lib/Thelia/Model/Base/ProductImage.php +++ b/core/lib/Thelia/Model/Base/ProductImage.php @@ -290,7 +290,7 @@ abstract class ProductImage implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ProductImageI18n.php b/core/lib/Thelia/Model/Base/ProductImageI18n.php index c84f99af2..064f09986 100755 --- a/core/lib/Thelia/Model/Base/ProductImageI18n.php +++ b/core/lib/Thelia/Model/Base/ProductImageI18n.php @@ -272,7 +272,7 @@ abstract class ProductImageI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ProductPrice.php b/core/lib/Thelia/Model/Base/ProductPrice.php index 15502a385..dab6e47a4 100755 --- a/core/lib/Thelia/Model/Base/ProductPrice.php +++ b/core/lib/Thelia/Model/Base/ProductPrice.php @@ -274,7 +274,7 @@ abstract class ProductPrice implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ProductSaleElements.php b/core/lib/Thelia/Model/Base/ProductSaleElements.php index f79d9a246..22a8c9752 100755 --- a/core/lib/Thelia/Model/Base/ProductSaleElements.php +++ b/core/lib/Thelia/Model/Base/ProductSaleElements.php @@ -332,7 +332,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ProductVersion.php b/core/lib/Thelia/Model/Base/ProductVersion.php index 071dfc742..1779cee20 100755 --- a/core/lib/Thelia/Model/Base/ProductVersion.php +++ b/core/lib/Thelia/Model/Base/ProductVersion.php @@ -300,7 +300,7 @@ abstract class ProductVersion implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Resource.php b/core/lib/Thelia/Model/Base/Resource.php index b513ea326..827de2643 100755 --- a/core/lib/Thelia/Model/Base/Resource.php +++ b/core/lib/Thelia/Model/Base/Resource.php @@ -298,7 +298,7 @@ abstract class Resource implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/ResourceI18n.php b/core/lib/Thelia/Model/Base/ResourceI18n.php index 4419f7fc8..b740bd858 100755 --- a/core/lib/Thelia/Model/Base/ResourceI18n.php +++ b/core/lib/Thelia/Model/Base/ResourceI18n.php @@ -272,7 +272,7 @@ abstract class ResourceI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Rewriting.php b/core/lib/Thelia/Model/Base/Rewriting.php index c8109458d..12229c438 100755 --- a/core/lib/Thelia/Model/Base/Rewriting.php +++ b/core/lib/Thelia/Model/Base/Rewriting.php @@ -294,7 +294,7 @@ abstract class Rewriting implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/Tax.php b/core/lib/Thelia/Model/Base/Tax.php index c1ddbf23a..f3717366f 100755 --- a/core/lib/Thelia/Model/Base/Tax.php +++ b/core/lib/Thelia/Model/Base/Tax.php @@ -285,7 +285,7 @@ abstract class Tax implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/TaxI18n.php b/core/lib/Thelia/Model/Base/TaxI18n.php index a066fe4a8..8fdec086d 100755 --- a/core/lib/Thelia/Model/Base/TaxI18n.php +++ b/core/lib/Thelia/Model/Base/TaxI18n.php @@ -260,7 +260,7 @@ abstract class TaxI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/TaxRule.php b/core/lib/Thelia/Model/Base/TaxRule.php index e363541d7..101471313 100755 --- a/core/lib/Thelia/Model/Base/TaxRule.php +++ b/core/lib/Thelia/Model/Base/TaxRule.php @@ -311,7 +311,7 @@ abstract class TaxRule implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/TaxRuleCountry.php b/core/lib/Thelia/Model/Base/TaxRuleCountry.php index 66f6f585b..b5ae7941b 100755 --- a/core/lib/Thelia/Model/Base/TaxRuleCountry.php +++ b/core/lib/Thelia/Model/Base/TaxRuleCountry.php @@ -281,7 +281,7 @@ abstract class TaxRuleCountry implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Model/Base/TaxRuleI18n.php b/core/lib/Thelia/Model/Base/TaxRuleI18n.php index f685dd3cc..86215b335 100755 --- a/core/lib/Thelia/Model/Base/TaxRuleI18n.php +++ b/core/lib/Thelia/Model/Base/TaxRuleI18n.php @@ -248,7 +248,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** From 1d87708d3be85cd6816b7f661c199e5212ae51d9 Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 28 Aug 2013 19:21:48 +0200 Subject: [PATCH 052/268] Working - Update Coupon BackOffice routing --- .../Thelia/Config/Resources/routing/admin.xml | 16 +++++--- .../Controller/Admin/CouponController.php | 37 ++----------------- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 2561dcc99..cd7af7aef 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -37,16 +37,20 @@ - Thelia\Controller\Admin\CouponController::indexAction + Thelia\Controller\Admin\CouponController::processAction + browse - Thelia\Controller\Admin\CouponController::createAction + Thelia\Controller\Admin\CouponController::processAction + create - - Thelia\Controller\Admin\CouponController::editAction + + Thelia\Controller\Admin\CouponController::processAction + edit - - Thelia\Controller\Admin\CouponController::readAction + + Thelia\Controller\Admin\CouponController::processAction + read diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index e6159c9ac..b1cf197c8 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -46,37 +46,7 @@ class CouponController extends BaseAdminController */ public function indexAction() { - return $this->processAction(); - } - - /** - * Create a Coupon Action - * - * @return \Symfony\Component\HttpFoundation\Response - */ - public function createAction() - { - return $this->processAction('create'); - } - - /** - * Edit a Coupon Action - * - * @return \Symfony\Component\HttpFoundation\Response - */ - public function editAction() - { - return $this->processAction('edit'); - } - - /** - * Read a Coupon Action - * - * @return \Symfony\Component\HttpFoundation\Response - */ - public function readAction() - { - return $this->processAction('read'); + return $this->process(); } /** @@ -142,10 +112,11 @@ class CouponController extends BaseAdminController * * @return \Symfony\Component\HttpFoundation\Response */ - public function processAction($action = 'browse') + public function processAction() { + var_dump($this->getRequest()->attributes); // Get the current action -// $action = $this->getRequest()->get('action', 'browse'); + $action = $this->getRequest()->get('action', 'browse'); // Get the category ID // $id = $this->getRequest()->get('id', 0); From 6f31460be6288c5b414964d838fbf91130f3caee Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 28 Aug 2013 19:45:21 +0200 Subject: [PATCH 053/268] Working - Fix serialization not tested --- core/lib/Thelia/Tests/Constraint/Validator/DateParamTest.php | 2 +- core/lib/Thelia/Tests/Constraint/Validator/IntegerParamTest.php | 2 +- .../lib/Thelia/Tests/Constraint/Validator/IntervalParamTest.php | 2 +- core/lib/Thelia/Tests/Constraint/Validator/PriceParamTest.php | 2 +- .../lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php | 2 +- .../Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php | 2 +- .../Tests/Constraint/Validator/RepeatedIntervalParamTest.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/lib/Thelia/Tests/Constraint/Validator/DateParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/DateParamTest.php index 1b3739c5c..45b7f00ae 100644 --- a/core/lib/Thelia/Tests/Constraint/Validator/DateParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/DateParamTest.php @@ -121,7 +121,7 @@ class DateParamTest extends \PHPUnit_Framework_TestCase * Test is the object is serializable * If no data is lost during the process */ - protected function isSerializableTest() + public function isSerializableTest() { $adapter = new CouponBaseAdapter(); $dateValidator = new \DateTime("2012-07-08"); diff --git a/core/lib/Thelia/Tests/Constraint/Validator/IntegerParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/IntegerParamTest.php index c7b5b2ac0..0c7184dde 100644 --- a/core/lib/Thelia/Tests/Constraint/Validator/IntegerParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/IntegerParamTest.php @@ -123,7 +123,7 @@ class IntegerParamTest extends \PHPUnit_Framework_TestCase * Test is the object is serializable * If no data is lost during the process */ - protected function isSerializableTest() + public function isSerializableTest() { $adapter = new CouponBaseAdapter(); $intValidator = 42; diff --git a/core/lib/Thelia/Tests/Constraint/Validator/IntervalParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/IntervalParamTest.php index 05dad2f0c..77abdbe24 100644 --- a/core/lib/Thelia/Tests/Constraint/Validator/IntervalParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/IntervalParamTest.php @@ -147,7 +147,7 @@ class IntervalParamTest extends \PHPUnit_Framework_TestCase * Test is the object is serializable * If no data is lost during the process */ - protected function isSerializableTest() + public function isSerializableTest() { $adapter = new CouponBaseAdapter(); $dateValidatorStart = new \DateTime("2012-07-08"); diff --git a/core/lib/Thelia/Tests/Constraint/Validator/PriceParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/PriceParamTest.php index 7ccc508aa..1cdee6bd2 100644 --- a/core/lib/Thelia/Tests/Constraint/Validator/PriceParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/PriceParamTest.php @@ -199,7 +199,7 @@ class PriceParamTest extends \PHPUnit_Framework_TestCase * Test is the object is serializable * If no data is lost during the process */ - protected function isSerializableTest() + public function isSerializableTest() { $adapter = new CouponBaseAdapter(); $priceValidator = 42.50; diff --git a/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php index bd83d45db..198e6e611 100644 --- a/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php @@ -159,7 +159,7 @@ class QuantityParamTest extends \PHPUnit_Framework_TestCase * Test is the object is serializable * If no data is lost during the process */ - protected function isSerializableTest() + public function isSerializableTest() { $adapter = new CouponBaseAdapter(); $intValidator = 42; diff --git a/core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php index 5766cb6b1..875453666 100644 --- a/core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php @@ -270,7 +270,7 @@ class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase * Test is the object is serializable * If no data is lost during the process */ - protected function isSerializableTest() + public function isSerializableTest() { $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); diff --git a/core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php index 22a105ffb..2b3bd00c8 100644 --- a/core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php @@ -383,7 +383,7 @@ class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase * Test is the object is serializable * If no data is lost during the process */ - protected function isSerializableTest() + public function isSerializableTest() { $adapter = new CouponBaseAdapter(); $startDateValidator = new \DateTime("2012-07-08"); From cce270fdcc225912f16221ce711a2c2e1ea24dfc Mon Sep 17 00:00:00 2001 From: franck Date: Wed, 28 Aug 2013 19:47:31 +0200 Subject: [PATCH 054/268] Factorized ModelCriterialTools calls in loops --- .../Controller/Admin/CategoryController.php | 6 +- .../Thelia/Core/Template/Element/BaseLoop.php | 23 +++++ .../Thelia/Core/Template/Loop/Attribute.php | 3 +- .../Template/Loop/AttributeAvailability.php | 8 +- .../Template/Loop/AttributeCombination.php | 11 +-- .../Thelia/Core/Template/Loop/Category.php | 9 +- .../Core/Template/Loop/CategoryPath.php | 13 ++- .../lib/Thelia/Core/Template/Loop/Content.php | 8 +- .../lib/Thelia/Core/Template/Loop/Country.php | 8 +- .../Thelia/Core/Template/Loop/Currency.php | 8 +- .../lib/Thelia/Core/Template/Loop/Feature.php | 8 +- .../Template/Loop/FeatureAvailability.php | 8 +- .../Core/Template/Loop/FeatureValue.php | 9 +- core/lib/Thelia/Core/Template/Loop/Folder.php | 8 +- core/lib/Thelia/Core/Template/Loop/Image.php | 13 +-- .../lib/Thelia/Core/Template/Loop/Product.php | 8 +- core/lib/Thelia/Core/Template/Loop/Title.php | 8 +- core/lib/Thelia/Model/Category.php | 6 +- .../Thelia/Model/Tools/ModelCriteriaTools.php | 86 +++++++++++-------- .../css/bootstrap-editable.css | 78 ++++++++--------- templates/admin/default/assets/css/admin.less | 6 -- templates/admin/default/categories.html | 2 +- .../default/includes/category_breadcrumb.html | 4 +- .../default/includes/inner-form-toolbar.html | 2 +- 24 files changed, 150 insertions(+), 193 deletions(-) diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index fda94191c..4e798d683 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -89,7 +89,7 @@ class CategoryController extends BaseAdminController $categoryDeletionForm = new CategoryDeletionForm($this->getRequest()); $data = $this->validateForm($categoryDeletionForm, "POST")->getData(); -var_dump($data); + $categoryDeleteEvent = new CategoryDeleteEvent($data['category_id']); $this->dispatch(TheliaEvents::CATEGORY_DELETE, $categoryDeleteEvent); @@ -151,8 +151,8 @@ var_dump($data); protected function positionDown($args) { $event = new CategoryChangePositionEvent( - $this->getRequest()->get('category_id', 0), - CategoryChangePositionEvent::POSITION_DOWN + $this->getRequest()->get('category_id', 0), + CategoryChangePositionEvent::POSITION_DOWN ); $this->dispatch(TheliaEvents::CATEGORY_CHANGE_POSITION, $event); diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 72f782309..8861022e9 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -28,6 +28,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Core\Template\Loop\Argument\Argument; use Propel\Runtime\ActiveQuery\ModelCriteria; use Thelia\Core\Security\SecurityContext; +use Thelia\Model\Tools\ModelCriteriaTools; /** * @@ -234,6 +235,28 @@ abstract class BaseLoop } } + /** + * Setup ModelCriteria for proper i18n processing + * + * @param ModelCriteria $search the Propel Criteria to configure + * @param array $columns the i18n columns + * @param string $foreignTable the specified table (default to criteria table) + * @param string $foreignKey the foreign key in this table (default to criteria table) + */ + protected function configureI18nProcessing(ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') { + + /* manage translations */ + ModelCriteriaTools::getI18n( + $this->getBackend_context(), + $this->getLang(), + $search, + $this->request->getSession()->getLocale(), + $columns, + $foreignTable, + $foreignKey + ); + } + /** * * this function have to be implement in your own loop class. diff --git a/core/lib/Thelia/Core/Template/Loop/Attribute.php b/core/lib/Thelia/Core/Template/Loop/Attribute.php index 41721350b..0608732a4 100755 --- a/core/lib/Thelia/Core/Template/Loop/Attribute.php +++ b/core/lib/Thelia/Core/Template/Loop/Attribute.php @@ -34,7 +34,6 @@ use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; use Thelia\Model\Base\LangQuery; -use Thelia\Model\Tools\ModelCriteriaTools; use Thelia\Model\Base\CategoryQuery; use Thelia\Model\Base\ProductCategoryQuery; @@ -92,7 +91,7 @@ class Attribute extends BaseLoop $lang = $this->getLang(); /* manage translations */ - ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $this->configureI18nProcessing($search); $id = $this->getId(); diff --git a/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php index be42f5dab..0664c7d56 100755 --- a/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php +++ b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php @@ -33,8 +33,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; -use Thelia\Model\Tools\ModelCriteriaTools; - use Thelia\Model\Base\AttributeAvQuery; use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; @@ -79,12 +77,8 @@ class AttributeAvailability extends BaseLoop { $search = AttributeAvQuery::create(); - $backendContext = $this->getBackend_context(); - - $lang = $this->getLang(); - /* manage translations */ - ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $this->configureI18nProcessing($search); $id = $this->getId(); diff --git a/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php b/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php index 833f1abb3..556a5a1fd 100755 --- a/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php +++ b/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php @@ -33,8 +33,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; -use Thelia\Model\Tools\ModelCriteriaTools; - use Thelia\Model\Base\AttributeCombinationQuery; use Thelia\Model\Map\AttributeAvTableMap; use Thelia\Model\Map\AttributeTableMap; @@ -59,6 +57,7 @@ class AttributeCombination extends BaseLoop { return new ArgumentCollection( Argument::createIntTypeArgument('product_sale_elements', null, true), + Argument::createIntTypeArgument('lang'), new Argument( 'order', new TypeCollection( @@ -79,20 +78,16 @@ class AttributeCombination extends BaseLoop $search = AttributeCombinationQuery::create(); /* manage attribute translations */ - ModelCriteriaTools::getFrontEndI18n( + $this->configureI18nProcessing( $search, - ConfigQuery::read("default_lang_without_translation", 1), - $this->request->getSession()->getLocale(), array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), AttributeTableMap::TABLE_NAME, 'ATTRIBUTE_ID' ); /* manage attributeAv translations */ - ModelCriteriaTools::getFrontEndI18n( + $this->configureI18nProcessing( $search, - ConfigQuery::read("default_lang_without_translation", 1), - $this->request->getSession()->getLocale(), array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), AttributeAvTableMap::TABLE_NAME, 'ATTRIBUTE_AV_ID' diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 9b497bb1a..e01ce3df4 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -32,8 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; -use Thelia\Model\Tools\ModelCriteriaTools; - use Thelia\Model\CategoryQuery; use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; @@ -98,12 +96,8 @@ class Category extends BaseLoop { $search = CategoryQuery::create(); - $backendContext = $this->getBackend_context(); - - $lang = $this->getLang(); - /* manage translations */ - ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $this->configureI18nProcessing($search); $id = $this->getId(); @@ -169,7 +163,6 @@ class Category extends BaseLoop $loopResult = new LoopResult(); foreach ($categories as $category) { - /* * no cause pagination lost : * if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue; diff --git a/core/lib/Thelia/Core/Template/Loop/CategoryPath.php b/core/lib/Thelia/Core/Template/Loop/CategoryPath.php index d6c0cd02c..30238c26d 100755 --- a/core/lib/Thelia/Core/Template/Loop/CategoryPath.php +++ b/core/lib/Thelia/Core/Template/Loop/CategoryPath.php @@ -65,7 +65,8 @@ class CategoryPath extends BaseLoop Argument::createIntTypeArgument('category', null, true), Argument::createIntTypeArgument('depth'), Argument::createIntTypeArgument('level'), - Argument::createBooleanOrBothTypeArgument('visible', true, false) + Argument::createBooleanOrBothTypeArgument('visible', true, false), + Argument::createIntTypeArgument('lang') ); } @@ -80,6 +81,9 @@ class CategoryPath extends BaseLoop $visible = $this->getVisible(); $search = CategoryQuery::create(); + + $this->configureI18nProcessing($search, array('TITLE')); + $search->filterById($id); if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible); @@ -95,7 +99,7 @@ class CategoryPath extends BaseLoop $loopResultRow = new LoopResultRow(); $loopResultRow - ->set("TITLE",$category->getTitle()) + ->set("TITLE",$category->getVirtualColumn('i18n_TITLE')) ->set("URL", $category->getUrl()) ->set("ID", $category->getId()) ; @@ -114,8 +118,11 @@ class CategoryPath extends BaseLoop $ids[] = $parent; $search = CategoryQuery::create(); + + $this->configureI18nProcessing($search, array('TITLE')); + $search->filterById($parent); - if ($visible == true) $search->filterByVisible($visible); + if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible); } } } while ($category != null && $parent > 0); diff --git a/core/lib/Thelia/Core/Template/Loop/Content.php b/core/lib/Thelia/Core/Template/Loop/Content.php index 6632a184c..701206ea8 100755 --- a/core/lib/Thelia/Core/Template/Loop/Content.php +++ b/core/lib/Thelia/Core/Template/Loop/Content.php @@ -31,8 +31,6 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Model\Tools\ModelCriteriaTools; - use Thelia\Model\FolderQuery; use Thelia\Model\Map\ContentTableMap; use Thelia\Model\ContentFolderQuery; @@ -88,12 +86,8 @@ class Content extends BaseLoop { $search = ContentQuery::create(); - $backendContext = $this->getBackend_context(); - - $lang = $this->getLang(); - /* manage translations */ - ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $this->configureI18nProcessing($search); $id = $this->getId(); diff --git a/core/lib/Thelia/Core/Template/Loop/Country.php b/core/lib/Thelia/Core/Template/Loop/Country.php index c6f7d16de..d93d94cb4 100755 --- a/core/lib/Thelia/Core/Template/Loop/Country.php +++ b/core/lib/Thelia/Core/Template/Loop/Country.php @@ -31,8 +31,6 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Model\Tools\ModelCriteriaTools; - use Thelia\Model\CountryQuery; use Thelia\Model\ConfigQuery; @@ -70,12 +68,8 @@ class Country extends BaseLoop { $search = CountryQuery::create(); - $backendContext = $this->getBackend_context(); - - $lang = $this->getLang(); - /* manage translations */ - ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $this->configureI18nProcessing($search); $id = $this->getId(); diff --git a/core/lib/Thelia/Core/Template/Loop/Currency.php b/core/lib/Thelia/Core/Template/Loop/Currency.php index d833ff8ae..b793b86fd 100755 --- a/core/lib/Thelia/Core/Template/Loop/Currency.php +++ b/core/lib/Thelia/Core/Template/Loop/Currency.php @@ -31,8 +31,6 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Model\Tools\ModelCriteriaTools; - use Thelia\Model\CurrencyQuery; use Thelia\Model\ConfigQuery; @@ -69,12 +67,8 @@ class Currency extends BaseLoop { $search = CurrencyQuery::create(); - $backendContext = $this->getBackend_context(); - - $lang = $this->getLang(); - /* manage translations */ - ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), array('NAME')); + $this->configureI18nProcessing($search, array('NAME')); $id = $this->getId(); diff --git a/core/lib/Thelia/Core/Template/Loop/Feature.php b/core/lib/Thelia/Core/Template/Loop/Feature.php index 85d037080..e2de85dbc 100755 --- a/core/lib/Thelia/Core/Template/Loop/Feature.php +++ b/core/lib/Thelia/Core/Template/Loop/Feature.php @@ -31,8 +31,6 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Model\Tools\ModelCriteriaTools; - use Thelia\Model\Base\CategoryQuery; use Thelia\Model\Base\ProductCategoryQuery; use Thelia\Model\Base\FeatureQuery; @@ -84,12 +82,8 @@ class Feature extends BaseLoop { $search = FeatureQuery::create(); - $backendContext = $this->getBackend_context(); - - $lang = $this->getLang(); - /* manage translations */ - ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $this->configureI18nProcessing($search); $id = $this->getId(); diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php index ce6f8767a..c04d70031 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php @@ -31,8 +31,6 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Model\Tools\ModelCriteriaTools; - use Thelia\Model\Base\FeatureAvQuery; use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; @@ -77,12 +75,8 @@ class FeatureAvailability extends BaseLoop { $search = FeatureAvQuery::create(); - $backendContext = $this->getBackend_context(); - - $lang = $this->getLang(); - /* manage translations */ - ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $this->configureI18nProcessing($search); $id = $this->getId(); diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php index 8a29d7c74..42d50c57b 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php @@ -33,8 +33,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; -use Thelia\Model\Tools\ModelCriteriaTools; - use Thelia\Model\Base\FeatureProductQuery; use Thelia\Model\ConfigQuery; use Thelia\Model\Map\FeatureAvTableMap; @@ -70,7 +68,8 @@ class FeatureValue extends BaseLoop new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse')) ), 'manual' - ) + ), + Argument::createIntTypeArgument('lang') ); } @@ -84,10 +83,8 @@ class FeatureValue extends BaseLoop $search = FeatureProductQuery::create(); /* manage featureAv translations */ - ModelCriteriaTools::getFrontEndI18n( + $this->configureI18nProcessing( $search, - ConfigQuery::read("default_lang_without_translation", 1), - $this->request->getSession()->getLocale(), array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), FeatureAvTableMap::TABLE_NAME, 'FEATURE_AV_ID' diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php index c95b0dc42..327ce76d4 100755 --- a/core/lib/Thelia/Core/Template/Loop/Folder.php +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -32,8 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; -use Thelia\Model\Tools\ModelCriteriaTools; - use Thelia\Model\FolderQuery; use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; @@ -80,12 +78,8 @@ class Folder extends BaseLoop { $search = FolderQuery::create(); - $backendContext = $this->getBackend_context(); - - $lang = $this->getLang(); - /* manage translations */ - ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $this->configureI18nProcessing($search); $id = $this->getId(); diff --git a/core/lib/Thelia/Core/Template/Loop/Image.php b/core/lib/Thelia/Core/Template/Loop/Image.php index a1e866cb2..638905dc2 100755 --- a/core/lib/Thelia/Core/Template/Loop/Image.php +++ b/core/lib/Thelia/Core/Template/Loop/Image.php @@ -207,16 +207,8 @@ class Image extends BaseLoop } - /** - * \Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. - * - * @todo : verify here if we want results for row without translations. - */ - - $search->joinWithI18n( - $this->request->getSession()->getLocale(), - (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN - ); + /* manage translations */ + $this->configureI18nProcessing($search); $results = $this->search($search, $pagination); @@ -295,6 +287,7 @@ class Image extends BaseLoop ), 'manual' ), + Argument::createIntTypeArgument('lang'), Argument::createIntTypeArgument('width'), Argument::createIntTypeArgument('height'), diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 10112ef28..1570acca8 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -33,8 +33,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; -use Thelia\Model\Tools\ModelCriteriaTools; - use Thelia\Model\CategoryQuery; use Thelia\Model\Map\FeatureProductTableMap; use Thelia\Model\Map\ProductPriceTableMap; @@ -138,12 +136,8 @@ class Product extends BaseLoop { $search = ProductQuery::create(); - $backendContext = $this->getBackend_context(); - - $lang = $this->getLang(); - /* manage translations */ - ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale()); + $this->configureI18nProcessing($search); $attributeNonStrictMatch = $this->getAttribute_non_strict_match(); $isPSELeftJoinList = array(); diff --git a/core/lib/Thelia/Core/Template/Loop/Title.php b/core/lib/Thelia/Core/Template/Loop/Title.php index caa5e7d87..c53be086a 100755 --- a/core/lib/Thelia/Core/Template/Loop/Title.php +++ b/core/lib/Thelia/Core/Template/Loop/Title.php @@ -31,8 +31,6 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Model\Tools\ModelCriteriaTools; - use Thelia\Model\CustomerTitleQuery; use Thelia\Model\ConfigQuery; @@ -67,12 +65,8 @@ class Title extends BaseLoop { $search = CustomerTitleQuery::create(); - $backendContext = $this->getBackend_context(); - - $lang = $this->getLang(); - /* manage translations */ - ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), array('SHORT', 'LONG')); + $this->configureI18nProcessing($search, array('SHORT', 'LONG')); $id = $this->getId(); diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php index 88e7cfc10..2ffd375dd 100755 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -48,7 +48,7 @@ class Category extends BaseCategory ->findOne() ; - return $last->getPosition() + 1; + return $last != null ? $last->getPosition() + 1 : 1; } /** @@ -74,6 +74,4 @@ class Category extends BaseCategory return $countProduct; } - - -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php index e9323ebfa..3913b2890 100755 --- a/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php +++ b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php @@ -6,6 +6,7 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Join; use Propel\Runtime\ActiveQuery\ModelCriteria; use Thelia\Model\Base\LangQuery; +use Thelia\Model\ConfigQuery; /** * Class ModelCriteriaTools @@ -17,13 +18,12 @@ class ModelCriteriaTools { /** * @param ModelCriteria $search - * @param $defaultLangWithoutTranslation - * @param $askedLocale + * @param $requestedLocale * @param array $columns * @param null $foreignTable * @param string $foreignKey */ - public static function getFrontEndI18n(ModelCriteria &$search, $defaultLangWithoutTranslation, $askedLocale, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') + public static function getFrontEndI18n(ModelCriteria &$search, $requestedLocale, $columns, $foreignTable, $foreignKey) { if($foreignTable === null) { $foreignTable = $search->getTableMap()->getName(); @@ -32,21 +32,24 @@ class ModelCriteriaTools $aliasPrefix = $foreignTable . '_'; } - $askedLocaleI18nAlias = 'asked_locale_i18n'; + $defaultLangWithoutTranslation = ConfigQuery::read("default_lang_without_translation", 1); + + $requestedLocaleI18nAlias = 'requested_locale_i18n'; $defaultLocaleI18nAlias = 'default_locale_i18n'; - if($defaultLangWithoutTranslation == 0) { - $askedLocaleJoin = new Join(); - $askedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $askedLocaleI18nAlias); - $askedLocaleJoin->setJoinType(Criteria::INNER_JOIN); + if (!$defaultLangWithoutTranslation == 0) { - $search->addJoinObject($askedLocaleJoin, $askedLocaleI18nAlias) - ->addJoinCondition($askedLocaleI18nAlias ,'`' . $askedLocaleI18nAlias . '`.LOCALE = ?', $askedLocale, null, \PDO::PARAM_STR); + $requestedLocaleJoin = new Join(); + $requestedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $requestedLocaleI18nAlias); + $requestedLocaleJoin->setJoinType(Criteria::INNER_JOIN); - $search->withColumn('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED'); + $search->addJoinObject($requestedLocaleJoin, $requestedLocaleI18nAlias) + ->addJoinCondition($requestedLocaleI18nAlias ,'`' . $requestedLocaleI18nAlias . '`.LOCALE = ?', $requestedLocale, null, \PDO::PARAM_STR); + + $search->withColumn('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED'); foreach($columns as $column) { - $search->withColumn('`' . $askedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column); + $search->withColumn('`' . $requestedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column); } } else { $defaultLocale = LangQuery::create()->findOneById($defaultLangWithoutTranslation)->getLocale(); @@ -58,24 +61,24 @@ class ModelCriteriaTools $search->addJoinObject($defaultLocaleJoin, $defaultLocaleI18nAlias) ->addJoinCondition($defaultLocaleI18nAlias ,'`' . $defaultLocaleI18nAlias . '`.LOCALE = ?', $defaultLocale, null, \PDO::PARAM_STR); - $askedLocaleJoin = new Join(); - $askedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $askedLocaleI18nAlias); - $askedLocaleJoin->setJoinType(Criteria::LEFT_JOIN); + $requestedLocaleJoin = new Join(); + $requestedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $requestedLocaleI18nAlias); + $requestedLocaleJoin->setJoinType(Criteria::LEFT_JOIN); - $search->addJoinObject($askedLocaleJoin, $askedLocaleI18nAlias) - ->addJoinCondition($askedLocaleI18nAlias ,'`' . $askedLocaleI18nAlias . '`.LOCALE = ?', $askedLocale, null, \PDO::PARAM_STR); + $search->addJoinObject($requestedLocaleJoin, $requestedLocaleI18nAlias) + ->addJoinCondition($requestedLocaleI18nAlias ,'`' . $requestedLocaleI18nAlias . '`.LOCALE = ?', $requestedLocale, null, \PDO::PARAM_STR); - $search->withColumn('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED'); + $search->withColumn('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED'); - $search->where('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.ID)')->_or()->where('NOT ISNULL(`' . $defaultLocaleI18nAlias . '`.ID)'); + $search->where('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.ID)')->_or()->where('NOT ISNULL(`' . $defaultLocaleI18nAlias . '`.ID)'); foreach($columns as $column) { - $search->withColumn('CASE WHEN NOT ISNULL(`' . $askedLocaleI18nAlias . '`.ID) THEN `' . $askedLocaleI18nAlias . '`.`' . $column . '` ELSE `' . $defaultLocaleI18nAlias . '`.`' . $column . '` END', $aliasPrefix . 'i18n_' . $column); + $search->withColumn('CASE WHEN NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.ID) THEN `' . $requestedLocaleI18nAlias . '`.`' . $column . '` ELSE `' . $defaultLocaleI18nAlias . '`.`' . $column . '` END', $aliasPrefix . 'i18n_' . $column); } } } - public static function getBackEndI18n(ModelCriteria &$search, $askedLocale, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') + public static function getBackEndI18n(ModelCriteria &$search, $requestedLocale, $columns, $foreignTable, $foreignKey) { if($foreignTable === null) { $foreignTable = $search->getTableMap()->getName(); @@ -84,35 +87,44 @@ class ModelCriteriaTools $aliasPrefix = $foreignTable . '_'; } - $askedLocaleI18nAlias = 'asked_locale_i18n'; + $requestedLocaleI18nAlias = 'requested_locale_i18n'; - $askedLocaleJoin = new Join(); - $askedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $askedLocaleI18nAlias); - $askedLocaleJoin->setJoinType(Criteria::LEFT_JOIN); + $requestedLocaleJoin = new Join(); + $requestedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $requestedLocaleI18nAlias); + $requestedLocaleJoin->setJoinType(Criteria::LEFT_JOIN); - $search->addJoinObject($askedLocaleJoin, $askedLocaleI18nAlias) - ->addJoinCondition($askedLocaleI18nAlias ,'`' . $askedLocaleI18nAlias . '`.LOCALE = ?', $askedLocale, null, \PDO::PARAM_STR); + $search->addJoinObject($requestedLocaleJoin, $requestedLocaleI18nAlias) + ->addJoinCondition($requestedLocaleI18nAlias ,'`' . $requestedLocaleI18nAlias . '`.LOCALE = ?', $requestedLocale, null, \PDO::PARAM_STR); - $search->withColumn('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED'); + $search->withColumn('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED'); foreach($columns as $column) { - $search->withColumn('`' . $askedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column); + $search->withColumn('`' . $requestedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column); } } - public static function getI18n($backendContext, $lang, ModelCriteria &$search, $defaultLangWithoutTranslation, $currentLocale, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') + public static function getI18n($backendContext, $requestedLangId, ModelCriteria &$search, $currentLocale, $columns, $foreignTable, $foreignKey) { - if($lang !== null) { - $localeSearch = LangQuery::create()->findOneById($lang); - if($localeSearch === null) { - throw new \InvalidArgumentException('Incorrect lang argument given in attribute loop'); + // If a lang has been requested, find the related Lang object, and get the locale + if ($requestedLangId !== null) { + $localeSearch = LangQuery::create()->findOneById($requestedLangId); + + if ($localeSearch === null) { + throw new \InvalidArgumentException(sprintf('Incorrect lang argument given in attribute loop: lang ID %d not found', $requestedLangId)); } + + $locale = $localeSearch->getLocale(); + } + else { + // Use the currently defined locale + $locale = $currentLocale; } - if($backendContext) { - self::getBackEndI18n($search, $lang === null ? $currentLocale : $localeSearch->getLocale(), $columns, $foreignTable, $foreignKey); + // Call the proper method depending on the context: front or back + if ($backendContext) { + self::getBackEndI18n($search, $locale, $columns, $foreignTable, $foreignKey); } else { - self::getFrontEndI18n($search, $defaultLangWithoutTranslation, $lang === null ? $currentLocale : $localeSearch->getLocale(), $columns, $foreignTable, $foreignKey); + self::getFrontEndI18n($search, $locale, $columns, $foreignTable, $foreignKey); } } } diff --git a/templates/admin/default/assets/bootstrap-editable/css/bootstrap-editable.css b/templates/admin/default/assets/bootstrap-editable/css/bootstrap-editable.css index 2d9cc4eae..16de488fa 100755 --- a/templates/admin/default/assets/bootstrap-editable/css/bootstrap-editable.css +++ b/templates/admin/default/assets/bootstrap-editable/css/bootstrap-editable.css @@ -1,4 +1,4 @@ -/*! X-editable - v1.4.6 +/*! X-editable - v1.4.6 * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * http://github.com/vitalets/x-editable * Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */ @@ -18,45 +18,45 @@ vertical-align: top; margin-left: 7px; /* inline-block emulation for IE7*/ - zoom: 1; + zoom: 1; *display: inline; } .editable-buttons.editable-buttons-bottom { - display: block; + display: block; margin-top: 7px; margin-left: 0; } .editable-input { - vertical-align: top; + vertical-align: top; display: inline-block; /* should be inline to take effect of parent's white-space: nowrap */ width: auto; /* bootstrap-responsive has width: 100% that breakes layout */ white-space: normal; /* reset white-space decalred in parent*/ /* display-inline emulation for IE7*/ - zoom: 1; - *display: inline; + zoom: 1; + *display: inline; } .editable-buttons .editable-cancel { - margin-left: 7px; + margin-left: 7px; } /*for jquery-ui buttons need set height to look more pretty*/ .editable-buttons button.ui-button-icon-only { - height: 24px; + height: 24px; width: 30px; } .editableform-loading { - background: url('../img/loading.gif') center center no-repeat; + background: url('../img/loading.gif') center center no-repeat; height: 25px; - width: auto; - min-width: 25px; + width: auto; + min-width: 25px; } .editable-inline .editableform-loading { - background-position: left 5px; + background-position: left 5px; } .editable-error-block { @@ -68,17 +68,17 @@ /*add padding for jquery ui*/ .editable-error-block.ui-state-error { - padding: 3px; -} + padding: 3px; +} .editable-error { - color: red; + color: red; } /* ---- For specific types ---- */ .editableform .editable-date { - padding: 0; + padding: 0; margin: 0; float: left; } @@ -86,25 +86,25 @@ /* move datepicker icon to center of add-on button. See https://github.com/vitalets/x-editable/issues/183 */ .editable-inline .add-on .icon-th { margin-top: 3px; - margin-left: 1px; + margin-left: 1px; } /* checklist vertical alignment */ -.editable-checklist label input[type="checkbox"], +.editable-checklist label input[type="checkbox"], .editable-checklist label span { vertical-align: middle; margin: 0; } .editable-checklist label { - white-space: nowrap; + white-space: nowrap; } /* set exact width of textarea to fit buttons toolbar */ .editable-wysihtml5 { - width: 566px; - height: 250px; + width: 566px; + height: 250px; } /* clear button shown as link in date inputs */ @@ -119,16 +119,16 @@ .editable-clear-x { background: url('../img/clear.png') center center no-repeat; display: block; - width: 13px; + width: 13px; height: 13px; position: absolute; opacity: 0.6; z-index: 100; - + top: 50%; right: 6px; margin-top: -6px; - + } .editable-clear-x:hover { @@ -140,49 +140,49 @@ } .editable-container.editable-popup { max-width: none !important; /* without this rule poshytip/tooltip does not stretch */ -} +} .editable-container.popover { width: auto; /* without this rule popover does not stretch */ } .editable-container.editable-inline { - display: inline-block; + display: inline-block; vertical-align: middle; width: auto; /* inline-block emulation for IE7*/ - zoom: 1; - *display: inline; + zoom: 1; + *display: inline; } .editable-container.ui-widget { font-size: inherit; /* jqueryui widget font 1.1em too big, overwrite it */ z-index: 9990; /* should be less than select2 dropdown z-index to close dropdown first when click */ } -.editable-click, -a.editable-click, +.editable-click, +a.editable-click, a.editable-click:hover { text-decoration: none; - border-bottom: dashed 1px #0088cc; + border-bottom: dotted 1px #0088cc; } -.editable-click.editable-disabled, -a.editable-click.editable-disabled, +.editable-click.editable-disabled, +a.editable-click.editable-disabled, a.editable-click.editable-disabled:hover { - color: #585858; + color: #585858; cursor: default; border-bottom: none; } .editable-empty, .editable-empty:hover, .editable-empty:focus{ - font-style: italic; - color: #DD1144; + font-style: italic; + color: #DD1144; /* border-bottom: none; */ text-decoration: none; } .editable-unsaved { - font-weight: bold; + font-weight: bold; } .editable-unsaved:after { @@ -194,12 +194,12 @@ a.editable-click.editable-disabled:hover { -moz-transition: background-color 1400ms ease-out; -o-transition: background-color 1400ms ease-out; -ms-transition: background-color 1400ms ease-out; - transition: background-color 1400ms ease-out; + transition: background-color 1400ms ease-out; } /*see https://github.com/vitalets/x-editable/issues/139 */ .form-horizontal .editable -{ +{ padding-top: 5px; display:inline-block; } diff --git a/templates/admin/default/assets/css/admin.less b/templates/admin/default/assets/css/admin.less index 0f1d499ce..9d9f2c482 100755 --- a/templates/admin/default/assets/css/admin.less +++ b/templates/admin/default/assets/css/admin.less @@ -717,10 +717,4 @@ label { // Center the alert box (20px bottom margin) in the table cell padding: 20px 20px 0 20px; } -} - -// -- Editable tweaks --------------------------------------------------------- - -.editable-click, a.editable-click, a.editable-click:hover { - border-bottom: 1px dotted #0088CC; } \ No newline at end of file diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html index e37018e02..7bf76988c 100755 --- a/templates/admin/default/categories.html +++ b/templates/admin/default/categories.html @@ -241,7 +241,7 @@ $(function() { $.ajax({ url : "{url path='admin/catalog/category'}", data : { - id : $(this).data('id'), + category_id : $(this).data('id'), action : 'visibilityToggle' } }); diff --git a/templates/admin/default/includes/category_breadcrumb.html b/templates/admin/default/includes/category_breadcrumb.html index 0870a4c2e..cf03c4082 100755 --- a/templates/admin/default/includes/category_breadcrumb.html +++ b/templates/admin/default/includes/category_breadcrumb.html @@ -12,11 +12,11 @@ {if $action == 'edit'} {intl l='Editing %cat' cat="{$TITLE}"} {else} - {$TITLE} {intl l="(edit)"} + {$TITLE} {intl l="(edit)"} {/if} {else} -
    • {$TITLE} /
    • +
    • {$TITLE} /
    • {/if} {/loop} {/ifloop} diff --git a/templates/admin/default/includes/inner-form-toolbar.html b/templates/admin/default/includes/inner-form-toolbar.html index 8d6f65cc8..4d5570f6c 100755 --- a/templates/admin/default/includes/inner-form-toolbar.html +++ b/templates/admin/default/includes/inner-form-toolbar.html @@ -12,7 +12,7 @@
      - - - - - - + - - - + + +
      @@ -1126,4 +1121,16 @@
      + + + + + + + + + + + +
      diff --git a/templates/default/category.html b/templates/default/category.html index af4cdcf14..440866a26 100755 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -22,7 +22,7 @@ {loop name="product" type="product" category="#ID"}
      -

      PRODUCT : #REF (#LOOP_COUNT / #LOOP_TOTAL)

      +

      PRODUCT #ID : #REF (#LOOP_COUNT / #LOOP_TOTAL)

      #TITLE

      #DESCRIPTION

      @@ -111,7 +111,7 @@ {loop name="product" type="product" category="#ID"}
      -

      PRODUCT : #REF (#LOOP_COUNT / #LOOP_TOTAL)

      +

      PRODUCT #ID : #REF (#LOOP_COUNT / #LOOP_TOTAL)

      #TITLE

      #DESCRIPTION

      From 75b456429763840ccf85a44d45e6e2a7c4187600 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Thu, 29 Aug 2013 09:20:58 +0200 Subject: [PATCH 056/268] rewriting tables --- local/config/schema.xml | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/local/config/schema.xml b/local/config/schema.xml index dbd57314b..0e20f2562 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1095,19 +1095,24 @@ + - + + + + + + + + - - -
      @@ -1121,16 +1126,4 @@
      - - - - - - - - - - - -
      From 4b9a54fa68a1b6121e5b4fd06c6870ec1f03f567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20ESPECHE?= Date: Thu, 29 Aug 2013 16:16:21 +0200 Subject: [PATCH 057/268] WIP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Implémentation coupon/list en cours - Implémentation coupon/read OK - Implémentation coupon/edit en cours --- .../assets/js/tablesorter/jquery-latest.js | 154 ++++++++++++++ .../js/tablesorter/jquery.tablesorter.min.js | 4 + templates/admin/default/coupon/edit.html | 55 ++++- templates/admin/default/coupon/list.html | 188 +++++++++++++++++- templates/admin/default/coupon/read.html | 102 +++++++++- 5 files changed, 490 insertions(+), 13 deletions(-) create mode 100644 templates/admin/default/assets/js/tablesorter/jquery-latest.js create mode 100644 templates/admin/default/assets/js/tablesorter/jquery.tablesorter.min.js diff --git a/templates/admin/default/assets/js/tablesorter/jquery-latest.js b/templates/admin/default/assets/js/tablesorter/jquery-latest.js new file mode 100644 index 000000000..ac7e7009d --- /dev/null +++ b/templates/admin/default/assets/js/tablesorter/jquery-latest.js @@ -0,0 +1,154 @@ +/*! + * jQuery JavaScript Library v1.4.2 + * http://jquery.com/ + * + * Copyright 2010, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2010, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Sat Feb 13 22:33:48 2010 -0500 + */ +(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/, +Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&& +(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this, +a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b=== +"find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this, +function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b
      a"; +var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected, +parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent= +false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n= +s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true, +applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando]; +else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this, +a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b=== +w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i, +cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected= +c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed"); +a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g, +function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split("."); +k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a), +C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B=0){a.type= +e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&& +f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive; +if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data", +e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a, +"_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a, +d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, +e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift(); +t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D|| +g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()}, +CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m, +g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)}, +text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}}, +setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return hl[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h= +h[3];l=0;for(m=h.length;l=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m=== +"="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g, +h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&& +q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML=""; +if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="

      ";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}(); +(function(){var g=s.createElement("div");g.innerHTML="
      ";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}: +function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f0)for(var j=d;j0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j= +{},i;if(f&&a.length){e=0;for(var o=a.length;e-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a=== +"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode", +d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")? +a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType=== +1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/"},F={option:[1,""],legend:[1,"
      ","
      "],thead:[1,"","
      "],tr:[2,"","
      "],td:[3,"","
      "],col:[2,"","
      "],area:[1,"",""],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div
      ","
      "];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d= +c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this}, +wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, +prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b, +this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild); +return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja, +""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]); +return this}else{e=0;for(var j=d.length;e0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["", +""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]===""&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e= +c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]? +c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja= +function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter= +Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a, +"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f= +a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b= +a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=//gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!== +"string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("
      ").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this}, +serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), +function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href, +global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&& +e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)? +"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache=== +false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B= +false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since", +c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E|| +d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x); +g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status=== +1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b=== +"json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional; +if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration=== +"number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]|| +c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start; +this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now= +this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem, +e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b
      "; +a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b); +c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a, +d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top- +f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset": +"pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in +e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window); diff --git a/templates/admin/default/assets/js/tablesorter/jquery.tablesorter.min.js b/templates/admin/default/assets/js/tablesorter/jquery.tablesorter.min.js new file mode 100644 index 000000000..b8605df1e --- /dev/null +++ b/templates/admin/default/assets/js/tablesorter/jquery.tablesorter.min.js @@ -0,0 +1,4 @@ + +(function($){$.extend({tablesorter:new +function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:true,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'/\.|\,/g',onRenderHeader:null,selectorHeaders:'thead th',debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}if(table.tBodies.length==0)return;var rows=table.tBodies[0].rows;if(rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function checkHeaderOptionsSortingLocked(table,i){if((table.config.headers[i])&&(table.config.headers[i].lockedOrder))return table.config.headers[i].lockedOrder;return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i b["+i+"]) ? 1 : 0));";};function makeSortTextDesc(i){return"((b["+i+"] < a["+i+"]) ? -1 : ((b["+i+"] > a["+i+"]) ? 1 : 0));";};function makeSortNumeric(i){return"a["+i+"]-b["+i+"];";};function makeSortNumericDesc(i){return"b["+i+"]-a["+i+"];";};function sortText(a,b){if(table.config.sortLocaleCompare)return a.localeCompare(b);return((ab)?1:0));};function sortTextDesc(a,b){if(table.config.sortLocaleCompare)return b.localeCompare(a);return((ba)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$.data(this,"tablesorter",config);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){$this.trigger("sortStart");var $cell=$(this);var i=this.column;this.order=this.count++%2;if(this.lockedOrder)this.order=this.lockedOrder;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i -
      +
      + + + -
      +
      +
      + +
      + +
      + +
      + + +
      + +
      + + +
      + +
      + +
      + +
      + +
      + +
      + + +
      + +
      + +
      + +
      +
      + + {include file='includes/js.inc.html'} diff --git a/templates/admin/default/coupon/list.html b/templates/admin/default/coupon/list.html index 95b2da098..f5c7b1508 100755 --- a/templates/admin/default/coupon/list.html +++ b/templates/admin/default/coupon/list.html @@ -6,15 +6,168 @@ {include file='includes/header.inc.html'} -
      -
      +
      + + + + -
      + +
      +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + List of enabled coupons +
      CodeTitleExpiration dateUsage leftActions
      XMAS13Coupon for XMAS -30 €25/12/201349 times + Edit + Disable +
      XMAS14Coupon for XMAS -30 €25/12/201349 times + Edit + Disable +
      XMAS15Coupon for XMAS -30 €25/12/201349 times + Edit + Disable +
      XMAS16Coupon for XMAS -30 €25/12/201349 times + Edit + Disable +
      +
      +
      + +
      +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + List of disabled coupons +
      CodeTitleExpiration dateUsage leftActions
      XMAS13Coupon for XMAS -30 €18/10/201349 times + Edit + Enabled +
      XMAS13Coupon for XMAS -20 €05/09/201349 times + Edit + Enabled +
      XMAS13Coupon for XMAS -50 €03/12/201349 times + Edit + Enabled +
      XMAS13Coupon for XMAS -5 €25/01/201349 times + Edit + Enabled +
      +
      +
      + + + + + + {include file='includes/js.inc.html'} @@ -24,6 +177,33 @@ {/javascripts} + +{javascripts file='../assets/js/tablesorter/jquery.tablesorter.min.js'} + +{/javascripts} + + {include file='includes/footer.inc.html'} diff --git a/templates/admin/default/coupon/read.html b/templates/admin/default/coupon/read.html index d29c7d927..9161f0d72 100755 --- a/templates/admin/default/coupon/read.html +++ b/templates/admin/default/coupon/read.html @@ -6,15 +6,91 @@ {include file='includes/header.inc.html'} -
      -
      +
      + + + -
      + +
      +
      + +
      + This coupon is disabled, you can enable to the bottom of this form. +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      CodeXMAS13
      TitleCoupon for XMAS -30 €
      Expiration date25/12/2013
      Usage left49 times
      May be combinedYes
      Cancel shippingNo
      EffectRemove 30 € to the cart price
      Conditions of application +
        +
      • Total cart supperior to 400 €
      • +
      • OR
      • +
      • At least 4 products
      • +
      +
      Actions + Edit + Enabled +
      + +
      +
      + + + {include file='includes/js.inc.html'} @@ -23,7 +99,25 @@ {/javascripts} + {include file='includes/footer.inc.html'} From 2396b78ce9557923b3c6b57645113140459dd148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20ESPECHE?= Date: Thu, 29 Aug 2013 16:17:28 +0200 Subject: [PATCH 058/268] Working Ajout du .DS_Store --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d0a538143..8de5039ed 100755 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ phpdoc*.log php-cs xhprof phpunit.phar +.DS_Store \ No newline at end of file From 6a7d5ec98e929e8ad7e175c05d72284a3d5770c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20ESPECHE?= Date: Thu, 29 Aug 2013 16:17:49 +0200 Subject: [PATCH 059/268] WIP Merge master --- core/lib/Thelia/Model/Base/RewritingUrl.php | 2 +- install/sqldb.map | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 install/sqldb.map diff --git a/core/lib/Thelia/Model/Base/RewritingUrl.php b/core/lib/Thelia/Model/Base/RewritingUrl.php index 75ee97e79..a6bcd3a26 100644 --- a/core/lib/Thelia/Model/Base/RewritingUrl.php +++ b/core/lib/Thelia/Model/Base/RewritingUrl.php @@ -298,7 +298,7 @@ abstract class RewritingUrl implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/install/sqldb.map b/install/sqldb.map new file mode 100644 index 000000000..63a93baa8 --- /dev/null +++ b/install/sqldb.map @@ -0,0 +1,2 @@ +# Sqlfile -> Database map +thelia.sql=thelia From 37659415ad3d9ac22b677334519a5765bb43684e Mon Sep 17 00:00:00 2001 From: gmorel Date: Thu, 29 Aug 2013 16:20:41 +0200 Subject: [PATCH 060/268] WIP - Add Coupon Event - Customer Parameter --- core/lib/Thelia/Action/Coupon.php | 23 +++ .../Core/Event/Coupon/CouponCreateEvent.php | 82 +++++++++ .../Core/Event/Coupon/CouponDisableEvent.php | 103 +++++++++++ .../Core/Event/Coupon/CouponEnableEvent.php | 103 +++++++++++ core/lib/Thelia/Model/Base/RewritingUrl.php | 2 +- .../Validator/CustomerParamTest.php | 161 ++++++++++++++++++ 6 files changed, 473 insertions(+), 1 deletion(-) create mode 100644 core/lib/Thelia/Core/Event/Coupon/CouponCreateEvent.php create mode 100644 core/lib/Thelia/Core/Event/Coupon/CouponDisableEvent.php create mode 100644 core/lib/Thelia/Core/Event/Coupon/CouponEnableEvent.php create mode 100644 core/lib/Thelia/Tests/Constraint/Validator/CustomerParamTest.php diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index 7b95d80fa..331265b73 100755 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -43,6 +43,29 @@ use Propel\Runtime\Exception\PropelException; class Coupon extends BaseAction implements EventSubscriberInterface { + /** + * Disable a Coupon + * + * @param ActionEvent $event + */ + public function delete(CategoryDeleteEvent $event) + { + $this->checkAuth("ADMIN", "admin.category.delete"); + + $category = CategoryQuery::create()->findPk($event->getId()); + + if ($category !== null) { + + $event->setDeletedCategory($category); + + $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_DELETECATEGORY, $event); + + $category->delete(); + + $event->getDispatcher()->dispatch(TheliaEvents::AFTER_DELETECATEGORY, $event); + } + } + /** * Returns an array of event names this subscriber listens to. * diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponCreateEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponCreateEvent.php new file mode 100644 index 000000000..c03e21f17 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Coupon/CouponCreateEvent.php @@ -0,0 +1,82 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Core\Event\Coupon; + +use Thelia\Model\Coupon; + +class CouponCreateEvent extends ActionEvent +{ + protected $title; + protected $parent; + protected $locale; + protected $created_category; + + public function __construct($title, $parent, $locale) + { + $this->title = $title; + $this->parent = $parent; + $this->locale = $locale; + } + + public function getTitle() + { + return $this->title; + } + + public function setTitle($title) + { + $this->title = $title; + } + + public function getParent() + { + return $this->parent; + } + + public function setParent($parent) + { + $this->parent = $parent; + } + + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + } + + public function getCreatedCategory() + { + return $this->created_category; + } + + public function setCreatedCategory(Category $created_category) + { + $this->created_category = $created_category; +var_dump($this->created_category); + } +} diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponDisableEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponDisableEvent.php new file mode 100644 index 000000000..db8e14243 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Coupon/CouponDisableEvent.php @@ -0,0 +1,103 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Core\Event\Coupon; +use Thelia\Model\Coupon; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/29/13 + * Time: 3:45 PM + * + * Occurring when a Coupon is disabled + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class CouponDisableEvent extends ActionEvent +{ + /** @var int Coupon id */ + protected $couponId; + + /** @var Coupon Coupon being disabled */ + protected $disabledCoupon; + + /** + * Constructor + * + * @param int $id Coupon Id + */ + public function __construct($id) + { + $this->id = $id; + } + + /** + * Get Coupon id + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * Set Coupon id + * + * @param int $id Coupon id + * + * @return $this + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get Coupon being disabled + * + * @return Coupon + */ + public function getDisabledCoupon() + { + return $this->disabledCoupon; + } + + /** + * Set Coupon to be disabled + * + * @param Coupon $disabledCoupon Coupon to disable + * + * @return $this + */ + public function setDisabledCoupon(Coupon $disabledCoupon) + { + $this->disabledCoupon = $disabledCoupon; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponEnableEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponEnableEvent.php new file mode 100644 index 000000000..ab06953e5 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Coupon/CouponEnableEvent.php @@ -0,0 +1,103 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Core\Event\Coupon; +use Thelia\Model\Coupon; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/29/13 + * Time: 3:45 PM + * + * Occurring when a Coupon is enabled + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class CouponEnableEvent extends ActionEvent +{ + /** @var int Coupon id */ + protected $couponId; + + /** @var Coupon Coupon being enabled */ + protected $enabledCoupon; + + /** + * Constructor + * + * @param int $id Coupon Id + */ + public function __construct($id) + { + $this->id = $id; + } + + /** + * Get Coupon id + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * Set Coupon id + * + * @param int $id Coupon id + * + * @return $this + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Get Coupon being enabled + * + * @return Coupon + */ + public function getEnabledCoupon() + { + return $this->enabledCoupon; + } + + /** + * Set Coupon to be enabled + * + * @param Coupon $enabledCoupon Coupon to enabled + * + * @return $this + */ + public function setEnabledCoupon(Coupon $enabledCoupon) + { + $this->enabledCoupon = $enabledCoupon; + + return $this; + } +} diff --git a/core/lib/Thelia/Model/Base/RewritingUrl.php b/core/lib/Thelia/Model/Base/RewritingUrl.php index 75ee97e79..a6bcd3a26 100644 --- a/core/lib/Thelia/Model/Base/RewritingUrl.php +++ b/core/lib/Thelia/Model/Base/RewritingUrl.php @@ -298,7 +298,7 @@ abstract class RewritingUrl implements ActiveRecordInterface */ public function hasVirtualColumn($name) { - return array_key_exists($name, $this->virtualColumns); + return isset($this->virtualColumns[$name]); } /** diff --git a/core/lib/Thelia/Tests/Constraint/Validator/CustomerParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/CustomerParamTest.php new file mode 100644 index 000000000..2cdec7846 --- /dev/null +++ b/core/lib/Thelia/Tests/Constraint/Validator/CustomerParamTest.php @@ -0,0 +1,161 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Coupon; + +use InvalidArgumentException; +use Thelia\Constraint\Validator\CustomerParam; +use Thelia\Constraint\Validator\PriceParam; +use Thelia\Constraint\Validator\QuantityParam; +use Thelia\Model\Customer; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Unit Test CustomerParam Class + * + * @package Constraint + * @author Guillaume MOREL + * + */ +class CustomerParamTest extends \PHPUnit_Framework_TestCase +{ + + /** @var CouponAdapterInterface $stubTheliaAdapter */ + protected $stubTheliaAdapter = null; + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $this->stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + } + + /** + * Generate valid CouponBaseAdapter + * + * @param int $customerId Customer id + * + * @return CouponAdapterInterface + */ + protected function generateValidCouponBaseAdapterMock($customerId = 4521) + { + $customer = new Customer(); + $customer->setId($customerId); + $customer->setFirstname('Firstname'); + $customer->setLastname('Lastname'); + $customer->setEmail('em@il.com'); + + /** @var CouponAdapterInterface $stubTheliaAdapter */ + $stubTheliaAdapter = $this->getMock( + 'Thelia\Coupon\CouponBaseAdapter', + array('getCustomer'), + array() + ); + $stubTheliaAdapter->expects($this->any()) + ->method('getCustomer') + ->will($this->returnValue($customer)); + + return $stubTheliaAdapter; + } + + /** + * + * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo + * + */ + public function testCanUseCoupon() + { + $customerId = 4521; + $couponValidForCustomerId = 4521; + + $adapter = $this->generateValidCouponBaseAdapterMock($customerId); + + $customerParam = new CustomerParam($adapter, $couponValidForCustomerId); + + $expected = 0; + $actual = $customerParam->compareTo($customerId); + $this->assertEquals($expected, $actual); + } + +// /** +// * +// * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo +// * +// */ +// public function testCanNotUseCouponTest() +// { +// +// } +// +// /** +// * +// * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo +// * @expectedException InvalidArgumentException +// * +// */ +// public function testCanNotUseCouponCustomerNotFoundTest() +// { +// +// } + + + + +// /** +// * Test is the object is serializable +// * If no data is lost during the process +// */ +// public function isSerializableTest() +// { +// $adapter = new CouponBaseAdapter(); +// $intValidator = 42; +// $intToValidate = -1; +// +// $param = new QuantityParam($adapter, $intValidator); +// +// $serialized = base64_encode(serialize($param)); +// /** @var QuantityParam $unserialized */ +// $unserialized = base64_decode(serialize($serialized)); +// +// $this->assertEquals($param->getValue(), $unserialized->getValue()); +// $this->assertEquals($param->getInteger(), $unserialized->getInteger()); +// +// $new = new QuantityParam($adapter, $unserialized->getInteger()); +// $this->assertEquals($param->getInteger(), $new->getInteger()); +// } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + +} From ed763344eca31d14283af3b6a6cff8c83d07f5cb Mon Sep 17 00:00:00 2001 From: mespeche Date: Thu, 29 Aug 2013 17:51:50 +0200 Subject: [PATCH 061/268] WIP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Début de mise en place de coupon/add (coupon/edit) --- .../js/bootstrap-datepicker.js | 474 ++++++++++++++++++ .../css/bootstrap-editable.css | 467 +---------------- templates/admin/default/assets/css/admin.less | 246 +++++++-- templates/admin/default/coupon/edit.html | 44 +- 4 files changed, 721 insertions(+), 510 deletions(-) create mode 100755 templates/admin/default/assets/bootstrap-datepicker/js/bootstrap-datepicker.js diff --git a/templates/admin/default/assets/bootstrap-datepicker/js/bootstrap-datepicker.js b/templates/admin/default/assets/bootstrap-datepicker/js/bootstrap-datepicker.js new file mode 100755 index 000000000..bf3a56df0 --- /dev/null +++ b/templates/admin/default/assets/bootstrap-datepicker/js/bootstrap-datepicker.js @@ -0,0 +1,474 @@ +/* ========================================================= + * bootstrap-datepicker.js + * http://www.eyecon.ro/bootstrap-datepicker + * ========================================================= + * Copyright 2012 Stefan Petre + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================= */ + +!function( $ ) { + + // Picker object + + var Datepicker = function(element, options){ + this.element = $(element); + this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy'); + this.picker = $(DPGlobal.template) + .appendTo('body') + .on({ + click: $.proxy(this.click, this)//, + //mousedown: $.proxy(this.mousedown, this) + }); + this.isInput = this.element.is('input'); + this.component = this.element.is('.date') ? this.element.find('.add-on') : false; + + if (this.isInput) { + this.element.on({ + focus: $.proxy(this.show, this), + //blur: $.proxy(this.hide, this), + keyup: $.proxy(this.update, this) + }); + } else { + if (this.component){ + this.component.on('click', $.proxy(this.show, this)); + } else { + this.element.on('click', $.proxy(this.show, this)); + } + } + + this.minViewMode = options.minViewMode||this.element.data('date-minviewmode')||0; + if (typeof this.minViewMode === 'string') { + switch (this.minViewMode) { + case 'months': + this.minViewMode = 1; + break; + case 'years': + this.minViewMode = 2; + break; + default: + this.minViewMode = 0; + break; + } + } + this.viewMode = options.viewMode||this.element.data('date-viewmode')||0; + if (typeof this.viewMode === 'string') { + switch (this.viewMode) { + case 'months': + this.viewMode = 1; + break; + case 'years': + this.viewMode = 2; + break; + default: + this.viewMode = 0; + break; + } + } + this.startViewMode = this.viewMode; + this.weekStart = options.weekStart||this.element.data('date-weekstart')||0; + this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1; + this.onRender = options.onRender; + this.fillDow(); + this.fillMonths(); + this.update(); + this.showMode(); + }; + + Datepicker.prototype = { + constructor: Datepicker, + + show: function(e) { + this.picker.show(); + this.height = this.component ? this.component.outerHeight() : this.element.outerHeight(); + this.place(); + $(window).on('resize', $.proxy(this.place, this)); + if (e ) { + e.stopPropagation(); + e.preventDefault(); + } + if (!this.isInput) { + } + var that = this; + $(document).on('mousedown', function(ev){ + if ($(ev.target).closest('.datepicker').length == 0) { + that.hide(); + } + }); + this.element.trigger({ + type: 'show', + date: this.date + }); + }, + + hide: function(){ + this.picker.hide(); + $(window).off('resize', this.place); + this.viewMode = this.startViewMode; + this.showMode(); + if (!this.isInput) { + $(document).off('mousedown', this.hide); + } + //this.set(); + this.element.trigger({ + type: 'hide', + date: this.date + }); + }, + + set: function() { + var formated = DPGlobal.formatDate(this.date, this.format); + if (!this.isInput) { + if (this.component){ + this.element.find('input').prop('value', formated); + } + this.element.data('date', formated); + } else { + this.element.prop('value', formated); + } + }, + + setValue: function(newDate) { + if (typeof newDate === 'string') { + this.date = DPGlobal.parseDate(newDate, this.format); + } else { + this.date = new Date(newDate); + } + this.set(); + this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0); + this.fill(); + }, + + place: function(){ + var offset = this.component ? this.component.offset() : this.element.offset(); + this.picker.css({ + top: offset.top + this.height, + left: offset.left + }); + }, + + update: function(newDate){ + this.date = DPGlobal.parseDate( + typeof newDate === 'string' ? newDate : (this.isInput ? this.element.prop('value') : this.element.data('date')), + this.format + ); + this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0); + this.fill(); + }, + + fillDow: function(){ + var dowCnt = this.weekStart; + var html = ''; + while (dowCnt < this.weekStart + 7) { + html += ''+DPGlobal.dates.daysMin[(dowCnt++)%7]+''; + } + html += ''; + this.picker.find('.datepicker-days thead').append(html); + }, + + fillMonths: function(){ + var html = ''; + var i = 0 + while (i < 12) { + html += ''+DPGlobal.dates.monthsShort[i++]+''; + } + this.picker.find('.datepicker-months td').append(html); + }, + + fill: function() { + var d = new Date(this.viewDate), + year = d.getFullYear(), + month = d.getMonth(), + currentDate = this.date.valueOf(); + this.picker.find('.datepicker-days th:eq(1)') + .text(DPGlobal.dates.months[month]+' '+year); + var prevMonth = new Date(year, month-1, 28,0,0,0,0), + day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth()); + prevMonth.setDate(day); + prevMonth.setDate(day - (prevMonth.getDay() - this.weekStart + 7)%7); + var nextMonth = new Date(prevMonth); + nextMonth.setDate(nextMonth.getDate() + 42); + nextMonth = nextMonth.valueOf(); + var html = []; + var clsName, + prevY, + prevM; + while(prevMonth.valueOf() < nextMonth) { + if (prevMonth.getDay() === this.weekStart) { + html.push(''); + } + clsName = this.onRender(prevMonth); + prevY = prevMonth.getFullYear(); + prevM = prevMonth.getMonth(); + if ((prevM < month && prevY === year) || prevY < year) { + clsName += ' old'; + } else if ((prevM > month && prevY === year) || prevY > year) { + clsName += ' new'; + } + if (prevMonth.valueOf() === currentDate) { + clsName += ' active'; + } + html.push(''+prevMonth.getDate() + ''); + if (prevMonth.getDay() === this.weekEnd) { + html.push(''); + } + prevMonth.setDate(prevMonth.getDate()+1); + } + this.picker.find('.datepicker-days tbody').empty().append(html.join('')); + var currentYear = this.date.getFullYear(); + + var months = this.picker.find('.datepicker-months') + .find('th:eq(1)') + .text(year) + .end() + .find('span').removeClass('active'); + if (currentYear === year) { + months.eq(this.date.getMonth()).addClass('active'); + } + + html = ''; + year = parseInt(year/10, 10) * 10; + var yearCont = this.picker.find('.datepicker-years') + .find('th:eq(1)') + .text(year + '-' + (year + 9)) + .end() + .find('td'); + year -= 1; + for (var i = -1; i < 11; i++) { + html += ''+year+''; + year += 1; + } + yearCont.html(html); + }, + + click: function(e) { + e.stopPropagation(); + e.preventDefault(); + var target = $(e.target).closest('span, td, th'); + if (target.length === 1) { + switch(target[0].nodeName.toLowerCase()) { + case 'th': + switch(target[0].className) { + case 'switch': + this.showMode(1); + break; + case 'prev': + case 'next': + this.viewDate['set'+DPGlobal.modes[this.viewMode].navFnc].call( + this.viewDate, + this.viewDate['get'+DPGlobal.modes[this.viewMode].navFnc].call(this.viewDate) + + DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1) + ); + this.fill(); + this.set(); + break; + } + break; + case 'span': + if (target.is('.month')) { + var month = target.parent().find('span').index(target); + this.viewDate.setMonth(month); + } else { + var year = parseInt(target.text(), 10)||0; + this.viewDate.setFullYear(year); + } + if (this.viewMode !== 0) { + this.date = new Date(this.viewDate); + this.element.trigger({ + type: 'changeDate', + date: this.date, + viewMode: DPGlobal.modes[this.viewMode].clsName + }); + } + this.showMode(-1); + this.fill(); + this.set(); + break; + case 'td': + if (target.is('.day') && !target.is('.disabled')){ + var day = parseInt(target.text(), 10)||1; + var month = this.viewDate.getMonth(); + if (target.is('.old')) { + month -= 1; + } else if (target.is('.new')) { + month += 1; + } + var year = this.viewDate.getFullYear(); + this.date = new Date(year, month, day,0,0,0,0); + this.viewDate = new Date(year, month, Math.min(28, day),0,0,0,0); + this.fill(); + this.set(); + this.element.trigger({ + type: 'changeDate', + date: this.date, + viewMode: DPGlobal.modes[this.viewMode].clsName + }); + } + break; + } + } + }, + + mousedown: function(e){ + e.stopPropagation(); + e.preventDefault(); + }, + + showMode: function(dir) { + if (dir) { + this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir)); + } + this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show(); + } + }; + + $.fn.datepicker = function ( option, val ) { + return this.each(function () { + var $this = $(this), + data = $this.data('datepicker'), + options = typeof option === 'object' && option; + if (!data) { + $this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options)))); + } + if (typeof option === 'string') data[option](val); + }); + }; + + $.fn.datepicker.defaults = { + onRender: function(date) { + return ''; + } + }; + $.fn.datepicker.Constructor = Datepicker; + + var DPGlobal = { + modes: [ + { + clsName: 'days', + navFnc: 'Month', + navStep: 1 + }, + { + clsName: 'months', + navFnc: 'FullYear', + navStep: 1 + }, + { + clsName: 'years', + navFnc: 'FullYear', + navStep: 10 + }], + dates:{ + days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], + daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], + daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"], + months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], + monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] + }, + isLeapYear: function (year) { + return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0)) + }, + getDaysInMonth: function (year, month) { + return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month] + }, + parseFormat: function(format){ + var separator = format.match(/[.\/\-\s].*?/), + parts = format.split(/\W+/); + if (!separator || !parts || parts.length === 0){ + throw new Error("Invalid date format."); + } + return {separator: separator, parts: parts}; + }, + parseDate: function(date, format) { + var parts = date.split(format.separator), + date = new Date(), + val; + date.setHours(0); + date.setMinutes(0); + date.setSeconds(0); + date.setMilliseconds(0); + if (parts.length === format.parts.length) { + var year = date.getFullYear(), day = date.getDate(), month = date.getMonth(); + for (var i=0, cnt = format.parts.length; i < cnt; i++) { + val = parseInt(parts[i], 10)||1; + switch(format.parts[i]) { + case 'dd': + case 'd': + day = val; + date.setDate(val); + break; + case 'mm': + case 'm': + month = val - 1; + date.setMonth(val - 1); + break; + case 'yy': + year = 2000 + val; + date.setFullYear(2000 + val); + break; + case 'yyyy': + year = val; + date.setFullYear(val); + break; + } + } + date = new Date(year, month, day, 0 ,0 ,0); + } + return date; + }, + formatDate: function(date, format){ + var val = { + d: date.getDate(), + m: date.getMonth() + 1, + yy: date.getFullYear().toString().substring(2), + yyyy: date.getFullYear() + }; + val.dd = (val.d < 10 ? '0' : '') + val.d; + val.mm = (val.m < 10 ? '0' : '') + val.m; + var date = []; + for (var i=0, cnt = format.parts.length; i < cnt; i++) { + date.push(val[format.parts[i]]); + } + return date.join(format.separator); + }, + headTemplate: ''+ + ''+ + '‹'+ + ''+ + '›'+ + ''+ + '', + contTemplate: '' + }; + DPGlobal.template = ''; + +}( window.jQuery ); \ No newline at end of file diff --git a/templates/admin/default/assets/bootstrap-editable/css/bootstrap-editable.css b/templates/admin/default/assets/bootstrap-editable/css/bootstrap-editable.css index 2d9cc4eae..faebd0543 100755 --- a/templates/admin/default/assets/bootstrap-editable/css/bootstrap-editable.css +++ b/templates/admin/default/assets/bootstrap-editable/css/bootstrap-editable.css @@ -1,8 +1,8 @@ -/*! X-editable - v1.4.6 -* In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery -* http://github.com/vitalets/x-editable -* Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */ - +/*! X-editable - v1.4.6 +* In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery +* http://github.com/vitalets/x-editable +* Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */ + .editableform { margin-bottom: 0; /* overwrites bootstrap margin */ } @@ -137,7 +137,7 @@ .editable-pre-wrapped { white-space: pre-wrap; -} +} .editable-container.editable-popup { max-width: none !important; /* without this rule poshytip/tooltip does not stretch */ } @@ -158,7 +158,7 @@ .editable-container.ui-widget { font-size: inherit; /* jqueryui widget font 1.1em too big, overwrite it */ z-index: 9990; /* should be less than select2 dropdown z-index to close dropdown first when click */ -} +} .editable-click, a.editable-click, a.editable-click:hover { @@ -202,455 +202,4 @@ a.editable-click.editable-disabled:hover { { padding-top: 5px; display:inline-block; -} - - -/*! - * Datepicker for Bootstrap - * - * Copyright 2012 Stefan Petre - * Improvements by Andrew Rowls - * Licensed under the Apache License v2.0 - * http://www.apache.org/licenses/LICENSE-2.0 - * - */ -.datepicker { - padding: 4px; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - direction: ltr; - /*.dow { - border-top: 1px solid #ddd !important; - }*/ - -} -.datepicker-inline { - width: 220px; -} -.datepicker.datepicker-rtl { - direction: rtl; -} -.datepicker.datepicker-rtl table tr td span { - float: right; -} -.datepicker-dropdown { - top: 0; - left: 0; -} -.datepicker-dropdown:before { - content: ''; - display: inline-block; - border-left: 7px solid transparent; - border-right: 7px solid transparent; - border-bottom: 7px solid #ccc; - border-bottom-color: rgba(0, 0, 0, 0.2); - position: absolute; - top: -7px; - left: 6px; -} -.datepicker-dropdown:after { - content: ''; - display: inline-block; - border-left: 6px solid transparent; - border-right: 6px solid transparent; - border-bottom: 6px solid #ffffff; - position: absolute; - top: -6px; - left: 7px; -} -.datepicker > div { - display: none; -} -.datepicker.days div.datepicker-days { - display: block; -} -.datepicker.months div.datepicker-months { - display: block; -} -.datepicker.years div.datepicker-years { - display: block; -} -.datepicker table { - margin: 0; -} -.datepicker td, -.datepicker th { - text-align: center; - width: 20px; - height: 20px; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - border: none; -} -.table-striped .datepicker table tr td, -.table-striped .datepicker table tr th { - background-color: transparent; -} -.datepicker table tr td.day:hover { - background: #eeeeee; - cursor: pointer; -} -.datepicker table tr td.old, -.datepicker table tr td.new { - color: #999999; -} -.datepicker table tr td.disabled, -.datepicker table tr td.disabled:hover { - background: none; - color: #999999; - cursor: default; -} -.datepicker table tr td.today, -.datepicker table tr td.today:hover, -.datepicker table tr td.today.disabled, -.datepicker table tr td.today.disabled:hover { - background-color: #fde19a; - background-image: -moz-linear-gradient(top, #fdd49a, #fdf59a); - background-image: -ms-linear-gradient(top, #fdd49a, #fdf59a); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fdd49a), to(#fdf59a)); - background-image: -webkit-linear-gradient(top, #fdd49a, #fdf59a); - background-image: -o-linear-gradient(top, #fdd49a, #fdf59a); - background-image: linear-gradient(top, #fdd49a, #fdf59a); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdd49a', endColorstr='#fdf59a', GradientType=0); - border-color: #fdf59a #fdf59a #fbed50; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); - color: #000; -} -.datepicker table tr td.today:hover, -.datepicker table tr td.today:hover:hover, -.datepicker table tr td.today.disabled:hover, -.datepicker table tr td.today.disabled:hover:hover, -.datepicker table tr td.today:active, -.datepicker table tr td.today:hover:active, -.datepicker table tr td.today.disabled:active, -.datepicker table tr td.today.disabled:hover:active, -.datepicker table tr td.today.active, -.datepicker table tr td.today:hover.active, -.datepicker table tr td.today.disabled.active, -.datepicker table tr td.today.disabled:hover.active, -.datepicker table tr td.today.disabled, -.datepicker table tr td.today:hover.disabled, -.datepicker table tr td.today.disabled.disabled, -.datepicker table tr td.today.disabled:hover.disabled, -.datepicker table tr td.today[disabled], -.datepicker table tr td.today:hover[disabled], -.datepicker table tr td.today.disabled[disabled], -.datepicker table tr td.today.disabled:hover[disabled] { - background-color: #fdf59a; -} -.datepicker table tr td.today:active, -.datepicker table tr td.today:hover:active, -.datepicker table tr td.today.disabled:active, -.datepicker table tr td.today.disabled:hover:active, -.datepicker table tr td.today.active, -.datepicker table tr td.today:hover.active, -.datepicker table tr td.today.disabled.active, -.datepicker table tr td.today.disabled:hover.active { - background-color: #fbf069 \9; -} -.datepicker table tr td.today:hover:hover { - color: #000; -} -.datepicker table tr td.today.active:hover { - color: #fff; -} -.datepicker table tr td.range, -.datepicker table tr td.range:hover, -.datepicker table tr td.range.disabled, -.datepicker table tr td.range.disabled:hover { - background: #eeeeee; - -webkit-border-radius: 0; - -moz-border-radius: 0; - border-radius: 0; -} -.datepicker table tr td.range.today, -.datepicker table tr td.range.today:hover, -.datepicker table tr td.range.today.disabled, -.datepicker table tr td.range.today.disabled:hover { - background-color: #f3d17a; - background-image: -moz-linear-gradient(top, #f3c17a, #f3e97a); - background-image: -ms-linear-gradient(top, #f3c17a, #f3e97a); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f3c17a), to(#f3e97a)); - background-image: -webkit-linear-gradient(top, #f3c17a, #f3e97a); - background-image: -o-linear-gradient(top, #f3c17a, #f3e97a); - background-image: linear-gradient(top, #f3c17a, #f3e97a); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f3c17a', endColorstr='#f3e97a', GradientType=0); - border-color: #f3e97a #f3e97a #edde34; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); - -webkit-border-radius: 0; - -moz-border-radius: 0; - border-radius: 0; -} -.datepicker table tr td.range.today:hover, -.datepicker table tr td.range.today:hover:hover, -.datepicker table tr td.range.today.disabled:hover, -.datepicker table tr td.range.today.disabled:hover:hover, -.datepicker table tr td.range.today:active, -.datepicker table tr td.range.today:hover:active, -.datepicker table tr td.range.today.disabled:active, -.datepicker table tr td.range.today.disabled:hover:active, -.datepicker table tr td.range.today.active, -.datepicker table tr td.range.today:hover.active, -.datepicker table tr td.range.today.disabled.active, -.datepicker table tr td.range.today.disabled:hover.active, -.datepicker table tr td.range.today.disabled, -.datepicker table tr td.range.today:hover.disabled, -.datepicker table tr td.range.today.disabled.disabled, -.datepicker table tr td.range.today.disabled:hover.disabled, -.datepicker table tr td.range.today[disabled], -.datepicker table tr td.range.today:hover[disabled], -.datepicker table tr td.range.today.disabled[disabled], -.datepicker table tr td.range.today.disabled:hover[disabled] { - background-color: #f3e97a; -} -.datepicker table tr td.range.today:active, -.datepicker table tr td.range.today:hover:active, -.datepicker table tr td.range.today.disabled:active, -.datepicker table tr td.range.today.disabled:hover:active, -.datepicker table tr td.range.today.active, -.datepicker table tr td.range.today:hover.active, -.datepicker table tr td.range.today.disabled.active, -.datepicker table tr td.range.today.disabled:hover.active { - background-color: #efe24b \9; -} -.datepicker table tr td.selected, -.datepicker table tr td.selected:hover, -.datepicker table tr td.selected.disabled, -.datepicker table tr td.selected.disabled:hover { - background-color: #9e9e9e; - background-image: -moz-linear-gradient(top, #b3b3b3, #808080); - background-image: -ms-linear-gradient(top, #b3b3b3, #808080); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#b3b3b3), to(#808080)); - background-image: -webkit-linear-gradient(top, #b3b3b3, #808080); - background-image: -o-linear-gradient(top, #b3b3b3, #808080); - background-image: linear-gradient(top, #b3b3b3, #808080); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#b3b3b3', endColorstr='#808080', GradientType=0); - border-color: #808080 #808080 #595959; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); - color: #fff; - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); -} -.datepicker table tr td.selected:hover, -.datepicker table tr td.selected:hover:hover, -.datepicker table tr td.selected.disabled:hover, -.datepicker table tr td.selected.disabled:hover:hover, -.datepicker table tr td.selected:active, -.datepicker table tr td.selected:hover:active, -.datepicker table tr td.selected.disabled:active, -.datepicker table tr td.selected.disabled:hover:active, -.datepicker table tr td.selected.active, -.datepicker table tr td.selected:hover.active, -.datepicker table tr td.selected.disabled.active, -.datepicker table tr td.selected.disabled:hover.active, -.datepicker table tr td.selected.disabled, -.datepicker table tr td.selected:hover.disabled, -.datepicker table tr td.selected.disabled.disabled, -.datepicker table tr td.selected.disabled:hover.disabled, -.datepicker table tr td.selected[disabled], -.datepicker table tr td.selected:hover[disabled], -.datepicker table tr td.selected.disabled[disabled], -.datepicker table tr td.selected.disabled:hover[disabled] { - background-color: #808080; -} -.datepicker table tr td.selected:active, -.datepicker table tr td.selected:hover:active, -.datepicker table tr td.selected.disabled:active, -.datepicker table tr td.selected.disabled:hover:active, -.datepicker table tr td.selected.active, -.datepicker table tr td.selected:hover.active, -.datepicker table tr td.selected.disabled.active, -.datepicker table tr td.selected.disabled:hover.active { - background-color: #666666 \9; -} -.datepicker table tr td.active, -.datepicker table tr td.active:hover, -.datepicker table tr td.active.disabled, -.datepicker table tr td.active.disabled:hover { - background-color: #006dcc; - background-image: -moz-linear-gradient(top, #0088cc, #0044cc); - background-image: -ms-linear-gradient(top, #0088cc, #0044cc); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); - background-image: -webkit-linear-gradient(top, #0088cc, #0044cc); - background-image: -o-linear-gradient(top, #0088cc, #0044cc); - background-image: linear-gradient(top, #0088cc, #0044cc); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0); - border-color: #0044cc #0044cc #002a80; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); - color: #fff; - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); -} -.datepicker table tr td.active:hover, -.datepicker table tr td.active:hover:hover, -.datepicker table tr td.active.disabled:hover, -.datepicker table tr td.active.disabled:hover:hover, -.datepicker table tr td.active:active, -.datepicker table tr td.active:hover:active, -.datepicker table tr td.active.disabled:active, -.datepicker table tr td.active.disabled:hover:active, -.datepicker table tr td.active.active, -.datepicker table tr td.active:hover.active, -.datepicker table tr td.active.disabled.active, -.datepicker table tr td.active.disabled:hover.active, -.datepicker table tr td.active.disabled, -.datepicker table tr td.active:hover.disabled, -.datepicker table tr td.active.disabled.disabled, -.datepicker table tr td.active.disabled:hover.disabled, -.datepicker table tr td.active[disabled], -.datepicker table tr td.active:hover[disabled], -.datepicker table tr td.active.disabled[disabled], -.datepicker table tr td.active.disabled:hover[disabled] { - background-color: #0044cc; -} -.datepicker table tr td.active:active, -.datepicker table tr td.active:hover:active, -.datepicker table tr td.active.disabled:active, -.datepicker table tr td.active.disabled:hover:active, -.datepicker table tr td.active.active, -.datepicker table tr td.active:hover.active, -.datepicker table tr td.active.disabled.active, -.datepicker table tr td.active.disabled:hover.active { - background-color: #003399 \9; -} -.datepicker table tr td span { - display: block; - width: 23%; - height: 54px; - line-height: 54px; - float: left; - margin: 1%; - cursor: pointer; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} -.datepicker table tr td span:hover { - background: #eeeeee; -} -.datepicker table tr td span.disabled, -.datepicker table tr td span.disabled:hover { - background: none; - color: #999999; - cursor: default; -} -.datepicker table tr td span.active, -.datepicker table tr td span.active:hover, -.datepicker table tr td span.active.disabled, -.datepicker table tr td span.active.disabled:hover { - background-color: #006dcc; - background-image: -moz-linear-gradient(top, #0088cc, #0044cc); - background-image: -ms-linear-gradient(top, #0088cc, #0044cc); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); - background-image: -webkit-linear-gradient(top, #0088cc, #0044cc); - background-image: -o-linear-gradient(top, #0088cc, #0044cc); - background-image: linear-gradient(top, #0088cc, #0044cc); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0); - border-color: #0044cc #0044cc #002a80; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); - color: #fff; - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); -} -.datepicker table tr td span.active:hover, -.datepicker table tr td span.active:hover:hover, -.datepicker table tr td span.active.disabled:hover, -.datepicker table tr td span.active.disabled:hover:hover, -.datepicker table tr td span.active:active, -.datepicker table tr td span.active:hover:active, -.datepicker table tr td span.active.disabled:active, -.datepicker table tr td span.active.disabled:hover:active, -.datepicker table tr td span.active.active, -.datepicker table tr td span.active:hover.active, -.datepicker table tr td span.active.disabled.active, -.datepicker table tr td span.active.disabled:hover.active, -.datepicker table tr td span.active.disabled, -.datepicker table tr td span.active:hover.disabled, -.datepicker table tr td span.active.disabled.disabled, -.datepicker table tr td span.active.disabled:hover.disabled, -.datepicker table tr td span.active[disabled], -.datepicker table tr td span.active:hover[disabled], -.datepicker table tr td span.active.disabled[disabled], -.datepicker table tr td span.active.disabled:hover[disabled] { - background-color: #0044cc; -} -.datepicker table tr td span.active:active, -.datepicker table tr td span.active:hover:active, -.datepicker table tr td span.active.disabled:active, -.datepicker table tr td span.active.disabled:hover:active, -.datepicker table tr td span.active.active, -.datepicker table tr td span.active:hover.active, -.datepicker table tr td span.active.disabled.active, -.datepicker table tr td span.active.disabled:hover.active { - background-color: #003399 \9; -} -.datepicker table tr td span.old, -.datepicker table tr td span.new { - color: #999999; -} -.datepicker th.datepicker-switch { - width: 145px; -} -.datepicker thead tr:first-child th, -.datepicker tfoot tr th { - cursor: pointer; -} -.datepicker thead tr:first-child th:hover, -.datepicker tfoot tr th:hover { - background: #eeeeee; -} -.datepicker .cw { - font-size: 10px; - width: 12px; - padding: 0 2px 0 5px; - vertical-align: middle; -} -.datepicker thead tr:first-child th.cw { - cursor: default; - background-color: transparent; -} -.input-append.date .add-on i, -.input-prepend.date .add-on i { - display: block; - cursor: pointer; - width: 16px; - height: 16px; -} -.input-daterange input { - text-align: center; -} -.input-daterange input:first-child { - -webkit-border-radius: 3px 0 0 3px; - -moz-border-radius: 3px 0 0 3px; - border-radius: 3px 0 0 3px; -} -.input-daterange input:last-child { - -webkit-border-radius: 0 3px 3px 0; - -moz-border-radius: 0 3px 3px 0; - border-radius: 0 3px 3px 0; -} -.input-daterange .add-on { - display: inline-block; - width: auto; - min-width: 16px; - height: 18px; - padding: 4px 5px; - font-weight: normal; - line-height: 18px; - text-align: center; - text-shadow: 0 1px 0 #ffffff; - vertical-align: middle; - background-color: #eeeeee; - border: 1px solid #ccc; - margin-left: -5px; - margin-right: -5px; -} +} \ No newline at end of file diff --git a/templates/admin/default/assets/css/admin.less b/templates/admin/default/assets/css/admin.less index 0f1d499ce..a9ca23bf1 100755 --- a/templates/admin/default/assets/css/admin.less +++ b/templates/admin/default/assets/css/admin.less @@ -1,31 +1,31 @@ // -- Tools -------------------------------------------------------------------- .rounded(@radius: 2px) { - -webkit-border-radius: @radius; - -moz-border-radius: @radius; - border-radius: @radius; + -webkit-border-radius: @radius; + -moz-border-radius: @radius; + border-radius: @radius; } .border-radius(@topright: 0, @bottomright: 0, @bottomleft: 0, @topleft: 0) { - -webkit-border-top-right-radius: @topright; - -webkit-border-bottom-right-radius: @bottomright; - -webkit-border-bottom-left-radius: @bottomleft; - -webkit-border-top-left-radius: @topleft; - -moz-border-radius-topright: @topright; - -moz-border-radius-bottomright: @bottomright; - -moz-border-radius-bottomleft: @bottomleft; - -moz-border-radius-topleft: @topleft; - border-top-right-radius: @topright; - border-bottom-right-radius: @bottomright; - border-bottom-left-radius: @bottomleft; - border-top-left-radius: @topleft; - .background-clip(padding-box); + -webkit-border-top-right-radius: @topright; + -webkit-border-bottom-right-radius: @bottomright; + -webkit-border-bottom-left-radius: @bottomleft; + -webkit-border-top-left-radius: @topleft; + -moz-border-radius-topright: @topright; + -moz-border-radius-bottomright: @bottomright; + -moz-border-radius-bottomleft: @bottomleft; + -moz-border-radius-topleft: @topleft; + border-top-right-radius: @topright; + border-bottom-right-radius: @bottomright; + border-bottom-left-radius: @bottomleft; + border-top-left-radius: @topleft; + .background-clip(padding-box); } .background-clip(@argument: padding-box) { - -moz-background-clip: @argument; - -webkit-background-clip: @argument; - background-clip: @argument; + -moz-background-clip: @argument; + -webkit-background-clip: @argument; + background-clip: @argument; } .box-shadow(@shadow: 0 1px 2px rgba(0,0,0,.05)) { @@ -34,6 +34,75 @@ box-shadow: @shadow; } +// Gradients +#gradient { + .horizontal(@startColor: #555, @endColor: #333) { + background-color: @endColor; + background-image: -moz-linear-gradient(left, @startColor, @endColor); // FF 3.6+ + background-image: -webkit-gradient(linear, 0 0, 100% 0, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+ + background-image: -webkit-linear-gradient(left, @startColor, @endColor); // Safari 5.1+, Chrome 10+ + background-image: -o-linear-gradient(left, @startColor, @endColor); // Opera 11.10 + background-image: linear-gradient(to right, @startColor, @endColor); // Standard, IE10 + background-repeat: repeat-x; + filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(@startColor),argb(@endColor))); // IE9 and down + } + .vertical(@startColor: #555, @endColor: #333) { + background-color: mix(@startColor, @endColor, 60%); + background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+ + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+ + background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+ + background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10 + background-image: linear-gradient(to bottom, @startColor, @endColor); // Standard, IE10 + background-repeat: repeat-x; + filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor),argb(@endColor))); // IE9 and down + } + .directional(@startColor: #555, @endColor: #333, @deg: 45deg) { + background-color: @endColor; + background-repeat: repeat-x; + background-image: -moz-linear-gradient(@deg, @startColor, @endColor); // FF 3.6+ + background-image: -webkit-linear-gradient(@deg, @startColor, @endColor); // Safari 5.1+, Chrome 10+ + background-image: -o-linear-gradient(@deg, @startColor, @endColor); // Opera 11.10 + background-image: linear-gradient(@deg, @startColor, @endColor); // Standard, IE10 + } + .horizontal-three-colors(@startColor: #00b3ee, @midColor: #7a43b6, @colorStop: 50%, @endColor: #c3325f) { + background-color: mix(@midColor, @endColor, 80%); + background-image: -webkit-gradient(left, linear, 0 0, 0 100%, from(@startColor), color-stop(@colorStop, @midColor), to(@endColor)); + background-image: -webkit-linear-gradient(left, @startColor, @midColor @colorStop, @endColor); + background-image: -moz-linear-gradient(left, @startColor, @midColor @colorStop, @endColor); + background-image: -o-linear-gradient(left, @startColor, @midColor @colorStop, @endColor); + background-image: linear-gradient(to right, @startColor, @midColor @colorStop, @endColor); + background-repeat: no-repeat; + filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor),argb(@endColor))); // IE9 and down, gets no color-stop at all for proper fallback + } + + .vertical-three-colors(@startColor: #00b3ee, @midColor: #7a43b6, @colorStop: 50%, @endColor: #c3325f) { + background-color: mix(@midColor, @endColor, 80%); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), color-stop(@colorStop, @midColor), to(@endColor)); + background-image: -webkit-linear-gradient(@startColor, @midColor @colorStop, @endColor); + background-image: -moz-linear-gradient(top, @startColor, @midColor @colorStop, @endColor); + background-image: -o-linear-gradient(@startColor, @midColor @colorStop, @endColor); + background-image: linear-gradient(@startColor, @midColor @colorStop, @endColor); + background-repeat: no-repeat; + filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor),argb(@endColor))); // IE9 and down, gets no color-stop at all for proper fallback + } + .radial(@innerColor: #555, @outerColor: #333) { + background-color: @outerColor; + background-image: -webkit-gradient(radial, center center, 0, center center, 460, from(@innerColor), to(@outerColor)); + background-image: -webkit-radial-gradient(circle, @innerColor, @outerColor); + background-image: -moz-radial-gradient(circle, @innerColor, @outerColor); + background-image: -o-radial-gradient(circle, @innerColor, @outerColor); + background-repeat: no-repeat; + } + .striped(@color: #555, @angle: 45deg) { + background-color: @color; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, rgba(255,255,255,.15)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255,255,255,.15)), color-stop(.75, rgba(255,255,255,.15)), color-stop(.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent); + } +} + // -- Base styling ------------------------------------------------------------ html, body { @@ -89,37 +158,13 @@ hr { } .btn-primary, .btn-large { - background: #e9730f; - background-image: linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -o-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -moz-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -webkit-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -ms-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -webkit-gradient( - linear, - left bottom, - left top, - color-stop(0, rgb(227,83,11)), - color-stop(1, rgb(243,153,34)) - ); + #gradient > .vertical(rgb(243,153,34), rgb(227,83,11)); box-shadow: inset 0px 0px 2px rgba(250,250,250,0.5), 0px 1px 3px rgba(0,0,0,0.2); color: white; } .btn-large:hover, .btn-primary:hover { - background: #e9730f; - background-image: linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -o-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -moz-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -webkit-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -ms-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -webkit-gradient( - linear, - left bottom, - left top, - color-stop(0, rgb(227,83,11)), - color-stop(1, rgb(243,153,34)) - ); + #gradient > .vertical(rgb(243,153,34), rgb(227,83,11)); box-shadow: inset 0px 0px 2px rgba(250,250,250,0.8), 0px 1px 3px rgba(0,0,0,0.2); color: white; } @@ -723,4 +768,115 @@ label { .editable-click, a.editable-click, a.editable-click:hover { border-bottom: 1px dotted #0088CC; +} + +// -- Boostrap datepicker ----------------------------------------------------- +.datepicker { + top: 0; + left: 0; + padding: 4px; + margin-top: 1px; + .rounded(4px); + &:before { + content: ''; + display: inline-block; + border-left: 7px solid transparent; + border-right: 7px solid transparent; + border-bottom: 7px solid #ccc; + border-bottom-color: rgba(0,0,0,.2); + position: absolute; + top: -7px; + left: 6px; + } + &:after { + content: ''; + display: inline-block; + border-left: 6px solid transparent; + border-right: 6px solid transparent; + border-bottom: 6px solid @white; + position: absolute; + top: -6px; + left: 7px; + } + >div { + display: none; + } + table{ + width: 100%; + margin: 0; + } + td, + th{ + text-align: center; + width: 20px; + height: 20px; + .rounded(4px); + } + td { + &.day:hover { + background: @grayLighter; + cursor: pointer; + } + &.day.disabled { + color: @grayLighter; + } + &.old, + &.new { + color: @grayLight; + } + &.active, + &.active:hover { + #gradient > .vertical(rgb(243,153,34), rgb(227,83,11)); + color: #fff; + text-shadow: 0 -1px 0 rgba(0,0,0,.25); + } + span { + display: block; + width: 47px; + height: 54px; + line-height: 54px; + float: left; + margin: 2px; + cursor: pointer; + .rounded(4px); + &:hover { + background: @grayLighter; + } + &.active { + #gradient > .vertical(rgb(243,153,34), rgb(227,83,11)); + color: #fff; + text-shadow: 0 -1px 0 rgba(0,0,0,.25); + } + &.old { + color: @grayLight; + } + } + } + + th { + &.switch { + width: 145px; + } + &.next, + &.prev { + font-size: @baseFontSize * 1.5; + } + } + + thead tr:first-child th { + cursor: pointer; + &:hover{ + background: @grayLighter; + } + } + +} +.input-append, +.input-prepend { + &.date { + .add-on span { + display: block; + cursor: pointer; + } + } } \ No newline at end of file diff --git a/templates/admin/default/coupon/edit.html b/templates/admin/default/coupon/edit.html index 74423013f..56c2b6229 100755 --- a/templates/admin/default/coupon/edit.html +++ b/templates/admin/default/coupon/edit.html @@ -23,8 +23,7 @@
      -
      - +
      @@ -51,9 +50,28 @@
      - +
      + + +
      +
      + + +
      +
      + +
      +
      + + + More description n°1 about item +
      @@ -65,11 +83,25 @@ {include file='includes/js.inc.html'} -{javascripts file='../assets/bootstrap-editable/js/bootstrap-editable.js'} - +{javascripts file='../assets/bootstrap-datepicker/js/bootstrap-datepicker.js'} + {/javascripts} -{include file='includes/footer.inc.html'} +{include file='includes/footer.inc.html'} \ No newline at end of file From db102a53290cc0139e459e1c2f9593ecc2dc7b24 Mon Sep 17 00:00:00 2001 From: mespeche Date: Fri, 30 Aug 2013 08:52:37 +0200 Subject: [PATCH 062/268] Working MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Supprésion de cette version de jQuery --- .../assets/js/tablesorter/jquery-latest.js | 154 ------------------ 1 file changed, 154 deletions(-) delete mode 100644 templates/admin/default/assets/js/tablesorter/jquery-latest.js diff --git a/templates/admin/default/assets/js/tablesorter/jquery-latest.js b/templates/admin/default/assets/js/tablesorter/jquery-latest.js deleted file mode 100644 index ac7e7009d..000000000 --- a/templates/admin/default/assets/js/tablesorter/jquery-latest.js +++ /dev/null @@ -1,154 +0,0 @@ -/*! - * jQuery JavaScript Library v1.4.2 - * http://jquery.com/ - * - * Copyright 2010, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2010, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Sat Feb 13 22:33:48 2010 -0500 - */ -(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/, -Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&& -(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this, -a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b=== -"find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this, -function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b
      a"; -var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected, -parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent= -false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n= -s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true, -applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando]; -else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this, -a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b=== -w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i, -cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected= -c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed"); -a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g, -function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split("."); -k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a), -C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B=0){a.type= -e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&& -f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive; -if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data", -e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a, -"_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a, -d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, -e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift(); -t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D|| -g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()}, -CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m, -g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)}, -text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}}, -setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return hl[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h= -h[3];l=0;for(m=h.length;l=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m=== -"="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g, -h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&& -q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML=""; -if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="

      ";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}(); -(function(){var g=s.createElement("div");g.innerHTML="
      ";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}: -function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f0)for(var j=d;j0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j= -{},i;if(f&&a.length){e=0;for(var o=a.length;e-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a=== -"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode", -d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")? -a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType=== -1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/"},F={option:[1,""],legend:[1,"
      ","
      "],thead:[1,"","
      "],tr:[2,"","
      "],td:[3,"","
      "],col:[2,"","
      "],area:[1,"",""],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div
      ","
      "];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d= -c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this}, -wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, -prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b, -this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild); -return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja, -""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]); -return this}else{e=0;for(var j=d.length;e0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["", -""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]===""&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e= -c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]? -c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja= -function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter= -Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a, -"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f= -a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b= -a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=//gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!== -"string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("
      ").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this}, -serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), -function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href, -global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&& -e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)? -"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache=== -false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B= -false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since", -c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E|| -d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x); -g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status=== -1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b=== -"json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional; -if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration=== -"number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]|| -c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start; -this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now= -this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem, -e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b
      "; -a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b); -c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a, -d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top- -f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset": -"pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in -e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window); From 0d4b992bc66c6c6885c52d6e1d758b8fa078c486 Mon Sep 17 00:00:00 2001 From: mespeche Date: Fri, 30 Aug 2013 08:54:03 +0200 Subject: [PATCH 063/268] WIP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Réorganisation des scripts --- templates/admin/default/coupon/list.html | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/templates/admin/default/coupon/list.html b/templates/admin/default/coupon/list.html index f5c7b1508..3b13d6eac 100755 --- a/templates/admin/default/coupon/list.html +++ b/templates/admin/default/coupon/list.html @@ -176,6 +176,10 @@ {/javascripts} +{javascripts file='../assets/js/tablesorter/jquery.tablesorter.min.js'} + +{/javascripts} + -{javascripts file='../assets/js/tablesorter/jquery.tablesorter.min.js'} - -{/javascripts} - - -{include file='includes/footer.inc.html'} +{include file='includes/footer.inc.html'} \ No newline at end of file From 4ba16dc2909586e03588cbd2085b5b5620e9afa0 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 30 Aug 2013 09:13:54 +0200 Subject: [PATCH 064/268] sid : rewriting --- .../Thelia/Rewriting/RewritingRetriever.php | 57 +++++++++++++++++-- .../Rewriting/RewritingRetrieverTest.php | 44 ++++++++++++++ core/lib/Thelia/Tests/Tools/URLTest.php | 39 +++++++++++++ core/lib/Thelia/Tools/URL.php | 34 +++++++++++ web/index_dev.php | 2 + 5 files changed, 170 insertions(+), 6 deletions(-) create mode 100755 core/lib/Thelia/Tests/Rewriting/RewritingRetrieverTest.php create mode 100755 core/lib/Thelia/Tests/Tools/URLTest.php diff --git a/core/lib/Thelia/Rewriting/RewritingRetriever.php b/core/lib/Thelia/Rewriting/RewritingRetriever.php index 5c49c4e2e..546b9d077 100755 --- a/core/lib/Thelia/Rewriting/RewritingRetriever.php +++ b/core/lib/Thelia/Rewriting/RewritingRetriever.php @@ -24,6 +24,7 @@ namespace Thelia\Rewriting; use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Model\Base\RewritingUrlQuery; +use Thelia\Model\Map\RewritingUrlTableMap; /** * Class RewritingRetriever @@ -36,7 +37,14 @@ class RewritingRetriever { public function getViewUrl($view, $viewId, $viewLocale) { - $url = RewritingUrlQuery::create() + $url = $this->getViewUrlQuery($view, $viewId, $viewLocale); + + return $url === null ? null : $url->getUrl(); + } + + protected function getViewUrlQuery($view, $viewId, $viewLocale) + { + return RewritingUrlQuery::create() ->joinRewritingArgument('ra', Criteria::LEFT_JOIN) ->where('ISNULL(`ra`.REWRITING_URL_ID)') ->filterByView($view) @@ -45,12 +53,49 @@ class RewritingRetriever ->filterByRedirected(null) ->orderByUpdatedAt(Criteria::DESC) ->findOne(); + } + + public function getSpecificUrl($view = null, $viewId = null, $viewLocale = null, $viewOtherParameters = array()) + { + $urlQuery = RewritingUrlQuery::create() + ->joinRewritingArgument('ra', Criteria::LEFT_JOIN) + ->withColumn('`ra`.PARAMETER', 'ra_parameter') + ->withColumn('`ra`.VALUE', 'ra_value') + ->filterByView($view) + ->filterByViewId($viewId) + ->filterByViewLocale($viewLocale) + ->filterByRedirected(null) + ->orderByUpdatedAt(Criteria::DESC); + + $otherParametersCount = count($viewOtherParameters); + if($otherParametersCount > 0) { + $parameterConditions = array(); + foreach($viewOtherParameters as $parameter => $value) { + $conditionName = 'other_parameter_condition_' . count($parameterConditions); + $urlQuery->condition('parameter_condition', '`ra_parameter`= ?', $parameter, \PDO::PARAM_STR) + ->condition('value_condition', '`ra_value` = ?', $value, \PDO::PARAM_STR) + ->combine(array('parameter_condition', 'value_condition'), Criteria::LOGICAL_AND, $conditionName); + $parameterConditions[] = $conditionName; + } + + $urlQuery->combine($parameterConditions, Criteria::LOGICAL_OR, 'parameter_full_condition'); + + $urlQuery->groupBy(RewritingUrlTableMap::ID); + + $urlQuery->condition('count_condition', 'COUNT(' . RewritingUrlTableMap::ID . ') = ?', $otherParametersCount, \PDO::PARAM_INT) + ->combine(array('count_condition', 'parameter_full_condition'), Criteria::LOGICAL_AND, 'full_having_condition'); + + + $urlQuery + ->having(array('full_having_condition')) + //->having('COUNT(' . RewritingUrlTableMap::ID . ') = ?', $otherParametersCount, \PDO::PARAM_INT) + ; + } else { + $urlQuery->where('ISNULL(`ra`.REWRITING_URL_ID)'); + } + + $url = $urlQuery->findOne(); return $url === null ? null : $url->getUrl(); } - - /*public function getSpecificUrl($view, $viewId, $viewLocale, $viewOtherParameters = array()) - { - - }*/ } diff --git a/core/lib/Thelia/Tests/Rewriting/RewritingRetrieverTest.php b/core/lib/Thelia/Tests/Rewriting/RewritingRetrieverTest.php new file mode 100755 index 000000000..741c22b4e --- /dev/null +++ b/core/lib/Thelia/Tests/Rewriting/RewritingRetrieverTest.php @@ -0,0 +1,44 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Rewriting; + +use Thelia\Rewriting\RewritingRetriever; + +/** + * + * @author Etienne Roudeix + * + */ +class RewritingRetrieverTest extends \PHPUnit_Framework_TestCase +{ + public function testGetViewUrl() + { + + } + + public function testGetSpecificUrl() + { + + } +} diff --git a/core/lib/Thelia/Tests/Tools/URLTest.php b/core/lib/Thelia/Tests/Tools/URLTest.php new file mode 100755 index 000000000..0c99651b4 --- /dev/null +++ b/core/lib/Thelia/Tests/Tools/URLTest.php @@ -0,0 +1,39 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Type; + +use Thelia\Tools\URL; + +/** + * + * @author Etienne Roudeix + * + */ +class URLTest extends \PHPUnit_Framework_TestCase +{ + public function testRetrieve() + { + + } +} diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index 01958bc1c..267e5554c 100755 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -23,6 +23,7 @@ namespace Thelia\Tools; +use Symfony\Component\HttpFoundation\Request; use Thelia\Model\ConfigQuery; use Thelia\Rewriting\RewritingRetriever; @@ -103,6 +104,13 @@ class URL return self::absoluteUrl($path, $parameters); } + /** + * @param $view + * @param $viewId + * @param $viewLocale + * + * @return null|string + */ public static function retrieve($view, $viewId, $viewLocale) { $rewrittenUrl = null; @@ -113,4 +121,30 @@ class URL return $rewrittenUrl === null ? self::viewUrl($view, array($view . '_id' => $viewId, 'locale' => $viewLocale)) : $rewrittenUrl; } + + public static function retrieveCurrent(Request $request) + { + $rewrittenUrl = null; + if(ConfigQuery::isRewritingEnable()) { + $view = $request->query->get('view', null); + $viewId = $view === null ? null : $request->query->get($view . '_id', null); + $viewLocale = $request->query->get('locale', null); + + $allOtherParameters = $request->query->all(); + if($view !== null) { + unset($allOtherParameters['view']); + } + if($viewId !== null) { + unset($allOtherParameters[$view . '_id']); + } + if($viewLocale !== null) { + unset($allOtherParameters['locale']); + } + + $retriever = new RewritingRetriever(); + $rewrittenUrl = $retriever->getSpecificUrl($view, $viewId, $viewLocale, $allOtherParameters); + } + + return $rewrittenUrl === null ? self::viewUrl($view, array($view . '_id' => $viewId, 'locale' => $viewLocale)) : $rewrittenUrl; + } } diff --git a/web/index_dev.php b/web/index_dev.php index 8991dc4a8..b5a98978a 100755 --- a/web/index_dev.php +++ b/web/index_dev.php @@ -21,6 +21,8 @@ if ( false === in_array($request->getClientIp(), $trustIp)) { $thelia = new Thelia("dev", true); +\Thelia\Tools\URL::retrieveCurrent($request); + $response = $thelia->handle($request)->prepare($request)->send(); $thelia->terminate($request, $response); From 71fa04a1936d180a76a3e4a8edc026ad64f1b03e Mon Sep 17 00:00:00 2001 From: gmorel Date: Fri, 30 Aug 2013 11:06:33 +0200 Subject: [PATCH 065/268] WIP - Update Coupon Controller/Form/Event - create() - Rule serialization/unserialization managed in Model/Coupon now --- .../Controller/Admin/CouponController.php | 52 +++++- .../Core/Event/Coupon/CouponCreateEvent.php | 83 +++++---- .../Core/Event/Coupon/CouponEditEvent.php | 82 +++++++++ core/lib/Thelia/Core/Event/TheliaEvents.php | 52 ++++++ core/lib/Thelia/Form/CouponCreationForm.php | 168 ++++++++++++++++++ core/lib/Thelia/Model/Coupon.php | 70 +++++++- install/sqldb.map | 2 - 7 files changed, 463 insertions(+), 46 deletions(-) create mode 100644 core/lib/Thelia/Core/Event/Coupon/CouponEditEvent.php create mode 100755 core/lib/Thelia/Form/CouponCreationForm.php delete mode 100644 install/sqldb.map diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index b1cf197c8..a4555bfd2 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -23,8 +23,13 @@ namespace Thelia\Controller\Admin; +use Thelia\Core\Event\Coupon\CouponCreateEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\AuthorizationException; +use Thelia\Coupon\CouponRuleCollection; +use Thelia\Form\CouponCreationForm; +use Thelia\Model\Coupon; /** * Created by JetBrains PhpStorm. @@ -74,6 +79,52 @@ class CouponController extends BaseAdminController { $this->checkAuth("ADMIN", "admin.coupon.view"); + + if ($this->getRequest()->isMethod('POST')) { + + $couponCreationForm = new CouponCreationForm($this->getRequest()); + + $form = $this->validateForm($couponCreationForm, "POST"); + + $data = $form->getData(); + + $couponBeingCreated = new Coupon(); + $couponBeingCreated->setCode($data["code"]); + $couponBeingCreated->setType($data["type"]); + $couponBeingCreated->setTitle($data["title"]); + $couponBeingCreated->setShortDescription($data["shortDescription"]); + $couponBeingCreated->setDescription($data["description"]); + $couponBeingCreated->setAmount($data["amount"]); + $couponBeingCreated->setIsEnabled($data["isEnabled"]); + $couponBeingCreated->setExpirationDate($data["expirationDate"]); + $couponBeingCreated->setSerializedRules( + new CouponRuleCollection( + array() + ) + ); + $couponBeingCreated->setIsCumulative($data["isCumulative"]); + $couponBeingCreated->setIsRemovingPostage($data["isRemovingPostage"]); + $couponBeingCreated->setMaxUsage($data["maxUsage"]); + $couponBeingCreated->setIsAvailableOnSpecialOffers($data["isAvailableOnSpecialOffers"]); + + $couponCreateEvent = new CouponCreateEvent( + $couponBeingCreated + ); + + $this->dispatch(TheliaEvents::BEFORE_CREATE_COUPON, $couponCreateEvent); + // @todo Save + $this->adminLogAppend( + sprintf( + 'Coupon %s (ID %s) created', + $couponBeingCreated->getTitle(), + $couponBeingCreated->getId() + ) + ); + $this->dispatch(TheliaEvents::AFTER_CREATE_COUPON, $couponCreateEvent); + } else { + + } + return $this->render('coupon/edit', $args); } @@ -114,7 +165,6 @@ class CouponController extends BaseAdminController */ public function processAction() { - var_dump($this->getRequest()->attributes); // Get the current action $action = $this->getRequest()->get('action', 'browse'); diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponCreateEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponCreateEvent.php index c03e21f17..9f0db34df 100644 --- a/core/lib/Thelia/Core/Event/Coupon/CouponCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Coupon/CouponCreateEvent.php @@ -22,61 +22,60 @@ /**********************************************************************************/ namespace Thelia\Core\Event\Coupon; - +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Coupon; +/** + * Created by JetBrains PhpStorm. + * Date: 8/29/13 + * Time: 3:45 PM + * + * Occurring when a Coupon is created + * + * @package Coupon + * @author Guillaume MOREL + * + */ class CouponCreateEvent extends ActionEvent { - protected $title; - protected $parent; - protected $locale; - protected $created_category; + /** + * @var Coupon Coupon being created + */ + protected $createdCoupon; - public function __construct($title, $parent, $locale) + /** + * Constructor + * + * @param Coupon $coupon Coupon being created + */ + public function __construct(Coupon $coupon) { - $this->title = $title; - $this->parent = $parent; - $this->locale = $locale; + $this->createdCoupon = $coupon; } - public function getTitle() + /** + * Modify Coupon being created + * + * @param Coupon $createdCoupon Coupon being created + * + * @return $this + */ + public function setCreatedCoupon(Coupon $createdCoupon) { - return $this->title; + $this->createdCoupon = $createdCoupon; + + return $this; } - public function setTitle($title) + /** + * Get Coupon being created + * + * @return Coupon + */ + public function getCreatedCoupon() { - $this->title = $title; + return clone $this->createdCoupon; } - public function getParent() - { - return $this->parent; - } - public function setParent($parent) - { - $this->parent = $parent; - } - - public function getLocale() - { - return $this->locale; - } - - public function setLocale($locale) - { - $this->locale = $locale; - } - - public function getCreatedCategory() - { - return $this->created_category; - } - - public function setCreatedCategory(Category $created_category) - { - $this->created_category = $created_category; -var_dump($this->created_category); - } } diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponEditEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponEditEvent.php new file mode 100644 index 000000000..bdde56c40 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Coupon/CouponEditEvent.php @@ -0,0 +1,82 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Core\Event\Coupon; +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\Coupon; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/29/13 + * Time: 3:45 PM + * + * Occurring when a Coupon is edited + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class CouponEditEvent extends ActionEvent +{ + /** @var int Coupon being edited id */ + protected $couponId; + + /** @var Coupon Coupon being created */ + protected $editedCoupon; + + /** + * Constructor + * + * @param Coupon $coupon Coupon being edited + */ + public function __construct(Coupon $coupon) + { + $this->created_coupon = $coupon; + } + + /** + * Modify Coupon being created + * + * @param Coupon $editedCoupon Coupon being created + * + * @return $this + */ + public function setCreatedCoupon(Coupon $editedCoupon) + { + $this->editedCoupon = $editedCoupon; + + return $this; + } + + /** + * Get Coupon being created + * + * @return Coupon + */ + public function getCreatedCoupon() + { + return clone $this->editedCoupon; + } + + +} diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 2dd85905d..ba0d97d2f 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -177,4 +177,56 @@ final class TheliaEvents * Sent on cimage cache clear request */ const IMAGE_CLEAR_CACHE = "action.clearImageCache"; + + + /** + * Sent just before a successful insert of a new Coupon in the database. + */ + + const BEFORE_CREATE_COUPON = "action.before_create_coupon"; + + /** + * Sent just after a successful insert of a new Coupon in the database. + */ + const AFTER_CREATE_COUPON = "action.after_create_coupon"; + + /** + * Sent just before a successful update of a new Coupon in the database. + */ + const BEFORE_EDIT_COUPON = "action.before_edit_coupon"; + + /** + * Sent just after a successful update of a new Coupon in the database. + */ + const AFTER_EDIT_COUPON = "action.after_edit_coupon"; + + /** + * Sent just before a successful disable of a new Coupon in the database. + */ + const BEFORE_DISABLE_COUPON = "action.before_disable_coupon"; + + /** + * Sent just after a successful disable of a new Coupon in the database. + */ + const AFTER_DISABLE_COUPON = "action.after_disable_coupon"; + + /** + * Sent just before a successful enable of a new Coupon in the database. + */ + const BEFORE_ENABLE_COUPON = "action.before_enable_coupon"; + + /** + * Sent just after a successful enable of a new Coupon in the database. + */ + const AFTER_ENABLE_COUPON = "action.after_enable_coupon"; + + /** + * Sent just before an attempt to use a Coupon + */ + const BEFORE_USE_COUPON = "action.before_use_coupon"; + + /** + * Sent just after an attempt to use a Coupon + */ + const AFTER_USE_COUPON = "action.after_use_coupon"; } diff --git a/core/lib/Thelia/Form/CouponCreationForm.php b/core/lib/Thelia/Form/CouponCreationForm.php new file mode 100755 index 000000000..39667cfdb --- /dev/null +++ b/core/lib/Thelia/Form/CouponCreationForm.php @@ -0,0 +1,168 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\NotBlank; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/29/13 + * Time: 3:45 PM + * + * Allow to build a form Coupon + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class CouponCreationForm extends BaseForm +{ + /** + * Build Coupon form + * + * @return void + */ + protected function buildForm() + { + $this->formBuilder + ->add( + "code", + "text", + array( + "constraints" => array( + new NotBlank() + ) + ) + ) + ->add( + "type", + "text", + array( + "constraints" => array( + new NotBlank() + ) + ) + ) + ->add( + "title", + "text", + array( + "constraints" => array( + new NotBlank() + ) + ) + ) + ->add( + "shortDescription", + "text", + array( + "constraints" => array( + new NotBlank() + ) + ) + ) + ->add( + "description", + "text", + array( + "constraints" => array( + new NotBlank() + ) + ) + ) + ->add( + "amount", + "text", + array( + "constraints" => array( + new NotBlank() + ) + ) + ) + ->add( + "isEnabled", + "text", + array( + "constraints" => array( + new NotBlank() + ) + ) + ) + ->add( + "expirationDate", + "text", + array( + "constraints" => array( + new NotBlank() + ) + ) + ) + ->add( + "isCumulative", + "text", + array( + "constraints" => array( + new NotBlank() + ) + ) + ) + ->add( + "isRemovingPostage", + "text", + array( + "constraints" => array( + new NotBlank() + ) + ) + ) + ->add( + "maxUsage", + "text", + array( + "constraints" => array( + new NotBlank() + ) + ) + ) + ->add( + "isAvailableOnSpecialOffers", + "text", + array( + "constraints" => array( + new NotBlank() + ) + ) + ); + } + + /** + * Get form name + * + * @return string + */ + public function getName() + { + return "thelia_coupon_creation"; + } +} diff --git a/core/lib/Thelia/Model/Coupon.php b/core/lib/Thelia/Model/Coupon.php index d135ccbb0..9718b5e36 100755 --- a/core/lib/Thelia/Model/Coupon.php +++ b/core/lib/Thelia/Model/Coupon.php @@ -1,9 +1,77 @@ . */ +/* */ +/**********************************************************************************/ namespace Thelia\Model; +use Thelia\Coupon\CouponRuleCollection; use Thelia\Model\Base\Coupon as BaseCoupon; -class Coupon extends BaseCoupon { +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Used to provide an effect (mostly a discount) + * 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 + * + */ +class Coupon extends BaseCoupon +{ + /** + * Set the value of [serialized_rules] column. + * + * @param CouponRuleCollection $rules A set of Rules + * + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setSerializedRules(CouponRuleCollection $rules) + { + if ($rules !== null) { + $v = (string) base64_encode(serialize($rules)); + } + + if ($this->serialized_rules !== $v) { + $this->serialized_rules = $v; + $this->modifiedColumns[] = CouponTableMap::SERIALIZED_RULES; + } + + + return $this; + } // setSerializedRules() + + + /** + * Get the [serialized_rules] column value. + * + * @return CouponRuleCollection Rules ready to be processed + */ + public function getSerializedRules() + { + return unserialize(base64_decode($this->serialized_rules)); + } } diff --git a/install/sqldb.map b/install/sqldb.map deleted file mode 100644 index 63a93baa8..000000000 --- a/install/sqldb.map +++ /dev/null @@ -1,2 +0,0 @@ -# Sqlfile -> Database map -thelia.sql=thelia From fd63115c970555cd01d58a55d34ad446187fe311 Mon Sep 17 00:00:00 2001 From: gmorel Date: Fri, 30 Aug 2013 12:23:49 +0200 Subject: [PATCH 066/268] WIP - Update Coupon Controller/Form/Event - create() --- core/lib/Thelia/Action/Coupon.php | 109 ++++++++++++++++-- .../Controller/Admin/CouponController.php | 109 +++++++++++------- core/lib/Thelia/Core/Event/TheliaEvents.php | 22 +++- 3 files changed, 189 insertions(+), 51 deletions(-) diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index 331265b73..1958d556b 100755 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -25,10 +25,14 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\ActionEvent; +use Thelia\Core\Event\Coupon\CouponCreateEvent; +use Thelia\Core\Event\Coupon\CouponDisableEvent; +use Thelia\Core\Event\Coupon\CouponEnableEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Category as CategoryModel; use Thelia\Form\CategoryCreationForm; use Thelia\Core\Event\CategoryEvent; +use Thelia\Model\CouponQuery; use Thelia\Tools\Redirect; use Thelia\Model\CategoryQuery; use Thelia\Model\AdminLog; @@ -40,29 +44,114 @@ use Propel\Runtime\Propel; use Thelia\Model\Map\CategoryTableMap; use Propel\Runtime\Exception\PropelException; +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Process Coupon Events + * + * @package Coupon + * @author Guillaume MOREL + * + */ class Coupon extends BaseAction implements EventSubscriberInterface { + /** + * Create a Coupon if a Coupon creation attempt is found + * + * @param CouponCreateEvent $event Coupon creation Event + */ + public function create(CouponCreateEvent $event) + { + $this->checkAuth("ADMIN", "admin.coupon.create"); + + $this->dispatch( + TheliaEvents::BEFORE_CREATE_COUPON, + $event + ); + + $event->getCreatedCoupon()->save(); + + $this->dispatch( + TheliaEvents::AFTER_CREATE_COUPON, + $event + ); + } /** - * Disable a Coupon + * Edit a Coupon if a Coupon edition attempt is found * - * @param ActionEvent $event + * @param CouponEditEvent $event Coupon edition Event */ - public function delete(CategoryDeleteEvent $event) + public function edit(CouponEditEvent $event) { - $this->checkAuth("ADMIN", "admin.category.delete"); + $this->checkAuth("ADMIN", "admin.coupon.edit"); - $category = CategoryQuery::create()->findPk($event->getId()); + $this->dispatch( + TheliaEvents::BEFORE_EDIT_COUPON, + $event + ); - if ($category !== null) { + $couponToUpdate = CouponQuery::create()->findPk($event->getId()); - $event->setDeletedCategory($category); + if ($couponToUpdate !== null) { + $event->getCreatedCoupon()->save(); + } - $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_DELETECATEGORY, $event); + $this->dispatch( + TheliaEvents::AFTER_EDIT_COUPON, + $event + ); + } - $category->delete(); + /** + * Disable a Coupon if a Coupon disable attempt is found + * + * @param CouponDisableEvent $event Coupon disable Event + */ + public function disable(CouponDisableEvent $event) + { + $this->checkAuth("ADMIN", "admin.coupon.disable"); - $event->getDispatcher()->dispatch(TheliaEvents::AFTER_DELETECATEGORY, $event); + $couponToUpdate = CouponQuery::create()->findPk($event->getId()); + + if ($couponToUpdate !== null) { + $couponToUpdate->setIsEnabled(0); + $event->getDispatcher()->dispatch( + TheliaEvents::BEFORE_DISABLE_COUPON, $event + ); + + $couponToUpdate->save(); + + $event->getDispatcher()->dispatch( + TheliaEvents::AFTER_DISABLE_COUPON, $event + ); + } + } + + /** + * Enable a Coupon if a Coupon enable attempt is found + * + * @param CouponEnableEvent $event Coupon enable Event + */ + public function enable(CouponEnableEvent $event) + { + $this->checkAuth("ADMIN", "admin.coupon.enable"); + + $couponToUpdate = CouponQuery::create()->findPk($event->getId()); + + if ($couponToUpdate !== null) { + $couponToUpdate->setIsEnabled(1); + $event->getDispatcher()->dispatch( + TheliaEvents::BEFORE_ENABLE_COUPON, $event + ); + + $couponToUpdate->save(); + + $event->getDispatcher()->dispatch( + TheliaEvents::AFTER_ENABLE_COUPON, $event + ); } } diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index a4555bfd2..ab018e245 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -29,6 +29,7 @@ use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\AuthorizationException; use Thelia\Coupon\CouponRuleCollection; use Thelia\Form\CouponCreationForm; +use Thelia\Form\Exception\FormValidationException; use Thelia\Model\Coupon; /** @@ -79,53 +80,46 @@ class CouponController extends BaseAdminController { $this->checkAuth("ADMIN", "admin.coupon.view"); - if ($this->getRequest()->isMethod('POST')) { + try { + $couponCreationForm = new CouponCreationForm($this->getRequest()); + $couponBeingCreated = $this->buildCouponFromForm( + $this->validateForm($couponCreationForm, "POST")->getData() + ); - $couponCreationForm = new CouponCreationForm($this->getRequest()); + $couponCreateEvent = new CouponCreateEvent( + $couponBeingCreated + ); - $form = $this->validateForm($couponCreationForm, "POST"); - - $data = $form->getData(); - - $couponBeingCreated = new Coupon(); - $couponBeingCreated->setCode($data["code"]); - $couponBeingCreated->setType($data["type"]); - $couponBeingCreated->setTitle($data["title"]); - $couponBeingCreated->setShortDescription($data["shortDescription"]); - $couponBeingCreated->setDescription($data["description"]); - $couponBeingCreated->setAmount($data["amount"]); - $couponBeingCreated->setIsEnabled($data["isEnabled"]); - $couponBeingCreated->setExpirationDate($data["expirationDate"]); - $couponBeingCreated->setSerializedRules( - new CouponRuleCollection( - array() - ) - ); - $couponBeingCreated->setIsCumulative($data["isCumulative"]); - $couponBeingCreated->setIsRemovingPostage($data["isRemovingPostage"]); - $couponBeingCreated->setMaxUsage($data["maxUsage"]); - $couponBeingCreated->setIsAvailableOnSpecialOffers($data["isAvailableOnSpecialOffers"]); - - $couponCreateEvent = new CouponCreateEvent( - $couponBeingCreated - ); - - $this->dispatch(TheliaEvents::BEFORE_CREATE_COUPON, $couponCreateEvent); - // @todo Save - $this->adminLogAppend( - sprintf( - 'Coupon %s (ID %s) created', - $couponBeingCreated->getTitle(), - $couponBeingCreated->getId() - ) - ); - $this->dispatch(TheliaEvents::AFTER_CREATE_COUPON, $couponCreateEvent); + $this->dispatch( + TheliaEvents::CREATE_COUPON, + $couponCreateEvent + ); + $this->adminLogAppend( + sprintf( + 'Coupon %s (ID %s) created', + $couponBeingCreated->getTitle(), + $couponBeingCreated->getId() + ) + ); + // @todo redirect if successful + } catch (FormValidationException $e) { + $couponCreationForm->setErrorMessage($e->getMessage()); + $this->getParserContext()->setErrorForm($couponCreationForm); + } catch (\Exception $e) { + Tlog::getInstance()->error( + sprintf( + "Failed to create coupon: %s", + $e->getMessage() + ) + ); + $this->getParserContext()->setGeneralError($e->getMessage()); + } } else { } - return $this->render('coupon/edit', $args); + return $this->render('coupon/edit', array()); } /** @@ -196,4 +190,39 @@ class CouponController extends BaseAdminController // We did not recognized the action -> return a 404 page return $this->pageNotFound(); } + + /** + * Build a Coupon from its form + * + * @param array $data Form data + * + * @return Coupon + */ + protected function buildCouponFromForm(array $data) + { + $couponBeingCreated = new Coupon(); + $couponBeingCreated->setCode($data["code"]); + $couponBeingCreated->setType($data["type"]); + $couponBeingCreated->setTitle($data["title"]); + $couponBeingCreated->setShortDescription($data["shortDescription"]); + $couponBeingCreated->setDescription($data["description"]); + $couponBeingCreated->setAmount($data["amount"]); + $couponBeingCreated->setIsEnabled($data["isEnabled"]); + $couponBeingCreated->setExpirationDate($data["expirationDate"]); + $couponBeingCreated->setSerializedRules( + new CouponRuleCollection( + array() + ) + ); + $couponBeingCreated->setIsCumulative($data["isCumulative"]); + $couponBeingCreated->setIsRemovingPostage( + $data["isRemovingPostage"] + ); + $couponBeingCreated->setMaxUsage($data["maxUsage"]); + $couponBeingCreated->setIsAvailableOnSpecialOffers( + $data["isAvailableOnSpecialOffers"] + ); + + return $couponBeingCreated; + } } diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index ba0d97d2f..8460efda9 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -179,10 +179,15 @@ final class TheliaEvents const IMAGE_CLEAR_CACHE = "action.clearImageCache"; + + /** + * Sent when creating a Coupon + */ + const COUPON_CREATE = "action.create_coupon"; + /** * Sent just before a successful insert of a new Coupon in the database. */ - const BEFORE_CREATE_COUPON = "action.before_create_coupon"; /** @@ -190,6 +195,11 @@ final class TheliaEvents */ const AFTER_CREATE_COUPON = "action.after_create_coupon"; + /** + * Sent when editing a Coupon + */ + const COUPON_EDIT = "action.edit_coupon"; + /** * Sent just before a successful update of a new Coupon in the database. */ @@ -200,6 +210,11 @@ final class TheliaEvents */ const AFTER_EDIT_COUPON = "action.after_edit_coupon"; + /** + * Sent when disabling a Coupon + */ + const COUPON_DISABLE = "action.disable_coupon"; + /** * Sent just before a successful disable of a new Coupon in the database. */ @@ -210,6 +225,11 @@ final class TheliaEvents */ const AFTER_DISABLE_COUPON = "action.after_disable_coupon"; + /** + * Sent when enabling a Coupon + */ + const COUPON_ENABLE = "action.enable_coupon"; + /** * Sent just before a successful enable of a new Coupon in the database. */ From 3c71aa613f9a10347dfa003699ea476b0eb67ee5 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 30 Aug 2013 14:30:33 +0200 Subject: [PATCH 067/268] url global substitution --- .../Core/Template/Loop/FeatureValue.php | 3 +- .../Thelia/Core/Template/ParserContext.php | 6 +- .../Template/Smarty/Plugins/UrlGenerator.php | 65 ++++++++- .../Thelia/Model/Map/RewritingUrlTableMap.php | 4 +- .../Thelia/Model/Tools/ModelCriteriaTools.php | 14 +- .../Thelia/Rewriting/RewritingRetriever.php | 13 +- core/lib/Thelia/Tools/URL.php | 26 ++-- install/thelia.sql | 4 +- local/config/schema.xml | 4 +- .../admin/default/includes/header.inc.html | 2 +- templates/default/cart.html | 2 +- templates/default/category.html | 137 +++--------------- templates/default/connexion.html | 4 +- templates/default/login.html | 6 +- web/index_dev.php | 2 - 15 files changed, 126 insertions(+), 166 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php index 2a8cac955..62f9ceb47 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php @@ -90,7 +90,8 @@ class FeatureValue extends BaseLoop $this->request->getSession()->getLocale(), array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), FeatureAvTableMap::TABLE_NAME, - 'FEATURE_AV_ID' + 'FEATURE_AV_ID', + true ); $feature = $this->getFeature(); diff --git a/core/lib/Thelia/Core/Template/ParserContext.php b/core/lib/Thelia/Core/Template/ParserContext.php index 03c3cf45f..af12018e6 100755 --- a/core/lib/Thelia/Core/Template/ParserContext.php +++ b/core/lib/Thelia/Core/Template/ParserContext.php @@ -40,11 +40,7 @@ class ParserContext implements \IteratorAggregate public function __construct(Request $request) { // Setup basic variables - $this - ->set('BASE_URL' , ConfigQuery::read('base_url', '/')) - ->set('INDEX_PAGE' , URL::getIndexPage()) - ->set('RETURN_TO_URL' , URL::absoluteUrl($request->getSession()->getReturnToUrl())) - ->set('THELIA_VERSION' , ConfigQuery::read('thelia_version', 'undefined')) + $this->set('THELIA_VERSION' , ConfigQuery::read('thelia_version', 'undefined')) ; } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php index b3814f088..33e699c43 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php @@ -47,14 +47,15 @@ class UrlGenerator extends AbstractSmartyPlugin public function generateUrlFunction($params, &$smarty) { // the path to process - $path = $this->getParam($params, 'path'); + $path = $this->getParam($params, 'path'); - $target = $this->getParam($params, 'target', null); + $target = $this->getParam($params, 'target', null); - $url = URL::absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target'))); + $url = URL::absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target'))); - if ($target != null) $url .= '#'.$target; - return $url; + if ($target != null) $url .= '#'.$target; + + return $url; } /** @@ -81,6 +82,15 @@ class UrlGenerator extends AbstractSmartyPlugin return $this->generateViewUrlFunction($params, true); } + public function navigateToUrlFunction($params, &$smarty) + { + $to = $this->getParam($params, 'to', null); + + $toMethod = $this->getNavigateToMethod($to); + + return $this->$toMethod(); + } + protected function generateViewUrlFunction($params, $forAdmin) { // the view name (without .html) @@ -125,7 +135,50 @@ class UrlGenerator extends AbstractSmartyPlugin return array( new SmartyPluginDescriptor('function', 'url', $this, 'generateUrlFunction'), new SmartyPluginDescriptor('function', 'viewurl', $this, 'generateFrontViewUrlFunction'), - new SmartyPluginDescriptor('function', 'admin_viewurl', $this, 'generateAdminViewUrlFunction') + new SmartyPluginDescriptor('function', 'admin_viewurl', $this, 'generateAdminViewUrlFunction'), + new SmartyPluginDescriptor('function', 'navigate', $this, 'navigateToUrlFunction'), ); } + + /** + * @return array sur le format "to_value" => "method_name" + */ + protected function getNavigateToValues() + { + return array( + "current" => "getCurrentUrl", + "return_to" => "getReturnToUrl", + "index" => "getIndexUrl", + ); + } + + protected function getNavigateToMethod($to) + { + if($to === null) { + throw new \InvalidArgumentException("Missing 'to' parameter in `navigate` substitution."); + } + + $navigateToValues = $this->getNavigateToValues(); + + if(!array_key_exists($to, $navigateToValues)) { + throw new \InvalidArgumentException("Incorrect value for parameter `to` in `navigate` substitution."); + } + + return $navigateToValues[$to]; + } + + protected function getCurrentUrl() + { + return URL::retrieveCurrent($this->request); + } + + protected function getReturnToUrl() + { + return URL::absoluteUrl($this->request->getSession()->getReturnToUrl()); + } + + protected function getIndexUrl() + { + return Url::getIndexPage(); + } } diff --git a/core/lib/Thelia/Model/Map/RewritingUrlTableMap.php b/core/lib/Thelia/Model/Map/RewritingUrlTableMap.php index c6d5e5473..1d6129ed8 100644 --- a/core/lib/Thelia/Model/Map/RewritingUrlTableMap.php +++ b/core/lib/Thelia/Model/Map/RewritingUrlTableMap.php @@ -162,9 +162,9 @@ class RewritingUrlTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('URL', 'Url', 'VARCHAR', true, 255, null); - $this->addColumn('VIEW', 'View', 'VARCHAR', false, 255, null); + $this->addColumn('VIEW', 'View', 'VARCHAR', true, 255, null); $this->addColumn('VIEW_ID', 'ViewId', 'VARCHAR', false, 255, null); - $this->addColumn('VIEW_LOCALE', 'ViewLocale', 'VARCHAR', false, 255, null); + $this->addColumn('VIEW_LOCALE', 'ViewLocale', 'VARCHAR', true, 255, null); $this->addForeignKey('REDIRECTED', 'Redirected', 'INTEGER', 'rewriting_url', 'ID', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); diff --git a/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php index 47c18a162..209006988 100755 --- a/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php +++ b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php @@ -23,7 +23,7 @@ class ModelCriteriaTools * @param null $foreignTable * @param string $foreignKey */ - public static function getFrontEndI18n(ModelCriteria &$search, $defaultLangWithoutTranslation, $askedLocale, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') + public static function getFrontEndI18n(ModelCriteria &$search, $defaultLangWithoutTranslation, $askedLocale, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID', $forceReturn = false) { if($foreignTable === null) { $foreignTable = $search->getTableMap()->getName(); @@ -32,13 +32,13 @@ class ModelCriteriaTools $aliasPrefix = $foreignTable . '_'; } - $askedLocaleI18nAlias = 'asked_locale_i18n'; - $defaultLocaleI18nAlias = 'default_locale_i18n'; + $askedLocaleI18nAlias = $aliasPrefix . 'asked_locale_i18n'; + $defaultLocaleI18nAlias = $aliasPrefix . 'default_locale_i18n'; if($defaultLangWithoutTranslation == 0) { $askedLocaleJoin = new Join(); $askedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $askedLocaleI18nAlias); - $askedLocaleJoin->setJoinType(Criteria::INNER_JOIN); + $askedLocaleJoin->setJoinType($forceReturn === false ? Criteria::INNER_JOIN : Criteria::LEFT_JOIN); $search->addJoinObject($askedLocaleJoin, $askedLocaleI18nAlias) ->addJoinCondition($askedLocaleI18nAlias ,'`' . $askedLocaleI18nAlias . '`.LOCALE = ?', $askedLocale, null, \PDO::PARAM_STR); @@ -67,7 +67,9 @@ class ModelCriteriaTools $search->withColumn('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED'); - $search->where('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.ID)')->_or()->where('NOT ISNULL(`' . $defaultLocaleI18nAlias . '`.ID)'); + if(!$forceReturn) { + $search->where('NOT ISNULL(`' . $askedLocaleI18nAlias . '`.ID)')->_or()->where('NOT ISNULL(`' . $defaultLocaleI18nAlias . '`.ID)'); + } foreach($columns as $column) { $search->withColumn('CASE WHEN NOT ISNULL(`' . $askedLocaleI18nAlias . '`.ID) THEN `' . $askedLocaleI18nAlias . '`.`' . $column . '` ELSE `' . $defaultLocaleI18nAlias . '`.`' . $column . '` END', $aliasPrefix . 'i18n_' . $column); @@ -84,7 +86,7 @@ class ModelCriteriaTools $aliasPrefix = $foreignTable . '_'; } - $askedLocaleI18nAlias = 'asked_locale_i18n'; + $askedLocaleI18nAlias = $aliasPrefix . 'asked_locale_i18n'; $askedLocaleJoin = new Join(); $askedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $askedLocaleI18nAlias); diff --git a/core/lib/Thelia/Rewriting/RewritingRetriever.php b/core/lib/Thelia/Rewriting/RewritingRetriever.php index 546b9d077..73b09dd2c 100755 --- a/core/lib/Thelia/Rewriting/RewritingRetriever.php +++ b/core/lib/Thelia/Rewriting/RewritingRetriever.php @@ -35,7 +35,7 @@ use Thelia\Model\Map\RewritingUrlTableMap; */ class RewritingRetriever { - public function getViewUrl($view, $viewId, $viewLocale) + public function getViewUrl($view, $viewLocale, $viewId) { $url = $this->getViewUrlQuery($view, $viewId, $viewLocale); @@ -48,22 +48,22 @@ class RewritingRetriever ->joinRewritingArgument('ra', Criteria::LEFT_JOIN) ->where('ISNULL(`ra`.REWRITING_URL_ID)') ->filterByView($view) - ->filterByViewId($viewId) ->filterByViewLocale($viewLocale) + ->filterByViewId($viewId) ->filterByRedirected(null) ->orderByUpdatedAt(Criteria::DESC) ->findOne(); } - public function getSpecificUrl($view = null, $viewId = null, $viewLocale = null, $viewOtherParameters = array()) + public function getSpecificUrl($view, $viewLocale, $viewId = null, $viewOtherParameters = array()) { $urlQuery = RewritingUrlQuery::create() ->joinRewritingArgument('ra', Criteria::LEFT_JOIN) ->withColumn('`ra`.PARAMETER', 'ra_parameter') ->withColumn('`ra`.VALUE', 'ra_value') ->filterByView($view) - ->filterByViewId($viewId) ->filterByViewLocale($viewLocale) + ->filterByViewId($viewId) ->filterByRedirected(null) ->orderByUpdatedAt(Criteria::DESC); @@ -86,10 +86,7 @@ class RewritingRetriever ->combine(array('count_condition', 'parameter_full_condition'), Criteria::LOGICAL_AND, 'full_having_condition'); - $urlQuery - ->having(array('full_having_condition')) - //->having('COUNT(' . RewritingUrlTableMap::ID . ') = ?', $otherParametersCount, \PDO::PARAM_INT) - ; + $urlQuery->having(array('full_having_condition')); } else { $urlQuery->where('ISNULL(`ra`.REWRITING_URL_ID)'); } diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index 267e5554c..1bf0e566c 100755 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -53,7 +53,11 @@ class URL // Already absolute ? if (substr($path, 0, 4) != 'http') { - $root = $path_only == self::PATH_TO_FILE ? ConfigQuery::read('base_url', '/') : self::getIndexPage(); + /** + * @etienne : can't be done here for it's already done in ::viewUrl / ::adminViewUrl + */ + //$root = $path_only == self::PATH_TO_FILE ? ConfigQuery::read('base_url', '/') : self::getIndexPage(); + $root = $path_only == self::PATH_TO_FILE ? ConfigQuery::read('base_url', '/') : ''; $base = rtrim($root, '/') . '/' . ltrim($path, '/'); } else @@ -116,7 +120,7 @@ class URL $rewrittenUrl = null; if(ConfigQuery::isRewritingEnable()) { $retriever = new RewritingRetriever(); - $rewrittenUrl = $retriever->getViewUrl($view, $viewId, $viewLocale); + $rewrittenUrl = $retriever->getViewUrl($view, $viewLocale, $viewId); } return $rewrittenUrl === null ? self::viewUrl($view, array($view . '_id' => $viewId, 'locale' => $viewLocale)) : $rewrittenUrl; @@ -127,24 +131,26 @@ class URL $rewrittenUrl = null; if(ConfigQuery::isRewritingEnable()) { $view = $request->query->get('view', null); - $viewId = $view === null ? null : $request->query->get($view . '_id', null); $viewLocale = $request->query->get('locale', null); + $viewId = $view === null ? null : $request->query->get($view . '_id', null); - $allOtherParameters = $request->query->all(); + $allParameters = $request->query->all(); + $allParametersWithoutView = $allParameters; if($view !== null) { - unset($allOtherParameters['view']); + unset($allParametersWithoutView['view']); + } + $allOtherParameters = $allParametersWithoutView; + if($viewLocale !== null) { + unset($allOtherParameters['locale']); } if($viewId !== null) { unset($allOtherParameters[$view . '_id']); } - if($viewLocale !== null) { - unset($allOtherParameters['locale']); - } $retriever = new RewritingRetriever(); - $rewrittenUrl = $retriever->getSpecificUrl($view, $viewId, $viewLocale, $allOtherParameters); + $rewrittenUrl = $retriever->getSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters); } - return $rewrittenUrl === null ? self::viewUrl($view, array($view . '_id' => $viewId, 'locale' => $viewLocale)) : $rewrittenUrl; + return $rewrittenUrl === null ? self::viewUrl($view, $allParametersWithoutView) : $rewrittenUrl; } } diff --git a/install/thelia.sql b/install/thelia.sql index 1993ee084..99b18513e 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -1443,9 +1443,9 @@ CREATE TABLE `rewriting_url` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `url` VARCHAR(255) NOT NULL, - `view` VARCHAR(255), + `view` VARCHAR(255) NOT NULL, `view_id` VARCHAR(255), - `view_locale` VARCHAR(255), + `view_locale` VARCHAR(255) NOT NULL, `redirected` INTEGER, `created_at` DATETIME, `updated_at` DATETIME, diff --git a/local/config/schema.xml b/local/config/schema.xml index 0e20f2562..17fcf612f 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1096,9 +1096,9 @@ - + - + diff --git a/templates/admin/default/includes/header.inc.html b/templates/admin/default/includes/header.inc.html index 65500f05a..05578de6b 100755 --- a/templates/admin/default/includes/header.inc.html +++ b/templates/admin/default/includes/header.inc.html @@ -67,7 +67,7 @@ {/loop} - + diff --git a/templates/default/cart.html b/templates/default/cart.html index 03ec8e3ee..5597d28ad 100755 --- a/templates/default/cart.html +++ b/templates/default/cart.html @@ -8,7 +8,7 @@ {form name="thelia.cart.add" } -{* We use $INDEX_PAGE as form action to avoid mixing post and get data *} +{* We use {navigate to="index"} as form action to avoid mixing post and get data *}
      {* diff --git a/templates/default/category.html b/templates/default/category.html index 440866a26..dd5c6a20a 100755 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -22,34 +22,10 @@ {loop name="product" type="product" category="#ID"}
      -

      PRODUCT #ID : #REF (#LOOP_COUNT / #LOOP_TOTAL)

      +

      PRODUCT #ID : #REF (#LOOP_COUNT / #LOOP_TOTAL)

      #TITLE

      #DESCRIPTION

      - {ifloop rel="acc"} -
      Accessories
      -
        - {loop name="acc" type="accessory" product="#ID" order="accessory"} -
      • #REF
      • - {/loop} -
      - {/ifloop} - {elseloop rel="acc"} -
      No accessory
      - {/elseloop} - - {ifloop rel="prod_ass_cont"} -
      Associated Content
      -
        - {loop name="prod_ass_cont" type="associated_content" product="#ID" order="associated_content"} -
      • #TITLE
      • - {/loop} -
      - {/ifloop} - {elseloop rel="prod_ass_cont"} -
      No associated content
      - {/elseloop} - {ifloop rel="ft"}
      Features
        @@ -67,29 +43,6 @@ {elseloop rel="ft"}
        No feature
        {/elseloop} - -
        Product sale elements
        - - {assign var=current_product value=#ID} - {loop name="pse" type="product_sale_elements" product="#ID"} -
        - {loop name="combi" type="attribute_combination" product_sale_elements="#ID"} - #ATTRIBUTE_TITLE = #ATTRIBUTE_AVAILABILITY_TITLE
        - {/loop} -
        #WEIGHT g -
        {if #IS_PROMO == 1} #PROMO_PRICE € (instead of #PRICE) {else} #PRICE € {/if} -

        - Add - - to my cart -
      -
      - {/loop} - {/loop} {loop name="catgory1" type="category" parent="#ID"} @@ -110,75 +63,29 @@ {loop name="product" type="product" category="#ID"} -
      -

      PRODUCT #ID : #REF (#LOOP_COUNT / #LOOP_TOTAL)

      -

      #TITLE

      -

      #DESCRIPTION

      +
      +

      PRODUCT #ID : #REF (#LOOP_COUNT / #LOOP_TOTAL)

      +

      #TITLE

      +

      #DESCRIPTION

      - {ifloop rel="acc"} -
      Accessories
      -
        - {loop name="acc" type="accessory" product="#ID" order="accessory"} -
      • #REF
      • - {/loop} -
      - {/ifloop} - {elseloop rel="acc"} -
      No accessory
      - {/elseloop} - - {ifloop rel="prod_ass_cont"} -
      Associated Content
      -
        - {loop name="prod_ass_cont" type="associated_content" product="#ID" order="associated_content"} -
      • #TITLE
      • - {/loop} -
      - {/ifloop} - {elseloop rel="prod_ass_cont"} -
      No associated content
      - {/elseloop} - - {ifloop rel="ft"} -
      Features
      -
        - {loop name="ft" type="feature" order="manual" product="#ID"} -
      • - #TITLE : - {loop name="ft_v" type="feature_value" product="{$current_product}" feature="#ID"} - #TITLE / #PERSONAL_VALUE + {ifloop rel="ft"} +
        Features
        +
          + {assign var=current_product value=#ID} + {loop name="ft" type="feature" order="manual" product="#ID"} +
        • + #TITLE : + {loop name="ft_v" type="feature_value" product="{$current_product}" feature="#ID"} + #TITLE / #PERSONAL_VALUE + {/loop} +
        • {/loop} - - {/loop} -
        - {/ifloop} - {elseloop rel="ft"} -
        No feature
        - {/elseloop} - -
        Product sale elements
        - - {assign var=current_product value=#ID} - {loop name="pse" type="product_sale_elements" product="#ID"} -
        - {loop name="combi" type="attribute_combination" product_sale_elements="#ID"} - #ATTRIBUTE_TITLE = #ATTRIBUTE_AVAILABILITY_TITLE
        - {/loop} -
        #WEIGHT g -
        {if #IS_PROMO == 1} #PROMO_PRICE € (instead of #PRICE) {else} #PRICE € {/if} -

        - Add - - to my cart -
      -
      - {/loop} - -
      + + {/ifloop} + {elseloop rel="ft"} +
      No feature
      + {/elseloop} + {/loop} {/loop} diff --git a/templates/default/connexion.html b/templates/default/connexion.html index e3109e8b3..a6a2cc665 100755 --- a/templates/default/connexion.html +++ b/templates/default/connexion.html @@ -1,7 +1,7 @@ {include file="includes/header.html"} {form name="thelia.customer.creation"} -{* We use $INDEX_PAGE as form action to avoid mixing post and get data *} +{* We use {navigate to="index"} as form action to avoid mixing post and get data *} {* The two fields below are not par of the form, they are here to defines @@ -16,7 +16,7 @@ *} {form_field form=$form field='success_url'} - {* the url the user is redirected to on login success *} + {* the url the user is redirected to on login success *} {/form_field} {form_field form=$form field='auto_login'} diff --git a/templates/default/login.html b/templates/default/login.html index 0041fd80c..a5a7585b7 100755 --- a/templates/default/login.html +++ b/templates/default/login.html @@ -3,8 +3,8 @@

      {intl l='Please login'}

      {form name="thelia.customer.login" } -{* We use $INDEX_PAGE as form action to avoid mixing post and get data *} - +{* We use {navigate to="index"} as form action to avoid mixing post and get data *} + {* The two fields below are not par of the Login form, they are here to defines @@ -20,7 +20,7 @@ *} {form_field form=$form field='success_url'} - {* the url the user is redirected to on login success *} + {* the url the user is redirected to on login success *} {/form_field} {* diff --git a/web/index_dev.php b/web/index_dev.php index b5a98978a..8991dc4a8 100755 --- a/web/index_dev.php +++ b/web/index_dev.php @@ -21,8 +21,6 @@ if ( false === in_array($request->getClientIp(), $trustIp)) { $thelia = new Thelia("dev", true); -\Thelia\Tools\URL::retrieveCurrent($request); - $response = $thelia->handle($request)->prepare($request)->send(); $thelia->terminate($request, $response); From e63ff065c7ed884156b43c4fdd47bd473945f6b7 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 30 Aug 2013 15:04:08 +0200 Subject: [PATCH 068/268] product page --- templates/default/product.html | 88 ++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 templates/default/product.html diff --git a/templates/default/product.html b/templates/default/product.html new file mode 100755 index 000000000..4f82b5fb8 --- /dev/null +++ b/templates/default/product.html @@ -0,0 +1,88 @@ +Here you are : {navigate to="current"}
      +From : {navigate to="return_to"}
      +Index : {navigate to="index"}
      + +

      Product page

      + +{ifloop rel="product"} + +{loop type="product" name="product" current="true"} + +
      +

      PRODUCT (#ID) : #REF

      +

      #TITLE

      +

      #DESCRIPTION

      + + {ifloop rel="acc"} +

      Accessories

      +
        + {loop name="acc" type="accessory" product="#ID" order="accessory"} +
      • #REF
      • + {/loop} +
      + {/ifloop} + {elseloop rel="acc"} +

      No accessory

      + {/elseloop} + + {ifloop rel="prod_ass_cont"} +

      Associated Content

      +
        + {loop name="prod_ass_cont" type="associated_content" product="#ID" order="associated_content"} +
      • #TITLE
      • + {/loop} +
      + {/ifloop} + {elseloop rel="prod_ass_cont"} +

      No associated content

      + {/elseloop} + + {ifloop rel="ft"} +

      Features

      +
        + {assign var=current_product value=#ID} + {loop name="ft" type="feature" order="manual" product="#ID"} +
      • + #TITLE : + {loop name="ft_v" type="feature_value" product="{$current_product}" feature="#ID"} + #TITLE / #PERSONAL_VALUE + {/loop} +
      • + {/loop} +
      + {/ifloop} + {elseloop rel="ft"} +

      No feature

      + {/elseloop} + +

      Product sale elements

      + + {assign var=current_product value=#ID} + {loop name="pse" type="product_sale_elements" product="#ID"} +
      + {loop name="combi" type="attribute_combination" product_sale_elements="#ID"} + #ATTRIBUTE_TITLE = #ATTRIBUTE_AVAILABILITY_TITLE
      + {/loop} +
      #WEIGHT g +
      {if #IS_PROMO == 1} #PROMO_PRICE € (instead of #PRICE) {else} #PRICE € {/if} +

      + Add + + to my cart + +
      + {/loop} + +
      + +{/loop} + +{/ifloop} + +{elseloop rel="product"} +

      Produit introuvable !

      +{/elseloop} \ No newline at end of file From e5f8f65f77bbc2e870051c45589b9665ff575430 Mon Sep 17 00:00:00 2001 From: mespeche Date: Fri, 30 Aug 2013 15:47:13 +0200 Subject: [PATCH 069/268] WIP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suite de mise en place de la page d'édition des coupons avec miniBrowser --- templates/admin/default/assets/css/admin.less | 17 +- templates/admin/default/assets/js/main.js | 116 ++++++++ templates/admin/default/coupon/edit.html | 270 +++++++++++++++--- templates/admin/default/coupon/list.html | 25 +- templates/admin/default/coupon/read.html | 23 +- web/test_to_remove/datas_coupon_edit.json | 85 ++++++ 6 files changed, 454 insertions(+), 82 deletions(-) create mode 100644 templates/admin/default/assets/js/main.js create mode 100644 web/test_to_remove/datas_coupon_edit.json diff --git a/templates/admin/default/assets/css/admin.less b/templates/admin/default/assets/css/admin.less index a9ca23bf1..e2ef57293 100755 --- a/templates/admin/default/assets/css/admin.less +++ b/templates/admin/default/assets/css/admin.less @@ -47,7 +47,7 @@ filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(@startColor),argb(@endColor))); // IE9 and down } .vertical(@startColor: #555, @endColor: #333) { - background-color: mix(@startColor, @endColor, 60%); + background-color: @endColor; background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+ background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+ @@ -158,7 +158,7 @@ hr { } .btn-primary, .btn-large { - #gradient > .vertical(rgb(243,153,34), rgb(227,83,11)); + #gradient > .vertical(rgb(243,153,34), rgb(227,83,11)); box-shadow: inset 0px 0px 2px rgba(250,250,250,0.5), 0px 1px 3px rgba(0,0,0,0.2); color: white; } @@ -874,9 +874,18 @@ label { .input-append, .input-prepend { &.date { - .add-on span { + span.add-on span { display: block; cursor: pointer; } } -} \ No newline at end of file +} + +// -- Rules form ----------------------------------------------------- +.input-append{ + button.add-on{ + height: auto; + } +} + + diff --git a/templates/admin/default/assets/js/main.js b/templates/admin/default/assets/js/main.js new file mode 100644 index 000000000..7b5cc812f --- /dev/null +++ b/templates/admin/default/assets/js/main.js @@ -0,0 +1,116 @@ +(function($, window, document){ + + $(function($){ + + // -- Init datepicker -- + if($('.date').length){ + $('.date').datepicker(); + } + + // -- Init tablesorter -- + if($('.tablesorter').length){ + $('.tablesorter').tablesorter(); + } + + // -- Effect description + if($('[name=effect]').length){ + var $effectSelect = $('[name=effect]'), + $helpBlock = $effectSelect.next('.help-block'); + + $effectSelect.change(function(){ + var description = $(this).find(":selected").data('description'); + $helpBlock.text(description); + }); + } + + // -- Confirm Box -- + if($('[data-toggle="confirm"]').length){ + $('[data-toggle="confirm"]').click(function(e){ + + var $link = $(this); + var modal = $(this).data('target'); + + $(modal).modal('show'); + + $(modal).on('shown', function () { + $('[data-confirm]').attr('href', $link.attr('href')); + }); + + if($(modal).is(':hidden')){ + e.preventDefault(); + } + + }); + } + + }); + + + +}(window.jQuery, window, document)); + +// -- Mini browser -- +function miniBrowser(root, url){ + + $.getJSON(url, { + root: root + }) + .done(function(data) { + var resultat = data; + + var breadcrumb = $('
      '); + $(resultat.breadcrumb).each(function(k, v){ + breadcrumb.append( + $('').html(' > '), + $('').attr('href', '#').html(v.display).click(function(e){ + e.preventDefault(); + + miniBrowser(v.url) + }) + ); + }); + + var categories = $('
      '); + $(resultat.categories).each(function(k, v){ + categories.append( + $('

      ').append( + $('').attr('href', '#').html(v.titre).click(function(e){ + e.preventDefault(); + + miniBrowser(v.id) + }) + ) + ); + }); + + var products = $('

      '); + $(resultat.products).each(function(k, v){ + products.append( + $('

      ').append( + $('').attr('href', '#').html(v.titre).click(function(e){ + e.preventDefault(); + + $('#productToAdd_ref').val(v.ref); + $('#productToAdd_titre').val(v.titre); + $('#productToAdd_quantite').val(1); + + manageStock(v.variants, v.promo?v.prix2:v.prix); + + $('#productToAdd_tva').val(v.tva); + + $('.productToAddInformation').show(); + $('#btn_ajout_produit').show(); + }) + ) + ); + }); + + $('#fastBrowser_breadcrumb').unbind().empty().append(breadcrumb); + $('#fastBrowser_categories').unbind().empty().append(categories); + $('#fastBrowser_products').unbind().empty().append(products); + }) + .fail(function() { + console.log('The JSON file cant be read'); + }); + +} \ No newline at end of file diff --git a/templates/admin/default/coupon/edit.html b/templates/admin/default/coupon/edit.html index 56c2b6229..4ad8f28c0 100755 --- a/templates/admin/default/coupon/edit.html +++ b/templates/admin/default/coupon/edit.html @@ -17,12 +17,12 @@

      + + -
      -
      - - - +
      +
      +
      @@ -35,72 +35,270 @@
      + +
      + +
      -
      - +
      - - + +
      -
      - - - More description n°1 about item -
      +
      +
      + + + More description n°1 about item +
      +
      + +
      +
      + + +
      +
      + + +
      +
      +
      + +
      + +
      + + +
      + +
      + + +
      + + + +
      +
      + +
      +
      +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + Rules + + + +
      ConditionsOperatorValueActions
      Total Amount>=300 + Edit + Delete +
      AND NbArticleFromCategory=12 - Chaussettes rouges + Edit + Delete +
      OR Date<=12/02/2014 + Edit + Delete +
      +
      + + +
      +
      + +
      + + +
      - +
      + + -
      -
      + + + + + +
      + +
      + +
      + +
      + + +
      +
      + + +
      + +
      + + + +
      +
      + + +
      + + + + + + + + + + + + + + + +
      + + + +
      + +
      + +
      + +
      + + + + + {include file='includes/js.inc.html'} {javascripts file='../assets/bootstrap-datepicker/js/bootstrap-datepicker.js'} {/javascripts} +{javascripts file='../assets/js/main.js'} + +{/javascripts} + diff --git a/templates/admin/default/coupon/list.html b/templates/admin/default/coupon/list.html index 3b13d6eac..882b27005 100755 --- a/templates/admin/default/coupon/list.html +++ b/templates/admin/default/coupon/list.html @@ -180,27 +180,8 @@ {/javascripts} - +{javascripts file='../assets/js/main.js'} + +{/javascripts} {include file='includes/footer.inc.html'} \ No newline at end of file diff --git a/templates/admin/default/coupon/read.html b/templates/admin/default/coupon/read.html index 9161f0d72..c4f61a022 100755 --- a/templates/admin/default/coupon/read.html +++ b/templates/admin/default/coupon/read.html @@ -99,25 +99,8 @@ {/javascripts} - - +{javascripts file='../assets/js/main.js'} + +{/javascripts} {include file='includes/footer.inc.html'} diff --git a/web/test_to_remove/datas_coupon_edit.json b/web/test_to_remove/datas_coupon_edit.json new file mode 100644 index 000000000..d64345682 --- /dev/null +++ b/web/test_to_remove/datas_coupon_edit.json @@ -0,0 +1,85 @@ +{ + "breadcrumb" : [ + { + "url" : "0", + "display" : "Racine", + "edit" : "", + "browse" : "" + } + ], + "categories" : [ + { + "id" : "1", + "ligne" : "1", + "classement" : "1", + "titre" : "Boyaux", + "langue_courante" : true, + "parent" : 0 + }, + { + "id" : "18", + "ligne" : "1", + "classement" : "2", + "titre" : "Epices \/ condiments", + "langue_courante" : true, + "parent" : 0 + }, + { + "id" : "100", + "ligne" : "1", + "classement" : "3", + "titre" : "Emballage", + "langue_courante" : true, + "parent" : 0 + }, + { + "id" : "194", + "ligne" : "1", + "classement" : "4", + "titre" : "Petits mat\u00e9riels", + "langue_courante" : true, + "parent" : 0 + }, + { + "id" : "355", + "ligne" : "1", + "classement" : "5", + "titre" : "Materiel de cuisine", + "langue_courante" : true, + "parent" : 0 + }, + { + "id" : "426", + "ligne" : "0", + "classement" : "6", + "titre" : "Bacs", + "langue_courante" : true, + "parent" : 0 + }, + { + "id" : "458", + "ligne" : "1", + "classement" : "7", + "titre" : "Hygi\u00e8ne & entretien", + "langue_courante" : true, + "parent" : 0 + }, + { + "id" : "592", + "ligne" : "1", + "classement" : "8", + "titre" : "Art de la table", + "langue_courante" : true, + "parent" : 0 + }, + { + "id" : "601", + "ligne" : "1", + "classement" : "9", + "titre" : "Mat\u00e9riels", + "langue_courante" : true, + "parent" : 0 + } + ], + "products":[] +} \ No newline at end of file From 64698b1d3dd30adb71d4a586171f4ed7d92034f1 Mon Sep 17 00:00:00 2001 From: mespeche Date: Fri, 30 Aug 2013 16:01:40 +0200 Subject: [PATCH 070/268] Working Remise en place du chartage CSS du composant datepicker et ajout de la mixin gradient --- .../css/bootstrap-editable.css | 453 +----------------- templates/admin/default/assets/css/admin.less | 43 +- 2 files changed, 6 insertions(+), 490 deletions(-) diff --git a/templates/admin/default/assets/bootstrap-editable/css/bootstrap-editable.css b/templates/admin/default/assets/bootstrap-editable/css/bootstrap-editable.css index 92063da35..ed3d651ae 100755 --- a/templates/admin/default/assets/bootstrap-editable/css/bootstrap-editable.css +++ b/templates/admin/default/assets/bootstrap-editable/css/bootstrap-editable.css @@ -202,455 +202,4 @@ a.editable-click.editable-disabled:hover { { padding-top: 5px; display:inline-block; -} - - -/*! - * Datepicker for Bootstrap - * - * Copyright 2012 Stefan Petre - * Improvements by Andrew Rowls - * Licensed under the Apache License v2.0 - * http://www.apache.org/licenses/LICENSE-2.0 - * - */ -.datepicker { - padding: 4px; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - direction: ltr; - /*.dow { - border-top: 1px solid #ddd !important; - }*/ - -} -.datepicker-inline { - width: 220px; -} -.datepicker.datepicker-rtl { - direction: rtl; -} -.datepicker.datepicker-rtl table tr td span { - float: right; -} -.datepicker-dropdown { - top: 0; - left: 0; -} -.datepicker-dropdown:before { - content: ''; - display: inline-block; - border-left: 7px solid transparent; - border-right: 7px solid transparent; - border-bottom: 7px solid #ccc; - border-bottom-color: rgba(0, 0, 0, 0.2); - position: absolute; - top: -7px; - left: 6px; -} -.datepicker-dropdown:after { - content: ''; - display: inline-block; - border-left: 6px solid transparent; - border-right: 6px solid transparent; - border-bottom: 6px solid #ffffff; - position: absolute; - top: -6px; - left: 7px; -} -.datepicker > div { - display: none; -} -.datepicker.days div.datepicker-days { - display: block; -} -.datepicker.months div.datepicker-months { - display: block; -} -.datepicker.years div.datepicker-years { - display: block; -} -.datepicker table { - margin: 0; -} -.datepicker td, -.datepicker th { - text-align: center; - width: 20px; - height: 20px; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - border: none; -} -.table-striped .datepicker table tr td, -.table-striped .datepicker table tr th { - background-color: transparent; -} -.datepicker table tr td.day:hover { - background: #eeeeee; - cursor: pointer; -} -.datepicker table tr td.old, -.datepicker table tr td.new { - color: #999999; -} -.datepicker table tr td.disabled, -.datepicker table tr td.disabled:hover { - background: none; - color: #999999; - cursor: default; -} -.datepicker table tr td.today, -.datepicker table tr td.today:hover, -.datepicker table tr td.today.disabled, -.datepicker table tr td.today.disabled:hover { - background-color: #fde19a; - background-image: -moz-linear-gradient(top, #fdd49a, #fdf59a); - background-image: -ms-linear-gradient(top, #fdd49a, #fdf59a); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fdd49a), to(#fdf59a)); - background-image: -webkit-linear-gradient(top, #fdd49a, #fdf59a); - background-image: -o-linear-gradient(top, #fdd49a, #fdf59a); - background-image: linear-gradient(top, #fdd49a, #fdf59a); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdd49a', endColorstr='#fdf59a', GradientType=0); - border-color: #fdf59a #fdf59a #fbed50; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); - color: #000; -} -.datepicker table tr td.today:hover, -.datepicker table tr td.today:hover:hover, -.datepicker table tr td.today.disabled:hover, -.datepicker table tr td.today.disabled:hover:hover, -.datepicker table tr td.today:active, -.datepicker table tr td.today:hover:active, -.datepicker table tr td.today.disabled:active, -.datepicker table tr td.today.disabled:hover:active, -.datepicker table tr td.today.active, -.datepicker table tr td.today:hover.active, -.datepicker table tr td.today.disabled.active, -.datepicker table tr td.today.disabled:hover.active, -.datepicker table tr td.today.disabled, -.datepicker table tr td.today:hover.disabled, -.datepicker table tr td.today.disabled.disabled, -.datepicker table tr td.today.disabled:hover.disabled, -.datepicker table tr td.today[disabled], -.datepicker table tr td.today:hover[disabled], -.datepicker table tr td.today.disabled[disabled], -.datepicker table tr td.today.disabled:hover[disabled] { - background-color: #fdf59a; -} -.datepicker table tr td.today:active, -.datepicker table tr td.today:hover:active, -.datepicker table tr td.today.disabled:active, -.datepicker table tr td.today.disabled:hover:active, -.datepicker table tr td.today.active, -.datepicker table tr td.today:hover.active, -.datepicker table tr td.today.disabled.active, -.datepicker table tr td.today.disabled:hover.active { - background-color: #fbf069 \9; -} -.datepicker table tr td.today:hover:hover { - color: #000; -} -.datepicker table tr td.today.active:hover { - color: #fff; -} -.datepicker table tr td.range, -.datepicker table tr td.range:hover, -.datepicker table tr td.range.disabled, -.datepicker table tr td.range.disabled:hover { - background: #eeeeee; - -webkit-border-radius: 0; - -moz-border-radius: 0; - border-radius: 0; -} -.datepicker table tr td.range.today, -.datepicker table tr td.range.today:hover, -.datepicker table tr td.range.today.disabled, -.datepicker table tr td.range.today.disabled:hover { - background-color: #f3d17a; - background-image: -moz-linear-gradient(top, #f3c17a, #f3e97a); - background-image: -ms-linear-gradient(top, #f3c17a, #f3e97a); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f3c17a), to(#f3e97a)); - background-image: -webkit-linear-gradient(top, #f3c17a, #f3e97a); - background-image: -o-linear-gradient(top, #f3c17a, #f3e97a); - background-image: linear-gradient(top, #f3c17a, #f3e97a); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f3c17a', endColorstr='#f3e97a', GradientType=0); - border-color: #f3e97a #f3e97a #edde34; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); - -webkit-border-radius: 0; - -moz-border-radius: 0; - border-radius: 0; -} -.datepicker table tr td.range.today:hover, -.datepicker table tr td.range.today:hover:hover, -.datepicker table tr td.range.today.disabled:hover, -.datepicker table tr td.range.today.disabled:hover:hover, -.datepicker table tr td.range.today:active, -.datepicker table tr td.range.today:hover:active, -.datepicker table tr td.range.today.disabled:active, -.datepicker table tr td.range.today.disabled:hover:active, -.datepicker table tr td.range.today.active, -.datepicker table tr td.range.today:hover.active, -.datepicker table tr td.range.today.disabled.active, -.datepicker table tr td.range.today.disabled:hover.active, -.datepicker table tr td.range.today.disabled, -.datepicker table tr td.range.today:hover.disabled, -.datepicker table tr td.range.today.disabled.disabled, -.datepicker table tr td.range.today.disabled:hover.disabled, -.datepicker table tr td.range.today[disabled], -.datepicker table tr td.range.today:hover[disabled], -.datepicker table tr td.range.today.disabled[disabled], -.datepicker table tr td.range.today.disabled:hover[disabled] { - background-color: #f3e97a; -} -.datepicker table tr td.range.today:active, -.datepicker table tr td.range.today:hover:active, -.datepicker table tr td.range.today.disabled:active, -.datepicker table tr td.range.today.disabled:hover:active, -.datepicker table tr td.range.today.active, -.datepicker table tr td.range.today:hover.active, -.datepicker table tr td.range.today.disabled.active, -.datepicker table tr td.range.today.disabled:hover.active { - background-color: #efe24b \9; -} -.datepicker table tr td.selected, -.datepicker table tr td.selected:hover, -.datepicker table tr td.selected.disabled, -.datepicker table tr td.selected.disabled:hover { - background-color: #9e9e9e; - background-image: -moz-linear-gradient(top, #b3b3b3, #808080); - background-image: -ms-linear-gradient(top, #b3b3b3, #808080); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#b3b3b3), to(#808080)); - background-image: -webkit-linear-gradient(top, #b3b3b3, #808080); - background-image: -o-linear-gradient(top, #b3b3b3, #808080); - background-image: linear-gradient(top, #b3b3b3, #808080); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#b3b3b3', endColorstr='#808080', GradientType=0); - border-color: #808080 #808080 #595959; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); - color: #fff; - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); -} -.datepicker table tr td.selected:hover, -.datepicker table tr td.selected:hover:hover, -.datepicker table tr td.selected.disabled:hover, -.datepicker table tr td.selected.disabled:hover:hover, -.datepicker table tr td.selected:active, -.datepicker table tr td.selected:hover:active, -.datepicker table tr td.selected.disabled:active, -.datepicker table tr td.selected.disabled:hover:active, -.datepicker table tr td.selected.active, -.datepicker table tr td.selected:hover.active, -.datepicker table tr td.selected.disabled.active, -.datepicker table tr td.selected.disabled:hover.active, -.datepicker table tr td.selected.disabled, -.datepicker table tr td.selected:hover.disabled, -.datepicker table tr td.selected.disabled.disabled, -.datepicker table tr td.selected.disabled:hover.disabled, -.datepicker table tr td.selected[disabled], -.datepicker table tr td.selected:hover[disabled], -.datepicker table tr td.selected.disabled[disabled], -.datepicker table tr td.selected.disabled:hover[disabled] { - background-color: #808080; -} -.datepicker table tr td.selected:active, -.datepicker table tr td.selected:hover:active, -.datepicker table tr td.selected.disabled:active, -.datepicker table tr td.selected.disabled:hover:active, -.datepicker table tr td.selected.active, -.datepicker table tr td.selected:hover.active, -.datepicker table tr td.selected.disabled.active, -.datepicker table tr td.selected.disabled:hover.active { - background-color: #666666 \9; -} -.datepicker table tr td.active, -.datepicker table tr td.active:hover, -.datepicker table tr td.active.disabled, -.datepicker table tr td.active.disabled:hover { - background-color: #006dcc; - background-image: -moz-linear-gradient(top, #0088cc, #0044cc); - background-image: -ms-linear-gradient(top, #0088cc, #0044cc); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); - background-image: -webkit-linear-gradient(top, #0088cc, #0044cc); - background-image: -o-linear-gradient(top, #0088cc, #0044cc); - background-image: linear-gradient(top, #0088cc, #0044cc); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0); - border-color: #0044cc #0044cc #002a80; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); - color: #fff; - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); -} -.datepicker table tr td.active:hover, -.datepicker table tr td.active:hover:hover, -.datepicker table tr td.active.disabled:hover, -.datepicker table tr td.active.disabled:hover:hover, -.datepicker table tr td.active:active, -.datepicker table tr td.active:hover:active, -.datepicker table tr td.active.disabled:active, -.datepicker table tr td.active.disabled:hover:active, -.datepicker table tr td.active.active, -.datepicker table tr td.active:hover.active, -.datepicker table tr td.active.disabled.active, -.datepicker table tr td.active.disabled:hover.active, -.datepicker table tr td.active.disabled, -.datepicker table tr td.active:hover.disabled, -.datepicker table tr td.active.disabled.disabled, -.datepicker table tr td.active.disabled:hover.disabled, -.datepicker table tr td.active[disabled], -.datepicker table tr td.active:hover[disabled], -.datepicker table tr td.active.disabled[disabled], -.datepicker table tr td.active.disabled:hover[disabled] { - background-color: #0044cc; -} -.datepicker table tr td.active:active, -.datepicker table tr td.active:hover:active, -.datepicker table tr td.active.disabled:active, -.datepicker table tr td.active.disabled:hover:active, -.datepicker table tr td.active.active, -.datepicker table tr td.active:hover.active, -.datepicker table tr td.active.disabled.active, -.datepicker table tr td.active.disabled:hover.active { - background-color: #003399 \9; -} -.datepicker table tr td span { - display: block; - width: 23%; - height: 54px; - line-height: 54px; - float: left; - margin: 1%; - cursor: pointer; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} -.datepicker table tr td span:hover { - background: #eeeeee; -} -.datepicker table tr td span.disabled, -.datepicker table tr td span.disabled:hover { - background: none; - color: #999999; - cursor: default; -} -.datepicker table tr td span.active, -.datepicker table tr td span.active:hover, -.datepicker table tr td span.active.disabled, -.datepicker table tr td span.active.disabled:hover { - background-color: #006dcc; - background-image: -moz-linear-gradient(top, #0088cc, #0044cc); - background-image: -ms-linear-gradient(top, #0088cc, #0044cc); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); - background-image: -webkit-linear-gradient(top, #0088cc, #0044cc); - background-image: -o-linear-gradient(top, #0088cc, #0044cc); - background-image: linear-gradient(top, #0088cc, #0044cc); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0); - border-color: #0044cc #0044cc #002a80; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); - color: #fff; - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); -} -.datepicker table tr td span.active:hover, -.datepicker table tr td span.active:hover:hover, -.datepicker table tr td span.active.disabled:hover, -.datepicker table tr td span.active.disabled:hover:hover, -.datepicker table tr td span.active:active, -.datepicker table tr td span.active:hover:active, -.datepicker table tr td span.active.disabled:active, -.datepicker table tr td span.active.disabled:hover:active, -.datepicker table tr td span.active.active, -.datepicker table tr td span.active:hover.active, -.datepicker table tr td span.active.disabled.active, -.datepicker table tr td span.active.disabled:hover.active, -.datepicker table tr td span.active.disabled, -.datepicker table tr td span.active:hover.disabled, -.datepicker table tr td span.active.disabled.disabled, -.datepicker table tr td span.active.disabled:hover.disabled, -.datepicker table tr td span.active[disabled], -.datepicker table tr td span.active:hover[disabled], -.datepicker table tr td span.active.disabled[disabled], -.datepicker table tr td span.active.disabled:hover[disabled] { - background-color: #0044cc; -} -.datepicker table tr td span.active:active, -.datepicker table tr td span.active:hover:active, -.datepicker table tr td span.active.disabled:active, -.datepicker table tr td span.active.disabled:hover:active, -.datepicker table tr td span.active.active, -.datepicker table tr td span.active:hover.active, -.datepicker table tr td span.active.disabled.active, -.datepicker table tr td span.active.disabled:hover.active { - background-color: #003399 \9; -} -.datepicker table tr td span.old, -.datepicker table tr td span.new { - color: #999999; -} -.datepicker th.datepicker-switch { - width: 145px; -} -.datepicker thead tr:first-child th, -.datepicker tfoot tr th { - cursor: pointer; -} -.datepicker thead tr:first-child th:hover, -.datepicker tfoot tr th:hover { - background: #eeeeee; -} -.datepicker .cw { - font-size: 10px; - width: 12px; - padding: 0 2px 0 5px; - vertical-align: middle; -} -.datepicker thead tr:first-child th.cw { - cursor: default; - background-color: transparent; -} -.input-append.date .add-on i, -.input-prepend.date .add-on i { - display: block; - cursor: pointer; - width: 16px; - height: 16px; -} -.input-daterange input { - text-align: center; -} -.input-daterange input:first-child { - -webkit-border-radius: 3px 0 0 3px; - -moz-border-radius: 3px 0 0 3px; - border-radius: 3px 0 0 3px; -} -.input-daterange input:last-child { - -webkit-border-radius: 0 3px 3px 0; - -moz-border-radius: 0 3px 3px 0; - border-radius: 0 3px 3px 0; -} -.input-daterange .add-on { - display: inline-block; - width: auto; - min-width: 16px; - height: 18px; - padding: 4px 5px; - font-weight: normal; - line-height: 18px; - text-align: center; - text-shadow: 0 1px 0 #ffffff; - vertical-align: middle; - background-color: #eeeeee; - border: 1px solid #ccc; - margin-left: -5px; - margin-right: -5px; -} +} \ No newline at end of file diff --git a/templates/admin/default/assets/css/admin.less b/templates/admin/default/assets/css/admin.less index ef52b73e7..2bad0952c 100755 --- a/templates/admin/default/assets/css/admin.less +++ b/templates/admin/default/assets/css/admin.less @@ -158,41 +158,13 @@ hr { } .btn-primary, .btn-large { -<<<<<<< HEAD #gradient > .vertical(rgb(243,153,34), rgb(227,83,11)); -======= - background: #e9730f; - background-image: linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -o-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -moz-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -webkit-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -ms-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -webkit-gradient( - linear, - left bottom, - left top, - color-stop(0, rgb(227,83,11)), - color-stop(1, rgb(243,153,34)) - ); ->>>>>>> 180302e7cce643db7cda695b5cfaec3586ebb72c box-shadow: inset 0px 0px 2px rgba(250,250,250,0.5), 0px 1px 3px rgba(0,0,0,0.2); color: white; } .btn-large:hover, .btn-primary:hover { - background: #e9730f; - background-image: linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -o-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -moz-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -webkit-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -ms-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%); - background-image: -webkit-gradient( - linear, - left bottom, - left top, - color-stop(0, rgb(227,83,11)), - color-stop(1, rgb(243,153,34)) - ); + #gradient > .vertical(rgb(243,153,34), rgb(227,83,11)); box-shadow: inset 0px 0px 2px rgba(250,250,250,0.8), 0px 1px 3px rgba(0,0,0,0.2); color: white; } @@ -790,7 +762,7 @@ label { // Center the alert box (20px bottom margin) in the table cell padding: 20px 20px 0 20px; } -<<<<<<< HEAD + } // -- Editable tweaks --------------------------------------------------------- @@ -855,7 +827,7 @@ label { } &.active, &.active:hover { - #gradient > .vertical(rgb(243,153,34), rgb(227,83,11)); + #gradient > .vertical(rgb(243,153,34),rgb(227,83,11)); color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,.25); } @@ -872,7 +844,7 @@ label { background: @grayLighter; } &.active { - #gradient > .vertical(rgb(243,153,34), rgb(227,83,11)); + #gradient > .vertical(rgb(243,153,34),rgb(227,83,11)); color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,.25); } @@ -915,9 +887,4 @@ label { button.add-on{ height: auto; } -} - - -======= -} ->>>>>>> 180302e7cce643db7cda695b5cfaec3586ebb72c +} \ No newline at end of file From d8df46737dceab03eb6cbc71e817467d78d9ebd7 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 30 Aug 2013 16:02:37 +0200 Subject: [PATCH 071/268] specific rewrittend url retrievement --- .../Thelia/Rewriting/RewritingRetriever.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/core/lib/Thelia/Rewriting/RewritingRetriever.php b/core/lib/Thelia/Rewriting/RewritingRetriever.php index 73b09dd2c..34be346f1 100755 --- a/core/lib/Thelia/Rewriting/RewritingRetriever.php +++ b/core/lib/Thelia/Rewriting/RewritingRetriever.php @@ -59,8 +59,9 @@ class RewritingRetriever { $urlQuery = RewritingUrlQuery::create() ->joinRewritingArgument('ra', Criteria::LEFT_JOIN) - ->withColumn('`ra`.PARAMETER', 'ra_parameter') - ->withColumn('`ra`.VALUE', 'ra_value') + //->withColumn('`ra`.PARAMETER', 'ra_parameter') + //->withColumn('`ra`.VALUE', 'ra_value') + ->withColumn('`ra`.REWRITING_URL_ID', 'ra_REWRITING_URL_ID') ->filterByView($view) ->filterByViewLocale($viewLocale) ->filterByViewId($viewId) @@ -70,23 +71,23 @@ class RewritingRetriever $otherParametersCount = count($viewOtherParameters); if($otherParametersCount > 0) { $parameterConditions = array(); + foreach($viewOtherParameters as $parameter => $value) { $conditionName = 'other_parameter_condition_' . count($parameterConditions); - $urlQuery->condition('parameter_condition', '`ra_parameter`= ?', $parameter, \PDO::PARAM_STR) - ->condition('value_condition', '`ra_value` = ?', $value, \PDO::PARAM_STR) + $urlQuery->condition('parameter_condition', '`ra`.PARAMETER= ?', $parameter, \PDO::PARAM_STR) + ->condition('value_condition', '`ra`.VALUE = ?', $value, \PDO::PARAM_STR) ->combine(array('parameter_condition', 'value_condition'), Criteria::LOGICAL_AND, $conditionName); $parameterConditions[] = $conditionName; } - $urlQuery->combine($parameterConditions, Criteria::LOGICAL_OR, 'parameter_full_condition'); + $urlQuery->where($parameterConditions, Criteria::LOGICAL_OR); $urlQuery->groupBy(RewritingUrlTableMap::ID); - $urlQuery->condition('count_condition', 'COUNT(' . RewritingUrlTableMap::ID . ') = ?', $otherParametersCount, \PDO::PARAM_INT) - ->combine(array('count_condition', 'parameter_full_condition'), Criteria::LOGICAL_AND, 'full_having_condition'); + $urlQuery->condition('count_condition_1', 'COUNT(' . RewritingUrlTableMap::ID . ') = ?', $otherParametersCount, \PDO::PARAM_INT) // ensure we got all the asked parameters (provided by the query) + ->condition('count_condition_2', 'COUNT(' . RewritingUrlTableMap::ID . ') = (SELECT COUNT(*) FROM rewriting_argument WHERE rewriting_argument.REWRITING_URL_ID = ra_REWRITING_URL_ID)'); // ensure we don't miss any parameters (needed to match the rewritten url) - - $urlQuery->having(array('full_having_condition')); + $urlQuery->having(array('count_condition_1', 'count_condition_2'), Criteria::LOGICAL_AND); } else { $urlQuery->where('ISNULL(`ra`.REWRITING_URL_ID)'); } From fe859591f437b5677747297945bdec69baaad391 Mon Sep 17 00:00:00 2001 From: mespeche Date: Fri, 30 Aug 2013 16:32:01 +0200 Subject: [PATCH 072/268] WIP Refonte et mise en place du minibrowser --- templates/admin/default/assets/js/main.js | 131 +++++++++++----------- templates/admin/default/coupon/edit.html | 16 +-- 2 files changed, 68 insertions(+), 79 deletions(-) diff --git a/templates/admin/default/assets/js/main.js b/templates/admin/default/assets/js/main.js index 7b5cc812f..e8f4a0aa7 100644 --- a/templates/admin/default/assets/js/main.js +++ b/templates/admin/default/assets/js/main.js @@ -1,6 +1,6 @@ (function($, window, document){ - $(function($){ + $(function(){ // -- Init datepicker -- if($('.date').length){ @@ -41,76 +41,71 @@ } }); - } + } - }); - - - -}(window.jQuery, window, document)); - -// -- Mini browser -- -function miniBrowser(root, url){ - - $.getJSON(url, { - root: root - }) - .done(function(data) { - var resultat = data; + // -- Mini browser -- + miniBrowser = function (root, url){ - var breadcrumb = $('
      '); - $(resultat.breadcrumb).each(function(k, v){ - breadcrumb.append( - $('').html(' > '), - $('').attr('href', '#').html(v.display).click(function(e){ - e.preventDefault(); + $.getJSON(url, { + root: root + }) + .done(function(data) { + var resultat = data; - miniBrowser(v.url) - }) - ); - }); - - var categories = $('
      '); - $(resultat.categories).each(function(k, v){ - categories.append( - $('

      ').append( - $('').attr('href', '#').html(v.titre).click(function(e){ - e.preventDefault(); + var breadcrumb = $('

      '); + $(resultat.breadcrumb).each(function(k, v){ + breadcrumb.append( + $('').html(' > '), + $('').attr('href', '#').html(v.display).click(function(e){ + e.preventDefault(); + miniBrowser(v.url); + }) + ); + }); + + var categories = $('
      '); + $(resultat.categories).each(function(k, v){ + categories.append( + $('

      ').append( + $('').attr('href', '#').html(v.titre).click(function(e){ + e.preventDefault(); + miniBrowser(v.id); + }) + ) + ); + }); + + var products = $('

      '); + $(resultat.products).each(function(k, v){ + products.append( + $('

      ').append( + $('').attr('href', '#').html(v.titre).click(function(e){ + e.preventDefault(); - miniBrowser(v.id) - }) - ) - ); - }); - - var products = $('

      '); - $(resultat.products).each(function(k, v){ - products.append( - $('

      ').append( - $('').attr('href', '#').html(v.titre).click(function(e){ - e.preventDefault(); + $('#productToAdd_ref').val(v.ref); + $('#productToAdd_titre').val(v.titre); + $('#productToAdd_quantite').val(1); + + manageStock(v.variants, v.promo?v.prix2:v.prix); + + $('#productToAdd_tva').val(v.tva); + + $('.productToAddInformation').show(); + $('#btn_ajout_produit').show(); + }) + ) + ); + }); + + $('#minibrowser-breadcrumb').unbind().empty().append(breadcrumb); + $('#minibrowser-categories').unbind().empty().append(categories); + }) + .fail(function() { + console.log('The JSON file cant be read'); + }); + + } - $('#productToAdd_ref').val(v.ref); - $('#productToAdd_titre').val(v.titre); - $('#productToAdd_quantite').val(1); - - manageStock(v.variants, v.promo?v.prix2:v.prix); - - $('#productToAdd_tva').val(v.tva); - - $('.productToAddInformation').show(); - $('#btn_ajout_produit').show(); - }) - ) - ); - }); - - $('#fastBrowser_breadcrumb').unbind().empty().append(breadcrumb); - $('#fastBrowser_categories').unbind().empty().append(categories); - $('#fastBrowser_products').unbind().empty().append(products); - }) - .fail(function() { - console.log('The JSON file cant be read'); }); - -} \ No newline at end of file + +}(window.jQuery, window, document)); \ No newline at end of file diff --git a/templates/admin/default/coupon/edit.html b/templates/admin/default/coupon/edit.html index 4ad8f28c0..6e2692480 100755 --- a/templates/admin/default/coupon/edit.html +++ b/templates/admin/default/coupon/edit.html @@ -201,7 +201,7 @@

      -
      +
      - +
      - + - - + - - +
      - - - - Categories list
      From 6fa4d3a9238917c5eb01d199b4c008b085e26c2e Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 30 Aug 2013 16:47:13 +0200 Subject: [PATCH 073/268] rewriting --- .../Thelia/Rewriting/RewritingRetriever.php | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Rewriting/RewritingRetriever.php b/core/lib/Thelia/Rewriting/RewritingRetriever.php index 34be346f1..0deb7de45 100755 --- a/core/lib/Thelia/Rewriting/RewritingRetriever.php +++ b/core/lib/Thelia/Rewriting/RewritingRetriever.php @@ -35,6 +35,13 @@ use Thelia\Model\Map\RewritingUrlTableMap; */ class RewritingRetriever { + /** + * @param $view + * @param $viewLocale + * @param $viewId + * + * @return null|$url + */ public function getViewUrl($view, $viewLocale, $viewId) { $url = $this->getViewUrlQuery($view, $viewId, $viewLocale); @@ -42,6 +49,13 @@ class RewritingRetriever return $url === null ? null : $url->getUrl(); } + /** + * @param $view + * @param $viewId + * @param $viewLocale + * + * @return null|RewritingUrl + */ protected function getViewUrlQuery($view, $viewId, $viewLocale) { return RewritingUrlQuery::create() @@ -55,12 +69,18 @@ class RewritingRetriever ->findOne(); } + /** + * @param $view + * @param $viewLocale + * @param null $viewId + * @param array $viewOtherParameters + * + * @return null|$url + */ public function getSpecificUrl($view, $viewLocale, $viewId = null, $viewOtherParameters = array()) { $urlQuery = RewritingUrlQuery::create() ->joinRewritingArgument('ra', Criteria::LEFT_JOIN) - //->withColumn('`ra`.PARAMETER', 'ra_parameter') - //->withColumn('`ra`.VALUE', 'ra_value') ->withColumn('`ra`.REWRITING_URL_ID', 'ra_REWRITING_URL_ID') ->filterByView($view) ->filterByViewLocale($viewLocale) From 6867eae9b76ea43eedecd13270f80954742a3e4e Mon Sep 17 00:00:00 2001 From: franck Date: Fri, 30 Aug 2013 19:46:12 +0200 Subject: [PATCH 074/268] Fixed customer front controller, events, addec admion config. --- core/lib/Thelia/Action/Category.php | 8 +- core/lib/Thelia/Action/Customer.php | 15 +- core/lib/Thelia/Config/Resources/action.xml | 4 +- .../Thelia/Config/Resources/routing/front.xml | 6 +- .../Controller/Admin/BaseAdminController.php | 8 +- .../Controller/Admin/CategoryController.php | 28 +- .../Controller/Admin/SessionController.php | 11 +- core/lib/Thelia/Controller/BaseController.php | 27 +- .../Controller/Front/CustomerController.php | 175 +++++++---- .../Thelia/Core/Event/CategoryChangeEvent.php | 44 +++ .../Event/CategoryChangePositionEvent.php | 29 +- .../Thelia/Core/Event/CategoryCreateEvent.php | 1 - .../Thelia/Core/Event/CategoryDeleteEvent.php | 14 +- .../Event/CategoryToggleVisibilityEvent.php | 14 +- .../Thelia/Core/Event/CustomerLoginEvent.php | 2 +- .../Core/EventListener/ControllerListener.php | 7 +- .../UsernamePasswordFormAuthenticator.php | 2 - .../Thelia/Core/Security/SecurityContext.php | 20 ++ .../Thelia/Core/Template/Element/BaseLoop.php | 2 +- .../Thelia/Core/Template/Loop/Category.php | 10 +- core/lib/Thelia/Core/Template/Loop/Image.php | 16 +- .../Thelia/Core/Template/ParserContext.php | 4 + core/lib/Thelia/Model/Base/Category.php | 1 - core/lib/Thelia/Model/Lang.php | 29 ++ .../Thelia/Model/Tools/ModelCriteriaTools.php | 3 +- install/faker.php | 8 +- templates/admin/default/assets/css/admin.less | 48 ++- templates/admin/default/categories.html | 71 ++++- templates/admin/default/configuration.html | 174 +++++++++++ templates/admin/default/edit_category.html | 279 ++++++++++-------- templates/admin/default/general_error.html | 2 +- .../admin/default/includes/header.inc.html | 12 +- templates/admin/default/login.html | 3 - templates/default/includes/header.html | 4 +- templates/default/login.html | 13 +- 35 files changed, 810 insertions(+), 284 deletions(-) create mode 100644 core/lib/Thelia/Core/Event/CategoryChangeEvent.php create mode 100644 templates/admin/default/configuration.html diff --git a/core/lib/Thelia/Action/Category.php b/core/lib/Thelia/Action/Category.php index d411d2a51..b9bde8a07 100755 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -75,7 +75,7 @@ class Category extends BaseAction implements EventSubscriberInterface { $this->checkAuth("ADMIN", "admin.category.delete"); - $category = CategoryQuery::create()->findPk($event->getId()); + $category = CategoryQuery::create()->findPk($event->getCategoryId()); if ($category !== null) { @@ -98,7 +98,7 @@ class Category extends BaseAction implements EventSubscriberInterface { $this->checkAuth("ADMIN", "admin.category.edit"); - $category = CategoryQuery::create()->findPk($event->getId()); + $category = CategoryQuery::create()->findPk($event->getCategoryId()); if ($category !== null) { @@ -136,7 +136,7 @@ class Category extends BaseAction implements EventSubscriberInterface */ protected function exchangePosition(CategoryChangePositionEvent $event) { - $category = CategoryQuery::create()->findPk($event->getId()); + $category = CategoryQuery::create()->findPk($event->getCategoryId()); if ($category !== null) { @@ -195,7 +195,7 @@ class Category extends BaseAction implements EventSubscriberInterface { $this->checkAuth("ADMIN", "admin.category.edit"); - $category = CategoryQuery::create()->findPk($event->getId()); + $category = CategoryQuery::create()->findPk($event->getCategoryId()); if ($category !== null) { diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 4c7a71d5e..aed93d390 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -38,6 +38,7 @@ use Symfony\Component\Validator\Exception\ValidatorException; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\UsernameNotFoundException; use Propel\Runtime\Exception\PropelException; +use Thelia\Core\Event\CustomerLoginEvent; class Customer extends BaseAction implements EventSubscriberInterface { @@ -46,7 +47,6 @@ class Customer extends BaseAction implements EventSubscriberInterface { $customer = new CustomerModel(); - $customer->setDispatcher($this->getDispatcher()); $this->createOrUpdateCustomer($customer, $event); @@ -56,7 +56,6 @@ class Customer extends BaseAction implements EventSubscriberInterface { $customer = $event->getCustomer(); - $customer->setDispatcher($this->getDispatcher()); $this->createOrUpdateCustomer($customer, $event); @@ -64,6 +63,8 @@ class Customer extends BaseAction implements EventSubscriberInterface private function createOrUpdateCustomer(CustomerModel $customer, CustomerCreateOrUpdateEvent $event) { + $customer->setDispatcher($this->getDispatcher()); + $customer->createOrUpdate( $event->getTitle(), $event->getFirstname(), @@ -87,6 +88,12 @@ class Customer extends BaseAction implements EventSubscriberInterface $event->setCustomer($customer); } + + public function login(CustomerLoginEvent $event) + { + $this->getSecurityContext()->setCustomerUser($event->getCustomer()); + } + /** * Perform user logout. The user is redirected to the provided view, if any. * @@ -94,8 +101,6 @@ class Customer extends BaseAction implements EventSubscriberInterface */ public function logout(ActionEvent $event) { - $event->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_LOGOUT, $event); - $this->getSecurityContext()->clearCustomerUser(); } @@ -129,6 +134,8 @@ class Customer extends BaseAction implements EventSubscriberInterface return array( TheliaEvents::CUSTOMER_CREATEACCOUNT => array("create", 128), TheliaEvents::CUSTOMER_UPDATEACCOUNT => array("modify", 128), + TheliaEvents::CUSTOMER_LOGOUT => array("logout", 128), + TheliaEvents::CUSTOMER_LOGIN => array("login" , 128), ); } } diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 2bd31ce3e..7d21eadee 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -22,12 +22,12 @@ - + - + diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index c420e1550..9329b22ad 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -18,10 +18,14 @@ Thelia\Controller\Front\CustomerController::updateAction - + Thelia\Controller\Front\CustomerController::loginAction + + Thelia\Controller\Front\CustomerController::logoutAction + + Thelia\Controller\Front\CartController::addItem cart diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 271ce3c05..989715de4 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -52,11 +52,13 @@ class BaseAdminController extends BaseController if (! empty($template)) { // If we have a view in the URL, render this view return $this->render($template); - } elseif (null != $view = $this->getRequest()->get('view')) { + } + elseif (null != $view = $this->getRequest()->get('view')) { return $this->render($view); } - } catch (\Exception $ex) { - // Nothing special + } + catch (\Exception $ex) { + return new Response($this->errorPage($ex->getMessage())); } return $this->pageNotFound(); diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 4e798d683..f922f1b9d 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -33,6 +33,7 @@ use Thelia\Core\Event\CategoryDeleteEvent; use Thelia\Core\Event\CategoryToggleVisibilityEvent; use Thelia\Core\Event\CategoryChangePositionEvent; use Thelia\Form\CategoryDeletionForm; +use Thelia\Model\Lang; class CategoryController extends BaseAdminController { @@ -99,7 +100,7 @@ class CategoryController extends BaseAdminController $this->adminLogAppend(sprintf("Category %s (ID %s) deleted", $category->getTitle(), $category->getId())); // Substitute _ID_ in the URL with the ID of the created category - $successUrl = str_replace('_ID_', $categoryDeleteEvent->getDeletedCategory()->getId(), $categoryDeletionForm->getSuccessUrl()); + $successUrl = str_replace('_ID_', $categoryDeleteEvent->getDeletedCategory()->getParent(), $categoryDeletionForm->getSuccessUrl()); // Redirect to the success URL $this->redirect($successUrl); @@ -185,11 +186,34 @@ class CategoryController extends BaseAdminController // Get the category ID $id = $this->getRequest()->get('id', 0); + // Find the current order + $category_order = $this->getRequest()->get( + 'category_order', + $this->getSession()->get('admin.category_order', 'manual') + ); + + // Find the current edit language ID + $edition_language = $this->getRequest()->get( + 'edition_language', + $this->getSession()->get('admin.edition_language', Lang::getDefaultLanguage()->getId()) + ); + $args = array( 'action' => $action, - 'current_category_id' => $id + 'current_category_id' => $id, + 'category_order' => $category_order, + 'edition_language' => $edition_language, + 'date_format' => Lang::getDefaultLanguage()->getDateFormat(), + 'time_format' => Lang::getDefaultLanguage()->getTimeFormat(), + 'datetime_format' => Lang::getDefaultLanguage()->getDateTimeFormat(), ); + // Store the current sort order in session + $this->getSession()->set('admin.category_order', $category_order); + + // Store the current edition language in session + $this->getSession()->set('admin.edition_language', $edition_language); + try { switch ($action) { case 'browse' : // Browse categories diff --git a/core/lib/Thelia/Controller/Admin/SessionController.php b/core/lib/Thelia/Controller/Admin/SessionController.php index 39dbc1205..4e4e909e2 100755 --- a/core/lib/Thelia/Controller/Admin/SessionController.php +++ b/core/lib/Thelia/Controller/Admin/SessionController.php @@ -51,13 +51,16 @@ class SessionController extends BaseAdminController public function checkLoginAction() { - $adminLoginForm = new AdminLogin($this->getRequest()); - $request = $this->getRequest(); - $authenticator = new AdminUsernamePasswordFormAuthenticator($request, $adminLoginForm); + $adminLoginForm = new AdminLogin($request); try { + + $form = $this->validateForm($adminLoginForm, "post"); + + $authenticator = new AdminUsernamePasswordFormAuthenticator($request, $adminLoginForm); + $user = $authenticator->getAuthentifiedUser(); // Success -> store user in security context @@ -85,7 +88,7 @@ class SessionController extends BaseAdminController // Log authentication failure AdminLog::append(sprintf("Undefined error: %s", $ex->getMessage()), $request); - $message = "Unable to process your request. Please try again."; + $message = "Unable to process your request. Please try again.".$ex->getMessage(); } // Store error information in the form diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 1a610768d..bede9f08c 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -35,6 +35,7 @@ use Thelia\Core\Factory\ActionEventFactory; use Thelia\Form\BaseForm; use Thelia\Form\Exception\FormValidationException; use Symfony\Component\EventDispatcher\Event; +use Thelia\Core\Event\DefaultActionEvent; /** * @@ -60,10 +61,12 @@ class BaseController extends ContainerAware * Dispatch a Thelia event * * @param string $eventName a TheliaEvent name, as defined in TheliaEvents class - * @param Event $event the event + * @param Event $event the action event, or null (a DefaultActionEvent will be dispatched) */ - protected function dispatch($eventName, Event $event = null) + protected function dispatch($eventName, ActionEvent $event = null) { + if ($event == null) $event = new DefaultActionEvent(); + $this->getDispatcher()->dispatch($eventName, $event); } @@ -145,7 +148,8 @@ class BaseController extends ContainerAware /** * - * redirect request to specify url + * redirect request to the specified url + * * @param string $url */ public function redirect($url) @@ -154,12 +158,21 @@ class BaseController extends ContainerAware } /** - * If success_url param is present in request, follow this link. + * If success_url param is present in request or in the provided form, redirect to this URL. + * + * @param BaseForm $form a base form, which may contains the success URL */ - protected function redirectSuccess() + protected function redirectSuccess(BaseForm $form = null) { - if (null !== $url = $this->getRequest()->get("success_url")) { - $this->redirect($url); + if ($form != null) { + $url = $form->getSuccessUrl(); } + else { + $url = $this->getRequest()->get("success_url"); + } + + echo "url=$url"; + + if (null !== $url) $this->redirect($url); } } diff --git a/core/lib/Thelia/Controller/Front/CustomerController.php b/core/lib/Thelia/Controller/Front/CustomerController.php index 698c69d70..de6d15129 100755 --- a/core/lib/Thelia/Controller/Front/CustomerController.php +++ b/core/lib/Thelia/Controller/Front/CustomerController.php @@ -22,8 +22,6 @@ /*************************************************************************************/ namespace Thelia\Controller\Front; -use Propel\Runtime\Exception\PropelException; -use Symfony\Component\Validator\Exception\ValidatorException; use Thelia\Core\Event\CustomerCreateOrUpdateEvent; use Thelia\Core\Event\CustomerLoginEvent; use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator; @@ -37,65 +35,101 @@ use Thelia\Form\Exception\FormValidationException; use Thelia\Model\Customer; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\CustomerEvent; +use Thelia\Core\Factory\ActionEventFactory; +use Thelia\Tools\URL; +use Thelia\Log\Tlog; +use Thelia\Core\Security\Exception\WrongPasswordException; class CustomerController extends BaseFrontController { /** - * create a new Customer. Retrieve data in form and dispatch a action.createCustomer event - * - * if error occurs, message is set in the parserContext + * Create a new customer. + * On success, redirect to success_url if exists, otherwise, display the same view again. */ public function createAction() { - $request = $this->getRequest(); - $customerCreation = new CustomerCreation($request); - try { - $form = $this->validateForm($customerCreation, "post"); + if (! $this->getSecurityContext()->hasCustomerUser()) { - $customerCreateEvent = $this->createEventInstance($form->getData()); + $message = false; - $this->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreateEvent); + $customerCreation = new CustomerCreation($this->getRequest()); - $this->processLogin($customerCreateEvent->getCustomer()); + try { + $form = $this->validateForm($customerCreation, "post"); - $this->redirectSuccess(); + $customerCreateEvent = $this->createEventInstance($form->getData()); - } catch (FormValidationException $e) { - $customerCreation->setErrorMessage($e->getMessage()); - $this->getParserContext()->setErrorForm($customerCreation); - } catch (PropelException $e) { - \Thelia\Log\Tlog::getInstance()->error(sprintf("error during customer creation process in front context with message : %s", $e->getMessage())); - $this->getParserContext()->setGeneralError($e->getMessage()); + $this->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreateEvent); + + $this->processLogin($customerCreateEvent->getCustomer()); + + $this->redirectSuccess($customerCreation); + } + catch (FormValidationException $e) { + $message = "Invalid or missing data. Please check your input"; + } + catch (\Exception $e) { + $message = "Sorry, an unknown error occured."; + } + + if ($message !== false) { + Tlog::getInstance()->error(sprintf("Error during customer creation process : %s. Exception was %s", $message, $e->getMessage())); + + $customerLoginForm->setErrorMessage($message); + + $this->getParserContext() + ->setErrorForm($customerLoginForm) + ->setGeneralError($message) + ; + } } - } + /** + * Update customer data. On success, redirect to success_url if exists. + * Otherwise, display the same view again. + */ public function updateAction() { - $request = $this->getRequest(); - $customerModification = new CustomerModification($request); + if ($this->getSecurityContext()->hasCustomerUser()) { - try { + $message = false; - $customer = $this->getSecurityContext()->getCustomerUser(); + $customerModification = new CustomerModification($this->getRequest()); - $form = $this->validateForm($customerModification, "post"); + try { - $customerChangeEvent = $this->createEventInstance($form->getData()); - $customerChangeEvent->setCustomer($customer); + $customer = $this->getSecurityContext()->getCustomerUser(); - $this->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_UPDATEACCOUNT, $customerChangeEvent); + $form = $this->validateForm($customerModification, "post"); - $this->processLogin($customerChangeEvent->getCustomer()); + $customerChangeEvent = $this->createEventInstance($form->getData()); + $customerChangeEvent->setCustomer($customer); - $this->redirectSuccess(); + $this->dispatch(TheliaEvents::CUSTOMER_UPDATEACCOUNT, $customerChangeEvent); - } catch (FormValidationException $e) { - $customerModification->setErrorMessage($e->getMessage()); - $this->getParserContext()->setErrorForm($customerModification); - } catch (PropelException $e) { - \Thelia\Log\Tlog::getInstance()->error(sprintf("error during updating customer in front context with message : %s", $e->getMessage())); - $this->getParserContext()->setGeneralError($e->getMessage()); + $this->processLogin($customerChangeEvent->getCustomer()); + + $this->redirectSuccess($customerModification); + + } + catch (FormValidationException $e) { + $message = "Invalid or missing data. Please check your input"; + } + catch (\Exception $e) { + $message = "Sorry, an unknown error occured."; + } + + if ($message !== false) { + Tlog::getInstance()->error(sprintf("Error during customer modification process : %s. Exception was %s", $message, $e->getMessage())); + + $customerLoginForm->setErrorMessage($message); + + $this->getParserContext() + ->setErrorForm($customerLoginForm) + ->setGeneralError($message) + ; + } } } @@ -103,39 +137,75 @@ class CustomerController extends BaseFrontController * Perform user login. On a successful login, the user is redirected to the URL * found in the success_url form parameter, or / if none was found. * - * If login is not successfull, the same view is dispolyed again. + * If login is not successfull, the same view is displayed again. * */ public function loginAction() { - $request = $this->getRequest(); + if (! $this->getSecurityContext()->hasCustomerUser()) { + $message = false; - $customerLoginForm = new CustomerLogin($request); + $request = $this->getRequest(); - $authenticator = new CustomerUsernamePasswordFormAuthenticator($request, $customerLoginForm); + try { - try { - $customer = $authenticator->getAuthentifiedUser(); + $customerLoginForm = new CustomerLogin($request); - $this->processLogin($customer); + $form = $this->validateForm($customerLoginForm, "post"); - $this->redirectSuccess(); - } catch (ValidatorException $e) { + $authenticator = new CustomerUsernamePasswordFormAuthenticator($request, $customerLoginForm); - } catch(UsernameNotFoundException $e) { + $customer = $authenticator->getAuthentifiedUser(); - } catch(AuthenticationException $e) { + $this->processLogin($customer); - } catch (\Exception $e) { + $this->redirectSuccess($customerLoginForm); + } + catch (FormValidationException $e) { + $message = "Invalid or missing data. Please check your input"; + } + catch(UsernameNotFoundException $e) { + $message = "This customer email was not found."; + } + catch (WrongPasswordException $e) { + $message = "Wrong password. Please try again."; + } + catch(AuthenticationException $e) { + $message = "Sorry, we failed to authentify you. Please try again."; + } + catch (\Exception $e) { + $message = "Sorry, an unknown error occured."; + } + + if ($message !== false) { + Tlog::getInstance()->error(sprintf("Error during customer login process : %s. Exception was %s", $message, $e->getMessage())); + + $customerLoginForm->setErrorMessage($message); + + $this->getParserContext()->setErrorForm($customerLoginForm); + } } } - public function processLogin(Customer $customer) + /** + * Perform customer logout. + * + * @param Customer $customer + */ + public function logoutAction() { - $this->getSecurityContext()->setCustomerUser($customer); + if ($this->getSecurityContext()->hasCustomerUser()) { + $this->dispatch(TheliaEvents::CUSTOMER_LOGOUT); + } - if($event) $this->dispatch(TheliaEvents::CUSTOMER_LOGIN, new CustomerLoginEvent($customer)); + // Redirect to home page + $this->redirect(URL::getIndexPage()); + } + + protected function processLogin(Customer $customer) + { + $this->dispatch(TheliaEvents::CUSTOMER_LOGIN, new CustomerLoginEvent($customer)); } /** @@ -161,10 +231,9 @@ class CustomerController extends BaseFrontController $this->getRequest()->getSession()->getLang(), isset($data["reseller"])?$data["reseller"]:null, isset($data["sponsor"])?$data["sponsor"]:null, - isset($data["discount"])?$data["discount"]:nullsch + isset($data["discount"])?$data["discount"]:null ); return $customerCreateEvent; } - } diff --git a/core/lib/Thelia/Core/Event/CategoryChangeEvent.php b/core/lib/Thelia/Core/Event/CategoryChangeEvent.php new file mode 100644 index 000000000..e8e183b3f --- /dev/null +++ b/core/lib/Thelia/Core/Event/CategoryChangeEvent.php @@ -0,0 +1,44 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Category; + +class CategoryCreateEvent extends ActionEvent +{ + protected $category_id; + protected $locale; + protected $title; + protected $chapo; + protected $description; + protected $postscriptum; + protected $url; + protected $visibility; + protected $parent; + + public function __construct($category_id) + { + $this->category_id = $category_id; + } +} diff --git a/core/lib/Thelia/Core/Event/CategoryChangePositionEvent.php b/core/lib/Thelia/Core/Event/CategoryChangePositionEvent.php index 141fc8182..94f131626 100644 --- a/core/lib/Thelia/Core/Event/CategoryChangePositionEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryChangePositionEvent.php @@ -30,28 +30,18 @@ class CategoryChangePositionEvent extends ActionEvent const POSITION_DOWN = 2; const POSITION_ABSOLUTE = 3; - protected $id; + protected $category_id; protected $mode; protected $position; protected $category; - public function __construct($id, $mode, $position = null) + public function __construct($category_id, $mode, $position = null) { - $this->id = $id; + $this->category_id = $category_id; $this->mode = $mode; $this->position = $position; } - public function getId() - { - return $this->id; - } - - public function setId($id) - { - $this->id = $id; - } - public function getMode() { return $this->mode; @@ -81,4 +71,15 @@ class CategoryChangePositionEvent extends ActionEvent { $this->category = $category; } -} \ No newline at end of file + + public function getCategoryId() + { + return $this->category_id; + } + + public function setCategoryId($category_id) + { + $this->category_id = $category_id; + } + +} diff --git a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php index 558b04277..f4d5a45ee 100644 --- a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php @@ -77,6 +77,5 @@ class CategoryCreateEvent extends ActionEvent public function setCreatedCategory(Category $created_category) { $this->created_category = $created_category; -var_dump($this->created_category); } } diff --git a/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php b/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php index c53cb7e10..3e863be8e 100644 --- a/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php @@ -26,22 +26,22 @@ use Thelia\Model\Category; class CategoryDeleteEvent extends ActionEvent { - protected $id; + protected $category_id; protected $deleted_category; - public function __construct($id) + public function __construct($category_id) { - $this->id = $id; + $this->category_id = $category_id; } - public function getId() + public function getCategoryId() { - return $this->id; + return $this->category_id; } - public function setId($id) + public function setCategoryId($category_id) { - $this->id = $id; + $this->category_id = $category_id; } public function getDeletedCategory() diff --git a/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php index b7237924e..ef921a0de 100644 --- a/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php @@ -26,22 +26,22 @@ use Thelia\Model\Category; class CategoryToggleVisibilityEvent extends ActionEvent { - protected $id; + protected $category_id; protected $category; - public function __construct($id) + public function __construct($category_id) { - $this->id = $id; + $this->category_id = $category_id; } - public function getId() + public function getCategoryId() { - return $this->id; + return $this->category_id; } - public function setId($id) + public function setCategoryId($category_id) { - $this->id = $id; + $this->category_id = $category_id; } public function getCategory() diff --git a/core/lib/Thelia/Core/Event/CustomerLoginEvent.php b/core/lib/Thelia/Core/Event/CustomerLoginEvent.php index cc363790d..9a26bba3f 100755 --- a/core/lib/Thelia/Core/Event/CustomerLoginEvent.php +++ b/core/lib/Thelia/Core/Event/CustomerLoginEvent.php @@ -26,7 +26,7 @@ namespace Thelia\Core\Event; use Thelia\Model\Customer; -class CustomerLoginEvent { +class CustomerLoginEvent extends ActionEvent { protected $customer; diff --git a/core/lib/Thelia/Core/EventListener/ControllerListener.php b/core/lib/Thelia/Core/EventListener/ControllerListener.php index 9bb432e6a..0585bbe81 100755 --- a/core/lib/Thelia/Core/EventListener/ControllerListener.php +++ b/core/lib/Thelia/Core/EventListener/ControllerListener.php @@ -59,12 +59,7 @@ class ControllerListener implements EventSubscriberInterface $event = new ActionEventFactory($request, $action, $event->getKernel()->getContainer()->getParameter("thelia.actionEvent")); $actionEvent = $event->createActionEvent(); $dispatcher->dispatch("action.".$action, $actionEvent); - - // Process form errors - if ($actionEvent->hasErrorForm()) { - $this->parserContext->setErrorForm($actionEvent->getErrorForm()); - } - } + } } public static function getSubscribedEvents() diff --git a/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php index 6dc938d88..d9a223430 100755 --- a/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php +++ b/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php @@ -55,8 +55,6 @@ class UsernamePasswordFormAuthenticator implements AuthenticatorInterface ); $this->options = array_merge($defaults, $options); - - $this->loginForm->bind($this->request); } /** diff --git a/core/lib/Thelia/Core/Security/SecurityContext.php b/core/lib/Thelia/Core/Security/SecurityContext.php index c09945f61..6ddb47f00 100755 --- a/core/lib/Thelia/Core/Security/SecurityContext.php +++ b/core/lib/Thelia/Core/Security/SecurityContext.php @@ -60,6 +60,16 @@ class SecurityContext return $this->getSession()->getAdminUser(); } + /** + * Check if an admin user is logged in. + * + * @return true if an admin user is logged in, false otherwise. + */ + public function hasAdminUser() + { + return $this->getSession()->getAdminUser() != null; + } + /** * Gets the currently authenticated customer, or null if none is defined * @@ -70,6 +80,16 @@ class SecurityContext return $this->getSession()->getCustomerUser(); } + /** + * Check if a customer user is logged in. + * + * @return true if a customer is logged in, false otherwise. + */ + public function hasCustomerUser() + { + return $this->getSession()->getCustomerUser() != null; + } + /** * Check if a user has at least one of the required roles * diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 8861022e9..03956386d 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -138,7 +138,7 @@ abstract class BaseLoop } elseif ($value !== null && !$argument->type->isValid($value)) { /* check type */ $faultActor[] = $argument->name; - $faultDetails[] = sprintf('Invalid value for "%s" argument in loop type: %s, name: %s', $argument->name, $loopType, $loopName); + $faultDetails[] = sprintf('Invalid value "%s" for "%s" argument in loop type: %s, name: %s', $value, $argument->name, $loopType, $loopName); } else { /* set default */ /* did it as last checking for we consider default value is acceptable no matter type or empty restriction */ diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index e01ce3df4..d7ed1ddf9 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -79,7 +79,7 @@ class Category extends BaseLoop new Argument( 'order', new TypeCollection( - new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'random')) + new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'visible', 'visible_reverse', 'random')) ), 'manual' ), @@ -146,6 +146,12 @@ class Category extends BaseLoop case "manual": $search->orderByPosition(Criteria::ASC); break; + case "visible": + $search->orderByVisible(Criteria::ASC); + break; + case "visible_reverse": + $search->orderByVisible(Criteria::DESC); + break; case "random": $search->clearOrderByColumns(); $search->addAscendingOrderByColumn('RAND()'); @@ -173,7 +179,7 @@ class Category extends BaseLoop $loopResultRow ->set("ID", $category->getId()) ->set("IS_TRANSLATED",$category->getVirtualColumn('IS_TRANSLATED')) - ->set("TITLE",$category->getVirtualColumn('i18n_TITLE')) + ->set("TITLE", $category->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $category->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM')) diff --git a/core/lib/Thelia/Core/Template/Loop/Image.php b/core/lib/Thelia/Core/Template/Loop/Image.php index 638905dc2..e26bcc9fe 100755 --- a/core/lib/Thelia/Core/Template/Loop/Image.php +++ b/core/lib/Thelia/Core/Template/Loop/Image.php @@ -63,7 +63,6 @@ class Image extends BaseLoop $queryClass = sprintf("\Thelia\Model\%sImageQuery", $object); $filterMethod = sprintf("filterBy%sId", $object); - $mapClass = sprintf("\Thelia\Model\Map\%sI18nTableMap", $object); // xxxImageQuery::create() $method = new \ReflectionMethod($queryClass, 'create'); @@ -73,19 +72,16 @@ class Image extends BaseLoop $method = new \ReflectionMethod($queryClass, $filterMethod); $method->invoke($search, $object_id); - $map = new \ReflectionClass($mapClass); - $title_map = $map->getConstant('TITLE'); - $orders = $this->getOrder(); // Results ordering foreach ($orders as $order) { switch ($order) { case "alpha": - $search->addAscendingOrderByColumn($title_map); + $search->addAscendingOrderByColumn('i18n_TITLE'); break; case "alpha-reverse": - $search->addDescendingOrderByColumn($title_map); + $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "manual-reverse": $search->orderByPosition(Criteria::DESC); @@ -122,7 +118,7 @@ class Image extends BaseLoop $source_id = $this->getSourceId(); - // echo "source = ".$this->getSource().", id=".$id."
      "; + // echo "source = ".$this->getSource().", id=".$source_id." - ".$this->getArg('source_id')->getValue()."
      "; if (is_null($source_id)) { throw new \InvalidArgumentException("'source_id' argument cannot be null if 'source' argument is specified."); @@ -167,6 +163,9 @@ class Image extends BaseLoop $search = $this->getSearchQuery($object_type, $object_id); + /* manage translations */ + $this->configureI18nProcessing($search); + $id = $this->getId(); if (! is_null($id)) { @@ -207,8 +206,7 @@ class Image extends BaseLoop } - /* manage translations */ - $this->configureI18nProcessing($search); + // echo "sql=".$search->toString(); $results = $this->search($search, $pagination); diff --git a/core/lib/Thelia/Core/Template/ParserContext.php b/core/lib/Thelia/Core/Template/ParserContext.php index 03c3cf45f..801b5a127 100755 --- a/core/lib/Thelia/Core/Template/ParserContext.php +++ b/core/lib/Thelia/Core/Template/ParserContext.php @@ -56,11 +56,15 @@ class ParserContext implements \IteratorAggregate public function setErrorForm(BaseForm $form) { $this->set('error_form', $form); + + return $this; } public function setGeneralError($error) { $this->set('general_error', $error); + + return $this; } public function getErrorForm() diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php index 46a8876ef..d03fd04ad 100755 --- a/core/lib/Thelia/Model/Base/Category.php +++ b/core/lib/Thelia/Model/Base/Category.php @@ -474,7 +474,6 @@ abstract class Category implements ActiveRecordInterface if (!$this->hasVirtualColumn($name)) { throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); } - return $this->virtualColumns[$name]; } diff --git a/core/lib/Thelia/Model/Lang.php b/core/lib/Thelia/Model/Lang.php index d63422680..3339dec64 100755 --- a/core/lib/Thelia/Model/Lang.php +++ b/core/lib/Thelia/Model/Lang.php @@ -6,4 +6,33 @@ use Thelia\Model\Base\Lang as BaseLang; class Lang extends BaseLang { + /** + * Return the default language object, using a local variable to cache it. + * + * @throws RuntimeException + */ + private static $default_lang = null; + + public static function getDefaultLanguage() { + + if (self::$default_lang == null) { + $default_lang = LangQuery::create()->findOneByByDefault(true); + + if ($default_lang == null) throw new RuntimeException("No default language is defined. Please define one."); + } + + return $default_lang; + } + + public function getDateFormat() { + return "d/m/Y"; + } + + public function getTimeFormat() { + return "H:i:s"; + } + + public function getDateTimeFormat() { + return "d/m/Y H:i:s"; + } } diff --git a/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php index 3913b2890..578b2c19d 100755 --- a/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php +++ b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php @@ -7,6 +7,7 @@ use Propel\Runtime\ActiveQuery\Join; use Propel\Runtime\ActiveQuery\ModelCriteria; use Thelia\Model\Base\LangQuery; use Thelia\Model\ConfigQuery; +use Thelia\Model\Lang; /** * Class ModelCriteriaTools @@ -52,7 +53,7 @@ class ModelCriteriaTools $search->withColumn('`' . $requestedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column); } } else { - $defaultLocale = LangQuery::create()->findOneById($defaultLangWithoutTranslation)->getLocale(); + $defaultLocale = Lang::getDefaultLanguage()->getLocale(); $defaultLocaleJoin = new Join(); $defaultLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $defaultLocaleI18nAlias); diff --git a/install/faker.php b/install/faker.php index 81edd767d..f1e7691d7 100755 --- a/install/faker.php +++ b/install/faker.php @@ -240,7 +240,7 @@ try { //categories and products $productIdList = array(); $categoryIdList = array(); - for($i=0; $i<4; $i++) { + for($i=1; $i<5; $i++) { $category = createCategory($faker, 0, $i, $categoryIdList, $contentIdList); for($j=1; $jsetProductId($productId); generate_image($image, 1, 'product', $productId); - + return $product; } @@ -415,7 +415,7 @@ function createCategory($faker, $parent, $position, &$categoryIdList, $contentId $image = new CategoryImage(); $image->setCategoryId($categoryId); generate_image($image, 1, 'category', $categoryId); - + return $category; } diff --git a/templates/admin/default/assets/css/admin.less b/templates/admin/default/assets/css/admin.less index 9d9f2c482..66a03ab37 100755 --- a/templates/admin/default/assets/css/admin.less +++ b/templates/admin/default/assets/css/admin.less @@ -216,6 +216,10 @@ hr { width: 23px; height: @top-bar-height; } + + a.profile { + color: #fff; + } } .view-shop { @@ -233,10 +237,6 @@ hr { .loginpage { - .brandbar { - width: 100%; - } - .hero-unit { background-color: transparent !important; @@ -316,6 +316,10 @@ hr { } } +.brandbar-wide { + width: 100%; +} + // -- Navigation bar ---------------------------------------------------------- .navbar { @@ -717,4 +721,40 @@ label { // Center the alert box (20px bottom margin) in the table cell padding: 20px 20px 0 20px; } + + th { + a { + color: inherit; + } + } + + td { + vertical-align: middle; + + img { + border: 2px solid white; + border-radius: 4px 4px 4px 4px; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); + } + } +} + +.menu-list-table .table-striped { + td, th { + text-align: left; + } + + td:nth-child(2) { + text-align: right; + } + + caption { + background-color: #FFFFFF; + border-bottom: 2px solid #A5CED8; + color: #5A6876; + font-weight: bold; + line-height: 30px; + text-align: left; + text-transform: uppercase; + } } \ No newline at end of file diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html index 7bf76988c..5d2ef5842 100755 --- a/templates/admin/default/categories.html +++ b/templates/admin/default/categories.html @@ -41,20 +41,72 @@ {ifloop rel="category_list"} - {intl l="Category title"} +   + + {if $category_order == 'alpha'} + + {$order_change = 'alpha_reverse'} + {elseif $category_order == 'alpha_reverse'} + + {$order_change = 'alpha'} + {else} + {$order_change = 'alpha'} + {/if} +
      + {intl l="Category title"} + + {module_include location='category_list_header'} - {intl l="Online"} - {intl l="Position"} + + {if $category_order == 'visible'} + + {$order_change = 'visible_reverse'} + {elseif $category_order == 'visible_reverse'} + + {$order_change = 'visible'} + {else} + {$order_change = 'visible'} + {/if} + + + {intl l="Online"} + + + + + {if $category_order == 'manual'} + + {$order_change = 'manual_reverse'} + {elseif $category_order == 'manual_reverse'} + + {$order_change = 'manual'} + {else} + {$order_change = 'manual'} + {/if} + + {intl l="Position"} + + {intl l="Actions"} - {loop name="category_list" type="category" visible="*" parent="{$current_category_id}" order="manual"} + {loop name="category_list" type="category" visible="*" parent="{$current_category_id}" order="$category_order"} - {$TITLE} + + {loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} + #TITLE + {/loop} + + + + + {$TITLE} + + {module_include location='category_list_row'} @@ -141,7 +193,7 @@ {ifloop rel="product_list"} - {intl l="Image"} +   {intl l="Product title"} @@ -156,7 +208,12 @@ {loop name="product_list" type="product" category="{$current_category_id}" order="manual"} - Image ! + + {loop type="image" name="cat_image" source="product" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} + + #TITLE + + {/loop} {$TITLE} diff --git a/templates/admin/default/configuration.html b/templates/admin/default/configuration.html new file mode 100644 index 000000000..6973807c7 --- /dev/null +++ b/templates/admin/default/configuration.html @@ -0,0 +1,174 @@ +{check_auth context="admin" roles="ADMIN" permissions="admin.configuration.view" login_tpl="/admin/login"} + +{$page_title={intl l='Configuration'}} + +{include file='includes/header.inc.html'} + +
      + +
      + + {module_include location='configuration_top'} + +

      {intl l="Thelia configuration"}

      + +
      + +
      + +
      + +
      + +
      + +
      + +
      + + {module_include location='configuration_bottom'} +
      +
      +
      + +{include file='includes/js.inc.html'} + +{include file='includes/footer.inc.html'} \ No newline at end of file diff --git a/templates/admin/default/edit_category.html b/templates/admin/default/edit_category.html index c1e19809f..dfd3b2b91 100755 --- a/templates/admin/default/edit_category.html +++ b/templates/admin/default/edit_category.html @@ -11,7 +11,7 @@
    - + {loop name="category_edit" type="category" visible="*" id="{$current_category_id}" backend_context="1" lang="$edition_language"}
    @@ -25,156 +25,187 @@
    -
    - -
    +
    -
    - -
    +
    +
    +
    - {include file="includes/inner-form-toolbar.html"} + {include file="includes/inner-form-toolbar.html"} -
    -
    -
    - +
    +
    +
    + -
    - -
    -
    +
    + +
    +
    -
    - +
    + -
    - -
    -
    +
    + +
    +
    -
    - +
    + -
    - +
    + -
    -
    +
    +
    -
    - +
    + -
    - -
    -
    +
    + +
    +
    -
    - +
    + -
    -
    - - {intl l='Use default'} +
    + +
    {intl l="The rewritten URL to the category page. Click \"Use Default\" button to use the default URL. Use only digits, letters, - and _ characters."}
    +
    +
    + +
    +
    + +
    +
    +
    +   +
    +

    {intl l='Category created on %date_create. Last modification: %date_change' date_create=$CREATE_DATE->format($datetime_format) date_change=$UPDATE_DATE->format($datetime_format)}

    +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + {include file="includes/inner-form-toolbar.html"} + +
    +
    +
    + + +
    +
    -
    {intl l="The rewritten URL to the category page. Click \"Use Default\" button to use the default URL. Use only digits, letters, - and _ characters."}
    -
    -
    +
    +
    + -
    -
    +
    + - + +
    +
    +
    +
    - {loop name="cat-parent" type="category-tree" visible="*" category="0" exclude="{$current_category_id}"} - - {/loop} +
    +
    +
    + - -
    -
    +
    + +
    +
    +
    -
    -
    - +
    +
    +
    -
    - -
    -
    -
    -
    -

    aff Date creation ?

    -

    aff date modif ?

    - - -
    +
    +

    Images

    +
    -
    -

    Détails divers

    -
    +
    +

    Documents

    +
    -
    -

    Images

    -
    +
    +

    Modules

    +
    -
    -

    Documents

    -
    - -
    -

    Modules

    -
    - -
    -
    +
    + + + {/loop} @@ -189,6 +220,12 @@ $(function() { e.preventDefault(); $(this).tab('show'); }); + + $('.use_default_rewriten_url').click(function(ev) { + alert("Not functionnal"); + + ev.preventDefault(); + }); }) diff --git a/templates/admin/default/general_error.html b/templates/admin/default/general_error.html index c41fee7a4..b8f9e8661 100755 --- a/templates/admin/default/general_error.html +++ b/templates/admin/default/general_error.html @@ -1,4 +1,4 @@ -{$page_title={intl l='AN error occured'}} +{$page_title={intl l='An error occured'}} {include file='includes/header.inc.html'} diff --git a/templates/admin/default/includes/header.inc.html b/templates/admin/default/includes/header.inc.html index 65500f05a..9b8d4b18a 100755 --- a/templates/admin/default/includes/header.inc.html +++ b/templates/admin/default/includes/header.inc.html @@ -54,7 +54,9 @@ {module_include location='inside_topbar'} - + {loop name="top-bar-search" type="auth" context="admin" roles="ADMIN" permissions="admin.search"}