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
f34a99cc
Commit
f34a99cc
authored
Mar 20, 2010
by
jwage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Fixing hardcoded dependency to EntityGenerator
parent
65536142
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
46 deletions
+40
-46
ConvertDoctrine1SchemaTask.php
...ctrine/ORM/Tools/Cli/Tasks/ConvertDoctrine1SchemaTask.php
+7
-1
ConvertMappingTask.php
lib/Doctrine/ORM/Tools/Cli/Tasks/ConvertMappingTask.php
+11
-6
GenerateEntitiesTask.php
lib/Doctrine/ORM/Tools/Cli/Tasks/GenerateEntitiesTask.php
+8
-8
AnnotationExporter.php
lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php
+8
-30
AbstractClassMetadataExporterTest.php
...ts/ORM/Tools/Export/AbstractClassMetadataExporterTest.php
+6
-1
No files found.
lib/Doctrine/ORM/Tools/Cli/Tasks/ConvertDoctrine1SchemaTask.php
View file @
f34a99cc
...
...
@@ -26,7 +26,8 @@ use Doctrine\Common\Cli\Tasks\AbstractTask,
Doctrine\Common\Cli\CliException
,
Doctrine\Common\Cli\Option
,
Doctrine\Common\Cli\OptionGroup
,
Doctrine\ORM\Tools\ConvertDoctrine1Schema
;
Doctrine\ORM\Tools\ConvertDoctrine1Schema
,
Doctrine\ORM\Tools\EntityGenerator
;
/**
* CLI Task to convert a Doctrine 1 schema to a Doctrine 2 mapping file
...
...
@@ -90,6 +91,11 @@ class ConvertDoctrine1SchemaTask extends AbstractTask
$cme
=
new
ClassMetadataExporter
();
$exporter
=
$cme
->
getExporter
(
$arguments
[
'to'
],
$arguments
[
'dest'
]);
if
(
$arguments
[
'to'
]
===
'annotation'
)
{
$entityGenerator
=
new
EntityGenerator
();
$exporter
->
setEntityGenerator
(
$entityGenerator
);
}
$converter
=
new
ConvertDoctrine1Schema
(
$arguments
[
'from'
]);
$metadatas
=
$converter
->
getMetadatas
();
...
...
lib/Doctrine/ORM/Tools/Cli/Tasks/ConvertMappingTask.php
View file @
f34a99cc
...
...
@@ -120,12 +120,17 @@ class ConvertMappingTask extends AbstractTask
// Get exporter and configure it
$exporter
=
$cme
->
getExporter
(
$arguments
[
'to'
],
$arguments
[
'dest'
]);
if
(
isset
(
$arguments
[
'extend'
])
&&
$arguments
[
'extend'
])
{
$exporter
->
setClassToExtend
(
$arguments
[
'extend'
]);
}
if
(
isset
(
$arguments
[
'num-spaces'
])
&&
$arguments
[
'extend'
])
{
$exporter
->
setNumSpaces
(
$arguments
[
'num-spaces'
]);
if
(
$arguments
[
'to'
]
===
'annotation'
)
{
$entityGenerator
=
new
EntityGenerator
();
$exporter
->
setEntityGenerator
(
$entityGenerator
);
if
(
isset
(
$arguments
[
'extend'
])
&&
$arguments
[
'extend'
])
{
$entityGenerator
->
setClassToExtend
(
$arguments
[
'extend'
]);
}
if
(
isset
(
$arguments
[
'num-spaces'
])
&&
$arguments
[
'extend'
])
{
$entityGenerator
->
setNumSpaces
(
$arguments
[
'num-spaces'
]);
}
}
$from
=
(
array
)
$arguments
[
'from'
];
...
...
lib/Doctrine/ORM/Tools/Cli/Tasks/GenerateEntitiesTask.php
View file @
f34a99cc
...
...
@@ -83,18 +83,18 @@ class GenerateEntitiesTask extends AbstractTask
$from
=
$arguments
[
'from'
];
$dest
=
realpath
(
$arguments
[
'dest'
]);
$
g
enerator
=
new
EntityGenerator
();
$
g
enerator
->
setGenerateAnnotations
(
false
);
$
g
enerator
->
setGenerateStubMethods
(
true
);
$
g
enerator
->
setRegenerateEntityIfExists
(
false
);
$
g
enerator
->
setUpdateEntityIfExists
(
true
);
$
entityG
enerator
=
new
EntityGenerator
();
$
entityG
enerator
->
setGenerateAnnotations
(
false
);
$
entityG
enerator
->
setGenerateStubMethods
(
true
);
$
entityG
enerator
->
setRegenerateEntityIfExists
(
false
);
$
entityG
enerator
->
setUpdateEntityIfExists
(
true
);
if
(
isset
(
$arguments
[
'extend'
])
&&
$arguments
[
'extend'
])
{
$
g
enerator
->
setClassToExtend
(
$arguments
[
'extend'
]);
$
entityG
enerator
->
setClassToExtend
(
$arguments
[
'extend'
]);
}
if
(
isset
(
$arguments
[
'num-spaces'
])
&&
$arguments
[
'extend'
])
{
$
g
enerator
->
setNumSpaces
(
$arguments
[
'num-spaces'
]);
$
entityG
enerator
->
setNumSpaces
(
$arguments
[
'num-spaces'
]);
}
$reader
=
new
ClassMetadataReader
();
...
...
@@ -108,7 +108,7 @@ class GenerateEntitiesTask extends AbstractTask
);
}
$
g
enerator
->
generate
(
$metadatas
,
$dest
);
$
entityG
enerator
->
generate
(
$metadatas
,
$dest
);
$printer
->
writeln
(
''
);
$printer
->
writeln
(
...
...
lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php
View file @
f34a99cc
...
...
@@ -38,13 +38,7 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo,
class
AnnotationExporter
extends
AbstractExporter
{
protected
$_extension
=
'.php'
;
private
$_generator
;
public
function
__construct
(
$dir
=
null
)
{
parent
::
__construct
(
$dir
);
$this
->
_generator
=
new
EntityGenerator
();
}
private
$_entityGenerator
;
/**
* Converts a single ClassMetadata instance to the exported format
...
...
@@ -55,12 +49,12 @@ class AnnotationExporter extends AbstractExporter
*/
public
function
exportClassMetadata
(
ClassMetadataInfo
$metadata
)
{
$this
->
_
g
enerator
->
setGenerateAnnotations
(
true
);
$this
->
_
g
enerator
->
setGenerateStubMethods
(
false
);
$this
->
_
g
enerator
->
setRegenerateEntityIfExists
(
false
);
$this
->
_
g
enerator
->
setUpdateEntityIfExists
(
false
);
$this
->
_
entityG
enerator
->
setGenerateAnnotations
(
true
);
$this
->
_
entityG
enerator
->
setGenerateStubMethods
(
false
);
$this
->
_
entityG
enerator
->
setRegenerateEntityIfExists
(
false
);
$this
->
_
entityG
enerator
->
setUpdateEntityIfExists
(
false
);
return
$this
->
_
g
enerator
->
generateEntityClass
(
$metadata
);
return
$this
->
_
entityG
enerator
->
generateEntityClass
(
$metadata
);
}
protected
function
_generateOutputPath
(
ClassMetadataInfo
$metadata
)
...
...
@@ -68,24 +62,8 @@ class AnnotationExporter extends AbstractExporter
return
$this
->
_outputDir
.
'/'
.
str_replace
(
'\\'
,
'/'
,
$metadata
->
name
)
.
$this
->
_extension
;
}
/**
* Set the number of spaces the exported class should have
*
* @param integer $numSpaces
* @return void
*/
public
function
setNumSpaces
(
$numSpaces
)
{
$this
->
_generator
->
setNumSpaces
(
$numSpaces
);
}
/**
* Set the name of the class the generated classes should extend from
*
* @return void
*/
public
function
setClassToExtend
(
$classToExtend
)
public
function
setEntityGenerator
(
EntityGenerator
$entityGenerator
)
{
$this
->
_
generator
->
setClassToExtend
(
$classToExtend
)
;
$this
->
_
entityGenerator
=
$entityGenerator
;
}
}
\ No newline at end of file
tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php
View file @
f34a99cc
...
...
@@ -22,7 +22,8 @@
namespace
Doctrine\Tests\ORM\Tools\Export
;
use
Doctrine\ORM\Tools\Export\ClassMetadataExporter
,
Doctrine\ORM\Mapping\ClassMetadataInfo
;
Doctrine\ORM\Mapping\ClassMetadataInfo
,
Doctrine\ORM\Tools\EntityGenerator
;
require_once
__DIR__
.
'/../../../TestInit.php'
;
...
...
@@ -80,6 +81,10 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
{
$type
=
$this
->
_getType
();
$exporter
=
$cme
->
getExporter
(
$type
,
__DIR__
.
'/export/'
.
$type
);
if
(
$type
===
'annotation'
)
{
$entityGenerator
=
new
EntityGenerator
();
$exporter
->
setEntityGenerator
(
$entityGenerator
);
}
$this
->
_extension
=
$exporter
->
getExtension
();
$metadatas
=
$cme
->
getMetadatas
();
if
(
$type
==
'annotation'
)
{
...
...
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