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
700060cf
Commit
700060cf
authored
Apr 11, 2010
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DDC-510 Refactored all Command Tools to use ClassMetadataFactory instead of ClassMetadataReader
parent
6e5b1bbe
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
149 deletions
+56
-149
ConvertDoctrine1SchemaCommand.php
...M/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php
+3
-1
ConvertMappingCommand.php
...trine/ORM/Tools/Console/Command/ConvertMappingCommand.php
+14
-35
GenerateEntitiesCommand.php
...ine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php
+21
-45
GenerateProxiesCommand.php
...rine/ORM/Tools/Console/Command/GenerateProxiesCommand.php
+9
-34
GenerateRepositoriesCommand.php
...ORM/Tools/Console/Command/GenerateRepositoriesCommand.php
+9
-34
No files found.
lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php
View file @
700060cf
...
...
@@ -23,7 +23,9 @@ namespace Doctrine\ORM\Tools\Console\Command;
use
Symfony\Components\Console\Input\InputArgument
,
Symfony\Components\Console\Input\InputOption
,
Symfony\Components\Console
;
Symfony\Components\Console
,
Doctrine\ORM\Tools\Export\ClassMetadataExporter
,
Doctrine\ORM\Tools\ConvertDoctrine1Schema
;
/**
* Command to convert a Doctrine 1 schema to a Doctrine 2 mapping file.
...
...
lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php
View file @
700060cf
...
...
@@ -23,7 +23,9 @@ namespace Doctrine\ORM\Tools\Console\Command;
use
Symfony\Components\Console\Input\InputArgument
,
Symfony\Components\Console\Input\InputOption
,
Symfony\Components\Console
;
Symfony\Components\Console
,
Doctrine\ORM\Tools\Console\MetadataFilter
,
Doctrine\ORM\Tools\Export\ClassMetadataExporter
;
/**
* Command to convert your mapping information between the various formats.
...
...
@@ -48,8 +50,9 @@ class ConvertMappingCommand extends Console\Command\Command
->
setName
(
'orm:convert-mapping'
)
->
setDescription
(
'Convert mapping information between supported formats.'
)
->
setDefinition
(
array
(
new
InputArgument
(
'from-path'
,
InputArgument
::
REQUIRED
,
'The path of mapping information.'
new
InputOption
(
'filter'
,
null
,
InputOption
::
PARAMETER_REQUIRED
|
InputOption
::
PARAMETER_IS_ARRAY
,
'A string pattern used to match entities that should be processed.'
),
new
InputArgument
(
'to-type'
,
InputArgument
::
REQUIRED
,
'The mapping type to be converted.'
...
...
@@ -58,10 +61,8 @@ class ConvertMappingCommand extends Console\Command\Command
'dest-path'
,
InputArgument
::
REQUIRED
,
'The path to generate your entities classes.'
),
new
InputOption
(
'from'
,
null
,
InputOption
::
PARAMETER_REQUIRED
|
InputOption
::
PARAMETER_IS_ARRAY
,
'Optional paths of mapping information.'
,
array
()
new
InputArgument
(
'from-database'
,
InputArgument
::
OPTIONAL
,
'The path of mapping information.'
),
new
InputOption
(
'extend'
,
null
,
InputOption
::
PARAMETER_OPTIONAL
,
...
...
@@ -84,37 +85,16 @@ EOT
protected
function
execute
(
Console\Input\InputInterface
$input
,
Console\Output\OutputInterface
$output
)
{
$em
=
$this
->
getHelper
(
'em'
)
->
getEntityManager
();
$cme
=
new
ClassMetadataExporter
();
// Process source directories
$fromPath
=
$input
->
getArgument
(
'from-path'
);
if
(
strtolower
(
$fromPath
)
!==
'database'
)
{
$fromPaths
=
array_merge
(
array
(
$fromPath
),
$input
->
getOption
(
'from'
));
foreach
(
$fromPaths
as
&
$dirName
)
{
$dirName
=
realpath
(
$dirName
);
if
(
!
file_exists
(
$dirName
))
{
throw
new
\InvalidArgumentException
(
sprintf
(
"Mapping directory '<info>%s</info>' does not exist."
,
$dirName
)
);
}
else
if
(
!
is_readable
(
$dirName
))
{
throw
new
\InvalidArgumentException
(
sprintf
(
"Mapping directory '<info>%s</info>' does not have read permissions."
,
$dirName
)
);
}
$metadatas
=
$em
->
getMetadataFactory
()
->
getAllMetadata
();
$metadatas
=
MetadataFilter
::
filter
(
$metadatas
,
$input
->
getOption
(
'filter'
));
$cme
->
addMappingSource
(
$dirName
);
}
}
else
{
if
(
$input
->
getArgument
(
'from-database'
)
===
true
)
{
$em
->
getConfiguration
()
->
setMetadataDriverImpl
(
new
\Doctrine\ORM\Mapping\Driver\DatabaseDriver
(
$em
->
getConnection
()
->
getSchemaManager
()
)
);
$cme
->
addMappingSource
(
$fromPath
);
}
// Process destination directory
...
...
@@ -132,6 +112,7 @@ EOT
$toType
=
strtolower
(
$input
->
getArgument
(
'to-type'
));
$cme
=
new
ClassMetadataExporter
();
$exporter
=
$cme
->
getExporter
(
$toType
,
$destPath
);
if
(
$toType
==
'annotation'
)
{
...
...
@@ -145,9 +126,7 @@ EOT
}
}
$metadatas
=
$cme
->
getMetadatas
();
if
(
$metadatas
)
{
if
(
count
(
$metadatas
))
{
foreach
(
$metadatas
as
$metadata
)
{
$output
->
write
(
sprintf
(
'Processing entity "<info>%s</info>"'
,
$metadata
->
name
)
.
PHP_EOL
);
}
...
...
@@ -156,7 +135,7 @@ EOT
$exporter
->
export
();
$output
->
write
(
PHP_EOL
.
sprintf
(
'Exporting "<info>%s</info>" mapping information to "<info>%s</info>"'
,
$toType
,
$destPath
'Exporting "<info>%s</info>" mapping information to "<info>%s</info>"'
.
PHP_EOL
,
$toType
,
$destPath
));
}
else
{
$output
->
write
(
'No Metadata Classes to process.'
.
PHP_EOL
);
...
...
lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php
View file @
700060cf
...
...
@@ -23,7 +23,9 @@ namespace Doctrine\ORM\Tools\Console\Command;
use
Symfony\Components\Console\Input\InputArgument
,
Symfony\Components\Console\Input\InputOption
,
Symfony\Components\Console
;
Symfony\Components\Console
,
Doctrine\ORM\Tools\Console\MetadataFilter
,
Doctrine\ORM\Tools\EntityGenerator
;
/**
* Command to generate entity classes and method stubs from your mapping information.
...
...
@@ -48,17 +50,13 @@ class GenerateEntitiesCommand extends Console\Command\Command
->
setName
(
'orm:generate-entities'
)
->
setDescription
(
'Generate entity classes and method stubs from your mapping information.'
)
->
setDefinition
(
array
(
new
InputArgument
(
'from-path'
,
InputArgument
::
REQUIRED
,
'The path of mapping information.'
new
InputOption
(
'filter'
,
null
,
InputOption
::
PARAMETER_REQUIRED
|
InputOption
::
PARAMETER_IS_ARRAY
,
'A string pattern used to match entities that should be processed.'
),
new
InputArgument
(
'dest-path'
,
InputArgument
::
REQUIRED
,
'The path to generate your entity classes.'
),
new
InputOption
(
'from'
,
null
,
InputOption
::
PARAMETER_REQUIRED
|
InputOption
::
PARAMETER_IS_ARRAY
,
'Optional paths of mapping information.'
,
array
()
),
new
InputOption
(
'generate-annotations'
,
null
,
InputOption
::
PARAMETER_OPTIONAL
,
'Flag to define if generator should generate annotation metadata on entities.'
,
false
...
...
@@ -97,27 +95,8 @@ EOT
{
$em
=
$this
->
getHelper
(
'em'
)
->
getEntityManager
();
$reader
=
new
ClassMetadataReader
();
$reader
->
setEntityManager
(
$em
);
// Process source directories
$fromPaths
=
array_merge
(
array
(
$input
->
getArgument
(
'from-path'
)),
$input
->
getOption
(
'from'
));
foreach
(
$fromPaths
as
$dirName
)
{
$dirName
=
realpath
(
$dirName
);
if
(
!
file_exists
(
$dirName
))
{
throw
new
\InvalidArgumentException
(
sprintf
(
"Mapping directory '<info>%s</info>' does not exist."
,
$dirName
)
);
}
else
if
(
!
is_readable
(
$dirName
))
{
throw
new
\InvalidArgumentException
(
sprintf
(
"Mapping directory '<info>%s</info>' does not have read permissions."
,
$dirName
)
);
}
$reader
->
addMappingSource
(
$dirName
);
}
$metadatas
=
$em
->
getMetadataFactory
()
->
getAllMetadata
();
$metadatas
=
MetadataFilter
::
filter
(
$metadatas
,
$input
->
getOption
(
'filter'
));
// Process destination directory
$destPath
=
realpath
(
$input
->
getArgument
(
'dest-path'
));
...
...
@@ -132,6 +111,7 @@ EOT
);
}
if
(
count
(
$metadatas
))
{
// Create EntityGenerator
$entityGenerator
=
new
EntityGenerator
();
...
...
@@ -145,10 +125,6 @@ EOT
$entityGenerator
->
setClassToExtend
(
$extend
);
}
// Retrieving ClassMetadatas
$metadatas
=
$reader
->
getMetadatas
();
if
(
!
empty
(
$metadatas
))
{
foreach
(
$metadatas
as
$metadata
)
{
$output
->
write
(
sprintf
(
'Processing entity "<info>%s</info>"'
,
$metadata
->
name
)
.
PHP_EOL
...
...
lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php
View file @
700060cf
...
...
@@ -23,7 +23,8 @@ namespace Doctrine\ORM\Tools\Console\Command;
use
Symfony\Components\Console\Input\InputArgument
,
Symfony\Components\Console\Input\InputOption
,
Symfony\Components\Console
;
Symfony\Components\Console
,
Doctrine\ORM\Tools\Console\MetadataFilter
;
/**
* Command to (re)generate the proxy classes used by doctrine.
...
...
@@ -48,18 +49,14 @@ class GenerateProxiesCommand extends Console\Command\Command
->
setName
(
'orm:generate-proxies'
)
->
setDescription
(
'Generates proxy classes for entity classes.'
)
->
setDefinition
(
array
(
new
InputArgument
(
'from-path'
,
InputArgument
::
REQUIRED
,
'The path of mapping information.'
new
InputOption
(
'filter'
,
null
,
InputOption
::
PARAMETER_REQUIRED
|
InputOption
::
PARAMETER_IS_ARRAY
,
'A string pattern used to match entities that should be processed.'
),
new
InputArgument
(
'dest-path'
,
InputArgument
::
OPTIONAL
,
'The path to generate your proxy classes. If none is provided, it will attempt to grab from configuration.'
),
new
InputOption
(
'from'
,
null
,
InputOption
::
PARAMETER_REQUIRED
|
InputOption
::
PARAMETER_IS_ARRAY
,
'Optional paths of mapping information.'
,
array
()
)
))
->
setHelp
(
<<<EOT
Generates proxy classes for entity classes.
...
...
@@ -74,27 +71,8 @@ EOT
{
$em
=
$this
->
getHelper
(
'em'
)
->
getEntityManager
();
$reader
=
new
ClassMetadataReader
();
$reader
->
setEntityManager
(
$em
);
// Process source directories
$fromPaths
=
array_merge
(
array
(
$input
->
getArgument
(
'from-path'
)),
$input
->
getOption
(
'from'
));
foreach
(
$fromPaths
as
$dirName
)
{
$dirName
=
realpath
(
$dirName
);
if
(
!
file_exists
(
$dirName
))
{
throw
new
\InvalidArgumentException
(
sprintf
(
"Mapping directory '<info>%s</info>' does not exist."
,
$dirName
)
);
}
else
if
(
!
is_readable
(
$dirName
))
{
throw
new
\InvalidArgumentException
(
sprintf
(
"Mapping directory '<info>%s</info>' does not have read permissions."
,
$dirName
)
);
}
$reader
->
addMappingSource
(
$dirName
);
}
$metadatas
=
$em
->
getMetadataFactory
()
->
getAllMetadata
();
$metadatas
=
MetadataFilter
::
filter
(
$metadatas
,
$input
->
getOption
(
'filter'
));
// Process destination directory
if
((
$destPath
=
$input
->
getArgument
(
'dest-path'
))
===
null
)
{
...
...
@@ -113,10 +91,7 @@ EOT
);
}
// Retrieving ClassMetadatas
$metadatas
=
$reader
->
getMetadatas
();
if
(
!
empty
(
$metadatas
))
{
if
(
count
(
$metadatas
))
{
foreach
(
$metadatas
as
$metadata
)
{
$output
->
write
(
sprintf
(
'Processing entity "<info>%s</info>"'
,
$metadata
->
name
)
.
PHP_EOL
...
...
lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php
View file @
700060cf
...
...
@@ -23,7 +23,8 @@ namespace Doctrine\ORM\Tools\Console\Command;
use
Symfony\Components\Console\Input\InputArgument
,
Symfony\Components\Console\Input\InputOption
,
Symfony\Components\Console
;
Symfony\Components\Console
,
Doctrine\ORM\Tools\Console\MetadataFilter
;
/**
* Command to generate repository classes for mapping information.
...
...
@@ -65,16 +66,12 @@ class <className> extends EntityRepository
->
setName
(
'orm:generate-repositories'
)
->
setDescription
(
'Generate repository classes from your mapping information.'
)
->
setDefinition
(
array
(
new
InputArgument
(
'from-path'
,
InputArgument
::
REQUIRED
,
'The path of mapping information.'
new
InputOption
(
'filter'
,
null
,
InputOption
::
PARAMETER_REQUIRED
|
InputOption
::
PARAMETER_IS_ARRAY
,
'A string pattern used to match entities that should be processed.'
),
new
InputArgument
(
'dest-path'
,
InputArgument
::
REQUIRED
,
'The path to generate your repository classes.'
),
new
InputOption
(
'from'
,
null
,
InputOption
::
PARAMETER_REQUIRED
|
InputOption
::
PARAMETER_IS_ARRAY
,
'Optional paths of mapping information.'
,
array
()
)
))
->
setHelp
(
<<<EOT
...
...
@@ -90,27 +87,8 @@ EOT
{
$em
=
$this
->
getHelper
(
'em'
)
->
getEntityManager
();
$reader
=
new
ClassMetadataReader
();
$reader
->
setEntityManager
(
$em
);
// Process source directories
$fromPaths
=
array_merge
(
array
(
$input
->
getArgument
(
'from-path'
)),
$input
->
getOption
(
'from'
));
foreach
(
$fromPaths
as
$dirName
)
{
$dirName
=
realpath
(
$dirName
);
if
(
!
file_exists
(
$dirName
))
{
throw
new
\InvalidArgumentException
(
sprintf
(
"Mapping directory '<info>%s</info>' does not exist."
,
$dirName
)
);
}
else
if
(
!
is_readable
(
$dirName
))
{
throw
new
\InvalidArgumentException
(
sprintf
(
"Mapping directory '<info>%s</info>' does not have read permissions."
,
$dirName
)
);
}
$reader
->
addMappingSource
(
$dirName
);
}
$metadatas
=
$em
->
getMetadataFactory
()
->
getAllMetadata
();
$metadatas
=
MetadataFilter
::
filter
(
$metadatas
,
$input
->
getOption
(
'filter'
));
// Process destination directory
$destPath
=
realpath
(
$input
->
getArgument
(
'dest-path'
));
...
...
@@ -125,10 +103,7 @@ EOT
);
}
// Retrieving ClassMetadatas
$metadatas
=
$reader
->
getMetadatas
();
if
(
!
empty
(
$metadatas
))
{
if
(
count
(
$metadatas
))
{
$numRepositories
=
0
;
foreach
(
$metadatas
as
$metadata
)
{
...
...
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