- * $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 ChildCouponQuery 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(CouponTableMap::IS_USED, $isUsed['min'], Criteria::GREATER_EQUAL);
- $useMinMax = true;
- }
- if (isset($isUsed['max'])) {
- $this->addUsingAlias(CouponTableMap::IS_USED, $isUsed['max'], Criteria::LESS_EQUAL);
- $useMinMax = true;
- }
- if ($useMinMax) {
- return $this;
- }
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
- }
-
- return $this->addUsingAlias(CouponTableMap::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
+ * $query->filterByIsEnabled(true); // WHERE is_enabled = true
+ * $query->filterByIsEnabled('yes'); // WHERE is_enabled = true
*
*
- * @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 boolean|string $isEnabled The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCouponQuery The current query, for fluid interface
*/
public function 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;
- }
+ if (is_string($isEnabled)) {
+ $is_enabled = in_array(strtolower($isEnabled), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(CouponTableMap::IS_ENABLED, $isEnabled, $comparison);
@@ -549,117 +494,6 @@ abstract class CouponQuery extends ModelCriteria
return $this->addUsingAlias(CouponTableMap::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 ChildCouponQuery 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(CouponTableMap::SERIALIZED_RULES, $serializedRules, $comparison);
- }
-
- /**
- * Filter the query on the is_cumulative column
- *
- * Example usage:
- *
- * $query->filterByIsCumulative(1234); // WHERE is_cumulative = 1234
- * $query->filterByIsCumulative(array(12, 34)); // WHERE is_cumulative IN (12, 34)
- * $query->filterByIsCumulative(array('min' => 12)); // WHERE is_cumulative > 12
- *
- *
- * @param mixed $isCumulative The value to use as filter.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ChildCouponQuery The current query, for fluid interface
- */
- public function filterByIsCumulative($isCumulative = null, $comparison = null)
- {
- if (is_array($isCumulative)) {
- $useMinMax = false;
- if (isset($isCumulative['min'])) {
- $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative['min'], Criteria::GREATER_EQUAL);
- $useMinMax = true;
- }
- if (isset($isCumulative['max'])) {
- $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative['max'], Criteria::LESS_EQUAL);
- $useMinMax = true;
- }
- if ($useMinMax) {
- return $this;
- }
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
- }
-
- return $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative, $comparison);
- }
-
- /**
- * Filter the query on the is_removing_postage column
- *
- * Example usage:
- *
- * $query->filterByIsRemovingPostage(1234); // WHERE is_removing_postage = 1234
- * $query->filterByIsRemovingPostage(array(12, 34)); // WHERE is_removing_postage IN (12, 34)
- * $query->filterByIsRemovingPostage(array('min' => 12)); // WHERE is_removing_postage > 12
- *
- *
- * @param mixed $isRemovingPostage The value to use as filter.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ChildCouponQuery The current query, for fluid interface
- */
- public function filterByIsRemovingPostage($isRemovingPostage = null, $comparison = null)
- {
- if (is_array($isRemovingPostage)) {
- $useMinMax = false;
- if (isset($isRemovingPostage['min'])) {
- $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['min'], Criteria::GREATER_EQUAL);
- $useMinMax = true;
- }
- if (isset($isRemovingPostage['max'])) {
- $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['max'], Criteria::LESS_EQUAL);
- $useMinMax = true;
- }
- if ($useMinMax) {
- return $this;
- }
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
- }
-
- return $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison);
- }
-
/**
* Filter the query on the max_usage column
*
@@ -701,6 +535,60 @@ abstract class CouponQuery extends ModelCriteria
return $this->addUsingAlias(CouponTableMap::MAX_USAGE, $maxUsage, $comparison);
}
+ /**
+ * Filter the query on the is_cumulative column
+ *
+ * Example usage:
+ *
+ * $query->filterByIsCumulative(true); // WHERE is_cumulative = true
+ * $query->filterByIsCumulative('yes'); // WHERE is_cumulative = true
+ *
+ *
+ * @param boolean|string $isCumulative The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByIsCumulative($isCumulative = null, $comparison = null)
+ {
+ if (is_string($isCumulative)) {
+ $is_cumulative = in_array(strtolower($isCumulative), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ }
+
+ return $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative, $comparison);
+ }
+
+ /**
+ * Filter the query on the is_removing_postage column
+ *
+ * Example usage:
+ *
+ * $query->filterByIsRemovingPostage(true); // WHERE is_removing_postage = true
+ * $query->filterByIsRemovingPostage('yes'); // WHERE is_removing_postage = true
+ *
+ *
+ * @param boolean|string $isRemovingPostage The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByIsRemovingPostage($isRemovingPostage = null, $comparison = null)
+ {
+ if (is_string($isRemovingPostage)) {
+ $is_removing_postage = in_array(strtolower($isRemovingPostage), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ }
+
+ return $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison);
+ }
+
/**
* Filter the query on the is_available_on_special_offers column
*
@@ -728,6 +616,62 @@ abstract class CouponQuery extends ModelCriteria
return $this->addUsingAlias(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $isAvailableOnSpecialOffers, $comparison);
}
+ /**
+ * Filter the query on the is_used column
+ *
+ * Example usage:
+ *
+ * $query->filterByIsUsed(true); // WHERE is_used = true
+ * $query->filterByIsUsed('yes'); // WHERE is_used = true
+ *
+ *
+ * @param boolean|string $isUsed The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByIsUsed($isUsed = null, $comparison = null)
+ {
+ if (is_string($isUsed)) {
+ $is_used = in_array(strtolower($isUsed), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ }
+
+ return $this->addUsingAlias(CouponTableMap::IS_USED, $isUsed, $comparison);
+ }
+
+ /**
+ * Filter the query on the serialized_conditions column
+ *
+ * Example usage:
+ *
+ * $query->filterBySerializedConditions('fooValue'); // WHERE serialized_conditions = 'fooValue'
+ * $query->filterBySerializedConditions('%fooValue%'); // WHERE serialized_conditions LIKE '%fooValue%'
+ *
+ *
+ * @param string $serializedConditions 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 filterBySerializedConditions($serializedConditions = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($serializedConditions)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $serializedConditions)) {
+ $serializedConditions = str_replace('*', '%', $serializedConditions);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CouponTableMap::SERIALIZED_CONDITIONS, $serializedConditions, $comparison);
+ }
+
/**
* Filter the query on the created_at column
*
diff --git a/core/lib/Thelia/Model/Base/CouponVersion.php b/core/lib/Thelia/Model/Base/CouponVersion.php
index efa4898f4..83e5bf6dc 100644
--- a/core/lib/Thelia/Model/Base/CouponVersion.php
+++ b/core/lib/Thelia/Model/Base/CouponVersion.php
@@ -79,15 +79,9 @@ abstract class CouponVersion implements ActiveRecordInterface
*/
protected $amount;
- /**
- * The value for the is_used field.
- * @var int
- */
- protected $is_used;
-
/**
* The value for the is_enabled field.
- * @var int
+ * @var boolean
*/
protected $is_enabled;
@@ -97,36 +91,42 @@ abstract class CouponVersion implements ActiveRecordInterface
*/
protected $expiration_date;
- /**
- * The value for the serialized_rules field.
- * @var string
- */
- protected $serialized_rules;
-
- /**
- * The value for the is_cumulative field.
- * @var int
- */
- protected $is_cumulative;
-
- /**
- * The value for the is_removing_postage field.
- * @var int
- */
- protected $is_removing_postage;
-
/**
* The value for the max_usage field.
* @var int
*/
protected $max_usage;
+ /**
+ * The value for the is_cumulative field.
+ * @var boolean
+ */
+ protected $is_cumulative;
+
+ /**
+ * The value for the is_removing_postage field.
+ * @var boolean
+ */
+ protected $is_removing_postage;
+
/**
* The value for the is_available_on_special_offers field.
* @var boolean
*/
protected $is_available_on_special_offers;
+ /**
+ * The value for the is_used field.
+ * @var boolean
+ */
+ protected $is_used;
+
+ /**
+ * The value for the serialized_conditions field.
+ * @var string
+ */
+ protected $serialized_conditions;
+
/**
* The value for the created_at field.
* @var string
@@ -470,21 +470,10 @@ abstract class CouponVersion implements ActiveRecordInterface
return $this->amount;
}
- /**
- * Get the [is_used] column value.
- *
- * @return int
- */
- public function getIsUsed()
- {
-
- return $this->is_used;
- }
-
/**
* Get the [is_enabled] column value.
*
- * @return int
+ * @return boolean
*/
public function getIsEnabled()
{
@@ -512,39 +501,6 @@ abstract class CouponVersion implements ActiveRecordInterface
}
}
- /**
- * Get the [serialized_rules] column value.
- *
- * @return string
- */
- public function getSerializedRules()
- {
-
- return $this->serialized_rules;
- }
-
- /**
- * Get the [is_cumulative] column value.
- *
- * @return int
- */
- public function getIsCumulative()
- {
-
- return $this->is_cumulative;
- }
-
- /**
- * Get the [is_removing_postage] column value.
- *
- * @return int
- */
- public function getIsRemovingPostage()
- {
-
- return $this->is_removing_postage;
- }
-
/**
* Get the [max_usage] column value.
*
@@ -556,6 +512,28 @@ abstract class CouponVersion implements ActiveRecordInterface
return $this->max_usage;
}
+ /**
+ * Get the [is_cumulative] column value.
+ *
+ * @return boolean
+ */
+ public function getIsCumulative()
+ {
+
+ return $this->is_cumulative;
+ }
+
+ /**
+ * Get the [is_removing_postage] column value.
+ *
+ * @return boolean
+ */
+ public function getIsRemovingPostage()
+ {
+
+ return $this->is_removing_postage;
+ }
+
/**
* Get the [is_available_on_special_offers] column value.
*
@@ -567,6 +545,28 @@ abstract class CouponVersion implements ActiveRecordInterface
return $this->is_available_on_special_offers;
}
+ /**
+ * Get the [is_used] column value.
+ *
+ * @return boolean
+ */
+ public function getIsUsed()
+ {
+
+ return $this->is_used;
+ }
+
+ /**
+ * Get the [serialized_conditions] column value.
+ *
+ * @return string
+ */
+ public function getSerializedConditions()
+ {
+
+ return $this->serialized_conditions;
+ }
+
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -707,36 +707,23 @@ abstract class CouponVersion implements ActiveRecordInterface
} // setAmount()
/**
- * Set the value of [is_used] column.
+ * Sets the value of the [is_enabled] column.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
*
- * @param 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
+ * @param boolean|integer|string $v The new value
* @return \Thelia\Model\CouponVersion The current object (for fluent API support)
*/
public function setIsEnabled($v)
{
if ($v !== null) {
- $v = (int) $v;
+ if (is_string($v)) {
+ $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ } else {
+ $v = (boolean) $v;
+ }
}
if ($this->is_enabled !== $v) {
@@ -769,69 +756,6 @@ abstract class CouponVersion implements ActiveRecordInterface
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()
-
- /**
- * Set the value of [is_cumulative] column.
- *
- * @param int $v new value
- * @return \Thelia\Model\CouponVersion The current object (for fluent API support)
- */
- public function setIsCumulative($v)
- {
- if ($v !== null) {
- $v = (int) $v;
- }
-
- if ($this->is_cumulative !== $v) {
- $this->is_cumulative = $v;
- $this->modifiedColumns[] = CouponVersionTableMap::IS_CUMULATIVE;
- }
-
-
- return $this;
- } // setIsCumulative()
-
- /**
- * Set the value of [is_removing_postage] column.
- *
- * @param int $v new value
- * @return \Thelia\Model\CouponVersion The current object (for fluent API support)
- */
- public function setIsRemovingPostage($v)
- {
- if ($v !== null) {
- $v = (int) $v;
- }
-
- if ($this->is_removing_postage !== $v) {
- $this->is_removing_postage = $v;
- $this->modifiedColumns[] = CouponVersionTableMap::IS_REMOVING_POSTAGE;
- }
-
-
- return $this;
- } // setIsRemovingPostage()
-
/**
* Set the value of [max_usage] column.
*
@@ -853,6 +777,64 @@ abstract class CouponVersion implements ActiveRecordInterface
return $this;
} // setMaxUsage()
+ /**
+ * Sets the value of the [is_cumulative] column.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ *
+ * @param boolean|integer|string $v The new value
+ * @return \Thelia\Model\CouponVersion The current object (for fluent API support)
+ */
+ public function setIsCumulative($v)
+ {
+ if ($v !== null) {
+ if (is_string($v)) {
+ $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ } else {
+ $v = (boolean) $v;
+ }
+ }
+
+ if ($this->is_cumulative !== $v) {
+ $this->is_cumulative = $v;
+ $this->modifiedColumns[] = CouponVersionTableMap::IS_CUMULATIVE;
+ }
+
+
+ return $this;
+ } // setIsCumulative()
+
+ /**
+ * Sets the value of the [is_removing_postage] column.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ *
+ * @param boolean|integer|string $v The new value
+ * @return \Thelia\Model\CouponVersion The current object (for fluent API support)
+ */
+ public function setIsRemovingPostage($v)
+ {
+ if ($v !== null) {
+ if (is_string($v)) {
+ $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ } else {
+ $v = (boolean) $v;
+ }
+ }
+
+ if ($this->is_removing_postage !== $v) {
+ $this->is_removing_postage = $v;
+ $this->modifiedColumns[] = CouponVersionTableMap::IS_REMOVING_POSTAGE;
+ }
+
+
+ return $this;
+ } // setIsRemovingPostage()
+
/**
* Sets the value of the [is_available_on_special_offers] column.
* Non-boolean arguments are converted using the following rules:
@@ -882,6 +864,56 @@ abstract class CouponVersion implements ActiveRecordInterface
return $this;
} // setIsAvailableOnSpecialOffers()
+ /**
+ * Sets the value of the [is_used] column.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ *
+ * @param boolean|integer|string $v The new value
+ * @return \Thelia\Model\CouponVersion The current object (for fluent API support)
+ */
+ public function setIsUsed($v)
+ {
+ if ($v !== null) {
+ if (is_string($v)) {
+ $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ } else {
+ $v = (boolean) $v;
+ }
+ }
+
+ if ($this->is_used !== $v) {
+ $this->is_used = $v;
+ $this->modifiedColumns[] = CouponVersionTableMap::IS_USED;
+ }
+
+
+ return $this;
+ } // setIsUsed()
+
+ /**
+ * Set the value of [serialized_conditions] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CouponVersion The current object (for fluent API support)
+ */
+ public function setSerializedConditions($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->serialized_conditions !== $v) {
+ $this->serialized_conditions = $v;
+ $this->modifiedColumns[] = CouponVersionTableMap::SERIALIZED_CONDITIONS;
+ }
+
+
+ return $this;
+ } // setSerializedConditions()
+
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -998,33 +1030,33 @@ abstract class CouponVersion implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponVersionTableMap::translateFieldName('Amount', TableMap::TYPE_PHPNAME, $indexType)];
$this->amount = (null !== $col) ? (double) $col : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponVersionTableMap::translateFieldName('IsUsed', TableMap::TYPE_PHPNAME, $indexType)];
- $this->is_used = (null !== $col) ? (int) $col : null;
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponVersionTableMap::translateFieldName('IsEnabled', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->is_enabled = (null !== $col) ? (boolean) $col : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponVersionTableMap::translateFieldName('IsEnabled', TableMap::TYPE_PHPNAME, $indexType)];
- $this->is_enabled = (null !== $col) ? (int) $col : null;
-
- $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponVersionTableMap::translateFieldName('ExpirationDate', TableMap::TYPE_PHPNAME, $indexType)];
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $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 ? 7 + $startcol : CouponVersionTableMap::translateFieldName('SerializedRules', TableMap::TYPE_PHPNAME, $indexType)];
- $this->serialized_rules = (null !== $col) ? (string) $col : null;
-
- $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponVersionTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)];
- $this->is_cumulative = (null !== $col) ? (int) $col : null;
-
- $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponVersionTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)];
- $this->is_removing_postage = (null !== $col) ? (int) $col : null;
-
- $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponVersionTableMap::translateFieldName('MaxUsage', TableMap::TYPE_PHPNAME, $indexType)];
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponVersionTableMap::translateFieldName('MaxUsage', TableMap::TYPE_PHPNAME, $indexType)];
$this->max_usage = (null !== $col) ? (int) $col : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponVersionTableMap::translateFieldName('IsAvailableOnSpecialOffers', TableMap::TYPE_PHPNAME, $indexType)];
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponVersionTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->is_cumulative = (null !== $col) ? (boolean) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponVersionTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->is_removing_postage = (null !== $col) ? (boolean) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponVersionTableMap::translateFieldName('IsAvailableOnSpecialOffers', TableMap::TYPE_PHPNAME, $indexType)];
$this->is_available_on_special_offers = (null !== $col) ? (boolean) $col : null;
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponVersionTableMap::translateFieldName('IsUsed', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->is_used = (null !== $col) ? (boolean) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponVersionTableMap::translateFieldName('SerializedConditions', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->serialized_conditions = (null !== $col) ? (string) $col : null;
+
$col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
@@ -1280,17 +1312,14 @@ abstract class CouponVersion implements ActiveRecordInterface
if ($this->isColumnModified(CouponVersionTableMap::AMOUNT)) {
$modifiedColumns[':p' . $index++] = 'AMOUNT';
}
- if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) {
- $modifiedColumns[':p' . $index++] = 'IS_USED';
- }
if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) {
$modifiedColumns[':p' . $index++] = 'IS_ENABLED';
}
if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) {
$modifiedColumns[':p' . $index++] = 'EXPIRATION_DATE';
}
- if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES)) {
- $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES';
+ if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) {
+ $modifiedColumns[':p' . $index++] = 'MAX_USAGE';
}
if ($this->isColumnModified(CouponVersionTableMap::IS_CUMULATIVE)) {
$modifiedColumns[':p' . $index++] = 'IS_CUMULATIVE';
@@ -1298,12 +1327,15 @@ abstract class CouponVersion implements ActiveRecordInterface
if ($this->isColumnModified(CouponVersionTableMap::IS_REMOVING_POSTAGE)) {
$modifiedColumns[':p' . $index++] = 'IS_REMOVING_POSTAGE';
}
- if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) {
- $modifiedColumns[':p' . $index++] = 'MAX_USAGE';
- }
if ($this->isColumnModified(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) {
$modifiedColumns[':p' . $index++] = 'IS_AVAILABLE_ON_SPECIAL_OFFERS';
}
+ if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) {
+ $modifiedColumns[':p' . $index++] = 'IS_USED';
+ }
+ if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_CONDITIONS)) {
+ $modifiedColumns[':p' . $index++] = 'SERIALIZED_CONDITIONS';
+ }
if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
}
@@ -1336,30 +1368,30 @@ abstract class CouponVersion implements ActiveRecordInterface
case 'AMOUNT':
$stmt->bindValue($identifier, $this->amount, PDO::PARAM_STR);
break;
- case 'IS_USED':
- $stmt->bindValue($identifier, $this->is_used, PDO::PARAM_INT);
- break;
case 'IS_ENABLED':
- $stmt->bindValue($identifier, $this->is_enabled, PDO::PARAM_INT);
+ $stmt->bindValue($identifier, (int) $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 'IS_CUMULATIVE':
- $stmt->bindValue($identifier, $this->is_cumulative, PDO::PARAM_INT);
- break;
- case 'IS_REMOVING_POSTAGE':
- $stmt->bindValue($identifier, $this->is_removing_postage, PDO::PARAM_INT);
- break;
case 'MAX_USAGE':
$stmt->bindValue($identifier, $this->max_usage, PDO::PARAM_INT);
break;
+ case 'IS_CUMULATIVE':
+ $stmt->bindValue($identifier, (int) $this->is_cumulative, PDO::PARAM_INT);
+ break;
+ case 'IS_REMOVING_POSTAGE':
+ $stmt->bindValue($identifier, (int) $this->is_removing_postage, PDO::PARAM_INT);
+ break;
case 'IS_AVAILABLE_ON_SPECIAL_OFFERS':
$stmt->bindValue($identifier, (int) $this->is_available_on_special_offers, PDO::PARAM_INT);
break;
+ case 'IS_USED':
+ $stmt->bindValue($identifier, (int) $this->is_used, PDO::PARAM_INT);
+ break;
+ case 'SERIALIZED_CONDITIONS':
+ $stmt->bindValue($identifier, $this->serialized_conditions, 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;
@@ -1437,29 +1469,29 @@ abstract class CouponVersion implements ActiveRecordInterface
return $this->getAmount();
break;
case 4:
- return $this->getIsUsed();
- break;
- case 5:
return $this->getIsEnabled();
break;
- case 6:
+ case 5:
return $this->getExpirationDate();
break;
- case 7:
- return $this->getSerializedRules();
- break;
- case 8:
- return $this->getIsCumulative();
- break;
- case 9:
- return $this->getIsRemovingPostage();
- break;
- case 10:
+ case 6:
return $this->getMaxUsage();
break;
- case 11:
+ case 7:
+ return $this->getIsCumulative();
+ break;
+ case 8:
+ return $this->getIsRemovingPostage();
+ break;
+ case 9:
return $this->getIsAvailableOnSpecialOffers();
break;
+ case 10:
+ return $this->getIsUsed();
+ break;
+ case 11:
+ return $this->getSerializedConditions();
+ break;
case 12:
return $this->getCreatedAt();
break;
@@ -1502,14 +1534,14 @@ abstract class CouponVersion implements ActiveRecordInterface
$keys[1] => $this->getCode(),
$keys[2] => $this->getType(),
$keys[3] => $this->getAmount(),
- $keys[4] => $this->getIsUsed(),
- $keys[5] => $this->getIsEnabled(),
- $keys[6] => $this->getExpirationDate(),
- $keys[7] => $this->getSerializedRules(),
- $keys[8] => $this->getIsCumulative(),
- $keys[9] => $this->getIsRemovingPostage(),
- $keys[10] => $this->getMaxUsage(),
- $keys[11] => $this->getIsAvailableOnSpecialOffers(),
+ $keys[4] => $this->getIsEnabled(),
+ $keys[5] => $this->getExpirationDate(),
+ $keys[6] => $this->getMaxUsage(),
+ $keys[7] => $this->getIsCumulative(),
+ $keys[8] => $this->getIsRemovingPostage(),
+ $keys[9] => $this->getIsAvailableOnSpecialOffers(),
+ $keys[10] => $this->getIsUsed(),
+ $keys[11] => $this->getSerializedConditions(),
$keys[12] => $this->getCreatedAt(),
$keys[13] => $this->getUpdatedAt(),
$keys[14] => $this->getVersion(),
@@ -1571,29 +1603,29 @@ abstract class CouponVersion implements ActiveRecordInterface
$this->setAmount($value);
break;
case 4:
- $this->setIsUsed($value);
- break;
- case 5:
$this->setIsEnabled($value);
break;
- case 6:
+ case 5:
$this->setExpirationDate($value);
break;
- case 7:
- $this->setSerializedRules($value);
- break;
- case 8:
- $this->setIsCumulative($value);
- break;
- case 9:
- $this->setIsRemovingPostage($value);
- break;
- case 10:
+ case 6:
$this->setMaxUsage($value);
break;
- case 11:
+ case 7:
+ $this->setIsCumulative($value);
+ break;
+ case 8:
+ $this->setIsRemovingPostage($value);
+ break;
+ case 9:
$this->setIsAvailableOnSpecialOffers($value);
break;
+ case 10:
+ $this->setIsUsed($value);
+ break;
+ case 11:
+ $this->setSerializedConditions($value);
+ break;
case 12:
$this->setCreatedAt($value);
break;
@@ -1631,14 +1663,14 @@ abstract class CouponVersion implements ActiveRecordInterface
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->setAmount($arr[$keys[3]]);
- if (array_key_exists($keys[4], $arr)) $this->setIsUsed($arr[$keys[4]]);
- if (array_key_exists($keys[5], $arr)) $this->setIsEnabled($arr[$keys[5]]);
- if (array_key_exists($keys[6], $arr)) $this->setExpirationDate($arr[$keys[6]]);
- if (array_key_exists($keys[7], $arr)) $this->setSerializedRules($arr[$keys[7]]);
- if (array_key_exists($keys[8], $arr)) $this->setIsCumulative($arr[$keys[8]]);
- if (array_key_exists($keys[9], $arr)) $this->setIsRemovingPostage($arr[$keys[9]]);
- if (array_key_exists($keys[10], $arr)) $this->setMaxUsage($arr[$keys[10]]);
- if (array_key_exists($keys[11], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[11]]);
+ if (array_key_exists($keys[4], $arr)) $this->setIsEnabled($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setExpirationDate($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setMaxUsage($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setIsCumulative($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setIsRemovingPostage($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setIsUsed($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setSerializedConditions($arr[$keys[11]]);
if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]);
if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]);
if (array_key_exists($keys[14], $arr)) $this->setVersion($arr[$keys[14]]);
@@ -1657,14 +1689,14 @@ abstract class CouponVersion implements ActiveRecordInterface
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::AMOUNT)) $criteria->add(CouponVersionTableMap::AMOUNT, $this->amount);
- if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) $criteria->add(CouponVersionTableMap::IS_USED, $this->is_used);
if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) $criteria->add(CouponVersionTableMap::IS_ENABLED, $this->is_enabled);
if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) $criteria->add(CouponVersionTableMap::EXPIRATION_DATE, $this->expiration_date);
- if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES)) $criteria->add(CouponVersionTableMap::SERIALIZED_RULES, $this->serialized_rules);
+ if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) $criteria->add(CouponVersionTableMap::MAX_USAGE, $this->max_usage);
if ($this->isColumnModified(CouponVersionTableMap::IS_CUMULATIVE)) $criteria->add(CouponVersionTableMap::IS_CUMULATIVE, $this->is_cumulative);
if ($this->isColumnModified(CouponVersionTableMap::IS_REMOVING_POSTAGE)) $criteria->add(CouponVersionTableMap::IS_REMOVING_POSTAGE, $this->is_removing_postage);
- if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) $criteria->add(CouponVersionTableMap::MAX_USAGE, $this->max_usage);
if ($this->isColumnModified(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) $criteria->add(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $this->is_available_on_special_offers);
+ if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) $criteria->add(CouponVersionTableMap::IS_USED, $this->is_used);
+ if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_CONDITIONS)) $criteria->add(CouponVersionTableMap::SERIALIZED_CONDITIONS, $this->serialized_conditions);
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);
@@ -1742,14 +1774,14 @@ abstract class CouponVersion implements ActiveRecordInterface
$copyObj->setCode($this->getCode());
$copyObj->setType($this->getType());
$copyObj->setAmount($this->getAmount());
- $copyObj->setIsUsed($this->getIsUsed());
$copyObj->setIsEnabled($this->getIsEnabled());
$copyObj->setExpirationDate($this->getExpirationDate());
- $copyObj->setSerializedRules($this->getSerializedRules());
+ $copyObj->setMaxUsage($this->getMaxUsage());
$copyObj->setIsCumulative($this->getIsCumulative());
$copyObj->setIsRemovingPostage($this->getIsRemovingPostage());
- $copyObj->setMaxUsage($this->getMaxUsage());
$copyObj->setIsAvailableOnSpecialOffers($this->getIsAvailableOnSpecialOffers());
+ $copyObj->setIsUsed($this->getIsUsed());
+ $copyObj->setSerializedConditions($this->getSerializedConditions());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
$copyObj->setVersion($this->getVersion());
@@ -1840,14 +1872,14 @@ abstract class CouponVersion implements ActiveRecordInterface
$this->code = null;
$this->type = null;
$this->amount = null;
- $this->is_used = null;
$this->is_enabled = null;
$this->expiration_date = null;
- $this->serialized_rules = null;
+ $this->max_usage = null;
$this->is_cumulative = null;
$this->is_removing_postage = null;
- $this->max_usage = null;
$this->is_available_on_special_offers = null;
+ $this->is_used = null;
+ $this->serialized_conditions = null;
$this->created_at = null;
$this->updated_at = null;
$this->version = null;
diff --git a/core/lib/Thelia/Model/Base/CouponVersionQuery.php b/core/lib/Thelia/Model/Base/CouponVersionQuery.php
index ed7e587e7..eebd85dd9 100644
--- a/core/lib/Thelia/Model/Base/CouponVersionQuery.php
+++ b/core/lib/Thelia/Model/Base/CouponVersionQuery.php
@@ -25,14 +25,14 @@ use Thelia\Model\Map\CouponVersionTableMap;
* @method ChildCouponVersionQuery orderByCode($order = Criteria::ASC) Order by the code column
* @method ChildCouponVersionQuery orderByType($order = Criteria::ASC) Order by the type column
* @method ChildCouponVersionQuery orderByAmount($order = Criteria::ASC) Order by the amount column
- * @method ChildCouponVersionQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column
* @method ChildCouponVersionQuery orderByIsEnabled($order = Criteria::ASC) Order by the is_enabled column
* @method ChildCouponVersionQuery orderByExpirationDate($order = Criteria::ASC) Order by the expiration_date column
- * @method ChildCouponVersionQuery orderBySerializedRules($order = Criteria::ASC) Order by the serialized_rules column
+ * @method ChildCouponVersionQuery orderByMaxUsage($order = Criteria::ASC) Order by the max_usage column
* @method ChildCouponVersionQuery orderByIsCumulative($order = Criteria::ASC) Order by the is_cumulative column
* @method ChildCouponVersionQuery orderByIsRemovingPostage($order = Criteria::ASC) Order by the is_removing_postage column
- * @method ChildCouponVersionQuery orderByMaxUsage($order = Criteria::ASC) Order by the max_usage column
* @method ChildCouponVersionQuery orderByIsAvailableOnSpecialOffers($order = Criteria::ASC) Order by the is_available_on_special_offers column
+ * @method ChildCouponVersionQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column
+ * @method ChildCouponVersionQuery orderBySerializedConditions($order = Criteria::ASC) Order by the serialized_conditions column
* @method ChildCouponVersionQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildCouponVersionQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
* @method ChildCouponVersionQuery orderByVersion($order = Criteria::ASC) Order by the version column
@@ -41,14 +41,14 @@ use Thelia\Model\Map\CouponVersionTableMap;
* @method ChildCouponVersionQuery groupByCode() Group by the code column
* @method ChildCouponVersionQuery groupByType() Group by the type column
* @method ChildCouponVersionQuery groupByAmount() Group by the amount column
- * @method ChildCouponVersionQuery groupByIsUsed() Group by the is_used column
* @method ChildCouponVersionQuery groupByIsEnabled() Group by the is_enabled column
* @method ChildCouponVersionQuery groupByExpirationDate() Group by the expiration_date column
- * @method ChildCouponVersionQuery groupBySerializedRules() Group by the serialized_rules column
+ * @method ChildCouponVersionQuery groupByMaxUsage() Group by the max_usage column
* @method ChildCouponVersionQuery groupByIsCumulative() Group by the is_cumulative column
* @method ChildCouponVersionQuery groupByIsRemovingPostage() Group by the is_removing_postage column
- * @method ChildCouponVersionQuery groupByMaxUsage() Group by the max_usage column
* @method ChildCouponVersionQuery groupByIsAvailableOnSpecialOffers() Group by the is_available_on_special_offers column
+ * @method ChildCouponVersionQuery groupByIsUsed() Group by the is_used column
+ * @method ChildCouponVersionQuery groupBySerializedConditions() Group by the serialized_conditions column
* @method ChildCouponVersionQuery groupByCreatedAt() Group by the created_at column
* @method ChildCouponVersionQuery groupByUpdatedAt() Group by the updated_at column
* @method ChildCouponVersionQuery groupByVersion() Group by the version column
@@ -68,14 +68,14 @@ use Thelia\Model\Map\CouponVersionTableMap;
* @method ChildCouponVersion findOneByCode(string $code) Return the first ChildCouponVersion filtered by the code column
* @method ChildCouponVersion findOneByType(string $type) Return the first ChildCouponVersion filtered by the type column
* @method ChildCouponVersion findOneByAmount(double $amount) Return the first ChildCouponVersion filtered by the amount column
- * @method ChildCouponVersion findOneByIsUsed(int $is_used) Return the first ChildCouponVersion filtered by the is_used column
- * @method ChildCouponVersion findOneByIsEnabled(int $is_enabled) Return the first ChildCouponVersion filtered by the is_enabled column
+ * @method ChildCouponVersion findOneByIsEnabled(boolean $is_enabled) Return the first ChildCouponVersion filtered by the is_enabled column
* @method ChildCouponVersion findOneByExpirationDate(string $expiration_date) Return the first ChildCouponVersion filtered by the expiration_date column
- * @method ChildCouponVersion findOneBySerializedRules(string $serialized_rules) Return the first ChildCouponVersion filtered by the serialized_rules column
- * @method ChildCouponVersion findOneByIsCumulative(int $is_cumulative) Return the first ChildCouponVersion filtered by the is_cumulative column
- * @method ChildCouponVersion findOneByIsRemovingPostage(int $is_removing_postage) Return the first ChildCouponVersion filtered by the is_removing_postage column
* @method ChildCouponVersion findOneByMaxUsage(int $max_usage) Return the first ChildCouponVersion filtered by the max_usage column
+ * @method ChildCouponVersion findOneByIsCumulative(boolean $is_cumulative) Return the first ChildCouponVersion filtered by the is_cumulative column
+ * @method ChildCouponVersion findOneByIsRemovingPostage(boolean $is_removing_postage) Return the first ChildCouponVersion filtered by the is_removing_postage column
* @method ChildCouponVersion findOneByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return the first ChildCouponVersion filtered by the is_available_on_special_offers column
+ * @method ChildCouponVersion findOneByIsUsed(boolean $is_used) Return the first ChildCouponVersion filtered by the is_used column
+ * @method ChildCouponVersion findOneBySerializedConditions(string $serialized_conditions) Return the first ChildCouponVersion filtered by the serialized_conditions column
* @method ChildCouponVersion findOneByCreatedAt(string $created_at) Return the first ChildCouponVersion filtered by the created_at column
* @method ChildCouponVersion findOneByUpdatedAt(string $updated_at) Return the first ChildCouponVersion filtered by the updated_at column
* @method ChildCouponVersion findOneByVersion(int $version) Return the first ChildCouponVersion filtered by the version column
@@ -84,14 +84,14 @@ use Thelia\Model\Map\CouponVersionTableMap;
* @method array findByCode(string $code) Return ChildCouponVersion objects filtered by the code column
* @method array findByType(string $type) Return ChildCouponVersion objects filtered by the type column
* @method array findByAmount(double $amount) Return ChildCouponVersion objects filtered by the amount column
- * @method array findByIsUsed(int $is_used) Return ChildCouponVersion objects filtered by the is_used column
- * @method array findByIsEnabled(int $is_enabled) Return ChildCouponVersion objects filtered by the is_enabled column
+ * @method array findByIsEnabled(boolean $is_enabled) Return ChildCouponVersion objects filtered by the is_enabled column
* @method array findByExpirationDate(string $expiration_date) Return ChildCouponVersion objects filtered by the expiration_date column
- * @method array findBySerializedRules(string $serialized_rules) Return ChildCouponVersion objects filtered by the serialized_rules column
- * @method array findByIsCumulative(int $is_cumulative) Return ChildCouponVersion objects filtered by the is_cumulative column
- * @method array findByIsRemovingPostage(int $is_removing_postage) Return ChildCouponVersion objects filtered by the is_removing_postage column
* @method array findByMaxUsage(int $max_usage) Return ChildCouponVersion objects filtered by the max_usage column
+ * @method array findByIsCumulative(boolean $is_cumulative) Return ChildCouponVersion objects filtered by the is_cumulative column
+ * @method array findByIsRemovingPostage(boolean $is_removing_postage) Return ChildCouponVersion objects filtered by the is_removing_postage column
* @method array findByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return ChildCouponVersion objects filtered by the is_available_on_special_offers column
+ * @method array findByIsUsed(boolean $is_used) Return ChildCouponVersion objects filtered by the is_used column
+ * @method array findBySerializedConditions(string $serialized_conditions) Return ChildCouponVersion objects filtered by the serialized_conditions column
* @method array findByCreatedAt(string $created_at) Return ChildCouponVersion objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildCouponVersion objects filtered by the updated_at column
* @method array findByVersion(int $version) Return ChildCouponVersion objects filtered by the version column
@@ -183,7 +183,7 @@ abstract class CouponVersionQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT ID, CODE, TYPE, AMOUNT, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES, IS_CUMULATIVE, IS_REMOVING_POSTAGE, MAX_USAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, CREATED_AT, UPDATED_AT, VERSION FROM coupon_version WHERE ID = :p0 AND VERSION = :p1';
+ $sql = 'SELECT ID, CODE, TYPE, AMOUNT, IS_ENABLED, EXPIRATION_DATE, MAX_USAGE, IS_CUMULATIVE, IS_REMOVING_POSTAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, IS_USED, SERIALIZED_CONDITIONS, 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);
@@ -426,83 +426,28 @@ abstract class CouponVersionQuery extends ModelCriteria
return $this->addUsingAlias(CouponVersionTableMap::AMOUNT, $amount, $comparison);
}
- /**
- * Filter the query on the is_used column
- *
- * Example usage:
- *
- * $query->filterByIsUsed(1234); // WHERE is_used = 1234
- * $query->filterByIsUsed(array(12, 34)); // WHERE is_used IN (12, 34)
- * $query->filterByIsUsed(array('min' => 12)); // WHERE is_used > 12
- *
- *
- * @param mixed $isUsed The value to use as filter.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ChildCouponVersionQuery The current query, for fluid interface
- */
- public function filterByIsUsed($isUsed = null, $comparison = null)
- {
- if (is_array($isUsed)) {
- $useMinMax = false;
- if (isset($isUsed['min'])) {
- $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed['min'], Criteria::GREATER_EQUAL);
- $useMinMax = true;
- }
- if (isset($isUsed['max'])) {
- $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed['max'], Criteria::LESS_EQUAL);
- $useMinMax = true;
- }
- if ($useMinMax) {
- return $this;
- }
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
- }
-
- return $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed, $comparison);
- }
-
/**
* Filter the query on the is_enabled column
*
* Example usage:
*
- * $query->filterByIsEnabled(1234); // WHERE is_enabled = 1234
- * $query->filterByIsEnabled(array(12, 34)); // WHERE is_enabled IN (12, 34)
- * $query->filterByIsEnabled(array('min' => 12)); // WHERE is_enabled > 12
+ * $query->filterByIsEnabled(true); // WHERE is_enabled = true
+ * $query->filterByIsEnabled('yes'); // WHERE is_enabled = true
*
*
- * @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 boolean|string $isEnabled The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCouponVersionQuery The current query, for fluid interface
*/
public function 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;
- }
+ if (is_string($isEnabled)) {
+ $is_enabled = in_array(strtolower($isEnabled), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(CouponVersionTableMap::IS_ENABLED, $isEnabled, $comparison);
@@ -551,117 +496,6 @@ abstract class CouponVersionQuery extends ModelCriteria
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 is_cumulative column
- *
- * Example usage:
- *
- * $query->filterByIsCumulative(1234); // WHERE is_cumulative = 1234
- * $query->filterByIsCumulative(array(12, 34)); // WHERE is_cumulative IN (12, 34)
- * $query->filterByIsCumulative(array('min' => 12)); // WHERE is_cumulative > 12
- *
- *
- * @param mixed $isCumulative The value to use as filter.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ChildCouponVersionQuery The current query, for fluid interface
- */
- public function filterByIsCumulative($isCumulative = null, $comparison = null)
- {
- if (is_array($isCumulative)) {
- $useMinMax = false;
- if (isset($isCumulative['min'])) {
- $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative['min'], Criteria::GREATER_EQUAL);
- $useMinMax = true;
- }
- if (isset($isCumulative['max'])) {
- $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative['max'], Criteria::LESS_EQUAL);
- $useMinMax = true;
- }
- if ($useMinMax) {
- return $this;
- }
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
- }
-
- return $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative, $comparison);
- }
-
- /**
- * Filter the query on the is_removing_postage column
- *
- * Example usage:
- *
- * $query->filterByIsRemovingPostage(1234); // WHERE is_removing_postage = 1234
- * $query->filterByIsRemovingPostage(array(12, 34)); // WHERE is_removing_postage IN (12, 34)
- * $query->filterByIsRemovingPostage(array('min' => 12)); // WHERE is_removing_postage > 12
- *
- *
- * @param mixed $isRemovingPostage The value to use as filter.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ChildCouponVersionQuery The current query, for fluid interface
- */
- public function filterByIsRemovingPostage($isRemovingPostage = null, $comparison = null)
- {
- if (is_array($isRemovingPostage)) {
- $useMinMax = false;
- if (isset($isRemovingPostage['min'])) {
- $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['min'], Criteria::GREATER_EQUAL);
- $useMinMax = true;
- }
- if (isset($isRemovingPostage['max'])) {
- $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['max'], Criteria::LESS_EQUAL);
- $useMinMax = true;
- }
- if ($useMinMax) {
- return $this;
- }
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
- }
-
- return $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison);
- }
-
/**
* Filter the query on the max_usage column
*
@@ -703,6 +537,60 @@ abstract class CouponVersionQuery extends ModelCriteria
return $this->addUsingAlias(CouponVersionTableMap::MAX_USAGE, $maxUsage, $comparison);
}
+ /**
+ * Filter the query on the is_cumulative column
+ *
+ * Example usage:
+ *
+ * $query->filterByIsCumulative(true); // WHERE is_cumulative = true
+ * $query->filterByIsCumulative('yes'); // WHERE is_cumulative = true
+ *
+ *
+ * @param boolean|string $isCumulative The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponVersionQuery The current query, for fluid interface
+ */
+ public function filterByIsCumulative($isCumulative = null, $comparison = null)
+ {
+ if (is_string($isCumulative)) {
+ $is_cumulative = in_array(strtolower($isCumulative), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ }
+
+ return $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative, $comparison);
+ }
+
+ /**
+ * Filter the query on the is_removing_postage column
+ *
+ * Example usage:
+ *
+ * $query->filterByIsRemovingPostage(true); // WHERE is_removing_postage = true
+ * $query->filterByIsRemovingPostage('yes'); // WHERE is_removing_postage = true
+ *
+ *
+ * @param boolean|string $isRemovingPostage The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponVersionQuery The current query, for fluid interface
+ */
+ public function filterByIsRemovingPostage($isRemovingPostage = null, $comparison = null)
+ {
+ if (is_string($isRemovingPostage)) {
+ $is_removing_postage = in_array(strtolower($isRemovingPostage), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ }
+
+ return $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison);
+ }
+
/**
* Filter the query on the is_available_on_special_offers column
*
@@ -730,6 +618,62 @@ abstract class CouponVersionQuery extends ModelCriteria
return $this->addUsingAlias(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $isAvailableOnSpecialOffers, $comparison);
}
+ /**
+ * Filter the query on the is_used column
+ *
+ * Example usage:
+ *
+ * $query->filterByIsUsed(true); // WHERE is_used = true
+ * $query->filterByIsUsed('yes'); // WHERE is_used = true
+ *
+ *
+ * @param boolean|string $isUsed The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponVersionQuery The current query, for fluid interface
+ */
+ public function filterByIsUsed($isUsed = null, $comparison = null)
+ {
+ if (is_string($isUsed)) {
+ $is_used = in_array(strtolower($isUsed), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ }
+
+ return $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed, $comparison);
+ }
+
+ /**
+ * Filter the query on the serialized_conditions column
+ *
+ * Example usage:
+ *
+ * $query->filterBySerializedConditions('fooValue'); // WHERE serialized_conditions = 'fooValue'
+ * $query->filterBySerializedConditions('%fooValue%'); // WHERE serialized_conditions LIKE '%fooValue%'
+ *
+ *
+ * @param string $serializedConditions 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 filterBySerializedConditions($serializedConditions = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($serializedConditions)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $serializedConditions)) {
+ $serializedConditions = str_replace('*', '%', $serializedConditions);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CouponVersionTableMap::SERIALIZED_CONDITIONS, $serializedConditions, $comparison);
+ }
+
/**
* Filter the query on the created_at column
*
diff --git a/core/lib/Thelia/Model/CategoryDocument.php b/core/lib/Thelia/Model/CategoryDocument.php
index 5724e2df1..0917ab30c 100755
--- a/core/lib/Thelia/Model/CategoryDocument.php
+++ b/core/lib/Thelia/Model/CategoryDocument.php
@@ -25,4 +25,28 @@ class CategoryDocument extends BaseCategoryDocument
return true;
}
+
+ /**
+ * Set Document parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setCategoryId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Document parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getCategoryId();
+ }
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Model/CategoryImage.php b/core/lib/Thelia/Model/CategoryImage.php
index 5bf964e10..17ee387b5 100755
--- a/core/lib/Thelia/Model/CategoryImage.php
+++ b/core/lib/Thelia/Model/CategoryImage.php
@@ -2,6 +2,8 @@
namespace Thelia\Model;
+use Symfony\Component\Filesystem\Filesystem;
+use Symfony\Component\HttpFoundation\File\UploadedFile;
use Thelia\Model\Base\CategoryImage as BaseCategoryImage;
use Propel\Runtime\Connection\ConnectionInterface;
@@ -25,4 +27,29 @@ class CategoryImage extends BaseCategoryImage
return true;
}
+
+ /**
+ * Set Image parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setCategoryId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Image parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getCategoryId();
+ }
+
}
diff --git a/core/lib/Thelia/Model/ContentDocument.php b/core/lib/Thelia/Model/ContentDocument.php
index 8ecf3a3a9..1409b2713 100755
--- a/core/lib/Thelia/Model/ContentDocument.php
+++ b/core/lib/Thelia/Model/ContentDocument.php
@@ -25,4 +25,28 @@ class ContentDocument extends BaseContentDocument
return true;
}
+
+ /**
+ * Set Document parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setContentId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Document parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getContentId();
+ }
}
diff --git a/core/lib/Thelia/Model/ContentImage.php b/core/lib/Thelia/Model/ContentImage.php
index ac1dcf755..b6a3085d4 100755
--- a/core/lib/Thelia/Model/ContentImage.php
+++ b/core/lib/Thelia/Model/ContentImage.php
@@ -25,4 +25,28 @@ class ContentImage extends BaseContentImage
return true;
}
+
+ /**
+ * Set Image parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setContentId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Image parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getContentId();
+ }
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Model/FeatureProduct.php b/core/lib/Thelia/Model/FeatureProduct.php
index 35a9b2ddc..fe6c5d8c1 100755
--- a/core/lib/Thelia/Model/FeatureProduct.php
+++ b/core/lib/Thelia/Model/FeatureProduct.php
@@ -3,8 +3,66 @@
namespace Thelia\Model;
use Thelia\Model\Base\FeatureProduct as BaseFeatureProduct;
+use Thelia\Core\Event\TheliaEvents;
+use Propel\Runtime\Connection\ConnectionInterface;
+use Thelia\Core\Event\FeatureProductEvent;
- class FeatureProduct extends BaseFeatureProduct
+class FeatureProduct extends BaseFeatureProduct
{
+ use \Thelia\Model\Tools\ModelEventDispatcherTrait;
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_CREATEFEATURE_PRODUCT, new FeatureProductEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_CREATEFEATURE_PRODUCT, new FeatureProductEvent($this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFEATURE_PRODUCT, new FeatureProductEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_UPDATEFEATURE_PRODUCT, new FeatureProductEvent($this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_DELETEFEATURE_PRODUCT, new FeatureProductEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_DELETEFEATURE_PRODUCT, new FeatureProductEvent($this));
+ }
}
diff --git a/core/lib/Thelia/Model/FeatureTemplate.php b/core/lib/Thelia/Model/FeatureTemplate.php
index 47a33027a..3f28a3a10 100644
--- a/core/lib/Thelia/Model/FeatureTemplate.php
+++ b/core/lib/Thelia/Model/FeatureTemplate.php
@@ -3,8 +3,30 @@
namespace Thelia\Model;
use Thelia\Model\Base\FeatureTemplate as BaseFeatureTemplate;
+use Propel\Runtime\Connection\ConnectionInterface;
- class FeatureTemplate extends BaseFeatureTemplate
+class FeatureTemplate extends BaseFeatureTemplate
{
+ use \Thelia\Model\Tools\ModelEventDispatcherTrait;
+ use \Thelia\Model\Tools\PositionManagementTrait;
+
+ /**
+ * Calculate next position relative to our template
+ */
+ protected function addCriteriaToPositionQuery($query)
+ {
+ $query->filterByTemplateId($this->getTemplateId());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ // Set the current position for the new object
+ $this->setPosition($this->getNextPosition());
+
+ return true;
+ }
}
diff --git a/core/lib/Thelia/Model/FolderDocument.php b/core/lib/Thelia/Model/FolderDocument.php
index 0a86995d2..1d84d9e55 100755
--- a/core/lib/Thelia/Model/FolderDocument.php
+++ b/core/lib/Thelia/Model/FolderDocument.php
@@ -25,4 +25,28 @@ class FolderDocument extends BaseFolderDocument
return true;
}
+
+ /**
+ * Set Document parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setFolderId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Document parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getFolderId();
+ }
}
diff --git a/core/lib/Thelia/Model/FolderImage.php b/core/lib/Thelia/Model/FolderImage.php
index 58d8f928e..f9491c9a5 100755
--- a/core/lib/Thelia/Model/FolderImage.php
+++ b/core/lib/Thelia/Model/FolderImage.php
@@ -25,4 +25,28 @@ class FolderImage extends BaseFolderImage
return true;
}
+
+ /**
+ * Set Image parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setFolderId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Image parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getFolderId();
+ }
}
diff --git a/core/lib/Thelia/Model/Map/CouponTableMap.php b/core/lib/Thelia/Model/Map/CouponTableMap.php
index bd9079be6..70d689a2a 100644
--- a/core/lib/Thelia/Model/Map/CouponTableMap.php
+++ b/core/lib/Thelia/Model/Map/CouponTableMap.php
@@ -89,11 +89,6 @@ class CouponTableMap extends TableMap
*/
const AMOUNT = 'coupon.AMOUNT';
- /**
- * the column name for the IS_USED field
- */
- const IS_USED = 'coupon.IS_USED';
-
/**
* the column name for the IS_ENABLED field
*/
@@ -105,9 +100,9 @@ class CouponTableMap extends TableMap
const EXPIRATION_DATE = 'coupon.EXPIRATION_DATE';
/**
- * the column name for the SERIALIZED_RULES field
+ * the column name for the MAX_USAGE field
*/
- const SERIALIZED_RULES = 'coupon.SERIALIZED_RULES';
+ const MAX_USAGE = 'coupon.MAX_USAGE';
/**
* the column name for the IS_CUMULATIVE field
@@ -119,16 +114,21 @@ class CouponTableMap extends TableMap
*/
const IS_REMOVING_POSTAGE = 'coupon.IS_REMOVING_POSTAGE';
- /**
- * the column name for the MAX_USAGE field
- */
- const MAX_USAGE = 'coupon.MAX_USAGE';
-
/**
* the column name for the IS_AVAILABLE_ON_SPECIAL_OFFERS field
*/
const IS_AVAILABLE_ON_SPECIAL_OFFERS = 'coupon.IS_AVAILABLE_ON_SPECIAL_OFFERS';
+ /**
+ * the column name for the IS_USED field
+ */
+ const IS_USED = 'coupon.IS_USED';
+
+ /**
+ * the column name for the SERIALIZED_CONDITIONS field
+ */
+ const SERIALIZED_CONDITIONS = 'coupon.SERIALIZED_CONDITIONS';
+
/**
* the column name for the CREATED_AT field
*/
@@ -165,11 +165,11 @@ class CouponTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Amount', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'IsCumulative', 'IsRemovingPostage', 'MaxUsage', 'IsAvailableOnSpecialOffers', 'CreatedAt', 'UpdatedAt', 'Version', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'amount', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'isCumulative', 'isRemovingPostage', 'maxUsage', 'isAvailableOnSpecialOffers', 'createdAt', 'updatedAt', 'version', ),
- self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::AMOUNT, CouponTableMap::IS_USED, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::SERIALIZED_RULES, CouponTableMap::IS_CUMULATIVE, CouponTableMap::IS_REMOVING_POSTAGE, CouponTableMap::MAX_USAGE, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ),
- self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'AMOUNT', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'MAX_USAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ),
- self::TYPE_FIELDNAME => array('id', 'code', 'type', 'amount', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'is_cumulative', 'is_removing_postage', 'max_usage', 'is_available_on_special_offers', 'created_at', 'updated_at', 'version', ),
+ self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Amount', 'IsEnabled', 'ExpirationDate', 'MaxUsage', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'IsUsed', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', 'Version', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'amount', 'isEnabled', 'expirationDate', 'maxUsage', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'isUsed', 'serializedConditions', 'createdAt', 'updatedAt', 'version', ),
+ self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::AMOUNT, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::MAX_USAGE, CouponTableMap::IS_CUMULATIVE, CouponTableMap::IS_REMOVING_POSTAGE, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponTableMap::IS_USED, CouponTableMap::SERIALIZED_CONDITIONS, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'AMOUNT', 'IS_ENABLED', 'EXPIRATION_DATE', 'MAX_USAGE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IS_USED', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'type', 'amount', 'is_enabled', 'expiration_date', 'max_usage', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'is_used', 'serialized_conditions', 'created_at', 'updated_at', 'version', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
);
@@ -180,11 +180,11 @@ class CouponTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Amount' => 3, 'IsUsed' => 4, 'IsEnabled' => 5, 'ExpirationDate' => 6, 'SerializedRules' => 7, 'IsCumulative' => 8, 'IsRemovingPostage' => 9, 'MaxUsage' => 10, 'IsAvailableOnSpecialOffers' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'isUsed' => 4, 'isEnabled' => 5, 'expirationDate' => 6, 'serializedRules' => 7, 'isCumulative' => 8, 'isRemovingPostage' => 9, 'maxUsage' => 10, 'isAvailableOnSpecialOffers' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ),
- self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::AMOUNT => 3, CouponTableMap::IS_USED => 4, CouponTableMap::IS_ENABLED => 5, CouponTableMap::EXPIRATION_DATE => 6, CouponTableMap::SERIALIZED_RULES => 7, CouponTableMap::IS_CUMULATIVE => 8, CouponTableMap::IS_REMOVING_POSTAGE => 9, CouponTableMap::MAX_USAGE => 10, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 11, CouponTableMap::CREATED_AT => 12, CouponTableMap::UPDATED_AT => 13, CouponTableMap::VERSION => 14, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'AMOUNT' => 3, 'IS_USED' => 4, 'IS_ENABLED' => 5, 'EXPIRATION_DATE' => 6, 'SERIALIZED_RULES' => 7, 'IS_CUMULATIVE' => 8, 'IS_REMOVING_POSTAGE' => 9, 'MAX_USAGE' => 10, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'is_used' => 4, 'is_enabled' => 5, 'expiration_date' => 6, 'serialized_rules' => 7, 'is_cumulative' => 8, 'is_removing_postage' => 9, 'max_usage' => 10, 'is_available_on_special_offers' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ),
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Amount' => 3, 'IsEnabled' => 4, 'ExpirationDate' => 5, 'MaxUsage' => 6, 'IsCumulative' => 7, 'IsRemovingPostage' => 8, 'IsAvailableOnSpecialOffers' => 9, 'IsUsed' => 10, 'SerializedConditions' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'isEnabled' => 4, 'expirationDate' => 5, 'maxUsage' => 6, 'isCumulative' => 7, 'isRemovingPostage' => 8, 'isAvailableOnSpecialOffers' => 9, 'isUsed' => 10, 'serializedConditions' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ),
+ self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::AMOUNT => 3, CouponTableMap::IS_ENABLED => 4, CouponTableMap::EXPIRATION_DATE => 5, CouponTableMap::MAX_USAGE => 6, CouponTableMap::IS_CUMULATIVE => 7, CouponTableMap::IS_REMOVING_POSTAGE => 8, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 9, CouponTableMap::IS_USED => 10, CouponTableMap::SERIALIZED_CONDITIONS => 11, CouponTableMap::CREATED_AT => 12, CouponTableMap::UPDATED_AT => 13, CouponTableMap::VERSION => 14, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'AMOUNT' => 3, 'IS_ENABLED' => 4, 'EXPIRATION_DATE' => 5, 'MAX_USAGE' => 6, 'IS_CUMULATIVE' => 7, 'IS_REMOVING_POSTAGE' => 8, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 9, 'IS_USED' => 10, 'SERIALIZED_CONDITIONS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'is_enabled' => 4, 'expiration_date' => 5, 'max_usage' => 6, 'is_cumulative' => 7, 'is_removing_postage' => 8, 'is_available_on_special_offers' => 9, 'is_used' => 10, 'serialized_conditions' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
);
@@ -208,14 +208,14 @@ class CouponTableMap extends TableMap
$this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
$this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null);
$this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null);
- $this->addColumn('IS_USED', 'IsUsed', 'TINYINT', true, null, null);
- $this->addColumn('IS_ENABLED', 'IsEnabled', 'TINYINT', true, null, null);
+ $this->addColumn('IS_ENABLED', 'IsEnabled', 'BOOLEAN', true, 1, null);
$this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null);
- $this->addColumn('SERIALIZED_RULES', 'SerializedRules', 'LONGVARCHAR', true, null, null);
- $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'TINYINT', true, null, null);
- $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'TINYINT', true, null, null);
$this->addColumn('MAX_USAGE', 'MaxUsage', 'INTEGER', true, null, null);
+ $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'BOOLEAN', true, 1, null);
+ $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'BOOLEAN', true, 1, null);
$this->addColumn('IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IsAvailableOnSpecialOffers', 'BOOLEAN', true, 1, null);
+ $this->addColumn('IS_USED', 'IsUsed', 'BOOLEAN', true, 1, null);
+ $this->addColumn('SERIALIZED_CONDITIONS', 'SerializedConditions', '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);
@@ -397,14 +397,14 @@ class CouponTableMap extends TableMap
$criteria->addSelectColumn(CouponTableMap::CODE);
$criteria->addSelectColumn(CouponTableMap::TYPE);
$criteria->addSelectColumn(CouponTableMap::AMOUNT);
- $criteria->addSelectColumn(CouponTableMap::IS_USED);
$criteria->addSelectColumn(CouponTableMap::IS_ENABLED);
$criteria->addSelectColumn(CouponTableMap::EXPIRATION_DATE);
- $criteria->addSelectColumn(CouponTableMap::SERIALIZED_RULES);
+ $criteria->addSelectColumn(CouponTableMap::MAX_USAGE);
$criteria->addSelectColumn(CouponTableMap::IS_CUMULATIVE);
$criteria->addSelectColumn(CouponTableMap::IS_REMOVING_POSTAGE);
- $criteria->addSelectColumn(CouponTableMap::MAX_USAGE);
$criteria->addSelectColumn(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS);
+ $criteria->addSelectColumn(CouponTableMap::IS_USED);
+ $criteria->addSelectColumn(CouponTableMap::SERIALIZED_CONDITIONS);
$criteria->addSelectColumn(CouponTableMap::CREATED_AT);
$criteria->addSelectColumn(CouponTableMap::UPDATED_AT);
$criteria->addSelectColumn(CouponTableMap::VERSION);
@@ -413,14 +413,14 @@ class CouponTableMap extends TableMap
$criteria->addSelectColumn($alias . '.CODE');
$criteria->addSelectColumn($alias . '.TYPE');
$criteria->addSelectColumn($alias . '.AMOUNT');
- $criteria->addSelectColumn($alias . '.IS_USED');
$criteria->addSelectColumn($alias . '.IS_ENABLED');
$criteria->addSelectColumn($alias . '.EXPIRATION_DATE');
- $criteria->addSelectColumn($alias . '.SERIALIZED_RULES');
+ $criteria->addSelectColumn($alias . '.MAX_USAGE');
$criteria->addSelectColumn($alias . '.IS_CUMULATIVE');
$criteria->addSelectColumn($alias . '.IS_REMOVING_POSTAGE');
- $criteria->addSelectColumn($alias . '.MAX_USAGE');
$criteria->addSelectColumn($alias . '.IS_AVAILABLE_ON_SPECIAL_OFFERS');
+ $criteria->addSelectColumn($alias . '.IS_USED');
+ $criteria->addSelectColumn($alias . '.SERIALIZED_CONDITIONS');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
$criteria->addSelectColumn($alias . '.VERSION');
diff --git a/core/lib/Thelia/Model/Map/CouponVersionTableMap.php b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php
index 30ce279b8..91e774912 100644
--- a/core/lib/Thelia/Model/Map/CouponVersionTableMap.php
+++ b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php
@@ -89,11 +89,6 @@ class CouponVersionTableMap extends TableMap
*/
const AMOUNT = 'coupon_version.AMOUNT';
- /**
- * the column name for the IS_USED field
- */
- const IS_USED = 'coupon_version.IS_USED';
-
/**
* the column name for the IS_ENABLED field
*/
@@ -105,9 +100,9 @@ class CouponVersionTableMap extends TableMap
const EXPIRATION_DATE = 'coupon_version.EXPIRATION_DATE';
/**
- * the column name for the SERIALIZED_RULES field
+ * the column name for the MAX_USAGE field
*/
- const SERIALIZED_RULES = 'coupon_version.SERIALIZED_RULES';
+ const MAX_USAGE = 'coupon_version.MAX_USAGE';
/**
* the column name for the IS_CUMULATIVE field
@@ -119,16 +114,21 @@ class CouponVersionTableMap extends TableMap
*/
const IS_REMOVING_POSTAGE = 'coupon_version.IS_REMOVING_POSTAGE';
- /**
- * the column name for the MAX_USAGE field
- */
- const MAX_USAGE = 'coupon_version.MAX_USAGE';
-
/**
* the column name for the IS_AVAILABLE_ON_SPECIAL_OFFERS field
*/
const IS_AVAILABLE_ON_SPECIAL_OFFERS = 'coupon_version.IS_AVAILABLE_ON_SPECIAL_OFFERS';
+ /**
+ * the column name for the IS_USED field
+ */
+ const IS_USED = 'coupon_version.IS_USED';
+
+ /**
+ * the column name for the SERIALIZED_CONDITIONS field
+ */
+ const SERIALIZED_CONDITIONS = 'coupon_version.SERIALIZED_CONDITIONS';
+
/**
* the column name for the CREATED_AT field
*/
@@ -156,11 +156,11 @@ class CouponVersionTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Amount', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'IsCumulative', 'IsRemovingPostage', 'MaxUsage', 'IsAvailableOnSpecialOffers', 'CreatedAt', 'UpdatedAt', 'Version', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'amount', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'isCumulative', 'isRemovingPostage', 'maxUsage', 'isAvailableOnSpecialOffers', 'createdAt', 'updatedAt', 'version', ),
- self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::AMOUNT, CouponVersionTableMap::IS_USED, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::SERIALIZED_RULES, CouponVersionTableMap::IS_CUMULATIVE, CouponVersionTableMap::IS_REMOVING_POSTAGE, CouponVersionTableMap::MAX_USAGE, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ),
- self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'AMOUNT', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'MAX_USAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ),
- self::TYPE_FIELDNAME => array('id', 'code', 'type', 'amount', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'is_cumulative', 'is_removing_postage', 'max_usage', 'is_available_on_special_offers', 'created_at', 'updated_at', 'version', ),
+ self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Amount', 'IsEnabled', 'ExpirationDate', 'MaxUsage', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'IsUsed', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', 'Version', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'amount', 'isEnabled', 'expirationDate', 'maxUsage', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'isUsed', 'serializedConditions', 'createdAt', 'updatedAt', 'version', ),
+ self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::AMOUNT, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::MAX_USAGE, CouponVersionTableMap::IS_CUMULATIVE, CouponVersionTableMap::IS_REMOVING_POSTAGE, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponVersionTableMap::IS_USED, CouponVersionTableMap::SERIALIZED_CONDITIONS, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'AMOUNT', 'IS_ENABLED', 'EXPIRATION_DATE', 'MAX_USAGE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IS_USED', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'type', 'amount', 'is_enabled', 'expiration_date', 'max_usage', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'is_used', 'serialized_conditions', 'created_at', 'updated_at', 'version', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
);
@@ -171,11 +171,11 @@ class CouponVersionTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Amount' => 3, 'IsUsed' => 4, 'IsEnabled' => 5, 'ExpirationDate' => 6, 'SerializedRules' => 7, 'IsCumulative' => 8, 'IsRemovingPostage' => 9, 'MaxUsage' => 10, 'IsAvailableOnSpecialOffers' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'isUsed' => 4, 'isEnabled' => 5, 'expirationDate' => 6, 'serializedRules' => 7, 'isCumulative' => 8, 'isRemovingPostage' => 9, 'maxUsage' => 10, 'isAvailableOnSpecialOffers' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ),
- self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::AMOUNT => 3, CouponVersionTableMap::IS_USED => 4, CouponVersionTableMap::IS_ENABLED => 5, CouponVersionTableMap::EXPIRATION_DATE => 6, CouponVersionTableMap::SERIALIZED_RULES => 7, CouponVersionTableMap::IS_CUMULATIVE => 8, CouponVersionTableMap::IS_REMOVING_POSTAGE => 9, CouponVersionTableMap::MAX_USAGE => 10, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 11, CouponVersionTableMap::CREATED_AT => 12, CouponVersionTableMap::UPDATED_AT => 13, CouponVersionTableMap::VERSION => 14, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'AMOUNT' => 3, 'IS_USED' => 4, 'IS_ENABLED' => 5, 'EXPIRATION_DATE' => 6, 'SERIALIZED_RULES' => 7, 'IS_CUMULATIVE' => 8, 'IS_REMOVING_POSTAGE' => 9, 'MAX_USAGE' => 10, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'is_used' => 4, 'is_enabled' => 5, 'expiration_date' => 6, 'serialized_rules' => 7, 'is_cumulative' => 8, 'is_removing_postage' => 9, 'max_usage' => 10, 'is_available_on_special_offers' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ),
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Amount' => 3, 'IsEnabled' => 4, 'ExpirationDate' => 5, 'MaxUsage' => 6, 'IsCumulative' => 7, 'IsRemovingPostage' => 8, 'IsAvailableOnSpecialOffers' => 9, 'IsUsed' => 10, 'SerializedConditions' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'isEnabled' => 4, 'expirationDate' => 5, 'maxUsage' => 6, 'isCumulative' => 7, 'isRemovingPostage' => 8, 'isAvailableOnSpecialOffers' => 9, 'isUsed' => 10, 'serializedConditions' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ),
+ self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::AMOUNT => 3, CouponVersionTableMap::IS_ENABLED => 4, CouponVersionTableMap::EXPIRATION_DATE => 5, CouponVersionTableMap::MAX_USAGE => 6, CouponVersionTableMap::IS_CUMULATIVE => 7, CouponVersionTableMap::IS_REMOVING_POSTAGE => 8, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 9, CouponVersionTableMap::IS_USED => 10, CouponVersionTableMap::SERIALIZED_CONDITIONS => 11, CouponVersionTableMap::CREATED_AT => 12, CouponVersionTableMap::UPDATED_AT => 13, CouponVersionTableMap::VERSION => 14, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'AMOUNT' => 3, 'IS_ENABLED' => 4, 'EXPIRATION_DATE' => 5, 'MAX_USAGE' => 6, 'IS_CUMULATIVE' => 7, 'IS_REMOVING_POSTAGE' => 8, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 9, 'IS_USED' => 10, 'SERIALIZED_CONDITIONS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'is_enabled' => 4, 'expiration_date' => 5, 'max_usage' => 6, 'is_cumulative' => 7, 'is_removing_postage' => 8, 'is_available_on_special_offers' => 9, 'is_used' => 10, 'serialized_conditions' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
);
@@ -199,14 +199,14 @@ class CouponVersionTableMap extends TableMap
$this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
$this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null);
$this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null);
- $this->addColumn('IS_USED', 'IsUsed', 'TINYINT', true, null, null);
- $this->addColumn('IS_ENABLED', 'IsEnabled', 'TINYINT', true, null, null);
+ $this->addColumn('IS_ENABLED', 'IsEnabled', 'BOOLEAN', true, 1, null);
$this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null);
- $this->addColumn('SERIALIZED_RULES', 'SerializedRules', 'LONGVARCHAR', true, null, null);
- $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'TINYINT', true, null, null);
- $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'TINYINT', true, null, null);
$this->addColumn('MAX_USAGE', 'MaxUsage', 'INTEGER', true, null, null);
+ $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'BOOLEAN', true, 1, null);
+ $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'BOOLEAN', true, 1, null);
$this->addColumn('IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IsAvailableOnSpecialOffers', 'BOOLEAN', true, 1, null);
+ $this->addColumn('IS_USED', 'IsUsed', 'BOOLEAN', true, 1, null);
+ $this->addColumn('SERIALIZED_CONDITIONS', 'SerializedConditions', '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);
@@ -411,14 +411,14 @@ class CouponVersionTableMap extends TableMap
$criteria->addSelectColumn(CouponVersionTableMap::CODE);
$criteria->addSelectColumn(CouponVersionTableMap::TYPE);
$criteria->addSelectColumn(CouponVersionTableMap::AMOUNT);
- $criteria->addSelectColumn(CouponVersionTableMap::IS_USED);
$criteria->addSelectColumn(CouponVersionTableMap::IS_ENABLED);
$criteria->addSelectColumn(CouponVersionTableMap::EXPIRATION_DATE);
- $criteria->addSelectColumn(CouponVersionTableMap::SERIALIZED_RULES);
+ $criteria->addSelectColumn(CouponVersionTableMap::MAX_USAGE);
$criteria->addSelectColumn(CouponVersionTableMap::IS_CUMULATIVE);
$criteria->addSelectColumn(CouponVersionTableMap::IS_REMOVING_POSTAGE);
- $criteria->addSelectColumn(CouponVersionTableMap::MAX_USAGE);
$criteria->addSelectColumn(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS);
+ $criteria->addSelectColumn(CouponVersionTableMap::IS_USED);
+ $criteria->addSelectColumn(CouponVersionTableMap::SERIALIZED_CONDITIONS);
$criteria->addSelectColumn(CouponVersionTableMap::CREATED_AT);
$criteria->addSelectColumn(CouponVersionTableMap::UPDATED_AT);
$criteria->addSelectColumn(CouponVersionTableMap::VERSION);
@@ -427,14 +427,14 @@ class CouponVersionTableMap extends TableMap
$criteria->addSelectColumn($alias . '.CODE');
$criteria->addSelectColumn($alias . '.TYPE');
$criteria->addSelectColumn($alias . '.AMOUNT');
- $criteria->addSelectColumn($alias . '.IS_USED');
$criteria->addSelectColumn($alias . '.IS_ENABLED');
$criteria->addSelectColumn($alias . '.EXPIRATION_DATE');
- $criteria->addSelectColumn($alias . '.SERIALIZED_RULES');
+ $criteria->addSelectColumn($alias . '.MAX_USAGE');
$criteria->addSelectColumn($alias . '.IS_CUMULATIVE');
$criteria->addSelectColumn($alias . '.IS_REMOVING_POSTAGE');
- $criteria->addSelectColumn($alias . '.MAX_USAGE');
$criteria->addSelectColumn($alias . '.IS_AVAILABLE_ON_SPECIAL_OFFERS');
+ $criteria->addSelectColumn($alias . '.IS_USED');
+ $criteria->addSelectColumn($alias . '.SERIALIZED_CONDITIONS');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
$criteria->addSelectColumn($alias . '.VERSION');
diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php
index cbb6c0051..2348a9c0d 100755
--- a/core/lib/Thelia/Model/Product.php
+++ b/core/lib/Thelia/Model/Product.php
@@ -87,12 +87,46 @@ class Product extends BaseProduct
return $this;
}
+ public function updateDefaultCategory($defaultCategoryId) {
+
+ // Allow uncategorized products (NULL instead of 0, to bypass delete cascade constraint)
+ if ($defaultCategoryId <= 0) $defaultCategoryId = NULL;
+
+ // Update the default category
+ $productCategory = ProductCategoryQuery::create()
+ ->filterByProductId($this->getId())
+ ->filterByDefaultCategory(true)
+ ->findOne()
+ ;
+
+ if ($productCategory == null || $productCategory->getCategoryId() != $defaultCategoryId) {
+ exit;
+ // Delete the old default category
+ if ($productCategory !== null) $productCategory->delete();
+
+ // Add the new default category
+ $productCategory = new ProductCategory();
+
+ $productCategory
+ ->setProduct($this)
+ ->setCategoryId($defaultCategoryId)
+ ->setDefaultCategory(true)
+ ->save()
+ ;
+ }
+ }
+
/**
* Create a new product, along with the default category ID
*
* @param int $defaultCategoryId the default category ID of this product
+ * @param float $basePrice the product base price
+ * @param int $priceCurrencyId the price currency Id
+ * @param int $taxRuleId the product tax rule ID
+ * @param float $baseWeight base weight in Kg
*/
- public function create($defaultCategoryId) {
+
+ public function create($defaultCategoryId, $basePrice, $priceCurrencyId, $taxRuleId, $baseWeight) {
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
@@ -105,18 +139,13 @@ class Product extends BaseProduct
$this->save($con);
// Add the default category
- $pc = new ProductCategory();
-
- $pc
- ->setProduct($this)
- ->setCategoryId($defaultCategoryId)
- ->setDefaultCategory(true)
- ->save($con)
- ;
+ $this->updateDefaultCategory($defaultCategoryId);
// Set the position
$this->setPosition($this->getNextPosition())->save($con);
+ $this->setTaxRuleId($taxRuleId);
+
// Create an empty product sale element
$sale_elements = new ProductSaleElements();
@@ -125,7 +154,8 @@ class Product extends BaseProduct
->setRef($this->getRef())
->setPromo(0)
->setNewness(0)
- ->setWeight(0)
+ ->setWeight($baseWeight)
+ ->setIsDefault(true)
->save($con)
;
@@ -134,9 +164,9 @@ class Product extends BaseProduct
$product_price
->setProductSaleElements($sale_elements)
- ->setPromoPrice(0)
- ->setPrice(0)
- ->setCurrency(CurrencyQuery::create()->findOneByByDefault(true))
+ ->setPromoPrice($basePrice)
+ ->setPrice($basePrice)
+ ->setCurrencyId($priceCurrencyId)
->save($con)
;
diff --git a/core/lib/Thelia/Model/ProductAssociatedContent.php b/core/lib/Thelia/Model/ProductAssociatedContent.php
index e07ee2cd6..843d76ba1 100644
--- a/core/lib/Thelia/Model/ProductAssociatedContent.php
+++ b/core/lib/Thelia/Model/ProductAssociatedContent.php
@@ -11,11 +11,22 @@ class ProductAssociatedContent extends BaseProductAssociatedContent {
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
+ use \Thelia\Model\Tools\PositionManagementTrait;
+
+ /**
+ * Calculate next position relative to our product
+ */
+ protected function addCriteriaToPositionQuery($query) {
+ $query->filterByProductId($this->getProductId());
+ }
+
/**
* {@inheritDoc}
*/
public function preInsert(ConnectionInterface $con = null)
{
+ $this->setPosition($this->getNextPosition());
+
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this));
return true;
diff --git a/core/lib/Thelia/Model/ProductDocument.php b/core/lib/Thelia/Model/ProductDocument.php
index 53515ff3c..b0f8032da 100755
--- a/core/lib/Thelia/Model/ProductDocument.php
+++ b/core/lib/Thelia/Model/ProductDocument.php
@@ -26,4 +26,28 @@ class ProductDocument extends BaseProductDocument
return true;
}
+ /**
+ * Set Document parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setProductId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Document parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getProductId();
+ }
+
}
diff --git a/core/lib/Thelia/Model/ProductImage.php b/core/lib/Thelia/Model/ProductImage.php
index 4bf0c40a6..6cc3ddd8c 100755
--- a/core/lib/Thelia/Model/ProductImage.php
+++ b/core/lib/Thelia/Model/ProductImage.php
@@ -25,4 +25,28 @@ class ProductImage extends BaseProductImage
return true;
}
+
+ /**
+ * Set Image parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setProductId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Image parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getProductId();
+ }
}
diff --git a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php
index 70da830ac..642d07402 100644
--- a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php
+++ b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php
@@ -126,7 +126,8 @@ trait PositionManagementTrait {
$result->setDispatcher($this->getDispatcher())->setPosition($my_position)->save();
$cnx->commit();
- } catch (Exception $e) {
+ }
+ catch (Exception $e) {
$cnx->rollback();
}
}
@@ -179,7 +180,10 @@ trait PositionManagementTrait {
try {
foreach ($results as $result) {
- $result->setDispatcher($this->getDispatcher())->setPosition($result->getPosition() + $delta)->save($cnx);
+
+ $objNewPosition = $result->getPosition() + $delta;
+
+ $result->setDispatcher($this->getDispatcher())->setPosition($objNewPosition)->save($cnx);
}
$this
@@ -188,7 +192,8 @@ trait PositionManagementTrait {
;
$cnx->commit();
- } catch (Exception $e) {
+ }
+ catch (Exception $e) {
$cnx->rollback();
}
}
diff --git a/core/lib/Thelia/Tests/Tools/FileManagerTest.php b/core/lib/Thelia/Tests/Tools/FileManagerTest.php
new file mode 100644
index 000000000..8dce5afcc
--- /dev/null
+++ b/core/lib/Thelia/Tests/Tools/FileManagerTest.php
@@ -0,0 +1,906 @@
+
+ */
+
+namespace Thelia\Tests\Type;
+
+
+use Thelia\Core\Event\DocumentCreateOrUpdateEvent;
+use Thelia\Core\Event\ImageCreateOrUpdateEvent;
+use Thelia\Core\Translation\Translator;
+use Thelia\Exception\ImageException;
+use Thelia\Model\Admin;
+use Thelia\Tools\FileManager;
+
+/**
+ * Class FileManagerTest
+ *
+ * @package Thelia\Tests\Type
+ */
+class FileManagerTest extends \PHPUnit_Framework_TestCase {
+
+
+ /**
+ * @covers Thelia\Tools\FileManager::copyUploadedFile
+ */
+ public function testCopyUploadedFile()
+ {
+ $this->markTestIncomplete(
+ 'Mock issue'
+ );
+
+ $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubTranslator->expects($this->any())
+ ->method('trans')
+ ->will($this->returnValue('translated'));
+
+ $stubRequest = $this->getMockBuilder('\Thelia\Core\HttpFoundation\Request')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubSecurity = $this->getMockBuilder('\Thelia\Core\Security\SecurityContext')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubSecurity->expects($this->any())
+ ->method('getAdminUser')
+ ->will($this->returnValue(new Admin()));
+
+
+
+ // Create a map of arguments to return values.
+ $map = array(
+ array('thelia.translator', $stubTranslator),
+ array('request', $stubRequest),
+ array('thelia.securityContext', $stubSecurity)
+ );
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubContainer->expects($this->any())
+ ->method('get')
+ ->will($this->returnValueMap($map));
+
+ $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductImage->expects($this->any())
+ ->method('getUploadDir')
+ ->will($this->returnValue(THELIA_LOCAL_DIR . 'media/images/product'));
+ $stubProductImage->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue(42));
+ $stubProductImage->expects($this->any())
+ ->method('setFile')
+ ->will($this->returnValue(true));
+ $stubProductImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(0));
+
+ $stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalName')
+ ->will($this->returnValue('goodName'));
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalExtension')
+ ->will($this->returnValue('png'));
+ $stubUploadedFile->expects($this->any())
+ ->method('move')
+ ->will($this->returnValue($stubUploadedFile));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $newUploadedFiles = array();
+
+ $actual = $fileManager->copyUploadedFile(24, FileManager::TYPE_PRODUCT, $stubProductImage, $stubUploadedFile, $newUploadedFiles, FileManager::FILE_TYPE_IMAGES);
+
+ $this->assertCount(1, $actual);
+ }
+
+
+ /**
+ * @covers Thelia\Tools\FileManager::copyUploadedFile
+ * @expectedException \Thelia\Exception\ImageException
+ */
+ public function testCopyUploadedFileExceptionImageException()
+ {
+ $this->markTestIncomplete(
+ 'Mock issue'
+ );
+
+ $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubTranslator->expects($this->any())
+ ->method('trans')
+ ->will($this->returnValue('translated'));
+
+ $stubRequest = $this->getMockBuilder('\Thelia\Core\HttpFoundation\Request')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubSecurity = $this->getMockBuilder('\Thelia\Core\Security\SecurityContext')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubSecurity->expects($this->any())
+ ->method('getAdminUser')
+ ->will($this->returnValue(new Admin()));
+
+
+
+ // Create a map of arguments to return values.
+ $map = array(
+ array('thelia.translator', $stubTranslator),
+ array('request', $stubRequest),
+ array('thelia.securityContext', $stubSecurity)
+ );
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubContainer->expects($this->any())
+ ->method('get')
+ ->will($this->returnValueMap($map));
+
+ $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductImage->expects($this->any())
+ ->method('getUploadDir')
+ ->will($this->returnValue(THELIA_LOCAL_DIR . 'media/images/product'));
+ $stubProductImage->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue(42));
+ $stubProductImage->expects($this->any())
+ ->method('setFile')
+ ->will($this->returnValue(true));
+ $stubProductImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(0));
+
+ $stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalName')
+ ->will($this->returnValue('goodName'));
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalExtension')
+ ->will($this->returnValue('png'));
+ $stubUploadedFile->expects($this->any())
+ ->method('move')
+ ->will($this->returnValue($stubUploadedFile));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $newUploadedFiles = array();
+
+ $actual = $fileManager->copyUploadedFile(24, FileManager::TYPE_PRODUCT, $stubProductImage, $stubUploadedFile, $newUploadedFiles, FileManager::FILE_TYPE_DOCUMENTS);
+
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveImage
+ */
+ public function testSaveImageProductImage()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubProductImage->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveImage($event, $stubProductImage);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveDocument
+ */
+ public function testSaveDocumentProductDocument()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubProductDocument = $this->getMockBuilder('\Thelia\Model\ProductDocument')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductDocument->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubProductDocument->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveDocument($event, $stubProductDocument);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveImage
+ */
+ public function testSaveImageCategoryImage()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubCategoryImage = $this->getMockBuilder('\Thelia\Model\CategoryImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubCategoryImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubCategoryImage->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_CATEGORY, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveImage($event, $stubCategoryImage);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveDocument
+ */
+ public function testSaveDocumentCategoryDocument()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubCategoryDocument = $this->getMockBuilder('\Thelia\Model\CategoryDocument')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubCategoryDocument->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubCategoryDocument->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_CATEGORY, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveDocument($event, $stubCategoryDocument);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveImage
+ */
+ public function testSaveImageFolderImage()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubFolderImage = $this->getMockBuilder('\Thelia\Model\FolderImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubFolderImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubFolderImage->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_FOLDER, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveImage($event, $stubFolderImage);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveDocument
+ */
+ public function testSaveDocumentFolderDocument()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubFolderDocument = $this->getMockBuilder('\Thelia\Model\FolderDocument')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubFolderDocument->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubFolderDocument->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_FOLDER, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveDocument($event, $stubFolderDocument);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveImage
+ */
+ public function testSaveImageContentImage()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubContentImage = $this->getMockBuilder('\Thelia\Model\ContentImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubContentImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubContentImage->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_CONTENT, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveImage($event, $stubContentImage);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveDocument
+ */
+ public function testSaveDocumentContentDocument()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubContentDocument = $this->getMockBuilder('\Thelia\Model\ContentDocument')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubContentDocument->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubContentDocument->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_CONTENT, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveDocument($event, $stubContentDocument);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveImage
+ * @expectedException \Thelia\Exception\ImageException
+ */
+ public function testSaveImageExceptionImageException()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $fileManager = new FileManager($stubContainer);
+
+ $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubProductImage->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $event = new ImageCreateOrUpdateEvent('bad', 24);
+
+ $fileManager->saveImage($event, $stubProductImage);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveDocument
+ * @expectedException \Thelia\Model\Exception\InvalidArgumentException
+ */
+ public function testSaveDocumentExceptionDocumentException()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $fileManager = new FileManager($stubContainer);
+
+ $stubProductDocument = $this->getMockBuilder('\Thelia\Model\ProductDocument')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductDocument->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubProductDocument->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $event = new DocumentCreateOrUpdateEvent('bad', 24);
+
+ $fileManager->saveDocument($event, $stubProductDocument);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveImage
+ * @expectedException \Thelia\Exception\ImageException
+ */
+ public function testSaveImageExceptionImageException2()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $fileManager = new FileManager($stubContainer);
+
+ $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(0));
+ $stubProductImage->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24);
+
+ $fileManager->saveImage($event, $stubProductImage);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveDocument
+ * @expectedException \Thelia\Model\Exception\InvalidArgumentException
+ */
+ public function testSaveDocumentExceptionDocumentException2()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $fileManager = new FileManager($stubContainer);
+
+ $stubProductDocument = $this->getMockBuilder('\Thelia\Model\ProductDocument')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductDocument->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(0));
+ $stubProductDocument->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24);
+
+ $fileManager->saveDocument($event, $stubProductDocument);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::sanitizeFileName
+ */
+ public function testSanitizeFileName()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+ $badFileName = 'azeéràçè§^"$*+-_°)(&é<>@#ty';
+
+ $expected = 'azeyryZyy-_yty';
+ $actual = $fileManager->sanitizeFileName($badFileName);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getImageModel
+ */
+ public function testGetImageModel()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+ $actual = $fileManager->getImageModel(FileManager::TYPE_PRODUCT);
+ $this->assertInstanceOf('\Thelia\Model\ProductImage', $actual);
+ $actual = $fileManager->getImageModel(FileManager::TYPE_CATEGORY);
+ $this->assertInstanceOf('\Thelia\Model\CategoryImage', $actual);
+ $actual = $fileManager->getImageModel(FileManager::TYPE_CONTENT);
+ $this->assertInstanceOf('\Thelia\Model\ContentImage', $actual);
+ $actual = $fileManager->getImageModel(FileManager::TYPE_FOLDER);
+ $this->assertInstanceOf('\Thelia\Model\FolderImage', $actual);
+ $actual = $fileManager->getImageModel('bad');
+ $this->assertNull($actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getDocumentModel
+ */
+ public function testGetDocumentModel()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+ $actual = $fileManager->getDocumentModel(FileManager::TYPE_PRODUCT);
+ $this->assertInstanceOf('\Thelia\Model\ProductDocument', $actual);
+ $actual = $fileManager->getDocumentModel(FileManager::TYPE_CATEGORY);
+ $this->assertInstanceOf('\Thelia\Model\CategoryDocument', $actual);
+ $actual = $fileManager->getDocumentModel(FileManager::TYPE_CONTENT);
+ $this->assertInstanceOf('\Thelia\Model\ContentDocument', $actual);
+ $actual = $fileManager->getDocumentModel(FileManager::TYPE_FOLDER);
+ $this->assertInstanceOf('\Thelia\Model\FolderDocument', $actual);
+ $actual = $fileManager->getDocumentModel('bad');
+ $this->assertNull($actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getImageModelQuery
+ */
+ public function testGetImageModelQuery()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+ $actual = $fileManager->getImageModelQuery(FileManager::TYPE_PRODUCT);
+ $this->assertInstanceOf('\Thelia\Model\ProductImageQuery', $actual);
+ $actual = $fileManager->getImageModelQuery(FileManager::TYPE_CATEGORY);
+ $this->assertInstanceOf('\Thelia\Model\CategoryImageQuery', $actual);
+ $actual = $fileManager->getImageModelQuery(FileManager::TYPE_CONTENT);
+ $this->assertInstanceOf('\Thelia\Model\ContentImageQuery', $actual);
+ $actual = $fileManager->getImageModelQuery(FileManager::TYPE_FOLDER);
+ $this->assertInstanceOf('\Thelia\Model\FolderImageQuery', $actual);
+ $actual = $fileManager->getImageModelQuery('bad');
+ $this->assertNull($actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getDocumentModelQuery
+ */
+ public function testGetDocumentModelQuery()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+ $actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_PRODUCT);
+ $this->assertInstanceOf('\Thelia\Model\ProductDocumentQuery', $actual);
+ $actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_CATEGORY);
+ $this->assertInstanceOf('\Thelia\Model\CategoryDocumentQuery', $actual);
+ $actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_CONTENT);
+ $this->assertInstanceOf('\Thelia\Model\ContentDocumentQuery', $actual);
+ $actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_FOLDER);
+ $this->assertInstanceOf('\Thelia\Model\FolderDocumentQuery', $actual);
+ $actual = $fileManager->getDocumentModelQuery('bad');
+ $this->assertNull($actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getParentFileModel
+ */
+ public function testGetParentFileModel()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+ $actual = $fileManager->getParentFileModel(FileManager::TYPE_PRODUCT, 1);
+ $this->assertInstanceOf('\Thelia\Model\Product', $actual);
+ $actual = $fileManager->getParentFileModel(FileManager::TYPE_CATEGORY, 1);
+ $this->assertInstanceOf('\Thelia\Model\Category', $actual);
+ $actual = $fileManager->getParentFileModel(FileManager::TYPE_CONTENT, 1);
+ $this->assertInstanceOf('\Thelia\Model\Content', $actual);
+ $actual = $fileManager->getParentFileModel(FileManager::TYPE_FOLDER, 1);
+ $this->assertInstanceOf('\Thelia\Model\Folder', $actual, 1);
+ $actual = $fileManager->getParentFileModel('bad', 1);
+ $this->assertNull($actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getImageForm
+ */
+ public function testGetImageForm()
+ {
+ // Mock issue
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+ /**
+ * @covers Thelia\Tools\FileManager::getDocumentForm
+ */
+ public function testGetDocumentForm()
+ {
+ // Mock issue
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getUploadDir
+ */
+ public function testGetUploadDir()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/images/product', $actual);
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/images/category', $actual);
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/images/content', $actual);
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/images/folder', $actual);
+ $actual = $fileManager->getUploadDir('bad', FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(false, $actual);
+
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/product', $actual);
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/category', $actual);
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/content', $actual);
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/folder', $actual);
+ $actual = $fileManager->getUploadDir('bad', FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(false, $actual);
+
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_FOLDER, 'bad');
+ $this->assertEquals(false, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getRedirectionUrl
+ */
+ public function testGetRedirectionUrl()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_PRODUCT, 1, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('/admin/products/update?product_id=1¤t_tab=images', $actual);
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CATEGORY, 1, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('/admin/categories/update?category_id=1¤t_tab=images', $actual);
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CONTENT, 1, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('/admin/content/update/1?current_tab=images', $actual);
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_FOLDER, 1, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('/admin/folders/update/1?current_tab=images', $actual);
+ $actual = $fileManager->getRedirectionUrl('bad', 1, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(false, $actual);
+
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_PRODUCT, 1, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('/admin/products/update?product_id=1¤t_tab=documents', $actual);
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CATEGORY, 1, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('/admin/categories/update?category_id=1¤t_tab=documents', $actual);
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CONTENT, 1, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('/admin/content/update/1?current_tab=documents', $actual);
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_FOLDER, 1, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('/admin/folders/update/1?current_tab=documents', $actual);
+ $actual = $fileManager->getRedirectionUrl('bad', 1, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(false, $actual);
+
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_FOLDER, 1, 'bad');
+ $this->assertEquals(false, $actual);
+ }
+
+
+ /**
+ * @covers Thelia\Tools\FileManager::getFormId
+ */
+ public function testGetFormId()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+
+ $actual = $fileManager->getFormId(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('thelia.admin.product.image.modification', $actual);
+ $actual = $fileManager->getFormId(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('thelia.admin.category.image.modification', $actual);
+ $actual = $fileManager->getFormId(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('thelia.admin.content.image.modification', $actual);
+ $actual = $fileManager->getFormId(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('thelia.admin.folder.image.modification', $actual);
+ $actual = $fileManager->getFormId('bad', FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(false, $actual);
+
+ $actual = $fileManager->getFormId(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('thelia.admin.product.document.modification', $actual);
+ $actual = $fileManager->getFormId(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('thelia.admin.category.document.modification', $actual);
+ $actual = $fileManager->getFormId(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('thelia.admin.content.document.modification', $actual);
+ $actual = $fileManager->getFormId(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('thelia.admin.folder.document.modification', $actual);
+ $actual = $fileManager->getFormId('bad', FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(false, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::renameFile
+ */
+ public function testRenameFile()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalExtension')
+ ->will($this->returnValue('yml'));
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalName')
+ ->will($this->returnValue('or1-g_n?al*/&é"filen@me#'));
+
+
+ $fileManager = new FileManager($stubContainer);
+
+ $expected = 'or1-g_nalyfilenme-1.yml';
+ $actual = $fileManager->renameFile(1, $stubUploadedFile);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::renameFile
+ */
+ public function testRenameFileWithoutExtension()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalExtension')
+ ->will($this->returnValue(''));
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalName')
+ ->will($this->returnValue('or1-g_n?al*/&é"filen@me#'));
+
+
+ $fileManager = new FileManager($stubContainer);
+
+ $expected = 'or1-g_nalyfilenme-1';
+ $actual = $fileManager->renameFile(1, $stubUploadedFile);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::isImage
+ */
+ public function testIsImage()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+
+ $actual = $fileManager->isImage('image/jpeg');
+ $this->assertTrue($actual);
+ $actual = $fileManager->isImage('image/png');
+ $this->assertTrue($actual);
+ $actual = $fileManager->isImage('image/gif');
+ $this->assertTrue($actual);
+
+ $actual = $fileManager->isImage('bad');
+ $this->assertFalse($actual);
+ $actual = $fileManager->isImage('image/jpg');
+ $this->assertFalse($actual);
+ $actual = $fileManager->isImage('application/x-msdownload');
+ $this->assertFalse($actual);
+ $actual = $fileManager->isImage('application/x-sh');
+ $this->assertFalse($actual);
+
+ }
+
+
+ /**
+ * @covers Thelia\Tools\FileManager::getAvailableTypes
+ */
+ public function testGetAvailableTypes()
+ {
+ $expected = array(
+ FileManager::TYPE_CATEGORY,
+ FileManager::TYPE_CONTENT,
+ FileManager::TYPE_FOLDER,
+ FileManager::TYPE_PRODUCT,
+ FileManager::TYPE_MODULE,
+ );
+ $actual = FileManager::getAvailableTypes();
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::adminLogAppend
+ */
+ public function testAdminLogAppend()
+ {
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::deleteFile
+ */
+ public function testDeleteFile()
+ {
+ // @todo see http://tech.vg.no/2011/03/09/mocking-the-file-system-using-phpunit-and-vfsstream/
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+}
diff --git a/core/lib/Thelia/Tools/FileManager.php b/core/lib/Thelia/Tools/FileManager.php
new file mode 100644
index 000000000..6c06fb416
--- /dev/null
+++ b/core/lib/Thelia/Tools/FileManager.php
@@ -0,0 +1,731 @@
+. */
+/* */
+/**********************************************************************************/
+namespace Thelia\Tools;
+
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\File\UploadedFile;
+use Thelia\Core\Event\DocumentCreateOrUpdateEvent;
+use Thelia\Core\Event\ImageCreateOrUpdateEvent;
+use Thelia\Core\HttpFoundation\Request;
+use Thelia\Core\Translation\Translator;
+use Thelia\Exception\ImageException;
+use Thelia\Form\CategoryDocumentModification;
+use Thelia\Form\CategoryImageModification;
+use Thelia\Form\ContentDocumentModification;
+use Thelia\Form\ContentImageModification;
+use Thelia\Form\FolderDocumentModification;
+use Thelia\Form\FolderImageModification;
+use Thelia\Form\ProductDocumentModification;
+use Thelia\Form\ProductImageModification;
+use Thelia\Model\AdminLog;
+use Thelia\Model\CategoryDocument;
+use Thelia\Model\CategoryDocumentQuery;
+use Thelia\Model\CategoryImage;
+use Thelia\Model\CategoryImageQuery;
+use Thelia\Model\CategoryQuery;
+use Thelia\Model\ContentDocument;
+use Thelia\Model\ContentDocumentQuery;
+use Thelia\Model\ContentImage;
+use Thelia\Model\ContentImageQuery;
+use Thelia\Model\ContentQuery;
+use Thelia\Model\Exception\InvalidArgumentException;
+use Thelia\Model\FolderDocument;
+use Thelia\Model\FolderDocumentQuery;
+use Thelia\Model\FolderImage;
+use Thelia\Model\FolderImageQuery;
+use Thelia\Model\FolderQuery;
+use Thelia\Model\ProductDocument;
+use Thelia\Model\ProductDocumentQuery;
+use Thelia\Model\ProductImage;
+use Thelia\Model\ProductImageQuery;
+use Thelia\Model\ProductQuery;
+
+/**
+ * Created by JetBrains PhpStorm.
+ * Date: 9/19/13
+ * Time: 3:24 PM
+ *
+ * File Manager
+ *
+ * @package File
+ * @author Guillaume MOREL | {intl l='ID'} | + +{intl l='Content title'} | + +{intl l='Position'} | + + {module_include location='product_contents_table_header'} + +{intl l="Actions"} | +
|---|---|---|---|
| {$ID} | + ++ {$TITLE} + | + ++ {admin_position_block + permission="admin.products.edit" + path={url path='/admin/product/update-content-position' product_id=$product_id current_tab="related"} + url_parameter="content_id" + in_place_edit_class="contentPositionChange" + position=$POSITION + id=$ID + } + | + + {module_include location='product_contents_table_row'} + +
+
+ {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.product.content.delete"}
+
+
+
+ {/loop}
+
+ |
+
|
+
+ {intl l="This product contains no contents"}
+
+ |
+ |||
| {intl l='ID'} | + +{intl l='Accessory title'} | + +{intl l='Position'} | + + {module_include location='product_accessories_table_header'} + +{intl l="Actions"} | +
|---|---|---|---|
| {$ID} | + ++ {$TITLE} + | + ++ {admin_position_block + permission="admin.products.edit" + path={url path='/admin/product/update-accessory-position' product_id=$product_id current_tab="related"} + url_parameter="accessory_id" + in_place_edit_class="accessoryPositionChange" + position=$POSITION + id=$ID + } + | + + {module_include location='product_accessories_table_row'} + +
+
+ {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.product.accessory.delete"}
+
+
+
+ {/loop}
+
+ |
+
|
+
+ {intl l="This product contains no accessories"}
+
+ |
+ |||
| {intl l='ID'} | + +{intl l='Category title'} | + + {module_include location='product_categories_table_header'} + +{intl l="Actions"} | +
|---|---|---|
| {$ID} | + ++ {$TITLE} + | + + {module_include location='product_categories_table_row'} + +
+
+ {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.product.category.delete"}
+
+
+
+ {/loop}
+
+ |
+
|
+
+ {intl l="This product doesn't belong to any additional category."}
+
+ |
+ ||