Commit 93445983 authored by jwage's avatar jwage

[2.0] Changes to convert Classmetadata constant integers to string representation

parent 320d21e2
......@@ -72,7 +72,7 @@ class YamlDriver extends AbstractFileDriver
}
if (isset($element['inheritanceType'])) {
$metadata->setInheritanceType($element['inheritanceType']);
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $element['inheritanceType']));
}
// Evaluate discriminatorColumn
......@@ -92,7 +92,8 @@ class YamlDriver extends AbstractFileDriver
// Evaluate changeTrackingPolicy
if (isset($element['changeTrackingPolicy'])) {
$metadata->setChangeTrackingPolicy($element['changeTrackingPolicy']);
$metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_'
. $element['changeTrackingPolicy']));
}
// Evaluate indexes
......
......@@ -70,6 +70,10 @@ abstract class AbstractExporter
*/
public function export()
{
if ( ! is_dir($this->_outputDir)) {
mkdir($this->_outputDir, 0777);
}
foreach ($this->_metadatas as $metadata) {
$outputPath = $this->_outputDir . '/' . str_replace('\\', '.', $metadata->name) . $this->_extension;
$output = $this->exportClassMetadata($metadata);
......@@ -101,4 +105,66 @@ abstract class AbstractExporter
* @return mixed $exported
*/
abstract public function exportClassMetadata(ClassMetadata $metadata);
protected function _getInheritanceTypeString($type)
{
switch ($type)
{
case Classmetadata::INHERITANCE_TYPE_NONE:
return 'NONE';
break;
case Classmetadata::INHERITANCE_TYPE_JOINED:
return 'JOINED';
break;
case Classmetadata::INHERITANCE_TYPE_SINGLE_TABLE:
return 'SINGLE_TABLE';
break;
case Classmetadata::INHERITANCE_TYPE_TABLE_PER_CLASS:
return 'PER_CLASS';
break;
}
}
protected function _getChangeTrackingPolicyString($policy)
{
switch ($policy)
{
case Classmetadata::CHANGETRACKING_DEFERRED_IMPLICIT:
return 'DEFERRED_IMPLICIT';
break;
case Classmetadata::CHANGETRACKING_DEFERRED_EXPLICIT:
return 'DEFERRED_EXPLICIT';
break;
case Classmetadata::CHANGETRACKING_NOTIFY:
return 'NOTIFY';
break;
}
}
protected function _getIdGeneratorTypeString($type)
{
switch ($type)
{
case Classmetadata::GENERATOR_TYPE_AUTO:
return 'AUTO';
break;
case Classmetadata::GENERATOR_TYPE_SEQUENCE:
return 'SEQUENCE';
break;
case Classmetadata::GENERATOR_TYPE_TABLE:
return 'TABLE';
break;
case Classmetadata::GENERATOR_TYPE_IDENTITY:
return 'IDENTITY';
break;
}
}
}
\ No newline at end of file
......@@ -59,10 +59,17 @@ class YamlExporter extends AbstractExporter
$array['schema'] = $metadata->primaryTable['schema'];
}
$array['inheritanceType'] = $metadata->getInheritanceType();
$array['discriminatorColumn'] = $metadata->getDiscriminatorColumn();
$array['discriminatorMap'] = $metadata->discriminatorMap;
$array['changeTrackingPolicy'] = $metadata->changeTrackingPolicy;
$array['inheritanceType'] = $this->_getInheritanceTypeString($metadata->getInheritanceType());
if ($column = $metadata->getDiscriminatorColumn()) {
$array['discriminatorColumn'] = $column;
}
if ($map = $metadata->discriminatorMap) {
$array['discriminatorMap'] = $map;
}
$array['changeTrackingPolicy'] = $this->_getChangeTrackingPolicyString($metadata->changeTrackingPolicy);
if (isset($metadata->primaryTable['indexes'])) {
$array['indexes'] = $metadata->primaryTable['indexes'];
......@@ -82,7 +89,7 @@ class YamlExporter extends AbstractExporter
}
}
if ($idGeneratorType = $metadata->getIdGeneratorType()) {
if ($idGeneratorType = $this->_getIdGeneratorTypeString($metadata->getIdGeneratorType())) {
$id[$metadata->getSingleIdentifierFieldName()]['generator']['strategy'] = $idGeneratorType;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment