From c9485075d455b0f232e546fbea20322f33c57447 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 13 Aug 2013 11:40:24 +0200 Subject: [PATCH 01/20] 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 02/20] 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 03/20] 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 04/20] 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 42270991c537f13d4483873b5a20c386b56578c8 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 20 Aug 2013 11:29:35 +0200 Subject: [PATCH 05/20] 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 06/20] 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 07/20] 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 08/20] 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 09/20] 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 8cc09824a8df6799e32ab043568cff8b68214543 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 21 Aug 2013 09:28:50 +0200 Subject: [PATCH 10/20] 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 11/20] 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 12/20] 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 13/20] 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 17cc6faec38c4f23712e6392d537f462002cc0a0 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Thu, 22 Aug 2013 15:03:31 +0200 Subject: [PATCH 14/20] 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 ec3ab5c3aa4a288bca6c357bbb2a3355966d970c Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Thu, 22 Aug 2013 17:47:46 +0200 Subject: [PATCH 15/20] 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 16/20] 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 fe4b77f7a8a8fd9dd970005e51591fea8a0c56d8 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 23 Aug 2013 10:55:59 +0200 Subject: [PATCH 17/20] 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 18/20] 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 19/20] 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 20/20] 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); } }