1
0
mirror of synced 2025-01-05 16:53:21 +03:00

Merge pull request #489 from stof/cs_fixes

Fixed coding standards in the Tools namespace
This commit is contained in:
Guilherme Blanco 2012-11-03 10:04:10 -07:00
commit fc40c437cb
38 changed files with 569 additions and 472 deletions

View File

@ -19,10 +19,11 @@
namespace Doctrine\ORM\Tools\Console\Command\ClearCache; namespace Doctrine\ORM\Tools\Console\Command\ClearCache;
use Symfony\Component\Console\Input\InputArgument, use Symfony\Component\Console\Command\Command;
Symfony\Component\Console\Input\InputOption, use Symfony\Component\Console\Input\InputOption;
Symfony\Component\Console, use Symfony\Component\Console\Input\InputInterface;
Doctrine\Common\Cache; use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Cache\ApcCache;
/** /**
* Command to clear the metadata cache of the various cache drivers. * Command to clear the metadata cache of the various cache drivers.
@ -35,7 +36,7 @@ use Symfony\Component\Console\Input\InputArgument,
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class MetadataCommand extends Console\Command\Command class MetadataCommand extends Command
{ {
/** /**
* @see Console\Command\Command * @see Console\Command\Command
@ -75,7 +76,7 @@ EOT
/** /**
* @see Console\Command\Command * @see Console\Command\Command
*/ */
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$em = $this->getHelper('em')->getEntityManager(); $em = $this->getHelper('em')->getEntityManager();
$cacheDriver = $em->getConfiguration()->getMetadataCacheImpl(); $cacheDriver = $em->getConfiguration()->getMetadataCacheImpl();
@ -84,11 +85,11 @@ EOT
throw new \InvalidArgumentException('No Metadata cache driver is configured on given EntityManager.'); throw new \InvalidArgumentException('No Metadata cache driver is configured on given EntityManager.');
} }
if ($cacheDriver instanceof Cache\ApcCache) { if ($cacheDriver instanceof ApcCache) {
throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI."); throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI.");
} }
$output->write('Clearing ALL Metadata cache entries' . PHP_EOL); $output->writeln('Clearing ALL Metadata cache entries');
$result = $cacheDriver->deleteAll(); $result = $cacheDriver->deleteAll();
$message = ($result) ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.'; $message = ($result) ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.';
@ -98,6 +99,6 @@ EOT
$message = ($result) ? 'Successfully flushed cache entries.' : $message; $message = ($result) ? 'Successfully flushed cache entries.' : $message;
} }
$output->write($message . PHP_EOL); $output->writeln($message);
} }
} }

View File

@ -19,10 +19,11 @@
namespace Doctrine\ORM\Tools\Console\Command\ClearCache; namespace Doctrine\ORM\Tools\Console\Command\ClearCache;
use Symfony\Component\Console\Input\InputArgument, use Symfony\Component\Console\Command\Command;
Symfony\Component\Console\Input\InputOption, use Symfony\Component\Console\Input\InputOption;
Symfony\Component\Console, use Symfony\Component\Console\Input\InputInterface;
Doctrine\Common\Cache; use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Cache\ApcCache;
/** /**
* Command to clear the query cache of the various cache drivers. * Command to clear the query cache of the various cache drivers.
@ -35,11 +36,8 @@ use Symfony\Component\Console\Input\InputArgument,
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class QueryCommand extends Console\Command\Command class QueryCommand extends Command
{ {
/**
* @see Console\Command\Command
*/
protected function configure() protected function configure()
{ {
$this $this
@ -72,10 +70,7 @@ EOT
); );
} }
/** protected function execute(InputInterface $input, OutputInterface $output)
* @see Console\Command\Command
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$em = $this->getHelper('em')->getEntityManager(); $em = $this->getHelper('em')->getEntityManager();
$cacheDriver = $em->getConfiguration()->getQueryCacheImpl(); $cacheDriver = $em->getConfiguration()->getQueryCacheImpl();
@ -84,7 +79,7 @@ EOT
throw new \InvalidArgumentException('No Query cache driver is configured on given EntityManager.'); throw new \InvalidArgumentException('No Query cache driver is configured on given EntityManager.');
} }
if ($cacheDriver instanceof Cache\ApcCache) { if ($cacheDriver instanceof ApcCache) {
throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI."); throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI.");
} }

View File

@ -19,10 +19,11 @@
namespace Doctrine\ORM\Tools\Console\Command\ClearCache; namespace Doctrine\ORM\Tools\Console\Command\ClearCache;
use Symfony\Component\Console\Input\InputArgument, use Symfony\Component\Console\Command\Command;
Symfony\Component\Console\Input\InputOption, use Symfony\Component\Console\Input\InputInterface;
Symfony\Component\Console, use Symfony\Component\Console\Input\InputOption;
Doctrine\Common\Cache; use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Cache\ApcCache;
/** /**
* Command to clear the result cache of the various cache drivers. * Command to clear the result cache of the various cache drivers.
@ -35,7 +36,7 @@ use Symfony\Component\Console\Input\InputArgument,
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class ResultCommand extends Console\Command\Command class ResultCommand extends Command
{ {
/** /**
* @see Console\Command\Command * @see Console\Command\Command
@ -75,7 +76,7 @@ EOT
/** /**
* @see Console\Command\Command * @see Console\Command\Command
*/ */
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$em = $this->getHelper('em')->getEntityManager(); $em = $this->getHelper('em')->getEntityManager();
$cacheDriver = $em->getConfiguration()->getResultCacheImpl(); $cacheDriver = $em->getConfiguration()->getResultCacheImpl();
@ -84,11 +85,11 @@ EOT
throw new \InvalidArgumentException('No Result cache driver is configured on given EntityManager.'); throw new \InvalidArgumentException('No Result cache driver is configured on given EntityManager.');
} }
if ($cacheDriver instanceof Cache\ApcCache) { if ($cacheDriver instanceof ApcCache) {
throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI."); throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI.");
} }
$output->write('Clearing ALL Result cache entries' . PHP_EOL); $output->writeln('Clearing ALL Result cache entries');
$result = $cacheDriver->deleteAll(); $result = $cacheDriver->deleteAll();
$message = ($result) ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.'; $message = ($result) ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.';
@ -98,6 +99,6 @@ EOT
$message = ($result) ? 'Successfully flushed cache entries.' : $message; $message = ($result) ? 'Successfully flushed cache entries.' : $message;
} }
$output->write($message . PHP_EOL); $output->writeln($message);
} }
} }

View File

@ -25,6 +25,10 @@ use Symfony\Component\Console\Input\InputArgument,
Doctrine\ORM\Tools\Export\ClassMetadataExporter, Doctrine\ORM\Tools\Export\ClassMetadataExporter,
Doctrine\ORM\Tools\ConvertDoctrine1Schema, Doctrine\ORM\Tools\ConvertDoctrine1Schema,
Doctrine\ORM\Tools\EntityGenerator; Doctrine\ORM\Tools\EntityGenerator;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Command\Command;
/** /**
* Command to convert a Doctrine 1 schema to a Doctrine 2 mapping file. * Command to convert a Doctrine 1 schema to a Doctrine 2 mapping file.
@ -37,7 +41,7 @@ use Symfony\Component\Console\Input\InputArgument,
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class ConvertDoctrine1SchemaCommand extends Console\Command\Command class ConvertDoctrine1SchemaCommand extends Command
{ {
/** /**
* @var EntityGenerator * @var EntityGenerator
@ -128,13 +132,8 @@ EOT
); );
} }
/** protected function execute(InputInterface $input, OutputInterface $output)
* @see Console\Command\Command
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$em = $this->getHelper('em')->getEntityManager();
// Process source directories // Process source directories
$fromPaths = array_merge(array($input->getArgument('from-path')), $input->getOption('from')); $fromPaths = array_merge(array($input->getArgument('from-path')), $input->getOption('from'));
@ -145,19 +144,18 @@ EOT
$extend = $input->getOption('extend'); $extend = $input->getOption('extend');
$numSpaces = $input->getOption('num-spaces'); $numSpaces = $input->getOption('num-spaces');
$this->convertDoctrine1Schema($em, $fromPaths, $destPath, $toType, $numSpaces, $extend, $output); $this->convertDoctrine1Schema($fromPaths, $destPath, $toType, $numSpaces, $extend, $output);
} }
/** /**
* @param \Doctrine\ORM\EntityManager $em
* @param array $fromPaths * @param array $fromPaths
* @param string $destPath * @param string $destPath
* @param string $toType * @param string $toType
* @param int $numSpaces * @param int $numSpaces
* @param string|null $extend * @param string|null $extend
* @param Console\Output\OutputInterface $output * @param OutputInterface $output
*/ */
public function convertDoctrine1Schema($em, $fromPaths, $destPath, $toType, $numSpaces, $extend, $output) public function convertDoctrine1Schema(array $fromPaths, $destPath, $toType, $numSpaces, $extend, OutputInterface $output)
{ {
foreach ($fromPaths as &$dirName) { foreach ($fromPaths as &$dirName) {
$dirName = realpath($dirName); $dirName = realpath($dirName);
@ -166,7 +164,9 @@ EOT
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("Doctrine 1.X schema directory '<info>%s</info>' does not exist.", $dirName) sprintf("Doctrine 1.X schema directory '<info>%s</info>' does not exist.", $dirName)
); );
} else if ( ! is_readable($dirName)) { }
if ( ! is_readable($dirName)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("Doctrine 1.X schema directory '<info>%s</info>' does not have read permissions.", $dirName) sprintf("Doctrine 1.X schema directory '<info>%s</info>' does not have read permissions.", $dirName)
); );
@ -177,7 +177,9 @@ EOT
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("Doctrine 2.X mapping destination directory '<info>%s</info>' does not exist.", $destPath) sprintf("Doctrine 2.X mapping destination directory '<info>%s</info>' does not exist.", $destPath)
); );
} else if ( ! is_writable($destPath)) { }
if ( ! is_writable($destPath)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("Doctrine 2.X mapping destination directory '<info>%s</info>' does not have write permissions.", $destPath) sprintf("Doctrine 2.X mapping destination directory '<info>%s</info>' does not have write permissions.", $destPath)
); );
@ -201,20 +203,20 @@ EOT
$metadata = $converter->getMetadata(); $metadata = $converter->getMetadata();
if ($metadata) { if ($metadata) {
$output->write(PHP_EOL); $output->writeln('');
foreach ($metadata as $class) { foreach ($metadata as $class) {
$output->write(sprintf('Processing entity "<info>%s</info>"', $class->name) . PHP_EOL); $output->writeln(sprintf('Processing entity "<info>%s</info>"', $class->name));
} }
$exporter->setMetadata($metadata); $exporter->setMetadata($metadata);
$exporter->export(); $exporter->export();
$output->write(PHP_EOL . sprintf( $output->writeln(PHP_EOL . sprintf(
'Converting Doctrine 1.X schema to "<info>%s</info>" mapping type in "<info>%s</info>"', $toType, $destPath 'Converting Doctrine 1.X schema to "<info>%s</info>" mapping type in "<info>%s</info>"', $toType, $destPath
)); ));
} else { } else {
$output->write('No Metadata Classes to process.' . PHP_EOL); $output->writeln('No Metadata Classes to process.');
} }
} }
} }

View File

@ -21,11 +21,14 @@ namespace Doctrine\ORM\Tools\Console\Command;
use Symfony\Component\Console\Input\InputArgument, use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption, Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console,
Doctrine\ORM\Tools\Console\MetadataFilter, Doctrine\ORM\Tools\Console\MetadataFilter,
Doctrine\ORM\Tools\Export\ClassMetadataExporter, Doctrine\ORM\Tools\Export\ClassMetadataExporter,
Doctrine\ORM\Tools\EntityGenerator, Doctrine\ORM\Tools\EntityGenerator,
Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
use Doctrine\ORM\Mapping\Driver\DatabaseDriver;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Command\Command;
/** /**
* Command to convert your mapping information between the various formats. * Command to convert your mapping information between the various formats.
@ -38,11 +41,8 @@ use Symfony\Component\Console\Input\InputArgument,
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class ConvertMappingCommand extends Console\Command\Command class ConvertMappingCommand extends Command
{ {
/**
* @see Console\Command\Command
*/
protected function configure() protected function configure()
{ {
$this $this
@ -100,15 +100,12 @@ EOT
); );
} }
/** protected function execute(InputInterface $input, OutputInterface $output)
* @see Console\Command\Command
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$em = $this->getHelper('em')->getEntityManager(); $em = $this->getHelper('em')->getEntityManager();
if ($input->getOption('from-database') === true) { if ($input->getOption('from-database') === true) {
$databaseDriver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver( $databaseDriver = new DatabaseDriver(
$em->getConnection()->getSchemaManager() $em->getConnection()->getSchemaManager()
); );
@ -136,7 +133,9 @@ EOT
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("Mapping destination directory '<info>%s</info>' does not exist.", $input->getArgument('dest-path')) sprintf("Mapping destination directory '<info>%s</info>' does not exist.", $input->getArgument('dest-path'))
); );
} else if ( ! is_writable($destPath)) { }
if ( ! is_writable($destPath)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("Mapping destination directory '<info>%s</info>' does not have write permissions.", $destPath) sprintf("Mapping destination directory '<info>%s</info>' does not have write permissions.", $destPath)
); );
@ -145,7 +144,7 @@ EOT
$toType = strtolower($input->getArgument('to-type')); $toType = strtolower($input->getArgument('to-type'));
$exporter = $this->getExporter($toType, $destPath); $exporter = $this->getExporter($toType, $destPath);
$exporter->setOverwriteExistingFiles( ($input->getOption('force') !== false) ); $exporter->setOverwriteExistingFiles($input->getOption('force'));
if ($toType == 'annotation') { if ($toType == 'annotation') {
$entityGenerator = new EntityGenerator(); $entityGenerator = new EntityGenerator();
@ -160,20 +159,26 @@ EOT
if (count($metadata)) { if (count($metadata)) {
foreach ($metadata as $class) { foreach ($metadata as $class) {
$output->write(sprintf('Processing entity "<info>%s</info>"', $class->name) . PHP_EOL); $output->writeln(sprintf('Processing entity "<info>%s</info>"', $class->name));
} }
$exporter->setMetadata($metadata); $exporter->setMetadata($metadata);
$exporter->export(); $exporter->export();
$output->write(PHP_EOL . sprintf( $output->writeln(PHP_EOL . sprintf(
'Exporting "<info>%s</info>" mapping information to "<info>%s</info>"' . PHP_EOL, $toType, $destPath 'Exporting "<info>%s</info>" mapping information to "<info>%s</info>"', $toType, $destPath
)); ));
} else { } else {
$output->write('No Metadata Classes to process.' . PHP_EOL); $output->writeln('No Metadata Classes to process.');
} }
} }
/**
* @param $toType
* @param $destPath
*
* @return \Doctrine\ORM\Tools\Export\Driver\AbstractExporter
*/
protected function getExporter($toType, $destPath) protected function getExporter($toType, $destPath)
{ {
$cme = new ClassMetadataExporter(); $cme = new ClassMetadataExporter();

View File

@ -19,9 +19,10 @@
namespace Doctrine\ORM\Tools\Console\Command; namespace Doctrine\ORM\Tools\Console\Command;
use Symfony\Component\Console\Input\InputArgument, use Symfony\Component\Console\Command\Command;
Symfony\Component\Console\Input\InputOption, use Symfony\Component\Console\Input\InputOption;
Symfony\Component\Console; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/** /**
* Command to ensure that Doctrine is properly configured for a production environment. * Command to ensure that Doctrine is properly configured for a production environment.
@ -35,11 +36,8 @@ use Symfony\Component\Console\Input\InputArgument,
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class EnsureProductionSettingsCommand extends Console\Command\Command class EnsureProductionSettingsCommand extends Command
{ {
/**
* @see Console\Command\Command
*/
protected function configure() protected function configure()
{ {
$this $this
@ -57,14 +55,10 @@ EOT
); );
} }
/** protected function execute(InputInterface $input, OutputInterface $output)
* @see Console\Command\Command
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$em = $this->getHelper('em')->getEntityManager(); $em = $this->getHelper('em')->getEntityManager();
$error = false;
try { try {
$em->getConfiguration()->ensureProductionSettings(); $em->getConfiguration()->ensureProductionSettings();
@ -72,12 +66,11 @@ EOT
$em->getConnection()->connect(); $em->getConnection()->connect();
} }
} catch (\Exception $e) { } catch (\Exception $e) {
$error = true;
$output->writeln('<error>' . $e->getMessage() . '</error>'); $output->writeln('<error>' . $e->getMessage() . '</error>');
return 1;
} }
if ($error === false) { $output->writeln('<info>Environment is correctly configured for production.</info>');
$output->write('<info>Environment is correctly configured for production.</info>' . PHP_EOL);
}
} }
} }

View File

@ -21,10 +21,12 @@ namespace Doctrine\ORM\Tools\Console\Command;
use Symfony\Component\Console\Input\InputArgument, use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption, Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console,
Doctrine\ORM\Tools\Console\MetadataFilter, Doctrine\ORM\Tools\Console\MetadataFilter,
Doctrine\ORM\Tools\EntityGenerator, Doctrine\ORM\Tools\EntityGenerator,
Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Command\Command;
/** /**
* Command to generate entity classes and method stubs from your mapping information. * Command to generate entity classes and method stubs from your mapping information.
@ -37,7 +39,7 @@ use Symfony\Component\Console\Input\InputArgument,
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class GenerateEntitiesCommand extends Console\Command\Command class GenerateEntitiesCommand extends Command
{ {
/** /**
* @see Console\Command\Command * @see Console\Command\Command
@ -106,7 +108,7 @@ EOT
/** /**
* @see Console\Command\Command * @see Console\Command\Command
*/ */
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$em = $this->getHelper('em')->getEntityManager(); $em = $this->getHelper('em')->getEntityManager();
@ -122,7 +124,9 @@ EOT
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("Entities destination directory '<info>%s</info>' does not exist.", $input->getArgument('dest-path')) sprintf("Entities destination directory '<info>%s</info>' does not exist.", $input->getArgument('dest-path'))
); );
} else if ( ! is_writable($destPath)) { }
if ( ! is_writable($destPath)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("Entities destination directory '<info>%s</info>' does not have write permissions.", $destPath) sprintf("Entities destination directory '<info>%s</info>' does not have write permissions.", $destPath)
); );
@ -143,8 +147,8 @@ EOT
} }
foreach ($metadatas as $metadata) { foreach ($metadatas as $metadata) {
$output->write( $output->writeln(
sprintf('Processing entity "<info>%s</info>"', $metadata->name) . PHP_EOL sprintf('Processing entity "<info>%s</info>"', $metadata->name)
); );
} }
@ -152,9 +156,9 @@ EOT
$entityGenerator->generate($metadatas, $destPath); $entityGenerator->generate($metadatas, $destPath);
// Outputting information message // Outputting information message
$output->write(PHP_EOL . sprintf('Entity classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL); $output->writeln(PHP_EOL . sprintf('Entity classes generated to "<info>%s</INFO>"', $destPath));
} else { } else {
$output->write('No Metadata Classes to process.' . PHP_EOL); $output->writeln('No Metadata Classes to process.');
} }
} }
} }

View File

@ -21,8 +21,10 @@ namespace Doctrine\ORM\Tools\Console\Command;
use Symfony\Component\Console\Input\InputArgument, use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption, Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console,
Doctrine\ORM\Tools\Console\MetadataFilter; Doctrine\ORM\Tools\Console\MetadataFilter;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Command\Command;
/** /**
* Command to (re)generate the proxy classes used by doctrine. * Command to (re)generate the proxy classes used by doctrine.
@ -35,11 +37,8 @@ use Symfony\Component\Console\Input\InputArgument,
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class GenerateProxiesCommand extends Console\Command\Command class GenerateProxiesCommand extends Command
{ {
/**
* @see Console\Command\Command
*/
protected function configure() protected function configure()
{ {
$this $this
@ -61,10 +60,7 @@ EOT
); );
} }
/** protected function execute(InputInterface $input, OutputInterface $output)
* @see Console\Command\Command
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$em = $this->getHelper('em')->getEntityManager(); $em = $this->getHelper('em')->getEntityManager();
@ -86,7 +82,9 @@ EOT
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("Proxies destination directory '<info>%s</info>' does not exist.", $em->getConfiguration()->getProxyDir()) sprintf("Proxies destination directory '<info>%s</info>' does not exist.", $em->getConfiguration()->getProxyDir())
); );
} else if ( ! is_writable($destPath)) { }
if ( ! is_writable($destPath)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("Proxies destination directory '<info>%s</info>' does not have write permissions.", $destPath) sprintf("Proxies destination directory '<info>%s</info>' does not have write permissions.", $destPath)
); );
@ -94,8 +92,8 @@ EOT
if ( count($metadatas)) { if ( count($metadatas)) {
foreach ($metadatas as $metadata) { foreach ($metadatas as $metadata) {
$output->write( $output->writeln(
sprintf('Processing entity "<info>%s</info>"', $metadata->name) . PHP_EOL sprintf('Processing entity "<info>%s</info>"', $metadata->name)
); );
} }
@ -103,9 +101,9 @@ EOT
$em->getProxyFactory()->generateProxyClasses($metadatas, $destPath); $em->getProxyFactory()->generateProxyClasses($metadatas, $destPath);
// Outputting information message // Outputting information message
$output->write(PHP_EOL . sprintf('Proxy classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL); $output->writeln(PHP_EOL . sprintf('Proxy classes generated to "<info>%s</INFO>"', $destPath));
} else { } else {
$output->write('No Metadata Classes to process.' . PHP_EOL); $output->writeln('No Metadata Classes to process.');
} }
} }

View File

@ -21,9 +21,11 @@ namespace Doctrine\ORM\Tools\Console\Command;
use Symfony\Component\Console\Input\InputArgument, use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption, Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console,
Doctrine\ORM\Tools\Console\MetadataFilter, Doctrine\ORM\Tools\Console\MetadataFilter,
Doctrine\ORM\Tools\EntityRepositoryGenerator; Doctrine\ORM\Tools\EntityRepositoryGenerator;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Command\Command;
/** /**
* Command to generate repository classes for mapping information. * Command to generate repository classes for mapping information.
@ -36,11 +38,8 @@ use Symfony\Component\Console\Input\InputArgument,
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class GenerateRepositoriesCommand extends Console\Command\Command class GenerateRepositoriesCommand extends Command
{ {
/**
* @see Console\Command\Command
*/
protected function configure() protected function configure()
{ {
$this $this
@ -61,10 +60,7 @@ EOT
); );
} }
/** protected function execute(InputInterface $input, OutputInterface $output)
* @see Console\Command\Command
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$em = $this->getHelper('em')->getEntityManager(); $em = $this->getHelper('em')->getEntityManager();
@ -78,7 +74,9 @@ EOT
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("Entities destination directory '<info>%s</info>' does not exist.", $input->getArgument('dest-path')) sprintf("Entities destination directory '<info>%s</info>' does not exist.", $input->getArgument('dest-path'))
); );
} else if ( ! is_writable($destPath)) { }
if ( ! is_writable($destPath)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("Entities destination directory '<info>%s</info>' does not have write permissions.", $destPath) sprintf("Entities destination directory '<info>%s</info>' does not have write permissions.", $destPath)
); );
@ -90,8 +88,8 @@ EOT
foreach ($metadatas as $metadata) { foreach ($metadatas as $metadata) {
if ($metadata->customRepositoryClassName) { if ($metadata->customRepositoryClassName) {
$output->write( $output->writeln(
sprintf('Processing repository "<info>%s</info>"', $metadata->customRepositoryClassName) . PHP_EOL sprintf('Processing repository "<info>%s</info>"', $metadata->customRepositoryClassName)
); );
$generator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $destPath); $generator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $destPath);
@ -102,12 +100,12 @@ EOT
if ($numRepositories) { if ($numRepositories) {
// Outputting information message // Outputting information message
$output->write(PHP_EOL . sprintf('Repository classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL); $output->writeln(PHP_EOL . sprintf('Repository classes generated to "<info>%s</INFO>"', $destPath) );
} else { } else {
$output->write('No Repository classes were found to be processed.' . PHP_EOL); $output->writeln('No Repository classes were found to be processed.' );
} }
} else { } else {
$output->write('No Metadata Classes to process.' . PHP_EOL); $output->writeln('No Metadata Classes to process.' );
} }
} }
} }

View File

@ -65,6 +65,8 @@ EOT
$output->writeln(sprintf("Found <info>%d</info> mapped entities:", count($entityClassNames))); $output->writeln(sprintf("Found <info>%d</info> mapped entities:", count($entityClassNames)));
$failure = false;
foreach ($entityClassNames as $entityClassName) { foreach ($entityClassNames as $entityClassName) {
try { try {
$entityManager->getClassMetadata($entityClassName); $entityManager->getClassMetadata($entityClassName);
@ -73,7 +75,11 @@ EOT
$output->writeln("<error>[FAIL]</error> ".$entityClassName); $output->writeln("<error>[FAIL]</error> ".$entityClassName);
$output->writeln(sprintf("<comment>%s</comment>", $e->getMessage())); $output->writeln(sprintf("<comment>%s</comment>", $e->getMessage()));
$output->writeln(''); $output->writeln('');
$failure = true;
} }
} }
return $failure ? 1 : 0;
} }
} }

View File

@ -19,9 +19,12 @@
namespace Doctrine\ORM\Tools\Console\Command; namespace Doctrine\ORM\Tools\Console\Command;
use Symfony\Component\Console\Input\InputArgument, use Symfony\Component\Console\Command\Command;
Symfony\Component\Console\Input\InputOption, use Symfony\Component\Console\Input\InputArgument;
Symfony\Component\Console; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Util\Debug;
/** /**
* Command to execute DQL queries in a given EntityManager. * Command to execute DQL queries in a given EntityManager.
@ -34,11 +37,8 @@ use Symfony\Component\Console\Input\InputArgument,
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class RunDqlCommand extends Console\Command\Command class RunDqlCommand extends Command
{ {
/**
* @see Console\Command\Command
*/
protected function configure() protected function configure()
{ {
$this $this
@ -70,10 +70,7 @@ EOT
); );
} }
/** protected function execute(InputInterface $input, OutputInterface $output)
* @see Console\Command\Command
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$em = $this->getHelper('em')->getEntityManager(); $em = $this->getHelper('em')->getEntityManager();
@ -116,6 +113,6 @@ EOT
$resultSet = $query->execute(array(), constant($hydrationMode)); $resultSet = $query->execute(array(), constant($hydrationMode));
\Doctrine\Common\Util\Debug::dump($resultSet, $input->getOption('depth')); Debug::dump($resultSet, $input->getOption('depth'));
} }
} }

View File

@ -48,11 +48,11 @@ abstract class AbstractCommand extends Command
if ( ! empty($metadatas)) { if ( ! empty($metadatas)) {
// Create SchemaTool // Create SchemaTool
$tool = new \Doctrine\ORM\Tools\SchemaTool($em); $tool = new SchemaTool($em);
$this->executeSchemaCommand($input, $output, $tool, $metadatas); return $this->executeSchemaCommand($input, $output, $tool, $metadatas);
} else { } else {
$output->write('No Metadata Classes to process.' . PHP_EOL); $output->writeln('No Metadata Classes to process.');
} }
} }
} }

View File

@ -62,15 +62,15 @@ EOT
protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas) protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
{ {
if ($input->getOption('dump-sql') === true) { if ($input->getOption('dump-sql')) {
$sqls = $schemaTool->getCreateSchemaSql($metadatas); $sqls = $schemaTool->getCreateSchemaSql($metadatas);
$output->write(implode(';' . PHP_EOL, $sqls) . ';' . PHP_EOL); $output->writeln(implode(';' . PHP_EOL, $sqls) . ';');
} else { } else {
$output->write('ATTENTION: This operation should not be executed in a production environment.' . PHP_EOL . PHP_EOL); $output->writeln('ATTENTION: This operation should not be executed in a production environment.' . PHP_EOL);
$output->write('Creating database schema...' . PHP_EOL); $output->writeln('Creating database schema...');
$schemaTool->createSchema($metadatas); $schemaTool->createSchema($metadatas);
$output->write('Database schema created successfully!' . PHP_EOL); $output->writeln('Database schema created successfully!');
} }
} }
} }

View File

@ -71,25 +71,34 @@ EOT
protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas) protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
{ {
$isFullDatabaseDrop = ($input->getOption('full-database')); $isFullDatabaseDrop = $input->getOption('full-database');
if ($input->getOption('dump-sql') === true) { if ($input->getOption('dump-sql')) {
if ($isFullDatabaseDrop) { if ($isFullDatabaseDrop) {
$sqls = $schemaTool->getDropDatabaseSQL(); $sqls = $schemaTool->getDropDatabaseSQL();
} else { } else {
$sqls = $schemaTool->getDropSchemaSQL($metadatas); $sqls = $schemaTool->getDropSchemaSQL($metadatas);
} }
$output->write(implode(';' . PHP_EOL, $sqls) . PHP_EOL); $output->writeln(implode(';' . PHP_EOL, $sqls));
} else if ($input->getOption('force') === true) {
$output->write('Dropping database schema...' . PHP_EOL); return 0;
}
if ($input->getOption('force')) {
$output->writeln('Dropping database schema...');
if ($isFullDatabaseDrop) { if ($isFullDatabaseDrop) {
$schemaTool->dropDatabase(); $schemaTool->dropDatabase();
} else { } else {
$schemaTool->dropSchema($metadatas); $schemaTool->dropSchema($metadatas);
} }
$output->write('Database schema dropped successfully!' . PHP_EOL);
} else { $output->writeln('Database schema dropped successfully!');
$output->write('ATTENTION: This operation should not be executed in a production environment.' . PHP_EOL . PHP_EOL);
return 0;
}
$output->writeln('ATTENTION: This operation should not be executed in a production environment.' . PHP_EOL);
if ($isFullDatabaseDrop) { if ($isFullDatabaseDrop) {
$sqls = $schemaTool->getDropDatabaseSQL(); $sqls = $schemaTool->getDropDatabaseSQL();
@ -98,11 +107,12 @@ EOT
} }
if (count($sqls)) { if (count($sqls)) {
$output->write('Schema-Tool would execute ' . count($sqls) . ' queries to drop the database.' . PHP_EOL); $output->writeln('Schema-Tool would execute ' . count($sqls) . ' queries to drop the database.');
$output->write('Please run the operation with --force to execute these queries or use --dump-sql to see them.' . PHP_EOL); $output->writeln('Please run the operation with --force to execute these queries or use --dump-sql to see them.');
} else {
$output->write('Nothing to drop. The database is empty!' . PHP_EOL); return 1;
} }
}
$output->writeln('Nothing to drop. The database is empty!');
} }
} }

View File

@ -94,28 +94,37 @@ EOT
protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas) protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
{ {
// Defining if update is complete or not (--complete not defined means $saveMode = true) // Defining if update is complete or not (--complete not defined means $saveMode = true)
$saveMode = ($input->getOption('complete') !== true); $saveMode = ! $input->getOption('complete');
$sqls = $schemaTool->getUpdateSchemaSql($metadatas, $saveMode); $sqls = $schemaTool->getUpdateSchemaSql($metadatas, $saveMode);
if (0 == count($sqls)) {
if (0 === count($sqls)) {
$output->writeln('Nothing to update - your database is already in sync with the current entity metadata.'); $output->writeln('Nothing to update - your database is already in sync with the current entity metadata.');
return; return;
} }
$dumpSql = (true === $input->getOption('dump-sql')); $dumpSql = true === $input->getOption('dump-sql');
$force = (true === $input->getOption('force')); $force = true === $input->getOption('force');
if ($dumpSql && $force) { if ($dumpSql && $force) {
throw new \InvalidArgumentException('You can pass either the --dump-sql or the --force option (but not both simultaneously).'); throw new \InvalidArgumentException('You can pass either the --dump-sql or the --force option (but not both simultaneously).');
} }
if ($dumpSql) { if ($dumpSql) {
$output->writeln(implode(';' . PHP_EOL, $sqls)); $output->writeln(implode(';' . PHP_EOL, $sqls));
} else if ($force) {
return 0;
}
if ($force) {
$output->writeln('Updating database schema...'); $output->writeln('Updating database schema...');
$schemaTool->updateSchema($metadatas, $saveMode); $schemaTool->updateSchema($metadatas, $saveMode);
$output->writeln(sprintf('Database schema updated successfully! "<info>%s</info>" queries were executed', count($sqls))); $output->writeln(sprintf('Database schema updated successfully! "<info>%s</info>" queries were executed', count($sqls)));
} else {
return 0;
}
$output->writeln('<comment>ATTENTION</comment>: This operation should not be executed in a production environment.'); $output->writeln('<comment>ATTENTION</comment>: This operation should not be executed in a production environment.');
$output->writeln(' Use the incremental update to detect changes during development and use'); $output->writeln(' Use the incremental update to detect changes during development and use');
$output->writeln(' the SQL DDL provided to manually update your database in production.'); $output->writeln(' the SQL DDL provided to manually update your database in production.');
@ -126,6 +135,7 @@ EOT
$output->writeln(sprintf(' <info>%s --force</info> to execute the command', $this->getName())); $output->writeln(sprintf(' <info>%s --force</info> to execute the command', $this->getName()));
$output->writeln(sprintf(' <info>%s --dump-sql</info> to dump the SQL statements to the screen', $this->getName())); $output->writeln(sprintf(' <info>%s --dump-sql</info> to dump the SQL statements to the screen', $this->getName()));
}
return 1;
} }
} }

View File

@ -19,9 +19,10 @@
namespace Doctrine\ORM\Tools\Console\Command; namespace Doctrine\ORM\Tools\Console\Command;
use Symfony\Component\Console\Input\InputArgument, use Symfony\Component\Console\Command\Command;
Symfony\Component\Console\Input\InputOption, use Symfony\Component\Console\Input\InputInterface;
Symfony\Component\Console; use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Tools\SchemaValidator;
/** /**
* Validate that the current mapping is valid * Validate that the current mapping is valid
@ -34,11 +35,8 @@ use Symfony\Component\Console\Input\InputArgument,
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class ValidateSchemaCommand extends Console\Command\Command class ValidateSchemaCommand extends Command
{ {
/**
* @see Console\Command\Command
*/
protected function configure() protected function configure()
{ {
$this $this
@ -50,35 +48,35 @@ EOT
); );
} }
/** protected function execute(InputInterface $input, OutputInterface $output)
* @see Console\Command\Command
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$em = $this->getHelper('em')->getEntityManager(); $em = $this->getHelper('em')->getEntityManager();
$validator = new \Doctrine\ORM\Tools\SchemaValidator($em); $validator = new SchemaValidator($em);
$errors = $validator->validateMapping(); $errors = $validator->validateMapping();
$exit = 0; $exit = 0;
if ($errors) { if ($errors) {
foreach ($errors as $className => $errorMessages) { foreach ($errors as $className => $errorMessages) {
$output->write("<error>[Mapping] FAIL - The entity-class '" . $className . "' mapping is invalid:</error>\n"); $output->writeln("<error>[Mapping] FAIL - The entity-class '" . $className . "' mapping is invalid:</error>");
foreach ($errorMessages as $errorMessage) { foreach ($errorMessages as $errorMessage) {
$output->write('* ' . $errorMessage . "\n"); $output->writeln('* ' . $errorMessage);
} }
$output->write("\n");
$output->writeln('');
} }
$exit += 1; $exit += 1;
} else { } else {
$output->write('<info>[Mapping] OK - The mapping files are correct.</info>' . "\n"); $output->writeln('<info>[Mapping] OK - The mapping files are correct.</info>');
} }
if (!$validator->schemaInSyncWithMetadata()) { if (!$validator->schemaInSyncWithMetadata()) {
$output->write('<error>[Database] FAIL - The database schema is not in sync with the current mapping file.</error>' . "\n"); $output->writeln('<error>[Database] FAIL - The database schema is not in sync with the current mapping file.</error>');
$exit += 2; $exit += 2;
} else { } else {
$output->write('<info>[Database] OK - The database schema is in sync with the mapping files.</info>' . "\n"); $output->writeln('<info>[Database] OK - The database schema is in sync with the mapping files.</info>');
} }
return $exit; return $exit;

View File

@ -21,6 +21,7 @@ namespace Doctrine\ORM\Tools\Console;
use Symfony\Component\Console\Application; use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Helper\HelperSet;
use Doctrine\ORM\Mapping\Version;
class ConsoleRunner class ConsoleRunner
{ {
@ -33,7 +34,7 @@ class ConsoleRunner
*/ */
static public function run(HelperSet $helperSet, $commands = array()) static public function run(HelperSet $helperSet, $commands = array())
{ {
$cli = new Application('Doctrine Command Line Interface', \Doctrine\ORM\Version::VERSION); $cli = new Application('Doctrine Command Line Interface', Version::VERSION);
$cli->setCatchExceptions(true); $cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet); $cli->setHelperSet($helperSet);
self::addCommands($cli); self::addCommands($cli);

View File

@ -44,7 +44,7 @@ class EntityManagerHelper extends Helper
/** /**
* Constructor * Constructor
* *
* @param \Doctrine\DBAL\Connection $connection Doctrine Database Connection * @param \Doctrine\ORM\EntityManager $em
*/ */
public function __construct(EntityManager $em) public function __construct(EntityManager $em)
{ {

View File

@ -32,41 +32,45 @@ namespace Doctrine\ORM\Tools\Console;
*/ */
class MetadataFilter extends \FilterIterator implements \Countable class MetadataFilter extends \FilterIterator implements \Countable
{ {
private $filter = array();
/** /**
* Filter Metadatas by one or more filter options. * Filter Metadatas by one or more filter options.
* *
* @param array $metadatas * @param array $metadatas
* @param array|string $filter * @param array|string $filter
*
* @return array * @return array
*/ */
static public function filter(array $metadatas, $filter) static public function filter(array $metadatas, $filter)
{ {
$metadatas = new MetadataFilter(new \ArrayIterator($metadatas), $filter); $metadatas = new MetadataFilter(new \ArrayIterator($metadatas), $filter);
return iterator_to_array($metadatas); return iterator_to_array($metadatas);
} }
private $_filter = array();
public function __construct(\ArrayIterator $metadata, $filter) public function __construct(\ArrayIterator $metadata, $filter)
{ {
$this->_filter = (array)$filter; $this->filter = (array) $filter;
parent::__construct($metadata); parent::__construct($metadata);
} }
public function accept() public function accept()
{ {
if (count($this->_filter) == 0) { if (count($this->filter) == 0) {
return true; return true;
} }
$it = $this->getInnerIterator(); $it = $this->getInnerIterator();
$metadata = $it->current(); $metadata = $it->current();
foreach ($this->_filter as $filter) { foreach ($this->filter as $filter) {
if (strpos($metadata->name, $filter) !== false) { if (strpos($metadata->name, $filter) !== false) {
return true; return true;
} }
} }
return false; return false;
} }

View File

@ -20,8 +20,9 @@
namespace Doctrine\ORM\Tools; namespace Doctrine\ORM\Tools;
use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Tools\Export\Driver\AbstractExporter;
use Doctrine\Common\Util\Inflector; use Doctrine\Common\Util\Inflector;
use Doctrine\DBAL\Types\Type;
use Symfony\Component\Yaml\Yaml;
/** /**
* Class to help with converting Doctrine 1 schema files to Doctrine 2 mapping files * Class to help with converting Doctrine 1 schema files to Doctrine 2 mapping files
@ -35,7 +36,8 @@ use Doctrine\Common\Util\Inflector;
*/ */
class ConvertDoctrine1Schema class ConvertDoctrine1Schema
{ {
private $_legacyTypeMap = array( private $from;
private $legacyTypeMap = array(
// TODO: This list may need to be updated // TODO: This list may need to be updated
'clob' => 'text', 'clob' => 'text',
'timestamp' => 'datetime', 'timestamp' => 'datetime',
@ -51,7 +53,7 @@ class ConvertDoctrine1Schema
*/ */
public function __construct($from) public function __construct($from)
{ {
$this->_from = (array) $from; $this->from = (array) $from;
} }
/** /**
@ -63,38 +65,38 @@ class ConvertDoctrine1Schema
public function getMetadata() public function getMetadata()
{ {
$schema = array(); $schema = array();
foreach ($this->_from as $path) { foreach ($this->from as $path) {
if (is_dir($path)) { if (is_dir($path)) {
$files = glob($path . '/*.yml'); $files = glob($path . '/*.yml');
foreach ($files as $file) { foreach ($files as $file) {
$schema = array_merge($schema, (array) \Symfony\Component\Yaml\Yaml::parse($file)); $schema = array_merge($schema, (array) Yaml::parse($file));
} }
} else { } else {
$schema = array_merge($schema, (array) \Symfony\Component\Yaml\Yaml::parse($path)); $schema = array_merge($schema, (array) Yaml::parse($path));
} }
} }
$metadatas = array(); $metadatas = array();
foreach ($schema as $className => $mappingInformation) { foreach ($schema as $className => $mappingInformation) {
$metadatas[] = $this->_convertToClassMetadataInfo($className, $mappingInformation); $metadatas[] = $this->convertToClassMetadataInfo($className, $mappingInformation);
} }
return $metadatas; return $metadatas;
} }
private function _convertToClassMetadataInfo($className, $mappingInformation) private function convertToClassMetadataInfo($className, $mappingInformation)
{ {
$metadata = new ClassMetadataInfo($className); $metadata = new ClassMetadataInfo($className);
$this->_convertTableName($className, $mappingInformation, $metadata); $this->convertTableName($className, $mappingInformation, $metadata);
$this->_convertColumns($className, $mappingInformation, $metadata); $this->convertColumns($className, $mappingInformation, $metadata);
$this->_convertIndexes($className, $mappingInformation, $metadata); $this->convertIndexes($className, $mappingInformation, $metadata);
$this->_convertRelations($className, $mappingInformation, $metadata); $this->convertRelations($className, $mappingInformation, $metadata);
return $metadata; return $metadata;
} }
private function _convertTableName($className, array $model, ClassMetadataInfo $metadata) private function convertTableName($className, array $model, ClassMetadataInfo $metadata)
{ {
if (isset($model['tableName']) && $model['tableName']) { if (isset($model['tableName']) && $model['tableName']) {
$e = explode('.', $model['tableName']); $e = explode('.', $model['tableName']);
@ -108,13 +110,13 @@ class ConvertDoctrine1Schema
} }
} }
private function _convertColumns($className, array $model, ClassMetadataInfo $metadata) private function convertColumns($className, array $model, ClassMetadataInfo $metadata)
{ {
$id = false; $id = false;
if (isset($model['columns']) && $model['columns']) { if (isset($model['columns']) && $model['columns']) {
foreach ($model['columns'] as $name => $column) { foreach ($model['columns'] as $name => $column) {
$fieldMapping = $this->_convertColumn($className, $name, $column, $metadata); $fieldMapping = $this->convertColumn($className, $name, $column, $metadata);
if (isset($fieldMapping['id']) && $fieldMapping['id']) { if (isset($fieldMapping['id']) && $fieldMapping['id']) {
$id = true; $id = true;
@ -134,46 +136,56 @@ class ConvertDoctrine1Schema
} }
} }
private function _convertColumn($className, $name, $column, ClassMetadataInfo $metadata) private function convertColumn($className, $name, $column, ClassMetadataInfo $metadata)
{ {
if (is_string($column)) { if (is_string($column)) {
$string = $column; $string = $column;
$column = array(); $column = array();
$column['type'] = $string; $column['type'] = $string;
} }
if ( ! isset($column['name'])) { if ( ! isset($column['name'])) {
$column['name'] = $name; $column['name'] = $name;
} }
// check if a column alias was used (column_name as field_name) // check if a column alias was used (column_name as field_name)
if (preg_match("/(\w+)\sas\s(\w+)/i", $column['name'], $matches)) { if (preg_match("/(\w+)\sas\s(\w+)/i", $column['name'], $matches)) {
$name = $matches[1]; $name = $matches[1];
$column['name'] = $name; $column['name'] = $name;
$column['alias'] = $matches[2]; $column['alias'] = $matches[2];
} }
if (preg_match("/([a-zA-Z]+)\(([0-9]+)\)/", $column['type'], $matches)) { if (preg_match("/([a-zA-Z]+)\(([0-9]+)\)/", $column['type'], $matches)) {
$column['type'] = $matches[1]; $column['type'] = $matches[1];
$column['length'] = $matches[2]; $column['length'] = $matches[2];
} }
$column['type'] = strtolower($column['type']); $column['type'] = strtolower($column['type']);
// check if legacy column type (1.x) needs to be mapped to a 2.0 one // check if legacy column type (1.x) needs to be mapped to a 2.0 one
if (isset($this->_legacyTypeMap[$column['type']])) { if (isset($this->legacyTypeMap[$column['type']])) {
$column['type'] = $this->_legacyTypeMap[$column['type']]; $column['type'] = $this->legacyTypeMap[$column['type']];
} }
if ( ! \Doctrine\DBAL\Types\Type::hasType($column['type'])) {
if ( ! Type::hasType($column['type'])) {
throw ToolsException::couldNotMapDoctrine1Type($column['type']); throw ToolsException::couldNotMapDoctrine1Type($column['type']);
} }
$fieldMapping = array(); $fieldMapping = array();
if (isset($column['primary'])) { if (isset($column['primary'])) {
$fieldMapping['id'] = true; $fieldMapping['id'] = true;
} }
$fieldMapping['fieldName'] = isset($column['alias']) ? $column['alias'] : $name; $fieldMapping['fieldName'] = isset($column['alias']) ? $column['alias'] : $name;
$fieldMapping['columnName'] = $column['name']; $fieldMapping['columnName'] = $column['name'];
$fieldMapping['type'] = $column['type']; $fieldMapping['type'] = $column['type'];
if (isset($column['length'])) { if (isset($column['length'])) {
$fieldMapping['length'] = $column['length']; $fieldMapping['length'] = $column['length'];
} }
$allowed = array('precision', 'scale', 'unique', 'options', 'notnull', 'version'); $allowed = array('precision', 'scale', 'unique', 'options', 'notnull', 'version');
foreach ($column as $key => $value) { foreach ($column as $key => $value) {
if (in_array($key, $allowed)) { if (in_array($key, $allowed)) {
$fieldMapping[$key] = $value; $fieldMapping[$key] = $value;
@ -186,23 +198,31 @@ class ConvertDoctrine1Schema
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
} elseif (isset($column['sequence'])) { } elseif (isset($column['sequence'])) {
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE);
$definition = array( $definition = array(
'sequenceName' => is_array($column['sequence']) ? $column['sequence']['name']:$column['sequence'] 'sequenceName' => is_array($column['sequence']) ? $column['sequence']['name']:$column['sequence']
); );
if (isset($column['sequence']['size'])) { if (isset($column['sequence']['size'])) {
$definition['allocationSize'] = $column['sequence']['size']; $definition['allocationSize'] = $column['sequence']['size'];
} }
if (isset($column['sequence']['value'])) { if (isset($column['sequence']['value'])) {
$definition['initialValue'] = $column['sequence']['value']; $definition['initialValue'] = $column['sequence']['value'];
} }
$metadata->setSequenceGeneratorDefinition($definition); $metadata->setSequenceGeneratorDefinition($definition);
} }
return $fieldMapping; return $fieldMapping;
} }
private function _convertIndexes($className, array $model, ClassMetadataInfo $metadata) private function convertIndexes($className, array $model, ClassMetadataInfo $metadata)
{ {
if (isset($model['indexes']) && $model['indexes']) { if (empty($model['indexes'])) {
return;
}
foreach ($model['indexes'] as $name => $index) { foreach ($model['indexes'] as $name => $index) {
$type = (isset($index['type']) && $index['type'] == 'unique') $type = (isset($index['type']) && $index['type'] == 'unique')
? 'uniqueConstraints' : 'indexes'; ? 'uniqueConstraints' : 'indexes';
@ -212,11 +232,13 @@ class ConvertDoctrine1Schema
); );
} }
} }
private function convertRelations($className, array $model, ClassMetadataInfo $metadata)
{
if (empty($model['relations'])) {
return;
} }
private function _convertRelations($className, array $model, ClassMetadataInfo $metadata)
{
if (isset($model['relations']) && $model['relations']) {
foreach ($model['relations'] as $name => $relation) { foreach ($model['relations'] as $name => $relation) {
if ( ! isset($relation['alias'])) { if ( ! isset($relation['alias'])) {
$relation['alias'] = $name; $relation['alias'] = $name;
@ -268,4 +290,3 @@ class ConvertDoctrine1Schema
} }
} }
} }
}

View File

@ -19,6 +19,7 @@
namespace Doctrine\ORM\Tools; namespace Doctrine\ORM\Tools;
use Doctrine\Common\Persistence\Proxy;
use Doctrine\ORM\Event\OnFlushEventArgs; use Doctrine\ORM\Event\OnFlushEventArgs;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\PersistentCollection;
@ -73,11 +74,13 @@ class DebugUnitOfWorkListener
fwrite($fh, "Flush Operation [".$this->context."] - Dumping identity map:\n"); fwrite($fh, "Flush Operation [".$this->context."] - Dumping identity map:\n");
foreach ($identityMap as $className => $map) { foreach ($identityMap as $className => $map) {
fwrite($fh, "Class: ". $className . "\n"); fwrite($fh, "Class: ". $className . "\n");
foreach ($map as $entity) { foreach ($map as $entity) {
fwrite($fh, " Entity: " . $this->getIdString($entity, $uow) . " " . spl_object_hash($entity)."\n"); fwrite($fh, " Entity: " . $this->getIdString($entity, $uow) . " " . spl_object_hash($entity)."\n");
fwrite($fh, " Associations:\n"); fwrite($fh, " Associations:\n");
$cm = $em->getClassMetadata($className); $cm = $em->getClassMetadata($className);
foreach ($cm->associationMappings as $field => $assoc) { foreach ($cm->associationMappings as $field => $assoc) {
fwrite($fh, " " . $field . " "); fwrite($fh, " " . $field . " ");
$value = $cm->reflFields[$field]->getValue($entity); $value = $cm->reflFields[$field]->getValue($entity);
@ -86,7 +89,7 @@ class DebugUnitOfWorkListener
if ($value === null) { if ($value === null) {
fwrite($fh, " NULL\n"); fwrite($fh, " NULL\n");
} else { } else {
if ($value instanceof Proxy && !$value->__isInitialized__) { if ($value instanceof Proxy && !$value->__isInitialized()) {
fwrite($fh, "[PROXY] "); fwrite($fh, "[PROXY] ");
} }
@ -98,6 +101,7 @@ class DebugUnitOfWorkListener
fwrite($fh, " NULL\n"); fwrite($fh, " NULL\n");
} elseif ($initialized) { } elseif ($initialized) {
fwrite($fh, "[INITIALIZED] " . $this->getType($value). " " . count($value) . " elements\n"); fwrite($fh, "[INITIALIZED] " . $this->getType($value). " " . count($value) . " elements\n");
foreach ($value as $obj) { foreach ($value as $obj) {
fwrite($fh, " " . $this->getIdString($obj, $uow) . " " . spl_object_hash($obj)."\n"); fwrite($fh, " " . $this->getIdString($obj, $uow) . " " . spl_object_hash($obj)."\n");
} }
@ -111,6 +115,7 @@ class DebugUnitOfWorkListener
} }
} }
} }
fclose($fh); fclose($fh);
} }
@ -118,17 +123,19 @@ class DebugUnitOfWorkListener
{ {
if (is_object($var)) { if (is_object($var)) {
$refl = new \ReflectionObject($var); $refl = new \ReflectionObject($var);
return $refl->getShortname(); return $refl->getShortname();
} else {
return gettype($var);
}
} }
private function getIdString($entity, $uow) return gettype($var);
}
private function getIdString($entity, UnitOfWork $uow)
{ {
if ($uow->isInIdentityMap($entity)) { if ($uow->isInIdentityMap($entity)) {
$ids = $uow->getEntityIdentifier($entity); $ids = $uow->getEntityIdentifier($entity);
$idstring = ""; $idstring = "";
foreach ($ids as $k => $v) { foreach ($ids as $k => $v) {
$idstring .= $k."=".$v; $idstring .= $k."=".$v;
} }
@ -137,6 +144,7 @@ class DebugUnitOfWorkListener
} }
$state = $uow->getEntityState($entity); $state = $uow->getEntityState($entity);
if ($state == UnitOfWork::STATE_NEW) { if ($state == UnitOfWork::STATE_NEW) {
$idstring .= " [NEW]"; $idstring .= " [NEW]";
} elseif ($state == UnitOfWork::STATE_REMOVED) { } elseif ($state == UnitOfWork::STATE_REMOVED) {

View File

@ -19,8 +19,8 @@
namespace Doctrine\ORM\Tools; namespace Doctrine\ORM\Tools;
use Doctrine\Common\Persistence\Mapping\StaticReflectionService;
use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\ClassMetadataFactory;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
/** /**
* The DisconnectedClassMetadataFactory is used to create ClassMetadataInfo objects * The DisconnectedClassMetadataFactory is used to create ClassMetadataInfo objects
@ -40,6 +40,6 @@ class DisconnectedClassMetadataFactory extends ClassMetadataFactory
{ {
public function getReflectionService() public function getReflectionService()
{ {
return new \Doctrine\Common\Persistence\Mapping\StaticReflectionService; return new StaticReflectionService();
} }
} }

View File

@ -345,6 +345,7 @@ public function __construct()
); );
$code = str_replace($placeHolders, $replacements, self::$classTemplate); $code = str_replace($placeHolders, $replacements, self::$classTemplate);
return str_replace('<spaces>', $this->spaces, $code); return str_replace('<spaces>', $this->spaces, $code);
} }
@ -565,6 +566,7 @@ public function __construct()
$inNamespace = false; $inNamespace = false;
$inClass = false; $inClass = false;
for ($i = 0; $i < count($tokens); $i++) { for ($i = 0; $i < count($tokens); $i++) {
$token = $tokens[$i]; $token = $tokens[$i];
if (in_array($token[0], array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT))) { if (in_array($token[0], array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT))) {
@ -624,6 +626,7 @@ public function __construct()
if ($this->extendsClass()) { if ($this->extendsClass()) {
// don't generate method if its already on the base class. // don't generate method if its already on the base class.
$reflClass = new \ReflectionClass($this->getClassToExtend()); $reflClass = new \ReflectionClass($this->getClassToExtend());
if ($reflClass->hasMethod($method)) { if ($reflClass->hasMethod($method)) {
return true; return true;
} }
@ -826,17 +829,20 @@ public function __construct()
if (isset($associationMapping['id']) && $associationMapping['id']) { if (isset($associationMapping['id']) && $associationMapping['id']) {
return false; return false;
} }
if (isset($associationMapping['joinColumns'])) { if (isset($associationMapping['joinColumns'])) {
$joinColumns = $associationMapping['joinColumns']; $joinColumns = $associationMapping['joinColumns'];
} else { } else {
//@todo thereis no way to retreive targetEntity metadata //@todo there is no way to retrieve targetEntity metadata
$joinColumns = array(); $joinColumns = array();
} }
foreach ($joinColumns as $joinColumn) { foreach ($joinColumns as $joinColumn) {
if(isset($joinColumn['nullable']) && !$joinColumn['nullable']) { if(isset($joinColumn['nullable']) && !$joinColumn['nullable']) {
return false; return false;
} }
} }
return true; return true;
} }
@ -902,7 +908,7 @@ public function __construct()
} }
if ($this->hasMethod($methodName, $metadata)) { if ($this->hasMethod($methodName, $metadata)) {
return; return '';
} }
$this->staticReflection[$metadata->name]['methods'][] = $methodName; $this->staticReflection[$metadata->name]['methods'][] = $methodName;
@ -936,7 +942,7 @@ public function __construct()
private function generateLifecycleCallbackMethod($name, $methodName, $metadata) private function generateLifecycleCallbackMethod($name, $methodName, $metadata)
{ {
if ($this->hasMethod($methodName, $metadata)) { if ($this->hasMethod($methodName, $metadata)) {
return; return '';
} }
$this->staticReflection[$metadata->name]['methods'][] = $methodName; $this->staticReflection[$metadata->name]['methods'][] = $methodName;

View File

@ -58,6 +58,7 @@ class <className> extends EntityRepository
'<namespace>' => $this->generateEntityRepositoryNamespace($fullClassName), '<namespace>' => $this->generateEntityRepositoryNamespace($fullClassName),
'<className>' => $className '<className>' => $className
); );
return str_replace(array_keys($variables), array_values($variables), self::$_template); return str_replace(array_keys($variables), array_values($variables), self::$_template);
} }

View File

@ -19,6 +19,7 @@
namespace Doctrine\ORM\Tools\Event; namespace Doctrine\ORM\Tools\Event;
use Doctrine\Common\EventArgs;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
@ -30,33 +31,34 @@ use Doctrine\ORM\EntityManager;
* @since 1.0 * @since 1.0
* @author Benjamin Eberlei <kontakt@beberlei.de> * @author Benjamin Eberlei <kontakt@beberlei.de>
*/ */
class GenerateSchemaEventArgs extends \Doctrine\Common\EventArgs class GenerateSchemaEventArgs extends EventArgs
{ {
private $_em = null; private $em;
private $_schema = null; private $schema;
/** /**
* @param ClassMetadata $classMetadata * @param EntityManager $em
* @param Schema $schema * @param Schema $schema
* @param Table $classTable
*/ */
public function __construct(EntityManager $em, Schema $schema) public function __construct(EntityManager $em, Schema $schema)
{ {
$this->_em = $em; $this->em = $em;
$this->_schema = $schema; $this->schema = $schema;
} }
/** /**
* @return EntityManager * @return EntityManager
*/ */
public function getEntityManager() { public function getEntityManager()
return $this->_em; {
return $this->em;
} }
/** /**
* @return Schema * @return Schema
*/ */
public function getSchema() { public function getSchema()
return $this->_schema; {
return $this->schema;
} }
} }

View File

@ -18,6 +18,7 @@
*/ */
namespace Doctrine\ORM\Tools\Event; namespace Doctrine\ORM\Tools\Event;
use Doctrine\Common\EventArgs;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
@ -30,11 +31,11 @@ use Doctrine\DBAL\Schema\Table;
* @since 1.0 * @since 1.0
* @author Benjamin Eberlei <kontakt@beberlei.de> * @author Benjamin Eberlei <kontakt@beberlei.de>
*/ */
class GenerateSchemaTableEventArgs extends \Doctrine\Common\EventArgs class GenerateSchemaTableEventArgs extends EventArgs
{ {
private $_classMetadata = null; private $classMetadata;
private $_schema = null; private $schema;
private $_classTable = null; private $classTable;
/** /**
* @param ClassMetadata $classMetadata * @param ClassMetadata $classMetadata
@ -43,29 +44,32 @@ class GenerateSchemaTableEventArgs extends \Doctrine\Common\EventArgs
*/ */
public function __construct(ClassMetadata $classMetadata, Schema $schema, Table $classTable) public function __construct(ClassMetadata $classMetadata, Schema $schema, Table $classTable)
{ {
$this->_classMetadata = $classMetadata; $this->classMetadata = $classMetadata;
$this->_schema = $schema; $this->schema = $schema;
$this->_classTable = $classTable; $this->classTable = $classTable;
} }
/** /**
* @return ClassMetadata * @return ClassMetadata
*/ */
public function getClassMetadata() { public function getClassMetadata()
return $this->_classMetadata; {
return $this->classMetadata;
} }
/** /**
* @return Schema * @return Schema
*/ */
public function getSchema() { public function getSchema()
return $this->_schema; {
return $this->schema;
} }
/** /**
* @return Table * @return Table
*/ */
public function getClassTable() { public function getClassTable()
return $this->_classTable; {
return $this->classTable;
} }
} }

View File

@ -20,13 +20,11 @@
namespace Doctrine\ORM\Tools\Export; namespace Doctrine\ORM\Tools\Export;
use Doctrine\ORM\Tools\Export\ExportException; use Doctrine\ORM\Tools\Export\ExportException;
use Doctrine\ORM\EntityManager;
/** /**
* Class used for converting your mapping information between the * Class used for converting your mapping information between the
* supported formats: yaml, xml, and php/annotation. * supported formats: yaml, xml, and php/annotation.
* *
*
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.0 * @since 2.0
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
@ -57,7 +55,8 @@ class ClassMetadataExporter
* *
* @param string $type The type to get (yml, xml, etc.) * @param string $type The type to get (yml, xml, etc.)
* @param string $source The directory where the exporter will export to * @param string $source The directory where the exporter will export to
* @return AbstractExporter $exporter *
* @return Driver\AbstractExporter $exporter
*/ */
public function getExporter($type, $dest = null) public function getExporter($type, $dest = null)
{ {

View File

@ -151,63 +151,49 @@ abstract class AbstractExporter
protected function _getInheritanceTypeString($type) protected function _getInheritanceTypeString($type)
{ {
switch ($type) switch ($type) {
{
case ClassMetadataInfo::INHERITANCE_TYPE_NONE: case ClassMetadataInfo::INHERITANCE_TYPE_NONE:
return 'NONE'; return 'NONE';
break;
case ClassMetadataInfo::INHERITANCE_TYPE_JOINED: case ClassMetadataInfo::INHERITANCE_TYPE_JOINED:
return 'JOINED'; return 'JOINED';
break;
case ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE: case ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE:
return 'SINGLE_TABLE'; return 'SINGLE_TABLE';
break;
case ClassMetadataInfo::INHERITANCE_TYPE_TABLE_PER_CLASS: case ClassMetadataInfo::INHERITANCE_TYPE_TABLE_PER_CLASS:
return 'PER_CLASS'; return 'PER_CLASS';
break;
} }
} }
protected function _getChangeTrackingPolicyString($policy) protected function _getChangeTrackingPolicyString($policy)
{ {
switch ($policy) switch ($policy) {
{
case ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT: case ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT:
return 'DEFERRED_IMPLICIT'; return 'DEFERRED_IMPLICIT';
break;
case ClassMetadataInfo::CHANGETRACKING_DEFERRED_EXPLICIT: case ClassMetadataInfo::CHANGETRACKING_DEFERRED_EXPLICIT:
return 'DEFERRED_EXPLICIT'; return 'DEFERRED_EXPLICIT';
break;
case ClassMetadataInfo::CHANGETRACKING_NOTIFY: case ClassMetadataInfo::CHANGETRACKING_NOTIFY:
return 'NOTIFY'; return 'NOTIFY';
break;
} }
} }
protected function _getIdGeneratorTypeString($type) protected function _getIdGeneratorTypeString($type)
{ {
switch ($type) switch ($type) {
{
case ClassMetadataInfo::GENERATOR_TYPE_AUTO: case ClassMetadataInfo::GENERATOR_TYPE_AUTO:
return 'AUTO'; return 'AUTO';
break;
case ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE: case ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE:
return 'SEQUENCE'; return 'SEQUENCE';
break;
case ClassMetadataInfo::GENERATOR_TYPE_TABLE: case ClassMetadataInfo::GENERATOR_TYPE_TABLE:
return 'TABLE'; return 'TABLE';
break;
case ClassMetadataInfo::GENERATOR_TYPE_IDENTITY: case ClassMetadataInfo::GENERATOR_TYPE_IDENTITY:
return 'IDENTITY'; return 'IDENTITY';
break;
} }
} }
} }

View File

@ -47,6 +47,7 @@ class AnnotationExporter extends AbstractExporter
if ( ! $this->_entityGenerator) { if ( ! $this->_entityGenerator) {
throw new \RuntimeException('For the AnnotationExporter you must set an EntityGenerator instance with the setEntityGenerator() method.'); throw new \RuntimeException('For the AnnotationExporter you must set an EntityGenerator instance with the setEntityGenerator() method.');
} }
$this->_entityGenerator->setGenerateAnnotations(true); $this->_entityGenerator->setGenerateAnnotations(true);
$this->_entityGenerator->setGenerateStubMethods(false); $this->_entityGenerator->setGenerateStubMethods(false);
$this->_entityGenerator->setRegenerateEntityIfExists(false); $this->_entityGenerator->setRegenerateEntityIfExists(false);

View File

@ -24,7 +24,6 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo;
/** /**
* ClassMetadata exporter for Doctrine XML mapping files * ClassMetadata exporter for Doctrine XML mapping files
* *
*
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.0 * @since 2.0
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
@ -79,6 +78,7 @@ class XmlExporter extends AbstractExporter
$discriminatorColumnXml = $root->addChild('discriminator-column'); $discriminatorColumnXml = $root->addChild('discriminator-column');
$discriminatorColumnXml->addAttribute('name', $metadata->discriminatorColumn['name']); $discriminatorColumnXml->addAttribute('name', $metadata->discriminatorColumn['name']);
$discriminatorColumnXml->addAttribute('type', $metadata->discriminatorColumn['type']); $discriminatorColumnXml->addAttribute('type', $metadata->discriminatorColumn['type']);
if (isset($metadata->discriminatorColumn['length'])) { if (isset($metadata->discriminatorColumn['length'])) {
$discriminatorColumnXml->addAttribute('length', $metadata->discriminatorColumn['length']); $discriminatorColumnXml->addAttribute('length', $metadata->discriminatorColumn['length']);
} }
@ -86,6 +86,7 @@ class XmlExporter extends AbstractExporter
if ($metadata->discriminatorMap) { if ($metadata->discriminatorMap) {
$discriminatorMapXml = $root->addChild('discriminator-map'); $discriminatorMapXml = $root->addChild('discriminator-map');
foreach ($metadata->discriminatorMap as $value => $className) { foreach ($metadata->discriminatorMap as $value => $className) {
$discriminatorMappingXml = $discriminatorMapXml->addChild('discriminator-mapping'); $discriminatorMappingXml = $discriminatorMapXml->addChild('discriminator-mapping');
$discriminatorMappingXml->addAttribute('value', $value); $discriminatorMappingXml->addAttribute('value', $value);
@ -94,6 +95,7 @@ class XmlExporter extends AbstractExporter
} }
$trackingPolicy = $this->_getChangeTrackingPolicyString($metadata->changeTrackingPolicy); $trackingPolicy = $this->_getChangeTrackingPolicyString($metadata->changeTrackingPolicy);
if ( $trackingPolicy != 'DEFERRED_IMPLICIT') { if ( $trackingPolicy != 'DEFERRED_IMPLICIT') {
$root->addChild('change-tracking-policy', $trackingPolicy); $root->addChild('change-tracking-policy', $trackingPolicy);
} }
@ -137,12 +139,15 @@ class XmlExporter extends AbstractExporter
$idXml = $root->addChild('id'); $idXml = $root->addChild('id');
$idXml->addAttribute('name', $field['fieldName']); $idXml->addAttribute('name', $field['fieldName']);
$idXml->addAttribute('type', $field['type']); $idXml->addAttribute('type', $field['type']);
if (isset($field['columnName'])) { if (isset($field['columnName'])) {
$idXml->addAttribute('column', $field['columnName']); $idXml->addAttribute('column', $field['columnName']);
} }
if (isset($field['associationKey']) && $field['associationKey']) { if (isset($field['associationKey']) && $field['associationKey']) {
$idXml->addAttribute('association-key', 'true'); $idXml->addAttribute('association-key', 'true');
} }
if ($idGeneratorType = $this->_getIdGeneratorTypeString($metadata->generatorType)) { if ($idGeneratorType = $this->_getIdGeneratorTypeString($metadata->generatorType)) {
$generatorXml = $idXml->addChild('generator'); $generatorXml = $idXml->addChild('generator');
$generatorXml->addAttribute('strategy', $idGeneratorType); $generatorXml->addAttribute('strategy', $idGeneratorType);
@ -155,50 +160,63 @@ class XmlExporter extends AbstractExporter
$fieldXml = $root->addChild('field'); $fieldXml = $root->addChild('field');
$fieldXml->addAttribute('name', $field['fieldName']); $fieldXml->addAttribute('name', $field['fieldName']);
$fieldXml->addAttribute('type', $field['type']); $fieldXml->addAttribute('type', $field['type']);
if (isset($field['columnName'])) { if (isset($field['columnName'])) {
$fieldXml->addAttribute('column', $field['columnName']); $fieldXml->addAttribute('column', $field['columnName']);
} }
if (isset($field['length'])) { if (isset($field['length'])) {
$fieldXml->addAttribute('length', $field['length']); $fieldXml->addAttribute('length', $field['length']);
} }
if (isset($field['precision'])) { if (isset($field['precision'])) {
$fieldXml->addAttribute('precision', $field['precision']); $fieldXml->addAttribute('precision', $field['precision']);
} }
if (isset($field['scale'])) { if (isset($field['scale'])) {
$fieldXml->addAttribute('scale', $field['scale']); $fieldXml->addAttribute('scale', $field['scale']);
} }
if (isset($field['unique']) && $field['unique']) { if (isset($field['unique']) && $field['unique']) {
$fieldXml->addAttribute('unique', $field['unique']); $fieldXml->addAttribute('unique', $field['unique']);
} }
if (isset($field['options'])) { if (isset($field['options'])) {
$optionsXml = $fieldXml->addChild('options'); $optionsXml = $fieldXml->addChild('options');
foreach ($field['options'] as $key => $value) { foreach ($field['options'] as $key => $value) {
$optionsXml->addAttribute($key, $value); $optionsXml->addAttribute($key, $value);
} }
} }
if (isset($field['version'])) { if (isset($field['version'])) {
$fieldXml->addAttribute('version', $field['version']); $fieldXml->addAttribute('version', $field['version']);
} }
if (isset($field['columnDefinition'])) { if (isset($field['columnDefinition'])) {
$fieldXml->addAttribute('column-definition', $field['columnDefinition']); $fieldXml->addAttribute('column-definition', $field['columnDefinition']);
} }
if (isset($field['nullable'])) { if (isset($field['nullable'])) {
$fieldXml->addAttribute('nullable', $field['nullable'] ? 'true' : 'false'); $fieldXml->addAttribute('nullable', $field['nullable'] ? 'true' : 'false');
} }
} }
} }
$orderMap = array( $orderMap = array(
ClassMetadataInfo::ONE_TO_ONE, ClassMetadataInfo::ONE_TO_ONE,
ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::ONE_TO_MANY,
ClassMetadataInfo::MANY_TO_ONE, ClassMetadataInfo::MANY_TO_ONE,
ClassMetadataInfo::MANY_TO_MANY, ClassMetadataInfo::MANY_TO_MANY,
); );
uasort($metadata->associationMappings, function($m1, $m2) use (&$orderMap){ uasort($metadata->associationMappings, function($m1, $m2) use (&$orderMap){
$a1 = array_search($m1['type'], $orderMap); $a1 = array_search($m1['type'], $orderMap);
$a2 = array_search($m2['type'], $orderMap); $a2 = array_search($m2['type'], $orderMap);
return strcmp($a1, $a2); return strcmp($a1, $a2);
}); });
foreach ($metadata->associationMappings as $name => $associationMapping) {
foreach ($metadata->associationMappings as $associationMapping) {
if ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_ONE) { if ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_ONE) {
$associationMappingXml = $root->addChild('one-to-one'); $associationMappingXml = $root->addChild('one-to-one');
} elseif ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_ONE) { } elseif ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_ONE) {
@ -215,41 +233,53 @@ class XmlExporter extends AbstractExporter
if (isset($associationMapping['mappedBy'])) { if (isset($associationMapping['mappedBy'])) {
$associationMappingXml->addAttribute('mapped-by', $associationMapping['mappedBy']); $associationMappingXml->addAttribute('mapped-by', $associationMapping['mappedBy']);
} }
if (isset($associationMapping['inversedBy'])) { if (isset($associationMapping['inversedBy'])) {
$associationMappingXml->addAttribute('inversed-by', $associationMapping['inversedBy']); $associationMappingXml->addAttribute('inversed-by', $associationMapping['inversedBy']);
} }
if (isset($associationMapping['indexBy'])) { if (isset($associationMapping['indexBy'])) {
$associationMappingXml->addAttribute('index-by', $associationMapping['indexBy']); $associationMappingXml->addAttribute('index-by', $associationMapping['indexBy']);
} }
if (isset($associationMapping['orphanRemoval']) && $associationMapping['orphanRemoval'] !== false) { if (isset($associationMapping['orphanRemoval']) && $associationMapping['orphanRemoval'] !== false) {
$associationMappingXml->addAttribute('orphan-removal', 'true'); $associationMappingXml->addAttribute('orphan-removal', 'true');
} }
if (isset($associationMapping['joinTable']) && $associationMapping['joinTable']) { if (isset($associationMapping['joinTable']) && $associationMapping['joinTable']) {
$joinTableXml = $associationMappingXml->addChild('join-table'); $joinTableXml = $associationMappingXml->addChild('join-table');
$joinTableXml->addAttribute('name', $associationMapping['joinTable']['name']); $joinTableXml->addAttribute('name', $associationMapping['joinTable']['name']);
$joinColumnsXml = $joinTableXml->addChild('join-columns'); $joinColumnsXml = $joinTableXml->addChild('join-columns');
foreach ($associationMapping['joinTable']['joinColumns'] as $joinColumn) { foreach ($associationMapping['joinTable']['joinColumns'] as $joinColumn) {
$joinColumnXml = $joinColumnsXml->addChild('join-column'); $joinColumnXml = $joinColumnsXml->addChild('join-column');
$joinColumnXml->addAttribute('name', $joinColumn['name']); $joinColumnXml->addAttribute('name', $joinColumn['name']);
$joinColumnXml->addAttribute('referenced-column-name', $joinColumn['referencedColumnName']); $joinColumnXml->addAttribute('referenced-column-name', $joinColumn['referencedColumnName']);
if (isset($joinColumn['onDelete'])) { if (isset($joinColumn['onDelete'])) {
$joinColumnXml->addAttribute('on-delete', $joinColumn['onDelete']); $joinColumnXml->addAttribute('on-delete', $joinColumn['onDelete']);
} }
} }
$inverseJoinColumnsXml = $joinTableXml->addChild('inverse-join-columns'); $inverseJoinColumnsXml = $joinTableXml->addChild('inverse-join-columns');
foreach ($associationMapping['joinTable']['inverseJoinColumns'] as $inverseJoinColumn) { foreach ($associationMapping['joinTable']['inverseJoinColumns'] as $inverseJoinColumn) {
$inverseJoinColumnXml = $inverseJoinColumnsXml->addChild('join-column'); $inverseJoinColumnXml = $inverseJoinColumnsXml->addChild('join-column');
$inverseJoinColumnXml->addAttribute('name', $inverseJoinColumn['name']); $inverseJoinColumnXml->addAttribute('name', $inverseJoinColumn['name']);
$inverseJoinColumnXml->addAttribute('referenced-column-name', $inverseJoinColumn['referencedColumnName']); $inverseJoinColumnXml->addAttribute('referenced-column-name', $inverseJoinColumn['referencedColumnName']);
if (isset($inverseJoinColumn['onDelete'])) { if (isset($inverseJoinColumn['onDelete'])) {
$inverseJoinColumnXml->addAttribute('on-delete', $inverseJoinColumn['onDelete']); $inverseJoinColumnXml->addAttribute('on-delete', $inverseJoinColumn['onDelete']);
} }
if (isset($inverseJoinColumn['columnDefinition'])) { if (isset($inverseJoinColumn['columnDefinition'])) {
$inverseJoinColumnXml->addAttribute('column-definition', $inverseJoinColumn['columnDefinition']); $inverseJoinColumnXml->addAttribute('column-definition', $inverseJoinColumn['columnDefinition']);
} }
if (isset($inverseJoinColumn['nullable'])) { if (isset($inverseJoinColumn['nullable'])) {
$inverseJoinColumnXml->addAttribute('nullable', $inverseJoinColumn['nullable']); $inverseJoinColumnXml->addAttribute('nullable', $inverseJoinColumn['nullable']);
} }
if (isset($inverseJoinColumn['orderBy'])) { if (isset($inverseJoinColumn['orderBy'])) {
$inverseJoinColumnXml->addAttribute('order-by', $inverseJoinColumn['orderBy']); $inverseJoinColumnXml->addAttribute('order-by', $inverseJoinColumn['orderBy']);
} }
@ -257,16 +287,20 @@ class XmlExporter extends AbstractExporter
} }
if (isset($associationMapping['joinColumns'])) { if (isset($associationMapping['joinColumns'])) {
$joinColumnsXml = $associationMappingXml->addChild('join-columns'); $joinColumnsXml = $associationMappingXml->addChild('join-columns');
foreach ($associationMapping['joinColumns'] as $joinColumn) { foreach ($associationMapping['joinColumns'] as $joinColumn) {
$joinColumnXml = $joinColumnsXml->addChild('join-column'); $joinColumnXml = $joinColumnsXml->addChild('join-column');
$joinColumnXml->addAttribute('name', $joinColumn['name']); $joinColumnXml->addAttribute('name', $joinColumn['name']);
$joinColumnXml->addAttribute('referenced-column-name', $joinColumn['referencedColumnName']); $joinColumnXml->addAttribute('referenced-column-name', $joinColumn['referencedColumnName']);
if (isset($joinColumn['onDelete'])) { if (isset($joinColumn['onDelete'])) {
$joinColumnXml->addAttribute('on-delete', $joinColumn['onDelete']); $joinColumnXml->addAttribute('on-delete', $joinColumn['onDelete']);
} }
if (isset($joinColumn['columnDefinition'])) { if (isset($joinColumn['columnDefinition'])) {
$joinColumnXml->addAttribute('column-definition', $joinColumn['columnDefinition']); $joinColumnXml->addAttribute('column-definition', $joinColumn['columnDefinition']);
} }
if (isset($joinColumn['nullable'])) { if (isset($joinColumn['nullable'])) {
$joinColumnXml->addAttribute('nullable', $joinColumn['nullable']); $joinColumnXml->addAttribute('nullable', $joinColumn['nullable']);
} }
@ -274,6 +308,7 @@ class XmlExporter extends AbstractExporter
} }
if (isset($associationMapping['orderBy'])) { if (isset($associationMapping['orderBy'])) {
$orderByXml = $associationMappingXml->addChild('order-by'); $orderByXml = $associationMappingXml->addChild('order-by');
foreach ($associationMapping['orderBy'] as $name => $direction) { foreach ($associationMapping['orderBy'] as $name => $direction) {
$orderByFieldXml = $orderByXml->addChild('order-by-field'); $orderByFieldXml = $orderByXml->addChild('order-by-field');
$orderByFieldXml->addAttribute('name', $name); $orderByFieldXml->addAttribute('name', $name);
@ -281,26 +316,34 @@ class XmlExporter extends AbstractExporter
} }
} }
$cascade = array(); $cascade = array();
if ($associationMapping['isCascadeRemove']) { if ($associationMapping['isCascadeRemove']) {
$cascade[] = 'cascade-remove'; $cascade[] = 'cascade-remove';
} }
if ($associationMapping['isCascadePersist']) { if ($associationMapping['isCascadePersist']) {
$cascade[] = 'cascade-persist'; $cascade[] = 'cascade-persist';
} }
if ($associationMapping['isCascadeRefresh']) { if ($associationMapping['isCascadeRefresh']) {
$cascade[] = 'cascade-refresh'; $cascade[] = 'cascade-refresh';
} }
if ($associationMapping['isCascadeMerge']) { if ($associationMapping['isCascadeMerge']) {
$cascade[] = 'cascade-merge'; $cascade[] = 'cascade-merge';
} }
if ($associationMapping['isCascadeDetach']) { if ($associationMapping['isCascadeDetach']) {
$cascade[] = 'cascade-detach'; $cascade[] = 'cascade-detach';
} }
if (count($cascade) === 5) { if (count($cascade) === 5) {
$cascade = array('cascade-all'); $cascade = array('cascade-all');
} }
if ($cascade) { if ($cascade) {
$cascadeXml = $associationMappingXml->addChild('cascade'); $cascadeXml = $associationMappingXml->addChild('cascade');
foreach ($cascade as $type) { foreach ($cascade as $type) {
$cascadeXml->addChild($type); $cascadeXml->addChild($type);
} }
@ -309,6 +352,7 @@ class XmlExporter extends AbstractExporter
if (isset($metadata->lifecycleCallbacks) && count($metadata->lifecycleCallbacks)>0) { if (isset($metadata->lifecycleCallbacks) && count($metadata->lifecycleCallbacks)>0) {
$lifecycleCallbacksXml = $root->addChild('lifecycle-callbacks'); $lifecycleCallbacksXml = $root->addChild('lifecycle-callbacks');
foreach ($metadata->lifecycleCallbacks as $name => $methods) { foreach ($metadata->lifecycleCallbacks as $name => $methods) {
foreach ($methods as $method) { foreach ($methods as $method) {
$lifecycleCallbackXml = $lifecycleCallbacksXml->addChild('lifecycle-callback'); $lifecycleCallbackXml = $lifecycleCallbacksXml->addChild('lifecycle-callback');
@ -323,6 +367,7 @@ class XmlExporter extends AbstractExporter
/** /**
* @param \SimpleXMLElement $simpleXml * @param \SimpleXMLElement $simpleXml
*
* @return string $xml * @return string $xml
*/ */
private function _asXml($simpleXml) private function _asXml($simpleXml)
@ -331,7 +376,6 @@ class XmlExporter extends AbstractExporter
$dom->loadXML($simpleXml->asXML()); $dom->loadXML($simpleXml->asXML());
$dom->formatOutput = true; $dom->formatOutput = true;
$result = $dom->saveXML(); return $dom->saveXML();
return $result;
} }
} }

View File

@ -19,6 +19,7 @@
namespace Doctrine\ORM\Tools\Export\Driver; namespace Doctrine\ORM\Tools\Export\Driver;
use Symfony\Component\Yaml\Yaml;
use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\ClassMetadataInfo;
/** /**
@ -59,6 +60,7 @@ class YamlExporter extends AbstractExporter
} }
$inheritanceType = $metadata->inheritanceType; $inheritanceType = $metadata->inheritanceType;
if ($inheritanceType !== ClassMetadataInfo::INHERITANCE_TYPE_NONE) { if ($inheritanceType !== ClassMetadataInfo::INHERITANCE_TYPE_NONE) {
$array['inheritanceType'] = $this->_getInheritanceTypeString($inheritanceType); $array['inheritanceType'] = $this->_getInheritanceTypeString($inheritanceType);
} }
@ -92,10 +94,8 @@ class YamlExporter extends AbstractExporter
$ids = array(); $ids = array();
foreach ($fieldMappings as $name => $fieldMapping) { foreach ($fieldMappings as $name => $fieldMapping) {
$fieldMapping['column'] = $fieldMapping['columnName']; $fieldMapping['column'] = $fieldMapping['columnName'];
unset(
$fieldMapping['columnName'], unset($fieldMapping['columnName'], $fieldMapping['fieldName']);
$fieldMapping['fieldName']
);
if ($fieldMapping['column'] == $name) { if ($fieldMapping['column'] == $name) {
unset($fieldMapping['column']); unset($fieldMapping['column']);
@ -127,24 +127,30 @@ class YamlExporter extends AbstractExporter
foreach ($metadata->associationMappings as $name => $associationMapping) { foreach ($metadata->associationMappings as $name => $associationMapping) {
$cascade = array(); $cascade = array();
if ($associationMapping['isCascadeRemove']) { if ($associationMapping['isCascadeRemove']) {
$cascade[] = 'remove'; $cascade[] = 'remove';
} }
if ($associationMapping['isCascadePersist']) { if ($associationMapping['isCascadePersist']) {
$cascade[] = 'persist'; $cascade[] = 'persist';
} }
if ($associationMapping['isCascadeRefresh']) { if ($associationMapping['isCascadeRefresh']) {
$cascade[] = 'refresh'; $cascade[] = 'refresh';
} }
if ($associationMapping['isCascadeMerge']) { if ($associationMapping['isCascadeMerge']) {
$cascade[] = 'merge'; $cascade[] = 'merge';
} }
if ($associationMapping['isCascadeDetach']) { if ($associationMapping['isCascadeDetach']) {
$cascade[] = 'detach'; $cascade[] = 'detach';
} }
if (count($cascade) === 5) { if (count($cascade) === 5) {
$cascade = array('all'); $cascade = array('all');
} }
$associationMappingArray = array( $associationMappingArray = array(
'targetEntity' => $associationMapping['targetEntity'], 'targetEntity' => $associationMapping['targetEntity'],
'cascade' => $cascade, 'cascade' => $cascade,
@ -153,12 +159,15 @@ class YamlExporter extends AbstractExporter
if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) { if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) {
$joinColumns = $associationMapping['joinColumns']; $joinColumns = $associationMapping['joinColumns'];
$newJoinColumns = array(); $newJoinColumns = array();
foreach ($joinColumns as $joinColumn) { foreach ($joinColumns as $joinColumn) {
$newJoinColumns[$joinColumn['name']]['referencedColumnName'] = $joinColumn['referencedColumnName']; $newJoinColumns[$joinColumn['name']]['referencedColumnName'] = $joinColumn['referencedColumnName'];
if (isset($joinColumn['onDelete'])) { if (isset($joinColumn['onDelete'])) {
$newJoinColumns[$joinColumn['name']]['onDelete'] = $joinColumn['onDelete']; $newJoinColumns[$joinColumn['name']]['onDelete'] = $joinColumn['onDelete'];
} }
} }
$oneToOneMappingArray = array( $oneToOneMappingArray = array(
'mappedBy' => $associationMapping['mappedBy'], 'mappedBy' => $associationMapping['mappedBy'],
'inversedBy' => $associationMapping['inversedBy'], 'inversedBy' => $associationMapping['inversedBy'],
@ -173,7 +182,6 @@ class YamlExporter extends AbstractExporter
} else { } else {
$array['manyToOne'][$name] = $associationMappingArray; $array['manyToOne'][$name] = $associationMappingArray;
} }
} elseif ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_MANY) { } elseif ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_MANY) {
$oneToManyMappingArray = array( $oneToManyMappingArray = array(
'mappedBy' => $associationMapping['mappedBy'], 'mappedBy' => $associationMapping['mappedBy'],
@ -200,6 +208,6 @@ class YamlExporter extends AbstractExporter
$array['lifecycleCallbacks'] = $metadata->lifecycleCallbacks; $array['lifecycleCallbacks'] = $metadata->lifecycleCallbacks;
} }
return \Symfony\Component\Yaml\Yaml::dump(array($metadata->name => $array), 10); return Yaml::dump(array($metadata->name => $array), 10);
} }
} }

View File

@ -148,6 +148,7 @@ class Paginator implements \Countable, \IteratorAggregate
$this->count = 0; $this->count = 0;
} }
} }
return $this->count; return $this->count;
} }
@ -196,6 +197,7 @@ class Paginator implements \Countable, \IteratorAggregate
->getResult($this->query->getHydrationMode()) ->getResult($this->query->getHydrationMode())
; ;
} }
return new \ArrayIterator($result); return new \ArrayIterator($result);
} }

View File

@ -61,6 +61,7 @@ class ResolveTargetEntityListener
public function loadClassMetadata(LoadClassMetadataEventArgs $args) public function loadClassMetadata(LoadClassMetadataEventArgs $args)
{ {
$cm = $args->getClassMetadata(); $cm = $args->getClassMetadata();
foreach ($cm->associationMappings as $mapping) { foreach ($cm->associationMappings as $mapping) {
if (isset($this->resolveTargetEntities[$mapping['targetEntity']])) { if (isset($this->resolveTargetEntities[$mapping['targetEntity']])) {
$this->remapAssociation($cm, $mapping); $this->remapAssociation($cm, $mapping);

View File

@ -21,7 +21,10 @@ namespace Doctrine\ORM\Tools;
use Doctrine\ORM\ORMException; use Doctrine\ORM\ORMException;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector;
use Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets; use Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
@ -33,7 +36,6 @@ use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
* The SchemaTool is a tool to create/drop/update database schemas based on * The SchemaTool is a tool to create/drop/update database schemas based on
* <tt>ClassMetadata</tt> class descriptors. * <tt>ClassMetadata</tt> class descriptors.
* *
*
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.0 * @since 2.0
* @author Guilherme Blanco <guilhermeblanco@hotmail.com> * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
@ -146,11 +148,10 @@ class SchemaTool
} }
$table = $schema->createTable($this->quoteStrategy->getTableName($class, $this->platform)); $table = $schema->createTable($this->quoteStrategy->getTableName($class, $this->platform));
$columns = array(); // table columns
if ($class->isInheritanceTypeSingleTable()) { if ($class->isInheritanceTypeSingleTable()) {
$columns = $this->_gatherColumns($class, $table); $this->gatherColumns($class, $table);
$this->_gatherRelationsSql($class, $table, $schema); $this->gatherRelationsSql($class, $table, $schema);
// Add the discriminator column // Add the discriminator column
$this->addDiscriminatorColumnDefinition($class, $table); $this->addDiscriminatorColumnDefinition($class, $table);
@ -163,8 +164,8 @@ class SchemaTool
foreach ($class->subClasses as $subClassName) { foreach ($class->subClasses as $subClassName) {
$subClass = $this->em->getClassMetadata($subClassName); $subClass = $this->em->getClassMetadata($subClassName);
$this->_gatherColumns($subClass, $table); $this->gatherColumns($subClass, $table);
$this->_gatherRelationsSql($subClass, $table, $schema); $this->gatherRelationsSql($subClass, $table, $schema);
$processedClasses[$subClassName] = true; $processedClasses[$subClassName] = true;
} }
} elseif ($class->isInheritanceTypeJoined()) { } elseif ($class->isInheritanceTypeJoined()) {
@ -173,7 +174,7 @@ class SchemaTool
foreach ($class->fieldMappings as $fieldName => $mapping) { foreach ($class->fieldMappings as $fieldName => $mapping) {
if ( ! isset($mapping['inherited'])) { if ( ! isset($mapping['inherited'])) {
$columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform); $columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform);
$this->_gatherColumn($class, $mapping, $table); $this->gatherColumn($class, $mapping, $table);
if ($class->isIdentifier($fieldName)) { if ($class->isIdentifier($fieldName)) {
$pkColumns[] = $columnName; $pkColumns[] = $columnName;
@ -181,7 +182,7 @@ class SchemaTool
} }
} }
$this->_gatherRelationsSql($class, $table, $schema); $this->gatherRelationsSql($class, $table, $schema);
// Add the discriminator column only to the root table // Add the discriminator column only to the root table
if ($class->name == $class->rootEntityName) { if ($class->name == $class->rootEntityName) {
@ -190,7 +191,7 @@ class SchemaTool
// Add an ID FK column to child tables // Add an ID FK column to child tables
/* @var \Doctrine\ORM\Mapping\ClassMetadata $class */ /* @var \Doctrine\ORM\Mapping\ClassMetadata $class */
$idMapping = $class->fieldMappings[$class->identifier[0]]; $idMapping = $class->fieldMappings[$class->identifier[0]];
$this->_gatherColumn($class, $idMapping, $table); $this->gatherColumn($class, $idMapping, $table);
$columnName = $this->quoteStrategy->getColumnName($class->identifier[0], $class, $this->platform); $columnName = $this->quoteStrategy->getColumnName($class->identifier[0], $class, $this->platform);
// TODO: This seems rather hackish, can we optimize it? // TODO: This seems rather hackish, can we optimize it?
$table->getColumn($columnName)->setAutoincrement(false); $table->getColumn($columnName)->setAutoincrement(false);
@ -198,7 +199,7 @@ class SchemaTool
$pkColumns[] = $columnName; $pkColumns[] = $columnName;
// Add a FK constraint on the ID column // Add a FK constraint on the ID column
$table->addUnnamedForeignKeyConstraint( $table->addForeignKeyConstraint(
$this->quoteStrategy->getTableName($this->em->getClassMetadata($class->rootEntityName), $this->platform), $this->quoteStrategy->getTableName($this->em->getClassMetadata($class->rootEntityName), $this->platform),
array($columnName), array($columnName), array('onDelete' => 'CASCADE') array($columnName), array($columnName), array('onDelete' => 'CASCADE')
); );
@ -209,8 +210,8 @@ class SchemaTool
} elseif ($class->isInheritanceTypeTablePerClass()) { } elseif ($class->isInheritanceTypeTablePerClass()) {
throw ORMException::notSupported(); throw ORMException::notSupported();
} else { } else {
$this->_gatherColumns($class, $table); $this->gatherColumns($class, $table);
$this->_gatherRelationsSql($class, $table, $schema); $this->gatherRelationsSql($class, $table, $schema);
} }
$pkColumns = array(); $pkColumns = array();
@ -283,10 +284,11 @@ class SchemaTool
* column of a class. * column of a class.
* *
* @param ClassMetadata $class * @param ClassMetadata $class
* @param Table $table
* @return array The portable column definition of the discriminator column as required by * @return array The portable column definition of the discriminator column as required by
* the DBAL. * the DBAL.
*/ */
private function addDiscriminatorColumnDefinition($class, $table) private function addDiscriminatorColumnDefinition($class, Table $table)
{ {
$discrColumn = $class->discriminatorColumn; $discrColumn = $class->discriminatorColumn;
@ -315,17 +317,16 @@ class SchemaTool
* @param Table $table * @param Table $table
* @return array The list of portable column definitions as required by the DBAL. * @return array The list of portable column definitions as required by the DBAL.
*/ */
private function _gatherColumns($class, $table) private function gatherColumns($class, Table $table)
{ {
$columns = array();
$pkColumns = array(); $pkColumns = array();
foreach ($class->fieldMappings as $fieldName => $mapping) { foreach ($class->fieldMappings as $mapping) {
if ($class->isInheritanceTypeSingleTable() && isset($mapping['inherited'])) { if ($class->isInheritanceTypeSingleTable() && isset($mapping['inherited'])) {
continue; continue;
} }
$column = $this->_gatherColumn($class, $mapping, $table); $this->gatherColumn($class, $mapping, $table);
if ($class->isIdentifier($mapping['fieldName'])) { if ($class->isIdentifier($mapping['fieldName'])) {
$pkColumns[] = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform); $pkColumns[] = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform);
@ -337,8 +338,6 @@ class SchemaTool
if(!$table->hasIndex('primary')) { if(!$table->hasIndex('primary')) {
//$table->setPrimaryKey($pkColumns); //$table->setPrimaryKey($pkColumns);
} }
return $columns;
} }
/** /**
@ -349,7 +348,7 @@ class SchemaTool
* @param Table $table * @param Table $table
* @return array The portable column definition as required by the DBAL. * @return array The portable column definition as required by the DBAL.
*/ */
private function _gatherColumn($class, array $mapping, $table) private function gatherColumn($class, array $mapping, Table $table)
{ {
$columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform); $columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform);
$columnType = $mapping['type']; $columnType = $mapping['type'];
@ -423,9 +422,9 @@ class SchemaTool
* @param \Doctrine\DBAL\Schema\Schema $schema * @param \Doctrine\DBAL\Schema\Schema $schema
* @return void * @return void
*/ */
private function _gatherRelationsSql($class, $table, $schema) private function gatherRelationsSql($class, Table $table, $schema)
{ {
foreach ($class->associationMappings as $fieldName => $mapping) { foreach ($class->associationMappings as $mapping) {
if (isset($mapping['inherited'])) { if (isset($mapping['inherited'])) {
continue; continue;
} }
@ -485,7 +484,9 @@ class SchemaTool
if ($class->hasField($referencedFieldName)) { if ($class->hasField($referencedFieldName)) {
return array($class, $referencedFieldName); return array($class, $referencedFieldName);
} else if (in_array($referencedColumnName, $class->getIdentifierColumnNames())) { }
if (in_array($referencedColumnName, $class->getIdentifierColumnNames())) {
// it seems to be an entity as foreign key // it seems to be an entity as foreign key
foreach ($class->getIdentifierFieldNames() as $fieldName) { foreach ($class->getIdentifierFieldNames() as $fieldName) {
if ($class->hasAssociation($fieldName) && $class->getSingleAssociationJoinColumnName($fieldName) == $referencedColumnName) { if ($class->hasAssociation($fieldName) && $class->getSingleAssociationJoinColumnName($fieldName) == $referencedColumnName) {
@ -548,10 +549,13 @@ class SchemaTool
} elseif (isset($fieldMapping['columnDefinition'])) { } elseif (isset($fieldMapping['columnDefinition'])) {
$columnDef = $fieldMapping['columnDefinition']; $columnDef = $fieldMapping['columnDefinition'];
} }
$columnOptions = array('notnull' => false, 'columnDefinition' => $columnDef); $columnOptions = array('notnull' => false, 'columnDefinition' => $columnDef);
if (isset($joinColumn['nullable'])) { if (isset($joinColumn['nullable'])) {
$columnOptions['notnull'] = !$joinColumn['nullable']; $columnOptions['notnull'] = !$joinColumn['nullable'];
} }
if ($fieldMapping['type'] == "string" && isset($fieldMapping['length'])) { if ($fieldMapping['type'] == "string" && isset($fieldMapping['length'])) {
$columnOptions['length'] = $fieldMapping['length']; $columnOptions['length'] = $fieldMapping['length'];
} elseif ($fieldMapping['type'] == "decimal") { } elseif ($fieldMapping['type'] == "decimal") {
@ -571,7 +575,7 @@ class SchemaTool
} }
} }
$theJoinTable->addUnnamedForeignKeyConstraint( $theJoinTable->addForeignKeyConstraint(
$foreignTableName, $localColumns, $foreignColumns, $fkOptions $foreignTableName, $localColumns, $foreignColumns, $fkOptions
); );
} }
@ -624,9 +628,9 @@ class SchemaTool
$sm = $this->em->getConnection()->getSchemaManager(); $sm = $this->em->getConnection()->getSchemaManager();
$schema = $sm->createSchema(); $schema = $sm->createSchema();
$visitor = new \Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector($this->platform); $visitor = new DropSchemaSqlCollector($this->platform);
/* @var $schema \Doctrine\DBAL\Schema\Schema */
$schema->visit($visitor); $schema->visit($visitor);
return $visitor->getQueries(); return $visitor->getQueries();
} }
@ -638,11 +642,12 @@ class SchemaTool
*/ */
public function getDropSchemaSQL(array $classes) public function getDropSchemaSQL(array $classes)
{ {
$visitor = new \Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector($this->platform); $visitor = new DropSchemaSqlCollector($this->platform);
$schema = $this->getSchemaFromMetadata($classes); $schema = $this->getSchemaFromMetadata($classes);
$sm = $this->em->getConnection()->getSchemaManager(); $sm = $this->em->getConnection()->getSchemaManager();
$fullSchema = $sm->createSchema(); $fullSchema = $sm->createSchema();
foreach ($fullSchema->getTables() as $table) { foreach ($fullSchema->getTables() as $table) {
if ( ! $schema->hasTable($table->getName())) { if ( ! $schema->hasTable($table->getName())) {
foreach ($table->getForeignKeys() as $foreignKey) { foreach ($table->getForeignKeys() as $foreignKey) {
@ -663,6 +668,7 @@ class SchemaTool
foreach ($schema->getSequences() as $sequence) { foreach ($schema->getSequences() as $sequence) {
$visitor->acceptSequence($sequence); $visitor->acceptSequence($sequence);
} }
foreach ($schema->getTables() as $table) { foreach ($schema->getTables() as $table) {
/* @var $sequence Table */ /* @var $sequence Table */
if ($table->hasPrimaryKey()) { if ($table->hasPrimaryKey()) {
@ -716,13 +722,13 @@ class SchemaTool
$fromSchema = $sm->createSchema(); $fromSchema = $sm->createSchema();
$toSchema = $this->getSchemaFromMetadata($classes); $toSchema = $this->getSchemaFromMetadata($classes);
$comparator = new \Doctrine\DBAL\Schema\Comparator(); $comparator = new Comparator();
$schemaDiff = $comparator->compare($fromSchema, $toSchema); $schemaDiff = $comparator->compare($fromSchema, $toSchema);
if ($saveMode) { if ($saveMode) {
return $schemaDiff->toSaveSql($this->platform); return $schemaDiff->toSaveSql($this->platform);
} else { }
return $schemaDiff->toSql($this->platform); return $schemaDiff->toSql($this->platform);
} }
} }
}

View File

@ -111,7 +111,6 @@ class SchemaValidator
"the target entity '". $targetMetadata->name . "' also maps an association as identifier."; "the target entity '". $targetMetadata->name . "' also maps an association as identifier.";
} }
/* @var $assoc AssociationMapping */
if ($assoc['mappedBy']) { if ($assoc['mappedBy']) {
if ($targetMetadata->hasField($assoc['mappedBy'])) { if ($targetMetadata->hasField($assoc['mappedBy'])) {
$ce[] = "The association " . $class->name . "#" . $fieldName . " refers to the owning side ". $ce[] = "The association " . $class->name . "#" . $fieldName . " refers to the owning side ".
@ -137,6 +136,7 @@ class SchemaValidator
$ce[] = "The association " . $class->name . "#" . $fieldName . " refers to the inverse side ". $ce[] = "The association " . $class->name . "#" . $fieldName . " refers to the inverse side ".
"field " . $assoc['targetEntity'] . "#" . $assoc['inversedBy'] . " which is not defined as association."; "field " . $assoc['targetEntity'] . "#" . $assoc['inversedBy'] . " which is not defined as association.";
} }
if (!$targetMetadata->hasAssociation($assoc['inversedBy'])) { if (!$targetMetadata->hasAssociation($assoc['inversedBy'])) {
$ce[] = "The association " . $class->name . "#" . $fieldName . " refers to the inverse side ". $ce[] = "The association " . $class->name . "#" . $fieldName . " refers to the inverse side ".
"field " . $assoc['targetEntity'] . "#" . $assoc['inversedBy'] . " which does not exist."; "field " . $assoc['targetEntity'] . "#" . $assoc['inversedBy'] . " which does not exist.";
@ -212,6 +212,7 @@ class SchemaValidator
if (count($identifierColumns) != count($assoc['joinColumns'])) { if (count($identifierColumns) != count($assoc['joinColumns'])) {
$ids = array(); $ids = array();
foreach ($assoc['joinColumns'] as $joinColumn) { foreach ($assoc['joinColumns'] as $joinColumn) {
$ids[] = $joinColumn['name']; $ids[] = $joinColumn['name'];
} }
@ -238,6 +239,7 @@ class SchemaValidator
if ($publicAttr->isStatic()) { if ($publicAttr->isStatic()) {
continue; continue;
} }
$ce[] = "Field '".$publicAttr->getName()."' in class '".$class->name."' must be private ". $ce[] = "Field '".$publicAttr->getName()."' in class '".$class->name."' must be private ".
"or protected. Public fields may break lazy-loading."; "or protected. Public fields may break lazy-loading.";
} }
@ -252,28 +254,6 @@ class SchemaValidator
return $ce; return $ce;
} }
/**
* @param string $columnName
* @param ClassMetadataInfo $class
* @return bool
*/
private function columnExistsOnEntity($columnName, $class)
{
if (isset($class->fieldNames[$columnName])) {
return true;
}
foreach ($class->associationMappings as $assoc) {
if ($assoc['isOwningSide']) {
foreach ($assoc['joinColumns'] as $columnMapping) {
if ($columnMapping['name'] == $columnName) {
return true;
}
}
}
}
return false;
}
/** /**
* Check if the Database Schema is in sync with the current metadata state. * Check if the Database Schema is in sync with the current metadata state.
* *
@ -284,6 +264,7 @@ class SchemaValidator
$schemaTool = new SchemaTool($this->em); $schemaTool = new SchemaTool($this->em);
$allMetadata = $this->em->getMetadataFactory()->getAllMetadata(); $allMetadata = $this->em->getMetadataFactory()->getAllMetadata();
return (count($schemaTool->getUpdateSchemaSql($allMetadata, true)) == 0);
return count($schemaTool->getUpdateSchemaSql($allMetadata, true)) == 0;
} }
} }

View File

@ -40,7 +40,7 @@ class Setup
* @param string $gitCheckoutRootPath * @param string $gitCheckoutRootPath
* @return void * @return void
*/ */
static public function registerAutoloadGit($gitCheckoutRootPath) public static function registerAutoloadGit($gitCheckoutRootPath)
{ {
if (!class_exists('Doctrine\Common\ClassLoader', false)) { if (!class_exists('Doctrine\Common\ClassLoader', false)) {
require_once $gitCheckoutRootPath . "/lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php"; require_once $gitCheckoutRootPath . "/lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php";
@ -65,7 +65,7 @@ class Setup
* *
* @return void * @return void
*/ */
static public function registerAutoloadPEAR() public static function registerAutoloadPEAR()
{ {
if (!class_exists('Doctrine\Common\ClassLoader', false)) { if (!class_exists('Doctrine\Common\ClassLoader', false)) {
require_once "Doctrine/Common/ClassLoader.php"; require_once "Doctrine/Common/ClassLoader.php";
@ -91,7 +91,7 @@ class Setup
* *
* @param string $directory * @param string $directory
*/ */
static public function registerAutoloadDirectory($directory) public static function registerAutoloadDirectory($directory)
{ {
if (!class_exists('Doctrine\Common\ClassLoader', false)) { if (!class_exists('Doctrine\Common\ClassLoader', false)) {
require_once $directory . "/Doctrine/Common/ClassLoader.php"; require_once $directory . "/Doctrine/Common/ClassLoader.php";
@ -114,10 +114,11 @@ class Setup
* @param bool $useSimpleAnnotationReader * @param bool $useSimpleAnnotationReader
* @return Configuration * @return Configuration
*/ */
static public function createAnnotationMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null, $useSimpleAnnotationReader = true) public static function createAnnotationMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null, $useSimpleAnnotationReader = true)
{ {
$config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config = self::createConfiguration($isDevMode, $proxyDir, $cache);
$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths, $useSimpleAnnotationReader)); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths, $useSimpleAnnotationReader));
return $config; return $config;
} }
@ -130,10 +131,11 @@ class Setup
* @param Cache $cache * @param Cache $cache
* @return Configuration * @return Configuration
*/ */
static public function createXMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null) public static function createXMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null)
{ {
$config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config = self::createConfiguration($isDevMode, $proxyDir, $cache);
$config->setMetadataDriverImpl(new XmlDriver($paths)); $config->setMetadataDriverImpl(new XmlDriver($paths));
return $config; return $config;
} }
@ -146,10 +148,11 @@ class Setup
* @param Cache $cache * @param Cache $cache
* @return Configuration * @return Configuration
*/ */
static public function createYAMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null) public static function createYAMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null)
{ {
$config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config = self::createConfiguration($isDevMode, $proxyDir, $cache);
$config->setMetadataDriverImpl(new YamlDriver($paths)); $config->setMetadataDriverImpl(new YamlDriver($paths));
return $config; return $config;
} }
@ -161,9 +164,10 @@ class Setup
* @param Cache $cache * @param Cache $cache
* @return Configuration * @return Configuration
*/ */
static public function createConfiguration($isDevMode = false, $proxyDir = null, Cache $cache = null) public static function createConfiguration($isDevMode = false, $proxyDir = null, Cache $cache = null)
{ {
$proxyDir = $proxyDir ?: sys_get_temp_dir(); $proxyDir = $proxyDir ?: sys_get_temp_dir();
if ($isDevMode === false && $cache === null) { if ($isDevMode === false && $cache === null) {
if (extension_loaded('apc')) { if (extension_loaded('apc')) {
$cache = new \Doctrine\Common\Cache\ApcCache(); $cache = new \Doctrine\Common\Cache\ApcCache();
@ -185,6 +189,7 @@ class Setup
} elseif ($cache === null) { } elseif ($cache === null) {
$cache = new ArrayCache(); $cache = new ArrayCache();
} }
$cache->setNamespace("dc2_" . md5($proxyDir) . "_"); // to avoid collisions $cache->setNamespace("dc2_" . md5($proxyDir) . "_"); // to avoid collisions
$config = new Configuration(); $config = new Configuration();

View File

@ -9,15 +9,14 @@ class ConvertDoctrine1SchemaCommandTest extends \Doctrine\Tests\OrmTestCase
public function testExecution() public function testExecution()
{ {
$entityGenerator = $this->getMock('Doctrine\ORM\Tools\EntityGenerator'); $entityGenerator = $this->getMock('Doctrine\ORM\Tools\EntityGenerator');
$metadataExporter = $this->getMock('Doctrine\ORM\Tools\Export\ClassMetadataExporter');
$command = new ConvertDoctrine1SchemaCommand(); $command = new ConvertDoctrine1SchemaCommand();
$command->setEntityGenerator($entityGenerator); $command->setEntityGenerator($entityGenerator);
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$output->expects($this->once()) $output->expects($this->once())
->method('write') ->method('writeln')
->with($this->equalTo('No Metadata Classes to process.' . PHP_EOL)); ->with($this->equalTo('No Metadata Classes to process.'));
$command->convertDoctrine1Schema($this->_getTestEntityManager(), array(), sys_get_temp_dir(), 'annotation', 4, null, $output); $command->convertDoctrine1Schema(array(), sys_get_temp_dir(), 'annotation', 4, null, $output);
} }
} }