From 0f4ba3b8757c18a0365a6d9c54d773de6268ac44 Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Tue, 13 Apr 2010 14:11:21 -0400 Subject: [PATCH] Fixing issue with orm:convert-mapping task and dest-path that does not exist yet as well when reverse engineering from-database --- .../Console/Command/ConvertMappingCommand.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php index 48e6f3eb2..89a6a55d5 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php @@ -61,8 +61,8 @@ class ConvertMappingCommand extends Console\Command\Command 'dest-path', InputArgument::REQUIRED, 'The path to generate your entities classes.' ), - new InputArgument( - 'from-database', InputArgument::OPTIONAL, 'The path of mapping information.' + new InputOption( + 'from-database', null, null, 'Whether or not to convert mapping information from existing database.' ), new InputOption( 'extend', null, InputOption::PARAMETER_OPTIONAL, @@ -86,10 +86,7 @@ EOT { $em = $this->getHelper('em')->getEntityManager(); - $metadatas = $em->getMetadataFactory()->getAllMetadata(); - $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter')); - - if ($input->getArgument('from-database') === true) { + if ($input->getOption('from-database') === true) { $em->getConfiguration()->setMetadataDriverImpl( new \Doctrine\ORM\Mapping\Driver\DatabaseDriver( $em->getConnection()->getSchemaManager() @@ -97,8 +94,14 @@ EOT ); } + $metadatas = $em->getMetadataFactory()->getAllMetadata(); + $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter')); + // 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)) { throw new \InvalidArgumentException(