use PropelColumnTypes instead of hardcoded values
This commit is contained in:
parent
0443b6706c
commit
d6e4ed86d2
|
@ -10,10 +10,10 @@
|
||||||
|
|
||||||
namespace Propel\PropelBundle\DataFixtures\Dumper;
|
namespace Propel\PropelBundle\DataFixtures\Dumper;
|
||||||
|
|
||||||
|
use Propel\PropelBundle\DataFixtures\AbstractDataHandler;
|
||||||
use \PDO;
|
use \PDO;
|
||||||
use \Propel;
|
use \Propel;
|
||||||
|
use \PropelColumnTypes;
|
||||||
use Propel\PropelBundle\DataFixtures\AbstractDataHandler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class to manage a common logic to dump data.
|
* 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] : '';
|
$values[$col] = strlen($row[$col]) ? $relatedTable->getPhpName().'_'.$row[$col] : '';
|
||||||
}
|
}
|
||||||
} elseif (!$isPrimaryKey || ($isPrimaryKey && !$tableMap->isUseIdGenerator())) {
|
} 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);
|
$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
|
// We did not want auto incremented primary keys
|
||||||
$values[$col] = $row[$col];
|
$values[$col] = $row[$col];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($column->getType() == \PropelColumnTypes::OBJECT) {
|
if (PropelColumnTypes::OBJECT === $column->getType()) {
|
||||||
$values[$col] = unserialize($row[$col]);
|
$values[$col] = unserialize($row[$col]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace Propel\PropelBundle\DataFixtures\Loader;
|
||||||
use \BasePeer;
|
use \BasePeer;
|
||||||
use \BaseObject;
|
use \BaseObject;
|
||||||
use \Propel;
|
use \Propel;
|
||||||
|
use \PropelColumnTypes;
|
||||||
use \PropelException;
|
use \PropelException;
|
||||||
use Propel\PropelBundle\DataFixtures\AbstractDataHandler;
|
use Propel\PropelBundle\DataFixtures\AbstractDataHandler;
|
||||||
use Propel\PropelBundle\Util\PropelInflector;
|
use Propel\PropelBundle\Util\PropelInflector;
|
||||||
|
@ -177,8 +178,9 @@ abstract class AbstractDataLoader extends AbstractDataHandler implements DataLoa
|
||||||
continue;
|
continue;
|
||||||
} catch (PropelException $e) {
|
} catch (PropelException $e) {
|
||||||
// Check whether this is actually an array stored in the object.
|
// 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 ('Cannot fetch TableMap for undefined table: ' . substr($name, 0, -1) === $e->getMessage()) {
|
||||||
if ('ARRAY' !== $tableMap->getColumn($name)->getType() && 'OBJECT' !== $tableMap->getColumn($name)->getType()) {
|
if (PropelColumnTypes::PHP_ARRAY !== $tableMap->getColumn($name)->getType()
|
||||||
|
&& PropelColumnTypes::OBJECT !== $tableMap->getColumn($name)->getType()) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue