[2.0] Changes to convert Classmetadata constant integers to string representation
This commit is contained in:
parent
320d21e2be
commit
93445983fb
3 changed files with 81 additions and 7 deletions
|
@ -72,7 +72,7 @@ class YamlDriver extends AbstractFileDriver
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($element['inheritanceType'])) {
|
if (isset($element['inheritanceType'])) {
|
||||||
$metadata->setInheritanceType($element['inheritanceType']);
|
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $element['inheritanceType']));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Evaluate discriminatorColumn
|
// Evaluate discriminatorColumn
|
||||||
|
@ -92,7 +92,8 @@ class YamlDriver extends AbstractFileDriver
|
||||||
|
|
||||||
// Evaluate changeTrackingPolicy
|
// Evaluate changeTrackingPolicy
|
||||||
if (isset($element['changeTrackingPolicy'])) {
|
if (isset($element['changeTrackingPolicy'])) {
|
||||||
$metadata->setChangeTrackingPolicy($element['changeTrackingPolicy']);
|
$metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_'
|
||||||
|
. $element['changeTrackingPolicy']));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Evaluate indexes
|
// Evaluate indexes
|
||||||
|
|
|
@ -70,6 +70,10 @@ abstract class AbstractExporter
|
||||||
*/
|
*/
|
||||||
public function export()
|
public function export()
|
||||||
{
|
{
|
||||||
|
if ( ! is_dir($this->_outputDir)) {
|
||||||
|
mkdir($this->_outputDir, 0777);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->_metadatas as $metadata) {
|
foreach ($this->_metadatas as $metadata) {
|
||||||
$outputPath = $this->_outputDir . '/' . str_replace('\\', '.', $metadata->name) . $this->_extension;
|
$outputPath = $this->_outputDir . '/' . str_replace('\\', '.', $metadata->name) . $this->_extension;
|
||||||
$output = $this->exportClassMetadata($metadata);
|
$output = $this->exportClassMetadata($metadata);
|
||||||
|
@ -101,4 +105,66 @@ abstract class AbstractExporter
|
||||||
* @return mixed $exported
|
* @return mixed $exported
|
||||||
*/
|
*/
|
||||||
abstract public function exportClassMetadata(ClassMetadata $metadata);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -59,10 +59,17 @@ class YamlExporter extends AbstractExporter
|
||||||
$array['schema'] = $metadata->primaryTable['schema'];
|
$array['schema'] = $metadata->primaryTable['schema'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$array['inheritanceType'] = $metadata->getInheritanceType();
|
$array['inheritanceType'] = $this->_getInheritanceTypeString($metadata->getInheritanceType());
|
||||||
$array['discriminatorColumn'] = $metadata->getDiscriminatorColumn();
|
|
||||||
$array['discriminatorMap'] = $metadata->discriminatorMap;
|
if ($column = $metadata->getDiscriminatorColumn()) {
|
||||||
$array['changeTrackingPolicy'] = $metadata->changeTrackingPolicy;
|
$array['discriminatorColumn'] = $column;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($map = $metadata->discriminatorMap) {
|
||||||
|
$array['discriminatorMap'] = $map;
|
||||||
|
}
|
||||||
|
|
||||||
|
$array['changeTrackingPolicy'] = $this->_getChangeTrackingPolicyString($metadata->changeTrackingPolicy);
|
||||||
|
|
||||||
if (isset($metadata->primaryTable['indexes'])) {
|
if (isset($metadata->primaryTable['indexes'])) {
|
||||||
$array['indexes'] = $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;
|
$id[$metadata->getSingleIdentifierFieldName()]['generator']['strategy'] = $idGeneratorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue