Commit 0f4ba3b8 authored by Jonathan H. Wage's avatar Jonathan H. Wage

Fixing issue with orm:convert-mapping task and dest-path that does not exist...

Fixing issue with orm:convert-mapping task and dest-path that does not exist yet as well when reverse engineering from-database
parent c81b770a
...@@ -61,8 +61,8 @@ class ConvertMappingCommand extends Console\Command\Command ...@@ -61,8 +61,8 @@ class ConvertMappingCommand extends Console\Command\Command
'dest-path', InputArgument::REQUIRED, 'dest-path', InputArgument::REQUIRED,
'The path to generate your entities classes.' 'The path to generate your entities classes.'
), ),
new InputArgument( new InputOption(
'from-database', InputArgument::OPTIONAL, 'The path of mapping information.' 'from-database', null, null, 'Whether or not to convert mapping information from existing database.'
), ),
new InputOption( new InputOption(
'extend', null, InputOption::PARAMETER_OPTIONAL, 'extend', null, InputOption::PARAMETER_OPTIONAL,
...@@ -86,10 +86,7 @@ EOT ...@@ -86,10 +86,7 @@ EOT
{ {
$em = $this->getHelper('em')->getEntityManager(); $em = $this->getHelper('em')->getEntityManager();
$metadatas = $em->getMetadataFactory()->getAllMetadata(); if ($input->getOption('from-database') === true) {
$metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
if ($input->getArgument('from-database') === true) {
$em->getConfiguration()->setMetadataDriverImpl( $em->getConfiguration()->setMetadataDriverImpl(
new \Doctrine\ORM\Mapping\Driver\DatabaseDriver( new \Doctrine\ORM\Mapping\Driver\DatabaseDriver(
$em->getConnection()->getSchemaManager() $em->getConnection()->getSchemaManager()
...@@ -97,8 +94,14 @@ EOT ...@@ -97,8 +94,14 @@ EOT
); );
} }
$metadatas = $em->getMetadataFactory()->getAllMetadata();
$metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
// Process destination directory // Process destination directory
$destPath = realpath($input->getArgument('dest-path')); if ( ! is_dir($destPath = $input->getArgument('dest-path'))) {
mkdir($destPath, 0777, true);
}
$destPath = realpath($destPath);
if ( ! file_exists($destPath)) { if ( ! file_exists($destPath)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment