From d6e4ed86d2b5bafb480e62843b48e55bbb6b2c21 Mon Sep 17 00:00:00 2001 From: William DURAND Date: Sat, 16 Feb 2013 01:57:35 +0100 Subject: [PATCH] use PropelColumnTypes instead of hardcoded values --- DataFixtures/Dumper/AbstractDataDumper.php | 10 +++++----- DataFixtures/Loader/AbstractDataLoader.php | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/DataFixtures/Dumper/AbstractDataDumper.php b/DataFixtures/Dumper/AbstractDataDumper.php index 192cc80..2f71eb7 100644 --- a/DataFixtures/Dumper/AbstractDataDumper.php +++ b/DataFixtures/Dumper/AbstractDataDumper.php @@ -10,10 +10,10 @@ namespace Propel\PropelBundle\DataFixtures\Dumper; +use Propel\PropelBundle\DataFixtures\AbstractDataHandler; use \PDO; use \Propel; - -use Propel\PropelBundle\DataFixtures\AbstractDataHandler; +use \PropelColumnTypes; /** * Abstract class to manage a common logic to dump data. @@ -148,16 +148,16 @@ abstract class AbstractDataDumper extends AbstractDataHandler implements DataDum $values[$col] = strlen($row[$col]) ? $relatedTable->getPhpName().'_'.$row[$col] : ''; } } elseif (!$isPrimaryKey || ($isPrimaryKey && !$tableMap->isUseIdGenerator())) { - if (!empty($row[$col]) && 'ARRAY' === $column->getType()) { + if (!empty($row[$col]) && PropelColumnTypes::PHP_ARRAY === $column->getType()) { $serialized = substr($row[$col], 2, -2); - $row[$col] = $serialized ? explode(' | ', $serialized) : array(); + $row[$col] = $serialized ? explode(' | ', $serialized) : array(); } // We did not want auto incremented primary keys $values[$col] = $row[$col]; } - if ($column->getType() == \PropelColumnTypes::OBJECT) { + if (PropelColumnTypes::OBJECT === $column->getType()) { $values[$col] = unserialize($row[$col]); } } diff --git a/DataFixtures/Loader/AbstractDataLoader.php b/DataFixtures/Loader/AbstractDataLoader.php index d43160e..781a741 100644 --- a/DataFixtures/Loader/AbstractDataLoader.php +++ b/DataFixtures/Loader/AbstractDataLoader.php @@ -13,6 +13,7 @@ namespace Propel\PropelBundle\DataFixtures\Loader; use \BasePeer; use \BaseObject; use \Propel; +use \PropelColumnTypes; use \PropelException; use Propel\PropelBundle\DataFixtures\AbstractDataHandler; use Propel\PropelBundle\Util\PropelInflector; @@ -177,8 +178,9 @@ abstract class AbstractDataLoader extends AbstractDataHandler implements DataLoa continue; } catch (PropelException $e) { // Check whether this is actually an array stored in the object. - if ('Cannot fetch TableMap for undefined table: '.substr($name, 0, -1) === $e->getMessage()) { - if ('ARRAY' !== $tableMap->getColumn($name)->getType() && 'OBJECT' !== $tableMap->getColumn($name)->getType()) { + if ('Cannot fetch TableMap for undefined table: ' . substr($name, 0, -1) === $e->getMessage()) { + if (PropelColumnTypes::PHP_ARRAY !== $tableMap->getColumn($name)->getType() + && PropelColumnTypes::OBJECT !== $tableMap->getColumn($name)->getType()) { throw $e; } }