From 178ed493f08da954452f8c698bee695b7405cbf6 Mon Sep 17 00:00:00 2001 From: Benjamin Perche Date: Thu, 10 Jul 2014 15:10:19 +0200 Subject: [PATCH] =?UTF-8?q?Update=20database,=20add=20export=20and=20impor?= =?UTF-8?q?t=20handle=20classes=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20core/lib/Thelia/Model/Base/Export.php=20=09modifi=C3=A9:=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20core/lib/Thelia/Model/Base/ExportQuery.?= =?UTF-8?q?php=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Theli?= =?UTF-8?q?a/Model/Base/Import.php=20=09modifi=C3=A9:=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20core/lib/Thelia/Model/Base/ImportQuery.php=20=09modifi?= =?UTF-8?q?=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/Model/Export.?= =?UTF-8?q?php=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Theli?= =?UTF-8?q?a/Model/Import.php=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20core/lib/Thelia/Model/Map/ExportTableMap.php=20=09modifi?= =?UTF-8?q?=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/Model/Map/Imp?= =?UTF-8?q?ortTableMap.php=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20lo?= =?UTF-8?q?cal/config/schema.xml=20=09modifi=C3=A9:=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20setup/thelia.sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/lib/Thelia/Model/Base/Export.php | 76 ++++++++++++++-- core/lib/Thelia/Model/Base/ExportQuery.php | 35 +++++++- core/lib/Thelia/Model/Base/Import.php | 76 ++++++++++++++-- core/lib/Thelia/Model/Base/ImportQuery.php | 35 +++++++- core/lib/Thelia/Model/Export.php | 31 +++++++ core/lib/Thelia/Model/Import.php | 94 ++++++++++++++++++++ core/lib/Thelia/Model/Map/ExportTableMap.php | 36 +++++--- core/lib/Thelia/Model/Map/ImportTableMap.php | 36 +++++--- local/config/schema.xml | 2 + setup/thelia.sql | 2 + 10 files changed, 375 insertions(+), 48 deletions(-) diff --git a/core/lib/Thelia/Model/Base/Export.php b/core/lib/Thelia/Model/Base/Export.php index b5902b177..a2d8cb9a3 100644 --- a/core/lib/Thelia/Model/Base/Export.php +++ b/core/lib/Thelia/Model/Base/Export.php @@ -77,6 +77,12 @@ abstract class Export implements ActiveRecordInterface */ protected $position; + /** + * The value for the handleclass field. + * @var string + */ + protected $handleclass; + /** * The value for the created_at field. * @var string @@ -419,6 +425,17 @@ abstract class Export implements ActiveRecordInterface return $this->position; } + /** + * Get the [handleclass] column value. + * + * @return string + */ + public function getHandleclass() + { + + return $this->handleclass; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -526,6 +543,27 @@ abstract class Export implements ActiveRecordInterface return $this; } // setPosition() + /** + * Set the value of [handleclass] column. + * + * @param string $v new value + * @return \Thelia\Model\Export The current object (for fluent API support) + */ + public function setHandleclass($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->handleclass !== $v) { + $this->handleclass = $v; + $this->modifiedColumns[ExportTableMap::HANDLECLASS] = true; + } + + + return $this; + } // setHandleclass() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -614,13 +652,16 @@ abstract class Export implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ExportTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; $this->position = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ExportTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ExportTableMap::translateFieldName('Handleclass', TableMap::TYPE_PHPNAME, $indexType)]; + $this->handleclass = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ExportTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ExportTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ExportTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -633,7 +674,7 @@ abstract class Export implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 5; // 5 = ExportTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 6; // 6 = ExportTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Export object", 0, $e); @@ -897,6 +938,9 @@ abstract class Export implements ActiveRecordInterface if ($this->isColumnModified(ExportTableMap::POSITION)) { $modifiedColumns[':p' . $index++] = '`POSITION`'; } + if ($this->isColumnModified(ExportTableMap::HANDLECLASS)) { + $modifiedColumns[':p' . $index++] = '`HANDLECLASS`'; + } if ($this->isColumnModified(ExportTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; } @@ -923,6 +967,9 @@ abstract class Export implements ActiveRecordInterface case '`POSITION`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; + case '`HANDLECLASS`': + $stmt->bindValue($identifier, $this->handleclass, 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; @@ -1001,9 +1048,12 @@ abstract class Export implements ActiveRecordInterface return $this->getPosition(); break; case 3: - return $this->getCreatedAt(); + return $this->getHandleclass(); break; case 4: + return $this->getCreatedAt(); + break; + case 5: return $this->getUpdatedAt(); break; default: @@ -1038,8 +1088,9 @@ abstract class Export implements ActiveRecordInterface $keys[0] => $this->getId(), $keys[1] => $this->getExportCategoryId(), $keys[2] => $this->getPosition(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), + $keys[3] => $this->getHandleclass(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1097,9 +1148,12 @@ abstract class Export implements ActiveRecordInterface $this->setPosition($value); break; case 3: - $this->setCreatedAt($value); + $this->setHandleclass($value); break; case 4: + $this->setCreatedAt($value); + break; + case 5: $this->setUpdatedAt($value); break; } // switch() @@ -1129,8 +1183,9 @@ abstract class Export implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setExportCategoryId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + if (array_key_exists($keys[3], $arr)) $this->setHandleclass($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); } /** @@ -1145,6 +1200,7 @@ abstract class Export implements ActiveRecordInterface if ($this->isColumnModified(ExportTableMap::ID)) $criteria->add(ExportTableMap::ID, $this->id); if ($this->isColumnModified(ExportTableMap::EXPORT_CATEGORY_ID)) $criteria->add(ExportTableMap::EXPORT_CATEGORY_ID, $this->export_category_id); if ($this->isColumnModified(ExportTableMap::POSITION)) $criteria->add(ExportTableMap::POSITION, $this->position); + if ($this->isColumnModified(ExportTableMap::HANDLECLASS)) $criteria->add(ExportTableMap::HANDLECLASS, $this->handleclass); if ($this->isColumnModified(ExportTableMap::CREATED_AT)) $criteria->add(ExportTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(ExportTableMap::UPDATED_AT)) $criteria->add(ExportTableMap::UPDATED_AT, $this->updated_at); @@ -1212,6 +1268,7 @@ abstract class Export implements ActiveRecordInterface { $copyObj->setExportCategoryId($this->getExportCategoryId()); $copyObj->setPosition($this->getPosition()); + $copyObj->setHandleclass($this->getHandleclass()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1556,6 +1613,7 @@ abstract class Export implements ActiveRecordInterface $this->id = null; $this->export_category_id = null; $this->position = null; + $this->handleclass = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/ExportQuery.php b/core/lib/Thelia/Model/Base/ExportQuery.php index 1a34da44f..65e266d73 100644 --- a/core/lib/Thelia/Model/Base/ExportQuery.php +++ b/core/lib/Thelia/Model/Base/ExportQuery.php @@ -25,12 +25,14 @@ use Thelia\Model\Map\ExportTableMap; * @method ChildExportQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildExportQuery orderByExportCategoryId($order = Criteria::ASC) Order by the export_category_id column * @method ChildExportQuery orderByPosition($order = Criteria::ASC) Order by the position column + * @method ChildExportQuery orderByHandleclass($order = Criteria::ASC) Order by the handleClass column * @method ChildExportQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildExportQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildExportQuery groupById() Group by the id column * @method ChildExportQuery groupByExportCategoryId() Group by the export_category_id column * @method ChildExportQuery groupByPosition() Group by the position column + * @method ChildExportQuery groupByHandleclass() Group by the handleClass column * @method ChildExportQuery groupByCreatedAt() Group by the created_at column * @method ChildExportQuery groupByUpdatedAt() Group by the updated_at column * @@ -52,12 +54,14 @@ use Thelia\Model\Map\ExportTableMap; * @method ChildExport findOneById(int $id) Return the first ChildExport filtered by the id column * @method ChildExport findOneByExportCategoryId(int $export_category_id) Return the first ChildExport filtered by the export_category_id column * @method ChildExport findOneByPosition(int $position) Return the first ChildExport filtered by the position column + * @method ChildExport findOneByHandleclass(string $handleClass) Return the first ChildExport filtered by the handleClass column * @method ChildExport findOneByCreatedAt(string $created_at) Return the first ChildExport filtered by the created_at column * @method ChildExport findOneByUpdatedAt(string $updated_at) Return the first ChildExport filtered by the updated_at column * * @method array findById(int $id) Return ChildExport objects filtered by the id column * @method array findByExportCategoryId(int $export_category_id) Return ChildExport objects filtered by the export_category_id column * @method array findByPosition(int $position) Return ChildExport objects filtered by the position column + * @method array findByHandleclass(string $handleClass) Return ChildExport objects filtered by the handleClass column * @method array findByCreatedAt(string $created_at) Return ChildExport objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildExport objects filtered by the updated_at column * @@ -148,7 +152,7 @@ abstract class ExportQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `EXPORT_CATEGORY_ID`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `export` WHERE `ID` = :p0'; + $sql = 'SELECT `ID`, `EXPORT_CATEGORY_ID`, `POSITION`, `HANDLECLASS`, `CREATED_AT`, `UPDATED_AT` FROM `export` WHERE `ID` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -362,6 +366,35 @@ abstract class ExportQuery extends ModelCriteria return $this->addUsingAlias(ExportTableMap::POSITION, $position, $comparison); } + /** + * Filter the query on the handleClass column + * + * Example usage: + * + * $query->filterByHandleclass('fooValue'); // WHERE handleClass = 'fooValue' + * $query->filterByHandleclass('%fooValue%'); // WHERE handleClass LIKE '%fooValue%' + * + * + * @param string $handleclass 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 ChildExportQuery The current query, for fluid interface + */ + public function filterByHandleclass($handleclass = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($handleclass)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $handleclass)) { + $handleclass = str_replace('*', '%', $handleclass); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ExportTableMap::HANDLECLASS, $handleclass, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Import.php b/core/lib/Thelia/Model/Base/Import.php index e2b0e3cd6..180125c2e 100644 --- a/core/lib/Thelia/Model/Base/Import.php +++ b/core/lib/Thelia/Model/Base/Import.php @@ -77,6 +77,12 @@ abstract class Import implements ActiveRecordInterface */ protected $position; + /** + * The value for the handleclass field. + * @var string + */ + protected $handleclass; + /** * The value for the created_at field. * @var string @@ -419,6 +425,17 @@ abstract class Import implements ActiveRecordInterface return $this->position; } + /** + * Get the [handleclass] column value. + * + * @return string + */ + public function getHandleclass() + { + + return $this->handleclass; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -526,6 +543,27 @@ abstract class Import implements ActiveRecordInterface return $this; } // setPosition() + /** + * Set the value of [handleclass] column. + * + * @param string $v new value + * @return \Thelia\Model\Import The current object (for fluent API support) + */ + public function setHandleclass($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->handleclass !== $v) { + $this->handleclass = $v; + $this->modifiedColumns[ImportTableMap::HANDLECLASS] = true; + } + + + return $this; + } // setHandleclass() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -614,13 +652,16 @@ abstract class Import implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ImportTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; $this->position = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ImportTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ImportTableMap::translateFieldName('Handleclass', TableMap::TYPE_PHPNAME, $indexType)]; + $this->handleclass = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ImportTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ImportTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ImportTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -633,7 +674,7 @@ abstract class Import implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 5; // 5 = ImportTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 6; // 6 = ImportTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Import object", 0, $e); @@ -897,6 +938,9 @@ abstract class Import implements ActiveRecordInterface if ($this->isColumnModified(ImportTableMap::POSITION)) { $modifiedColumns[':p' . $index++] = '`POSITION`'; } + if ($this->isColumnModified(ImportTableMap::HANDLECLASS)) { + $modifiedColumns[':p' . $index++] = '`HANDLECLASS`'; + } if ($this->isColumnModified(ImportTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; } @@ -923,6 +967,9 @@ abstract class Import implements ActiveRecordInterface case '`POSITION`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; + case '`HANDLECLASS`': + $stmt->bindValue($identifier, $this->handleclass, 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; @@ -1001,9 +1048,12 @@ abstract class Import implements ActiveRecordInterface return $this->getPosition(); break; case 3: - return $this->getCreatedAt(); + return $this->getHandleclass(); break; case 4: + return $this->getCreatedAt(); + break; + case 5: return $this->getUpdatedAt(); break; default: @@ -1038,8 +1088,9 @@ abstract class Import implements ActiveRecordInterface $keys[0] => $this->getId(), $keys[1] => $this->getImportCategoryId(), $keys[2] => $this->getPosition(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), + $keys[3] => $this->getHandleclass(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1097,9 +1148,12 @@ abstract class Import implements ActiveRecordInterface $this->setPosition($value); break; case 3: - $this->setCreatedAt($value); + $this->setHandleclass($value); break; case 4: + $this->setCreatedAt($value); + break; + case 5: $this->setUpdatedAt($value); break; } // switch() @@ -1129,8 +1183,9 @@ abstract class Import implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setImportCategoryId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + if (array_key_exists($keys[3], $arr)) $this->setHandleclass($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); } /** @@ -1145,6 +1200,7 @@ abstract class Import implements ActiveRecordInterface if ($this->isColumnModified(ImportTableMap::ID)) $criteria->add(ImportTableMap::ID, $this->id); if ($this->isColumnModified(ImportTableMap::IMPORT_CATEGORY_ID)) $criteria->add(ImportTableMap::IMPORT_CATEGORY_ID, $this->import_category_id); if ($this->isColumnModified(ImportTableMap::POSITION)) $criteria->add(ImportTableMap::POSITION, $this->position); + if ($this->isColumnModified(ImportTableMap::HANDLECLASS)) $criteria->add(ImportTableMap::HANDLECLASS, $this->handleclass); if ($this->isColumnModified(ImportTableMap::CREATED_AT)) $criteria->add(ImportTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(ImportTableMap::UPDATED_AT)) $criteria->add(ImportTableMap::UPDATED_AT, $this->updated_at); @@ -1212,6 +1268,7 @@ abstract class Import implements ActiveRecordInterface { $copyObj->setImportCategoryId($this->getImportCategoryId()); $copyObj->setPosition($this->getPosition()); + $copyObj->setHandleclass($this->getHandleclass()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1556,6 +1613,7 @@ abstract class Import implements ActiveRecordInterface $this->id = null; $this->import_category_id = null; $this->position = null; + $this->handleclass = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/ImportQuery.php b/core/lib/Thelia/Model/Base/ImportQuery.php index 7fa735844..883783ebb 100644 --- a/core/lib/Thelia/Model/Base/ImportQuery.php +++ b/core/lib/Thelia/Model/Base/ImportQuery.php @@ -25,12 +25,14 @@ use Thelia\Model\Map\ImportTableMap; * @method ChildImportQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildImportQuery orderByImportCategoryId($order = Criteria::ASC) Order by the import_category_id column * @method ChildImportQuery orderByPosition($order = Criteria::ASC) Order by the position column + * @method ChildImportQuery orderByHandleclass($order = Criteria::ASC) Order by the handleClass column * @method ChildImportQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildImportQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildImportQuery groupById() Group by the id column * @method ChildImportQuery groupByImportCategoryId() Group by the import_category_id column * @method ChildImportQuery groupByPosition() Group by the position column + * @method ChildImportQuery groupByHandleclass() Group by the handleClass column * @method ChildImportQuery groupByCreatedAt() Group by the created_at column * @method ChildImportQuery groupByUpdatedAt() Group by the updated_at column * @@ -52,12 +54,14 @@ use Thelia\Model\Map\ImportTableMap; * @method ChildImport findOneById(int $id) Return the first ChildImport filtered by the id column * @method ChildImport findOneByImportCategoryId(int $import_category_id) Return the first ChildImport filtered by the import_category_id column * @method ChildImport findOneByPosition(int $position) Return the first ChildImport filtered by the position column + * @method ChildImport findOneByHandleclass(string $handleClass) Return the first ChildImport filtered by the handleClass column * @method ChildImport findOneByCreatedAt(string $created_at) Return the first ChildImport filtered by the created_at column * @method ChildImport findOneByUpdatedAt(string $updated_at) Return the first ChildImport filtered by the updated_at column * * @method array findById(int $id) Return ChildImport objects filtered by the id column * @method array findByImportCategoryId(int $import_category_id) Return ChildImport objects filtered by the import_category_id column * @method array findByPosition(int $position) Return ChildImport objects filtered by the position column + * @method array findByHandleclass(string $handleClass) Return ChildImport objects filtered by the handleClass column * @method array findByCreatedAt(string $created_at) Return ChildImport objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildImport objects filtered by the updated_at column * @@ -148,7 +152,7 @@ abstract class ImportQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `IMPORT_CATEGORY_ID`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `import` WHERE `ID` = :p0'; + $sql = 'SELECT `ID`, `IMPORT_CATEGORY_ID`, `POSITION`, `HANDLECLASS`, `CREATED_AT`, `UPDATED_AT` FROM `import` WHERE `ID` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -362,6 +366,35 @@ abstract class ImportQuery extends ModelCriteria return $this->addUsingAlias(ImportTableMap::POSITION, $position, $comparison); } + /** + * Filter the query on the handleClass column + * + * Example usage: + * + * $query->filterByHandleclass('fooValue'); // WHERE handleClass = 'fooValue' + * $query->filterByHandleclass('%fooValue%'); // WHERE handleClass LIKE '%fooValue%' + * + * + * @param string $handleclass 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 ChildImportQuery The current query, for fluid interface + */ + public function filterByHandleclass($handleclass = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($handleclass)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $handleclass)) { + $handleclass = str_replace('*', '%', $handleclass); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ImportTableMap::HANDLECLASS, $handleclass, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Export.php b/core/lib/Thelia/Model/Export.php index 1abef0932..ef48cbf45 100644 --- a/core/lib/Thelia/Model/Export.php +++ b/core/lib/Thelia/Model/Export.php @@ -3,6 +3,8 @@ namespace Thelia\Model; use Propel\Runtime\ActiveQuery\Criteria; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Thelia\ImportExport\ExportHandlerInterface; use Thelia\Model\Base\Export as BaseExport; use Thelia\Model\Map\ExportTableMap; @@ -10,6 +12,7 @@ class Export extends BaseExport { public function upPosition() { + if (($position = $this->getPosition()) > 1) { $previous = ExportQuery::create() @@ -70,4 +73,32 @@ class Export extends BaseExport $this->setPosition($position)->save(); } + + public function getHandleClassInstance(ContainerInterface $container) + { + $class = $this->getHandleClass(); + + if (!class_exists($class)) { + throw new \ErrorException( + "The class \"%class\" doesn't exist", + [ + "%class" => $class + ] + ); + } + + $instance = new $class($container); + + if (!$class instanceof ExportHandlerInterface) { + throw new \ErrorException( + "The class \"%class\" must implement %interface", + [ + "%class" => $class, + "%interface" => "\\Thelia\\ImportExport\\ExportHandlerInterface", + ] + ); + } + + return $instance; + } } diff --git a/core/lib/Thelia/Model/Import.php b/core/lib/Thelia/Model/Import.php index b0a589ff0..b54829fb0 100644 --- a/core/lib/Thelia/Model/Import.php +++ b/core/lib/Thelia/Model/Import.php @@ -2,9 +2,103 @@ namespace Thelia\Model; +use Propel\Runtime\ActiveQuery\Criteria; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Thelia\ImportExport\ExportHandlerInterface; use Thelia\Model\Base\Import as BaseImport; +use Thelia\Model\Map\ImportTableMap; class Import extends BaseImport { + public function upPosition() + { + if (($position = $this->getPosition()) > 1) { + + $previous = ImportQuery::create() + ->filterByPosition($position - 1) + ->findOneByImportCategoryId($this->getImportCategoryId()); + + if (null !== $previous) { + $previous->setPosition($position)->save(); + } + + $this->setPosition($position - 1)->save(); + } + + return $this; + } + + public function downPosition() + { + $max = ImportQuery::create() + ->orderByPosition(Criteria::DESC) + ->select(ImportTableMap::POSITION) + ->findOne() + ; + + $count = $this->getImportCategory()->countImports(); + + if ($count > $max) { + $max = $count; + } + + $position = $this->getPosition(); + + if ($position < $max) { + + $next = ImportQuery::create() + ->filterByPosition($position + 1) + ->findOneByImportCategoryId($this->getImportCategoryId()); + + if (null !== $next) { + $next->setPosition($position)->save(); + } + + $this->setPosition($position + 1)->save(); + } + + return $this; + } + + public function updatePosition($position) + { + $reverse = ImportQuery::create() + ->findOneByPosition($position) + ; + + if (null !== $reverse) { + $reverse->setPosition($this->getPosition())->save(); + } + + $this->setPosition($position)->save(); + } + + public function getHandleClassInstance(ContainerInterface $container) + { + $class = $this->getHandleClass(); + + if (!class_exists($class)) { + throw new \ErrorException( + "The class \"%class\" doesn't exist", + [ + "%class" => $class + ] + ); + } + + $instance = new $class($container); + + if (!$class instanceof ExportHandlerInterface) { + throw new \ErrorException( + "The class \"%class\" must implement %interface", + [ + "%class" => $class, + "%interface" => "\\Thelia\\ImportExport\\ExportHandlerInterface", + ] + ); + } + + return $instance; + } } diff --git a/core/lib/Thelia/Model/Map/ExportTableMap.php b/core/lib/Thelia/Model/Map/ExportTableMap.php index f9ead6b5b..58b667b9d 100644 --- a/core/lib/Thelia/Model/Map/ExportTableMap.php +++ b/core/lib/Thelia/Model/Map/ExportTableMap.php @@ -58,7 +58,7 @@ class ExportTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 5; + const NUM_COLUMNS = 6; /** * The number of lazy-loaded columns @@ -68,7 +68,7 @@ class ExportTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 5; + const NUM_HYDRATE_COLUMNS = 6; /** * the column name for the ID field @@ -85,6 +85,11 @@ class ExportTableMap extends TableMap */ const POSITION = 'export.POSITION'; + /** + * the column name for the HANDLECLASS field + */ + const HANDLECLASS = 'export.HANDLECLASS'; + /** * the column name for the CREATED_AT field */ @@ -116,12 +121,12 @@ class ExportTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'ExportCategoryId', 'Position', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'exportCategoryId', 'position', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ExportTableMap::ID, ExportTableMap::EXPORT_CATEGORY_ID, ExportTableMap::POSITION, ExportTableMap::CREATED_AT, ExportTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'EXPORT_CATEGORY_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'export_category_id', 'position', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id', 'ExportCategoryId', 'Position', 'Handleclass', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'exportCategoryId', 'position', 'handleclass', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ExportTableMap::ID, ExportTableMap::EXPORT_CATEGORY_ID, ExportTableMap::POSITION, ExportTableMap::HANDLECLASS, ExportTableMap::CREATED_AT, ExportTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'EXPORT_CATEGORY_ID', 'POSITION', 'HANDLECLASS', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'export_category_id', 'position', 'handleClass', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -131,12 +136,12 @@ class ExportTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'ExportCategoryId' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'exportCategoryId' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(ExportTableMap::ID => 0, ExportTableMap::EXPORT_CATEGORY_ID => 1, ExportTableMap::POSITION => 2, ExportTableMap::CREATED_AT => 3, ExportTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'EXPORT_CATEGORY_ID' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'export_category_id' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id' => 0, 'ExportCategoryId' => 1, 'Position' => 2, 'Handleclass' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'exportCategoryId' => 1, 'position' => 2, 'handleclass' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(ExportTableMap::ID => 0, ExportTableMap::EXPORT_CATEGORY_ID => 1, ExportTableMap::POSITION => 2, ExportTableMap::HANDLECLASS => 3, ExportTableMap::CREATED_AT => 4, ExportTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'EXPORT_CATEGORY_ID' => 1, 'POSITION' => 2, 'HANDLECLASS' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'export_category_id' => 1, 'position' => 2, 'handleClass' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -158,6 +163,7 @@ class ExportTableMap extends TableMap $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('EXPORT_CATEGORY_ID', 'ExportCategoryId', 'INTEGER', 'export_category', 'ID', true, null, null); $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); + $this->addColumn('HANDLECLASS', 'Handleclass', 'CLOB', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -335,12 +341,14 @@ class ExportTableMap extends TableMap $criteria->addSelectColumn(ExportTableMap::ID); $criteria->addSelectColumn(ExportTableMap::EXPORT_CATEGORY_ID); $criteria->addSelectColumn(ExportTableMap::POSITION); + $criteria->addSelectColumn(ExportTableMap::HANDLECLASS); $criteria->addSelectColumn(ExportTableMap::CREATED_AT); $criteria->addSelectColumn(ExportTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.EXPORT_CATEGORY_ID'); $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.HANDLECLASS'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/ImportTableMap.php b/core/lib/Thelia/Model/Map/ImportTableMap.php index 873b4d196..735c20236 100644 --- a/core/lib/Thelia/Model/Map/ImportTableMap.php +++ b/core/lib/Thelia/Model/Map/ImportTableMap.php @@ -58,7 +58,7 @@ class ImportTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 5; + const NUM_COLUMNS = 6; /** * The number of lazy-loaded columns @@ -68,7 +68,7 @@ class ImportTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 5; + const NUM_HYDRATE_COLUMNS = 6; /** * the column name for the ID field @@ -85,6 +85,11 @@ class ImportTableMap extends TableMap */ const POSITION = 'import.POSITION'; + /** + * the column name for the HANDLECLASS field + */ + const HANDLECLASS = 'import.HANDLECLASS'; + /** * the column name for the CREATED_AT field */ @@ -116,12 +121,12 @@ class ImportTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'ImportCategoryId', 'Position', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'importCategoryId', 'position', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ImportTableMap::ID, ImportTableMap::IMPORT_CATEGORY_ID, ImportTableMap::POSITION, ImportTableMap::CREATED_AT, ImportTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'IMPORT_CATEGORY_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'import_category_id', 'position', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id', 'ImportCategoryId', 'Position', 'Handleclass', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'importCategoryId', 'position', 'handleclass', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ImportTableMap::ID, ImportTableMap::IMPORT_CATEGORY_ID, ImportTableMap::POSITION, ImportTableMap::HANDLECLASS, ImportTableMap::CREATED_AT, ImportTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'IMPORT_CATEGORY_ID', 'POSITION', 'HANDLECLASS', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'import_category_id', 'position', 'handleClass', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -131,12 +136,12 @@ class ImportTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'ImportCategoryId' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'importCategoryId' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(ImportTableMap::ID => 0, ImportTableMap::IMPORT_CATEGORY_ID => 1, ImportTableMap::POSITION => 2, ImportTableMap::CREATED_AT => 3, ImportTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'IMPORT_CATEGORY_ID' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'import_category_id' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id' => 0, 'ImportCategoryId' => 1, 'Position' => 2, 'Handleclass' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'importCategoryId' => 1, 'position' => 2, 'handleclass' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(ImportTableMap::ID => 0, ImportTableMap::IMPORT_CATEGORY_ID => 1, ImportTableMap::POSITION => 2, ImportTableMap::HANDLECLASS => 3, ImportTableMap::CREATED_AT => 4, ImportTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'IMPORT_CATEGORY_ID' => 1, 'POSITION' => 2, 'HANDLECLASS' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'import_category_id' => 1, 'position' => 2, 'handleClass' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -158,6 +163,7 @@ class ImportTableMap extends TableMap $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('IMPORT_CATEGORY_ID', 'ImportCategoryId', 'INTEGER', 'import_category', 'ID', true, null, null); $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); + $this->addColumn('HANDLECLASS', 'Handleclass', 'CLOB', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -335,12 +341,14 @@ class ImportTableMap extends TableMap $criteria->addSelectColumn(ImportTableMap::ID); $criteria->addSelectColumn(ImportTableMap::IMPORT_CATEGORY_ID); $criteria->addSelectColumn(ImportTableMap::POSITION); + $criteria->addSelectColumn(ImportTableMap::HANDLECLASS); $criteria->addSelectColumn(ImportTableMap::CREATED_AT); $criteria->addSelectColumn(ImportTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.IMPORT_CATEGORY_ID'); $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.HANDLECLASS'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/local/config/schema.xml b/local/config/schema.xml index a62929ec3..b21b9526e 100644 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1536,6 +1536,7 @@ + @@ -1553,6 +1554,7 @@ + diff --git a/setup/thelia.sql b/setup/thelia.sql index c5fa24f45..92456c51b 100644 --- a/setup/thelia.sql +++ b/setup/thelia.sql @@ -1914,6 +1914,7 @@ CREATE TABLE `import` `id` INTEGER NOT NULL AUTO_INCREMENT, `import_category_id` INTEGER NOT NULL, `position` INTEGER NOT NULL, + `handleClass` LONGTEXT NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), @@ -1936,6 +1937,7 @@ CREATE TABLE `export` `id` INTEGER NOT NULL AUTO_INCREMENT, `export_category_id` INTEGER NOT NULL, `position` INTEGER NOT NULL, + `handleClass` LONGTEXT NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`),