Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
d1b2f93a
Commit
d1b2f93a
authored
Oct 05, 2009
by
jwage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Splitting ClassMetadata in to ClassMetadataInfo and other bug fixes
parent
968ebb80
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1978 additions
and
1882 deletions
+1978
-1882
IsolatedClassLoader.php
lib/Doctrine/Common/IsolatedClassLoader.php
+0
-1
EntityManager.php
lib/Doctrine/ORM/EntityManager.php
+1
-1
EntityRepository.php
lib/Doctrine/ORM/EntityRepository.php
+3
-3
ClassMetadata.php
lib/Doctrine/ORM/Mapping/ClassMetadata.php
+56
-1626
ClassMetadataFactory.php
lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
+3
-5
ClassMetadataInfo.php
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
+1662
-0
AnnotationDriver.php
lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
+2
-2
Driver.php
lib/Doctrine/ORM/Mapping/Driver/Driver.php
+3
-3
XmlDriver.php
lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
+3
-9
YamlDriver.php
lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
+3
-9
AbstractTask.php
lib/Doctrine/ORM/Tools/Cli/Tasks/AbstractTask.php
+0
-3
ConvertMappingTask.php
lib/Doctrine/ORM/Tools/Cli/Tasks/ConvertMappingTask.php
+13
-5
ClassmetadataExporter.php
lib/Doctrine/ORM/Tools/Export/ClassmetadataExporter.php
+0
-155
AbstractExporter.php
lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php
+14
-14
AnnotationExporter.php
lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php
+189
-17
PhpExporter.php
lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php
+2
-2
XmlExporter.php
lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
+9
-6
YamlExporter.php
lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
+6
-6
annotation.tpl.php
lib/Doctrine/ORM/Tools/Export/Driver/annotation.tpl.php
+9
-14
SchemaTool.php
lib/Doctrine/ORM/Tools/SchemaTool.php
+0
-1
No files found.
lib/Doctrine/Common/IsolatedClassLoader.php
View file @
d1b2f93a
...
@@ -108,7 +108,6 @@ class IsolatedClassLoader
...
@@ -108,7 +108,6 @@ class IsolatedClassLoader
$class
=
(
$this
->
_basePath
!==
null
?
$this
->
_basePath
.
DIRECTORY_SEPARATOR
:
''
)
$class
=
(
$this
->
_basePath
!==
null
?
$this
->
_basePath
.
DIRECTORY_SEPARATOR
:
''
)
.
str_replace
(
$this
->
_namespaceSeparator
,
DIRECTORY_SEPARATOR
,
$className
)
.
str_replace
(
$this
->
_namespaceSeparator
,
DIRECTORY_SEPARATOR
,
$className
)
.
$this
->
_fileExtension
;
.
$this
->
_fileExtension
;
require
$class
;
require
$class
;
return
true
;
return
true
;
...
...
lib/Doctrine/ORM/EntityManager.php
View file @
d1b2f93a
...
@@ -472,7 +472,7 @@ class EntityManager
...
@@ -472,7 +472,7 @@ class EntityManager
$metadata
=
$this
->
getClassMetadata
(
$entityName
);
$metadata
=
$this
->
getClassMetadata
(
$entityName
);
$customRepositoryClassName
=
$metadata
->
getCustomRepositoryClass
();
$customRepositoryClassName
=
$metadata
->
getCustomRepositoryClass
();
if
(
$customRepositoryClassName
!==
null
)
{
if
(
$customRepositoryClassName
!==
null
)
{
$repository
=
new
$customRepositoryClassName
(
$
entityName
,
$metadata
);
$repository
=
new
$customRepositoryClassName
(
$
this
,
$metadata
);
}
else
{
}
else
{
$repository
=
new
EntityRepository
(
$this
,
$metadata
);
$repository
=
new
EntityRepository
(
$this
,
$metadata
);
}
}
...
...
lib/Doctrine/ORM/EntityRepository.php
View file @
d1b2f93a
...
@@ -35,9 +35,9 @@ namespace Doctrine\ORM;
...
@@ -35,9 +35,9 @@ namespace Doctrine\ORM;
*/
*/
class
EntityRepository
class
EntityRepository
{
{
pr
ivate
$_entityName
;
pr
otected
$_entityName
;
pr
ivate
$_em
;
pr
otected
$_em
;
pr
ivate
$_class
;
pr
otected
$_class
;
/**
/**
* Initializes a new <tt>EntityRepository</tt>.
* Initializes a new <tt>EntityRepository</tt>.
...
...
lib/Doctrine/ORM/Mapping/ClassMetadata.php
View file @
d1b2f93a
This diff is collapsed.
Click to expand it.
lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
View file @
d1b2f93a
...
@@ -319,14 +319,12 @@ class ClassMetadataFactory
...
@@ -319,14 +319,12 @@ class ClassMetadataFactory
if
(
$assoc
->
isOneToOne
()
&&
$assoc
->
isOwningSide
)
{
if
(
$assoc
->
isOneToOne
()
&&
$assoc
->
isOwningSide
)
{
foreach
(
$assoc
->
targetToSourceKeyColumns
as
$sourceCol
)
{
foreach
(
$assoc
->
targetToSourceKeyColumns
as
$sourceCol
)
{
$columns
[]
=
$assoc
->
getQuotedJoinColumnName
(
$sourceCol
,
$this
->
_targetPlatform
);
$columns
[]
=
$assoc
->
getQuotedJoinColumnName
(
$sourceCol
,
$this
->
_targetPlatform
);
$values
[]
=
'?'
;
// Add column mapping for SQL result sets
// Add column mapping for SQL result sets
$class
->
resultColumnNames
[
$this
->
_targetPlatform
->
getSqlResultCasing
(
$sourceCol
)]
=
$sourceCol
;
$class
->
resultColumnNames
[
$this
->
_targetPlatform
->
getSqlResultCasing
(
$sourceCol
)]
=
$sourceCol
;
}
}
}
}
}
else
if
(
$class
->
name
!=
$class
->
rootEntityName
||
!
$class
->
isIdGeneratorIdentity
()
||
$class
->
identifier
[
0
]
!=
$name
)
{
}
else
if
(
$class
->
name
!=
$class
->
rootEntityName
||
!
$class
->
isIdGeneratorIdentity
()
||
$class
->
identifier
[
0
]
!=
$name
)
{
$columns
[]
=
$class
->
getQuotedColumnName
(
$name
,
$this
->
_targetPlatform
);
$columns
[]
=
$class
->
getQuotedColumnName
(
$name
,
$this
->
_targetPlatform
);
$values
[]
=
'?'
;
// Add column mapping for SQL result sets
// Add column mapping for SQL result sets
$columnName
=
$class
->
columnNames
[
$name
];
$columnName
=
$class
->
columnNames
[
$name
];
$class
->
resultColumnNames
[
$this
->
_targetPlatform
->
getSqlResultCasing
(
$columnName
)]
=
$columnName
;
$class
->
resultColumnNames
[
$this
->
_targetPlatform
->
getSqlResultCasing
(
$columnName
)]
=
$columnName
;
...
@@ -347,14 +345,12 @@ class ClassMetadataFactory
...
@@ -347,14 +345,12 @@ class ClassMetadataFactory
if
(
$assoc
->
isOwningSide
&&
$assoc
->
isOneToOne
())
{
if
(
$assoc
->
isOwningSide
&&
$assoc
->
isOneToOne
())
{
foreach
(
$assoc
->
targetToSourceKeyColumns
as
$sourceCol
)
{
foreach
(
$assoc
->
targetToSourceKeyColumns
as
$sourceCol
)
{
$columns
[]
=
$assoc
->
getQuotedJoinColumnName
(
$sourceCol
,
$this
->
_targetPlatform
);
$columns
[]
=
$assoc
->
getQuotedJoinColumnName
(
$sourceCol
,
$this
->
_targetPlatform
);
$values
[]
=
'?'
;
// Add column mapping for SQL result sets
// Add column mapping for SQL result sets
$class
->
resultColumnNames
[
$this
->
_targetPlatform
->
getSqlResultCasing
(
$sourceCol
)]
=
$sourceCol
;
$class
->
resultColumnNames
[
$this
->
_targetPlatform
->
getSqlResultCasing
(
$sourceCol
)]
=
$sourceCol
;
}
}
}
}
}
else
if
(
$class
->
generatorType
!=
ClassMetadata
::
GENERATOR_TYPE_IDENTITY
||
$class
->
identifier
[
0
]
!=
$name
)
{
}
else
if
(
$class
->
generatorType
!=
ClassMetadata
::
GENERATOR_TYPE_IDENTITY
||
$class
->
identifier
[
0
]
!=
$name
)
{
$columns
[]
=
$class
->
getQuotedColumnName
(
$name
,
$this
->
_targetPlatform
);
$columns
[]
=
$class
->
getQuotedColumnName
(
$name
,
$this
->
_targetPlatform
);
$values
[]
=
'?'
;
// Add column mapping for SQL result sets
// Add column mapping for SQL result sets
$columnName
=
$class
->
columnNames
[
$name
];
$columnName
=
$class
->
columnNames
[
$name
];
$class
->
resultColumnNames
[
$this
->
_targetPlatform
->
getSqlResultCasing
(
$columnName
)]
=
$columnName
;
$class
->
resultColumnNames
[
$this
->
_targetPlatform
->
getSqlResultCasing
(
$columnName
)]
=
$columnName
;
...
@@ -371,7 +367,6 @@ class ClassMetadataFactory
...
@@ -371,7 +367,6 @@ class ClassMetadataFactory
if
(
$class
->
isInheritanceTypeSingleTable
()
||
$class
->
isInheritanceTypeJoined
()
if
(
$class
->
isInheritanceTypeSingleTable
()
||
$class
->
isInheritanceTypeJoined
()
&&
$class
->
name
==
$class
->
rootEntityName
)
{
&&
$class
->
name
==
$class
->
rootEntityName
)
{
$columns
[]
=
$class
->
getQuotedDiscriminatorColumnName
(
$this
->
_targetPlatform
);
$columns
[]
=
$class
->
getQuotedDiscriminatorColumnName
(
$this
->
_targetPlatform
);
$values
[]
=
'?'
;
}
}
// Add column mapping for SQL result sets
// Add column mapping for SQL result sets
$columnName
=
$class
->
discriminatorColumn
[
'name'
];
$columnName
=
$class
->
discriminatorColumn
[
'name'
];
...
@@ -384,6 +379,9 @@ class ClassMetadataFactory
...
@@ -384,6 +379,9 @@ class ClassMetadataFactory
$class
->
getQuotedColumnName
(
$class
->
identifier
[
0
],
$this
->
_targetPlatform
)
$class
->
getQuotedColumnName
(
$class
->
identifier
[
0
],
$this
->
_targetPlatform
)
);
);
}
else
{
}
else
{
$columns
=
array_unique
(
$columns
);
$values
=
array_fill
(
0
,
count
(
$columns
),
'?'
);
$class
->
insertSql
=
'INSERT INTO '
.
$class
->
insertSql
=
'INSERT INTO '
.
$class
->
getQuotedTableName
(
$this
->
_targetPlatform
)
$class
->
getQuotedTableName
(
$this
->
_targetPlatform
)
.
' ('
.
implode
(
', '
,
$columns
)
.
') '
.
' ('
.
implode
(
', '
,
$columns
)
.
') '
...
...
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
0 → 100644
View file @
d1b2f93a
This diff is collapsed.
Click to expand it.
lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
View file @
d1b2f93a
...
@@ -24,7 +24,7 @@ namespace Doctrine\ORM\Mapping\Driver;
...
@@ -24,7 +24,7 @@ namespace Doctrine\ORM\Mapping\Driver;
use
Doctrine\Common\DoctrineException
,
use
Doctrine\Common\DoctrineException
,
Doctrine\Common\Cache\ArrayCache
,
Doctrine\Common\Cache\ArrayCache
,
Doctrine\Common\Annotations\AnnotationReader
,
Doctrine\Common\Annotations\AnnotationReader
,
Doctrine\ORM\Mapping\ClassMetadata
,
Doctrine\ORM\Mapping\ClassMetadata
Info
,
Doctrine\ORM\Mapping\MappingException
;
Doctrine\ORM\Mapping\MappingException
;
require
__DIR__
.
'/DoctrineAnnotations.php'
;
require
__DIR__
.
'/DoctrineAnnotations.php'
;
...
@@ -59,7 +59,7 @@ class AnnotationDriver implements Driver
...
@@ -59,7 +59,7 @@ class AnnotationDriver implements Driver
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
loadMetadataForClass
(
$className
,
ClassMetadata
$metadata
)
public
function
loadMetadataForClass
(
$className
,
ClassMetadata
Info
$metadata
)
{
{
$class
=
$metadata
->
getReflectionClass
();
$class
=
$metadata
->
getReflectionClass
();
...
...
lib/Doctrine/ORM/Mapping/Driver/Driver.php
View file @
d1b2f93a
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
namespace
Doctrine\ORM\Mapping\Driver
;
namespace
Doctrine\ORM\Mapping\Driver
;
use
Doctrine\ORM\Mapping\ClassMetadata
;
use
Doctrine\ORM\Mapping\ClassMetadata
Info
;
/**
/**
* Contract for metadata drivers.
* Contract for metadata drivers.
...
@@ -38,9 +38,9 @@ interface Driver
...
@@ -38,9 +38,9 @@ interface Driver
* Loads the metadata for the specified class into the provided container.
* Loads the metadata for the specified class into the provided container.
*
*
* @param string $className
* @param string $className
* @param ClassMetadata $metadata
* @param ClassMetadata
Info
$metadata
*/
*/
public
function
loadMetadataForClass
(
$className
,
ClassMetadata
$metadata
);
public
function
loadMetadataForClass
(
$className
,
ClassMetadata
Info
$metadata
);
/**
/**
* Whether the class with the specified name should have its metadata loaded.
* Whether the class with the specified name should have its metadata loaded.
...
...
lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
View file @
d1b2f93a
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
namespace
Doctrine\ORM\Mapping\Driver
;
namespace
Doctrine\ORM\Mapping\Driver
;
use
Doctrine\ORM\Mapping\ClassMetadata
;
use
Doctrine\ORM\Mapping\ClassMetadata
Info
;
/**
/**
* XmlDriver is a metadata driver that enables mapping through XML files.
* XmlDriver is a metadata driver that enables mapping through XML files.
...
@@ -44,10 +44,8 @@ class XmlDriver extends AbstractFileDriver
...
@@ -44,10 +44,8 @@ class XmlDriver extends AbstractFileDriver
* @param string $className
* @param string $className
* @param ClassMetadata $metadata
* @param ClassMetadata $metadata
*/
*/
public
function
loadMetadataForClass
(
$className
,
ClassMetadata
$metadata
)
public
function
loadMetadataForClass
(
$className
,
ClassMetadata
Info
$metadata
)
{
{
$class
=
$metadata
->
getReflectionClass
();
$xmlRoot
=
$this
->
getElement
(
$className
);
$xmlRoot
=
$this
->
getElement
(
$className
);
if
(
$xmlRoot
->
getName
()
==
'entity'
)
{
if
(
$xmlRoot
->
getName
()
==
'entity'
)
{
...
@@ -327,11 +325,7 @@ class XmlDriver extends AbstractFileDriver
...
@@ -327,11 +325,7 @@ class XmlDriver extends AbstractFileDriver
// Evaluate <lifecycle-callbacks...>
// Evaluate <lifecycle-callbacks...>
if
(
isset
(
$xmlRoot
->
{
'lifecycle-callbacks'
}))
{
if
(
isset
(
$xmlRoot
->
{
'lifecycle-callbacks'
}))
{
foreach
(
$xmlRoot
->
{
'lifecycle-callbacks'
}
->
{
'lifecycle-callback'
}
as
$lifecycleCallback
)
{
foreach
(
$xmlRoot
->
{
'lifecycle-callbacks'
}
->
{
'lifecycle-callback'
}
as
$lifecycleCallback
)
{
$method
=
$class
->
getMethod
((
string
)
$lifecycleCallback
[
'method'
]);
$metadata
->
addLifecycleCallback
((
string
)
$lifecycleCallback
[
'method'
],
constant
(
'\Doctrine\ORM\Events::'
.
(
string
)
$lifecycleCallback
[
'type'
]));
if
(
$method
->
isPublic
())
{
$metadata
->
addLifecycleCallback
(
$method
->
getName
(),
constant
(
'\Doctrine\ORM\Events::'
.
(
string
)
$lifecycleCallback
[
'type'
]));
}
}
}
}
}
}
}
...
...
lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
View file @
d1b2f93a
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
namespace
Doctrine\ORM\Mapping\Driver
;
namespace
Doctrine\ORM\Mapping\Driver
;
use
Doctrine\ORM\Mapping\ClassMetadata
,
use
Doctrine\ORM\Mapping\ClassMetadata
Info
,
Doctrine\Common\DoctrineException
,
Doctrine\Common\DoctrineException
,
Doctrine\ORM\Mapping\MappingException
;
Doctrine\ORM\Mapping\MappingException
;
...
@@ -47,10 +47,8 @@ class YamlDriver extends AbstractFileDriver
...
@@ -47,10 +47,8 @@ class YamlDriver extends AbstractFileDriver
{
{
protected
$_fileExtension
=
'.dcm.yml'
;
protected
$_fileExtension
=
'.dcm.yml'
;
public
function
loadMetadataForClass
(
$className
,
ClassMetadata
$metadata
)
public
function
loadMetadataForClass
(
$className
,
ClassMetadata
Info
$metadata
)
{
{
$class
=
$metadata
->
getReflectionClass
();
$element
=
$this
->
getElement
(
$className
);
$element
=
$this
->
getElement
(
$className
);
if
(
$element
[
'type'
]
==
'entity'
)
{
if
(
$element
[
'type'
]
==
'entity'
)
{
...
@@ -320,11 +318,7 @@ class YamlDriver extends AbstractFileDriver
...
@@ -320,11 +318,7 @@ class YamlDriver extends AbstractFileDriver
// Evaluate lifeCycleCallbacks
// Evaluate lifeCycleCallbacks
if
(
isset
(
$element
[
'lifecycleCallbacks'
]))
{
if
(
isset
(
$element
[
'lifecycleCallbacks'
]))
{
foreach
(
$element
[
'lifecycleCallbacks'
]
as
$method
=>
$type
)
{
foreach
(
$element
[
'lifecycleCallbacks'
]
as
$method
=>
$type
)
{
$method
=
$class
->
getMethod
(
$method
);
$metadata
->
addLifecycleCallback
(
$method
,
constant
(
'\Doctrine\ORM\Events::'
.
$type
));
if
(
$method
->
isPublic
())
{
$metadata
->
addLifecycleCallback
(
$method
->
getName
(),
constant
(
'\Doctrine\ORM\Events::'
.
$type
));
}
}
}
}
}
}
}
...
...
lib/Doctrine/ORM/Tools/Cli/Tasks/AbstractTask.php
View file @
d1b2f93a
...
@@ -164,9 +164,6 @@ abstract class AbstractTask
...
@@ -164,9 +164,6 @@ abstract class AbstractTask
if
(
!
isset
(
$this
->
_arguments
[
'config'
]))
{
if
(
!
isset
(
$this
->
_arguments
[
'config'
]))
{
if
(
file_exists
(
'./cli-config.php'
))
{
if
(
file_exists
(
'./cli-config.php'
))
{
require
'./cli-config.php'
;
require
'./cli-config.php'
;
}
else
{
$this
->
_printer
->
writeln
(
'--config option or cli-config.php in the same directory required'
,
'ERROR'
);
return
false
;
}
}
}
else
{
}
else
{
require
$this
->
_arguments
[
'config'
];
require
$this
->
_arguments
[
'config'
];
...
...
lib/Doctrine/ORM/Tools/Cli/Tasks/ConvertMappingTask.php
View file @
d1b2f93a
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
namespace
Doctrine\ORM\Tools\Cli\Tasks
;
namespace
Doctrine\ORM\Tools\Cli\Tasks
;
use
Doctrine\ORM\Tools\Export\Class
m
etadataExporter
;
use
Doctrine\ORM\Tools\Export\Class
M
etadataExporter
;
/**
/**
* CLI Task to convert your mapping information between the various formats
* CLI Task to convert your mapping information between the various formats
...
@@ -86,12 +86,14 @@ class ConvertMappingTask extends AbstractTask
...
@@ -86,12 +86,14 @@ class ConvertMappingTask extends AbstractTask
$args
=
$this
->
getArguments
();
$args
=
$this
->
getArguments
();
$printer
=
$this
->
getPrinter
();
$printer
=
$this
->
getPrinter
();
if
(
!
(
isset
(
$args
[
'from'
])
&&
isset
(
$args
[
'to'
])
&&
isset
(
$args
[
'dest'
])))
if
(
!
(
isset
(
$args
[
'from'
])
&&
isset
(
$args
[
'to'
])
&&
isset
(
$args
[
'dest'
])))
{
{
$printer
->
writeln
(
'You must include a value for all four options: --from, --to and --dest'
,
'ERROR'
);
$printer
->
writeln
(
'You must include a value for all four options: --from, --to and --dest'
,
'ERROR'
);
return
false
;
return
false
;
}
}
if
(
$args
[
'to'
]
!=
'annotation'
&&
$args
[
'extend'
])
{
$printer
->
writeln
(
'You can only use the --extend argument when converting to annoations.'
);
return
false
;
}
return
true
;
return
true
;
}
}
...
@@ -100,7 +102,7 @@ class ConvertMappingTask extends AbstractTask
...
@@ -100,7 +102,7 @@ class ConvertMappingTask extends AbstractTask
$printer
=
$this
->
getPrinter
();
$printer
=
$this
->
getPrinter
();
$args
=
$this
->
getArguments
();
$args
=
$this
->
getArguments
();
$cme
=
new
Class
m
etadataExporter
();
$cme
=
new
Class
M
etadataExporter
();
$from
=
(
array
)
$args
[
'from'
];
$from
=
(
array
)
$args
[
'from'
];
foreach
(
$from
as
$path
)
{
foreach
(
$from
as
$path
)
{
$type
=
$this
->
_determinePathType
(
$path
);
$type
=
$this
->
_determinePathType
(
$path
);
...
@@ -111,6 +113,12 @@ class ConvertMappingTask extends AbstractTask
...
@@ -111,6 +113,12 @@ class ConvertMappingTask extends AbstractTask
}
}
$exporter
=
$cme
->
getExporter
(
$args
[
'to'
]);
$exporter
=
$cme
->
getExporter
(
$args
[
'to'
]);
if
(
isset
(
$args
[
'extend'
]))
{
$exporter
->
setClassToExtend
(
$args
[
'extend'
]);
}
if
(
isset
(
$args
[
'num-spaces'
]))
{
$exporter
->
setNumSpaces
(
$args
[
'num-spaces'
]);
}
$exporter
->
setOutputDir
(
$args
[
'dest'
]);
$exporter
->
setOutputDir
(
$args
[
'dest'
]);
$printer
->
writeln
(
sprintf
(
'Exporting %s mapping information to directory: "%s"'
,
$args
[
'to'
],
$args
[
'dest'
]),
'INFO'
);
$printer
->
writeln
(
sprintf
(
'Exporting %s mapping information to directory: "%s"'
,
$args
[
'to'
],
$args
[
'dest'
]),
'INFO'
);
...
...
lib/Doctrine/ORM/Tools/Export/ClassmetadataExporter.php
deleted
100644 → 0
View file @
968ebb80
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\ORM\Tools\Export
;
use
Doctrine\ORM\EntityManager
;
use
Doctrine\ORM\Mapping\Classmetadata
;
/**
* Class used for converting your mapping information between the
* supported formats: yaml, xml, and php/annotation.
*
* [php]
* // Unify all your mapping information which is written in php, xml, yml
* // and convert it to a single set of yaml files.
*
* $cme = new Doctrine\ORM\Tools\Export\ClassmetadataExporter();
* $cme->addMappingDir(__DIR__ . '/Entities', 'php');
* $cme->addMappingDir(__DIR__ . '/xml', 'xml');
* $cme->addMappingDir(__DIR__ . '/yaml', 'yaml');
*
* $exporter = $cme->getExporter('yaml');
* $exporter->setOutputDir(__DIR__ . '/new_yaml');
* $exporter->export();
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @author Jonathan Wage <jonwage@gmail.com>
*/
class
ClassmetadataExporter
{
private
$_exporterDrivers
=
array
(
'xml'
=>
'Doctrine\ORM\Tools\Export\Driver\XmlExporter'
,
'yaml'
=>
'Doctrine\ORM\Tools\Export\Driver\YamlExporter'
,
'yml'
=>
'Doctrine\ORM\Tools\Export\Driver\YamlExporter'
,
'php'
=>
'Doctrine\ORM\Tools\Export\Driver\PhpExporter'
,
'annotation'
=>
'Doctrine\ORM\Tools\Export\Driver\AnnotationExporter'
);
private
$_mappingDrivers
=
array
(
'annotation'
=>
'Doctrine\ORM\Mapping\Driver\AnnotationDriver'
,
'yaml'
=>
'Doctrine\ORM\Mapping\Driver\YamlDriver'
,
'yml'
=>
'Doctrine\ORM\Mapping\Driver\YamlDriver'
,
'xml'
=>
'Doctrine\ORM\Mapping\Driver\XmlDriver'
);
private
$_mappingDirectories
=
array
();
public
function
addMappingDir
(
$dir
,
$type
)
{
if
(
$type
===
'php'
)
{
$this
->
_mappingDirectories
[]
=
array
(
$dir
,
$type
);
}
else
{
if
(
!
isset
(
$this
->
_mappingDrivers
[
$type
]))
{
throw
DoctrineException
::
invalidMappingDriverType
(
$type
);
}
$class
=
$this
->
_mappingDrivers
[
$type
];
if
(
is_subclass_of
(
$class
,
'Doctrine\ORM\Mapping\Driver\AbstractFileDriver'
))
{
$driver
=
new
$class
(
$dir
,
constant
(
$class
.
'::PRELOAD'
));
}
else
{
$reader
=
new
\Doctrine\Common\Annotations\AnnotationReader
(
new
\Doctrine\Common\Cache\ArrayCache
);
$reader
->
setDefaultAnnotationNamespace
(
'Doctrine\ORM\Mapping\\'
);
$driver
=
new
$class
(
$reader
);
}
$this
->
_mappingDirectories
[]
=
array
(
$dir
,
$driver
);
}
}
private
function
_getMetadataInstances
()
{
$classes
=
array
();
foreach
(
$this
->
_mappingDirectories
as
$d
)
{
list
(
$dir
,
$driver
)
=
$d
;
if
(
$driver
==
'php'
)
{
$iter
=
new
\FilesystemIterator
(
$dir
);
foreach
(
$iter
as
$item
)
{
include
$item
->
getPathName
();
$vars
=
get_defined_vars
();
foreach
(
$vars
as
$var
)
{
if
(
$var
instanceof
\Doctrine\ORM\Mapping\ClassMetadata
)
{
$classes
[]
=
$var
;
}
}
}
$classes
=
array_unique
(
$classes
);
$classes
=
array_values
(
$classes
);
}
else
{
if
(
$driver
instanceof
\Doctrine\ORM\Mapping\Driver\AnnotationDriver
)
{
$iter
=
new
\FilesystemIterator
(
$dir
);
$declared
=
get_declared_classes
();
foreach
(
$iter
as
$item
)
{
$baseName
=
$item
->
getBaseName
();
if
(
$baseName
[
0
]
==
'.'
)
{
continue
;
}
require_once
$item
->
getPathName
();
}
$declared
=
array_diff
(
get_declared_classes
(),
$declared
);
foreach
(
$declared
as
$className
)
{
if
(
!
$driver
->
isTransient
(
$className
))
{
$metadata
=
new
ClassMetadata
(
$className
);
$driver
->
loadMetadataForClass
(
$className
,
$metadata
);
$classes
[]
=
$metadata
;
}
}
}
else
{
$preloadedClasses
=
$driver
->
preload
(
true
);
foreach
(
$preloadedClasses
as
$className
)
{
$metadata
=
new
ClassMetadata
(
$className
);
$driver
->
loadMetadataForClass
(
$className
,
$metadata
);
$classes
[]
=
$metadata
;
}
}
}
}
return
$classes
;
}
public
function
getExporter
(
$type
,
$dir
=
null
)
{
if
(
!
isset
(
$this
->
_exporterDrivers
[
$type
]))
{
throw
DoctrineException
::
invalidExporterDriverType
(
$type
);
}
$class
=
$this
->
_exporterDrivers
[
$type
];
return
new
$class
(
$this
->
_getMetadataInstances
());
}
}
\ No newline at end of file
lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php
View file @
d1b2f93a
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
namespace
Doctrine\ORM\Tools\Export\Driver
;
namespace
Doctrine\ORM\Tools\Export\Driver
;
use
Doctrine\ORM\Mapping\ClassMetadata
;
use
Doctrine\ORM\Mapping\ClassMetadata
Info
;
/**
/**
* Abstract base class which is to be used for the Exporter drivers
* Abstract base class which is to be used for the Exporter drivers
...
@@ -101,28 +101,28 @@ abstract class AbstractExporter
...
@@ -101,28 +101,28 @@ abstract class AbstractExporter
* Converts a single ClassMetadata instance to the exported format
* Converts a single ClassMetadata instance to the exported format
* and returns it
* and returns it
*
*
* @param ClassMetadata $metadata
* @param ClassMetadata
Info
$metadata
* @return mixed $exported
* @return mixed $exported
*/
*/
abstract
public
function
exportClassMetadata
(
ClassMetadata
$metadata
);
abstract
public
function
exportClassMetadata
(
ClassMetadata
Info
$metadata
);
protected
function
_getInheritanceTypeString
(
$type
)
protected
function
_getInheritanceTypeString
(
$type
)
{
{
switch
(
$type
)
switch
(
$type
)
{
{
case
ClassMetadata
::
INHERITANCE_TYPE_NONE
:
case
ClassMetadata
Info
::
INHERITANCE_TYPE_NONE
:
return
'NONE'
;
return
'NONE'
;
break
;
break
;
case
ClassMetadata
::
INHERITANCE_TYPE_JOINED
:
case
ClassMetadata
Info
::
INHERITANCE_TYPE_JOINED
:
return
'JOINED'
;
return
'JOINED'
;
break
;
break
;
case
ClassMetadata
::
INHERITANCE_TYPE_SINGLE_TABLE
:
case
ClassMetadata
Info
::
INHERITANCE_TYPE_SINGLE_TABLE
:
return
'SINGLE_TABLE'
;
return
'SINGLE_TABLE'
;
break
;
break
;
case
ClassMetadata
::
INHERITANCE_TYPE_TABLE_PER_CLASS
:
case
ClassMetadata
Info
::
INHERITANCE_TYPE_TABLE_PER_CLASS
:
return
'PER_CLASS'
;
return
'PER_CLASS'
;
break
;
break
;
}
}
...
@@ -132,15 +132,15 @@ abstract class AbstractExporter
...
@@ -132,15 +132,15 @@ abstract class AbstractExporter
{
{
switch
(
$policy
)
switch
(
$policy
)
{
{
case
ClassMetadata
::
CHANGETRACKING_DEFERRED_IMPLICIT
:
case
ClassMetadata
Info
::
CHANGETRACKING_DEFERRED_IMPLICIT
:
return
'DEFERRED_IMPLICIT'
;
return
'DEFERRED_IMPLICIT'
;
break
;
break
;
case
ClassMetadata
::
CHANGETRACKING_DEFERRED_EXPLICIT
:
case
ClassMetadata
Info
::
CHANGETRACKING_DEFERRED_EXPLICIT
:
return
'DEFERRED_EXPLICIT'
;
return
'DEFERRED_EXPLICIT'
;
break
;
break
;
case
ClassMetadata
::
CHANGETRACKING_NOTIFY
:
case
ClassMetadata
Info
::
CHANGETRACKING_NOTIFY
:
return
'NOTIFY'
;
return
'NOTIFY'
;
break
;
break
;
}
}
...
@@ -150,19 +150,19 @@ abstract class AbstractExporter
...
@@ -150,19 +150,19 @@ abstract class AbstractExporter
{
{
switch
(
$type
)
switch
(
$type
)
{
{
case
ClassMetadata
::
GENERATOR_TYPE_AUTO
:
case
ClassMetadata
Info
::
GENERATOR_TYPE_AUTO
:
return
'AUTO'
;
return
'AUTO'
;
break
;
break
;
case
ClassMetadata
::
GENERATOR_TYPE_SEQUENCE
:
case
ClassMetadata
Info
::
GENERATOR_TYPE_SEQUENCE
:
return
'SEQUENCE'
;
return
'SEQUENCE'
;
break
;
break
;
case
ClassMetadata
::
GENERATOR_TYPE_TABLE
:
case
ClassMetadata
Info
::
GENERATOR_TYPE_TABLE
:
return
'TABLE'
;
return
'TABLE'
;
break
;
break
;
case
ClassMetadata
::
GENERATOR_TYPE_IDENTITY
:
case
ClassMetadata
Info
::
GENERATOR_TYPE_IDENTITY
:
return
'IDENTITY'
;
return
'IDENTITY'
;
break
;
break
;
}
}
...
...
lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php
View file @
d1b2f93a
This diff is collapsed.
Click to expand it.
lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php
View file @
d1b2f93a
...
@@ -41,10 +41,10 @@ class PhpExporter extends AbstractExporter
...
@@ -41,10 +41,10 @@ class PhpExporter extends AbstractExporter
* Converts a single ClassMetadata instance to the exported format
* Converts a single ClassMetadata instance to the exported format
* and returns it
* and returns it
*
*
* @param ClassMetadata $metadata
* @param ClassMetadata
Info
$metadata
* @return mixed $exported
* @return mixed $exported
*/
*/
public
function
exportClassMetadata
(
ClassMetadata
$metadata
)
public
function
exportClassMetadata
(
ClassMetadata
Info
$metadata
)
{
{
$lines
=
array
();
$lines
=
array
();
$lines
[]
=
'<?php'
;
$lines
[]
=
'<?php'
;
...
...
lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
View file @
d1b2f93a
...
@@ -22,7 +22,10 @@
...
@@ -22,7 +22,10 @@
namespace
Doctrine\ORM\Tools\Export\Driver
;
namespace
Doctrine\ORM\Tools\Export\Driver
;
use
Doctrine\ORM\Mapping\ClassMetadata
;
use
Doctrine\ORM\Mapping\ClassMetadataInfo
,
Doctrine\ORM\Mapping\OneToOneMapping
,
Doctrine\ORM\Mapping\OneToManyMapping
,
Doctrine\ORM\Mapping\ManyToManyMapping
;
/**
/**
* ClassMetadata exporter for Doctrine XML mapping files
* ClassMetadata exporter for Doctrine XML mapping files
...
@@ -41,10 +44,10 @@ class XmlExporter extends AbstractExporter
...
@@ -41,10 +44,10 @@ class XmlExporter extends AbstractExporter
* Converts a single ClassMetadata instance to the exported format
* Converts a single ClassMetadata instance to the exported format
* and returns it
* and returns it
*
*
* @param ClassMetadata $metadata
* @param ClassMetadata
Info
$metadata
* @return mixed $exported
* @return mixed $exported
*/
*/
public
function
exportClassMetadata
(
ClassMetadata
$metadata
)
public
function
exportClassMetadata
(
ClassMetadata
Info
$metadata
)
{
{
$xml
=
new
\SimpleXmlElement
(
"<?xml version=
\"
1.0
\"
encoding=
\"
utf-8
\"
?><doctrine-mapping/>"
);
$xml
=
new
\SimpleXmlElement
(
"<?xml version=
\"
1.0
\"
encoding=
\"
utf-8
\"
?><doctrine-mapping/>"
);
...
@@ -170,11 +173,11 @@ class XmlExporter extends AbstractExporter
...
@@ -170,11 +173,11 @@ class XmlExporter extends AbstractExporter
}
}
foreach
(
$metadata
->
associationMappings
as
$name
=>
$associationMapping
)
{
foreach
(
$metadata
->
associationMappings
as
$name
=>
$associationMapping
)
{
if
(
$associationMapping
instanceof
\Doctrine\ORM\Mapping\
OneToOneMapping
)
{
if
(
$associationMapping
instanceof
OneToOneMapping
)
{
$associationMappingXml
=
$root
->
addChild
(
'one-to-one'
);
$associationMappingXml
=
$root
->
addChild
(
'one-to-one'
);
}
else
if
(
$associationMapping
instanceof
\Doctrine\ORM\Mapping\
OneToManyMapping
)
{
}
else
if
(
$associationMapping
instanceof
OneToManyMapping
)
{
$associationMappingXml
=
$root
->
addChild
(
'one-to-many'
);
$associationMappingXml
=
$root
->
addChild
(
'one-to-many'
);
}
else
if
(
$associationMapping
instanceof
\Doctrine\ORM\Mapping\
ManyToManyMapping
)
{
}
else
if
(
$associationMapping
instanceof
ManyToManyMapping
)
{
$associationMappingXml
=
$root
->
addChild
(
'many-to-many'
);
$associationMappingXml
=
$root
->
addChild
(
'many-to-many'
);
}
}
...
...
lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
View file @
d1b2f93a
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
namespace
Doctrine\ORM\Tools\Export\Driver
;
namespace
Doctrine\ORM\Tools\Export\Driver
;
use
Doctrine\ORM\Mapping\ClassMetadata
,
use
Doctrine\ORM\Mapping\ClassMetadata
Info
,
Doctrine\ORM\Mapping\OneToOneMapping
,
Doctrine\ORM\Mapping\OneToOneMapping
,
Doctrine\ORM\Mapping\OneToManyMapping
,
Doctrine\ORM\Mapping\OneToManyMapping
,
Doctrine\ORM\Mapping\ManyToManyMapping
;
Doctrine\ORM\Mapping\ManyToManyMapping
;
...
@@ -46,10 +46,10 @@ class YamlExporter extends AbstractExporter
...
@@ -46,10 +46,10 @@ class YamlExporter extends AbstractExporter
*
*
* TODO: Should this code be pulled out in to a toArray() method in ClassMetadata
* TODO: Should this code be pulled out in to a toArray() method in ClassMetadata
*
*
* @param ClassMetadata $metadata
* @param ClassMetadata
Info
$metadata
* @return mixed $exported
* @return mixed $exported
*/
*/
public
function
exportClassMetadata
(
ClassMetadata
$metadata
)
public
function
exportClassMetadata
(
ClassMetadata
Info
$metadata
)
{
{
$array
=
array
();
$array
=
array
();
if
(
$metadata
->
isMappedSuperclass
)
{
if
(
$metadata
->
isMappedSuperclass
)
{
...
@@ -114,7 +114,7 @@ class YamlExporter extends AbstractExporter
...
@@ -114,7 +114,7 @@ class YamlExporter extends AbstractExporter
),
),
);
);
if
(
$associationMapping
instanceof
\Doctrine\ORM\Mapping\
OneToOneMapping
)
{
if
(
$associationMapping
instanceof
OneToOneMapping
)
{
$oneToOneMappingArray
=
array
(
$oneToOneMappingArray
=
array
(
'mappedBy'
=>
$associationMapping
->
mappedByFieldName
,
'mappedBy'
=>
$associationMapping
->
mappedByFieldName
,
'joinColumns'
=>
$associationMapping
->
joinColumns
,
'joinColumns'
=>
$associationMapping
->
joinColumns
,
...
@@ -123,7 +123,7 @@ class YamlExporter extends AbstractExporter
...
@@ -123,7 +123,7 @@ class YamlExporter extends AbstractExporter
$associationMappingArray
=
array_merge
(
$associationMappingArray
,
$oneToOneMappingArray
);
$associationMappingArray
=
array_merge
(
$associationMappingArray
,
$oneToOneMappingArray
);
$array
[
'oneToOne'
][
$name
]
=
$associationMappingArray
;
$array
[
'oneToOne'
][
$name
]
=
$associationMappingArray
;
}
else
if
(
$associationMapping
instanceof
\Doctrine\ORM\Mapping\
OneToManyMapping
)
{
}
else
if
(
$associationMapping
instanceof
OneToManyMapping
)
{
$oneToManyMappingArray
=
array
(
$oneToManyMappingArray
=
array
(
'mappedBy'
=>
$associationMapping
->
mappedByFieldName
,
'mappedBy'
=>
$associationMapping
->
mappedByFieldName
,
'orphanRemoval'
=>
$associationMapping
->
orphanRemoval
,
'orphanRemoval'
=>
$associationMapping
->
orphanRemoval
,
...
@@ -131,7 +131,7 @@ class YamlExporter extends AbstractExporter
...
@@ -131,7 +131,7 @@ class YamlExporter extends AbstractExporter
$associationMappingArray
=
array_merge
(
$associationMappingArray
,
$oneToManyMappingArray
);
$associationMappingArray
=
array_merge
(
$associationMappingArray
,
$oneToManyMappingArray
);
$array
[
'oneToMany'
][
$name
]
=
$associationMappingArray
;
$array
[
'oneToMany'
][
$name
]
=
$associationMappingArray
;
}
else
if
(
$associationMapping
instanceof
\Doctrine\ORM\Mapping\
ManyToManyMapping
)
{
}
else
if
(
$associationMapping
instanceof
ManyToManyMapping
)
{
$manyToManyMappingArray
=
array
(
$manyToManyMappingArray
=
array
(
'mappedBy'
=>
$associationMapping
->
mappedByFieldName
,
'mappedBy'
=>
$associationMapping
->
mappedByFieldName
,
'joinTable'
=>
$associationMapping
->
joinTable
,
'joinTable'
=>
$associationMapping
->
joinTable
,
...
...
lib/Doctrine/ORM/Tools/Export/Driver/annotation.tpl.php
View file @
d1b2f93a
[?php
[?php
namespace
<?php
echo
$metadata
->
namespace
?>
;
namespace
<?php
echo
$this
->
getNamespace
(
$metadata
)
?>
;
<?php
if
(
$this
->
extendsClass
())
:
?>
use
<?php
echo
$this
->
getClassToExtendNamespace
()
?>
;
<?php
endif
;
?>
/**
/**
<?php
if
(
$metadata
->
isMappedSuperclass
)
:
?>
<?php
if
(
$metadata
->
isMappedSuperclass
)
:
?>
...
@@ -8,19 +12,10 @@ namespace <?php echo $metadata->namespace ?>;
...
@@ -8,19 +12,10 @@ namespace <?php echo $metadata->namespace ?>;
<?php
else
:
?>
<?php
else
:
?>
* @Entity
* @Entity
<?php
endif
;
?>
<?php
endif
;
?>
*
<?php
echo
$this
->
_
getTableAnnotation
(
$metadata
)
.
"
\n
"
?>
*
<?php
echo
$this
->
getTableAnnotation
(
$metadata
)
.
"
\n
"
?>
*/
*/
class
<?
Php
echo
$metadata
->
getReflectionClass
()
->
getShortName
()
.
"
\n
"
?>
class
<?
Php
echo
$this
->
getClassName
(
$metadata
)
?><?php
if
(
$this
->
extendsClass
())
:
?>
extends
<?php
echo
$this
->
getClassToExtendName
()
?><?php
endif
;
?>
{
<?php
foreach
(
$metadata
->
fieldMappings
as
$fieldMapping
)
:
?>
<?php
echo
$this
->
_getFieldMappingAnnotation
(
$fieldMapping
,
$metadata
)
.
"
\n
"
?>
private $
<?php
echo
$fieldMapping
[
'fieldName'
]
?>
;
<?php
endforeach
?>
<?php
foreach
(
$metadata
->
associationMappings
as
$associationMapping
)
:
?>
<?php
echo
$this
->
_getAssociationMappingAnnotation
(
$associationMapping
,
$metadata
)
.
"
\n
"
?>
private $
<?php
echo
$associationMapping
->
sourceFieldName
?>
;
<?php
endforeach
;
?>
{
<?php
include
(
'annotation_body.tpl.php'
)
?>
}
}
\ No newline at end of file
lib/Doctrine/ORM/Tools/SchemaTool.php
View file @
d1b2f93a
...
@@ -630,7 +630,6 @@ class SchemaTool
...
@@ -630,7 +630,6 @@ class SchemaTool
foreach
(
$newJoinColumns
as
$name
=>
$joinColumn
)
{
foreach
(
$newJoinColumns
as
$name
=>
$joinColumn
)
{
$changes
[
'add'
][
$name
]
=
$joinColumn
;
$changes
[
'add'
][
$name
]
=
$joinColumn
;
}
}
$sql
[]
=
$this
->
_platform
->
getAlterTableSql
(
$tableName
,
$changes
);
$sql
[]
=
$this
->
_platform
->
getAlterTableSql
(
$tableName
,
$changes
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment