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
0b68e947
Commit
0b68e947
authored
Mar 24, 2010
by
jwage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-449] Fixing issue with ClassMetadataReader and existing driver sources being added
parent
b2167985
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
16 deletions
+33
-16
ClassMetadataReader.php
lib/Doctrine/ORM/Tools/ClassMetadataReader.php
+21
-9
ClassMetadataExporter.php
lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php
+1
-0
ExportException.php
lib/Doctrine/ORM/Tools/Export/ExportException.php
+8
-3
DatabaseDriverTest.php
tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php
+3
-4
No files found.
lib/Doctrine/ORM/Tools/ClassMetadataReader.php
View file @
0b68e947
...
...
@@ -26,7 +26,8 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Mapping\MappingException
,
Doctrine\ORM\Mapping\Driver\Driver
,
Doctrine\ORM\Mapping\Driver\AnnotationDriver
,
Doctrine\ORM\EntityManager
;
Doctrine\ORM\EntityManager
,
Doctrine\ORM\Tools\Export\ExportException
;
/**
* Class to read metadata mapping information from multiple sources into an array
...
...
@@ -92,9 +93,15 @@ class ClassMetadataReader
* directories. Reads the mapping directories and populates ClassMetadataInfo
* instances.
*
* If you specify $autoload = true then this method will return ClassMetadata
* instances instead of ClassMetadataInfo instances. Keep in mind that if you
* specify it to autoload and it doesn't find the class your autoloader may
* throw an error.
*
* @param bool $autoload Whether or to try and autoload the classes
* @return array $classes
*/
public
function
getMetadatas
()
public
function
getMetadatas
(
$autoload
=
false
)
{
$classes
=
array
();
...
...
@@ -104,7 +111,7 @@ class ClassMetadataReader
$allClasses
=
$driver
->
getAllClassNames
();
foreach
(
$allClasses
as
$className
)
{
if
(
class_exists
(
$className
,
false
))
{
if
(
class_exists
(
$className
,
$autoload
))
{
$metadata
=
new
ClassMetadata
(
$className
);
}
else
{
$metadata
=
new
ClassMetadataInfo
(
$className
);
...
...
@@ -183,9 +190,12 @@ class ClassMetadataReader
private
function
_determineSourceType
(
$source
)
{
if
(
$source
instanceof
\Doctrine\ORM\Mapping\Driver\Driver
)
{
$type
=
array_search
(
get_class
(
$source
),
self
::
$_mappingDrivers
);
return
$type
;
// If the --from=<VALUE> is a directory lets determine if it is
// annotations, yaml, xml, etc.
if
(
is_dir
(
$source
))
{
}
else
if
(
is_dir
(
$source
))
{
$source
=
realpath
(
$source
);
// Find the files in the directory
...
...
@@ -218,12 +228,14 @@ class ClassMetadataReader
private
function
_getSourceByType
(
$type
,
$source
)
{
$source
=
realpath
(
$source
);
// If --from==database then the source is an instance of SchemaManager
// for the current EntityMAnager
if
(
$type
==
'database'
&&
$this
->
_em
)
{
// for the current EntityManager
if
(
$type
==
'database'
)
{
if
(
$source
instanceof
\Doctrine\ORM\Mapping\Driver\DatabaseDriver
)
{
return
$source
;
}
else
if
(
$this
->
_em
)
{
return
$this
->
_em
->
getConnection
()
->
getSchemaManager
();
}
// If source is annotation then lets try and find the existing annotation
// driver for the source instead of re-creating a new instance
}
else
if
(
$type
==
'annotation'
)
{
...
...
lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php
View file @
0b68e947
...
...
@@ -23,6 +23,7 @@
namespace
Doctrine\ORM\Tools\Export
;
use
Doctrine\ORM\Tools\ClassMetadataReader
,
Doctrine\ORM\Tools\Export\ExportException
,
Doctrine\ORM\EntityManager
;
/**
...
...
lib/Doctrine/ORM/Tools/Export/ExportException.php
View file @
0b68e947
...
...
@@ -2,12 +2,17 @@
namespace
Doctrine\ORM\Tools\Export
;
class
ExportException
extends
ORMException
{
public
static
function
invalidExporterDriverType
(
$type
)
{
use
Doctrine\ORM\ORMException
;
class
ExportException
extends
ORMException
{
public
static
function
invalidExporterDriverType
(
$type
)
{
return
new
self
(
"The specified export driver '
$type
' does not exist"
);
}
public
static
function
invalidMappingDriverType
(
$type
)
{
public
static
function
invalidMappingDriverType
(
$type
)
{
return
new
self
(
"The mapping driver '
$type
' does not exist"
);
}
}
\ No newline at end of file
tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php
View file @
0b68e947
...
...
@@ -4,7 +4,7 @@ namespace Doctrine\Tests\ORM\Functional;
require_once
__DIR__
.
'/../../TestInit.php'
;
use
Doctrine\ORM\Tools\
Export\ClassMetadataExport
er
;
use
Doctrine\ORM\Tools\
ClassMetadataRead
er
;
class
DatabaseDriverTest
extends
\Doctrine\Tests\OrmFunctionalTestCase
{
...
...
@@ -88,9 +88,8 @@ class DatabaseDriverTest extends \Doctrine\Tests\OrmFunctionalTestCase
*/
protected
function
extractClassMetadata
(
$className
)
{
$cm
=
new
ClassMetadataExporter
();
$cm
->
addMappingSource
(
$this
->
_sm
);
$exporter
=
$cm
->
getExporter
(
'yaml'
);
$cm
=
new
ClassMetadataReader
();
$cm
->
addMappingSource
(
new
\Doctrine\ORM\Mapping\Driver\DatabaseDriver
(
$this
->
_sm
));
$metadatas
=
$cm
->
getMetadatas
();
$output
=
false
;
...
...
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