From 8cc89beb41406905914e5711560abf7438a77436 Mon Sep 17 00:00:00 2001 From: jwage Date: Wed, 23 Jan 2008 16:47:58 +0000 Subject: [PATCH] Moved Doctrine_Migration_Builder and Doctrine_Import_Builder to Doctrine_Builder_Migration and Doctrine_Builder_Record. Updated code to work with new class names. --- lib/Doctrine.php | 6 +- .../Builder/BaseClass.php => Builder.php} | 79 ++++++++--------- .../{Import => }/Builder/Exception.php | 87 ++++++++++--------- .../Builder.php => Builder/Migration.php} | 4 +- .../Builder.php => Builder/Record.php} | 10 +-- lib/Doctrine/Import.php | 2 +- lib/Doctrine/Import/Schema.php | 2 +- lib/Doctrine/Migration.php | 4 +- lib/Doctrine/Migration/Diff.php | 35 ++++++++ lib/Doctrine/Record/Generator.php | 2 +- tests/Import/BuilderTestCase.php | 2 +- 11 files changed, 131 insertions(+), 102 deletions(-) rename lib/Doctrine/{Import/Builder/BaseClass.php => Builder.php} (67%) rename lib/Doctrine/{Import => }/Builder/Exception.php (79%) rename lib/Doctrine/{Migration/Builder.php => Builder/Migration.php} (99%) rename lib/Doctrine/{Import/Builder.php => Builder/Record.php} (98%) create mode 100644 lib/Doctrine/Migration/Diff.php diff --git a/lib/Doctrine.php b/lib/Doctrine.php index 18c12be4e..5a271b4f6 100644 --- a/lib/Doctrine.php +++ b/lib/Doctrine.php @@ -974,7 +974,7 @@ final class Doctrine */ public static function generateMigrationClass($className, $migrationsPath) { - $builder = new Doctrine_Migration_Builder($migrationsPath); + $builder = new Doctrine_Builder_Migration($migrationsPath); return $builder->generateMigrationClass($className); } @@ -988,7 +988,7 @@ final class Doctrine */ public static function generateMigrationsFromDb($migrationsPath) { - $builder = new Doctrine_Migration_Builder($migrationsPath); + $builder = new Doctrine_Builder_Migration($migrationsPath); return $builder->generateMigrationsFromDb(); } @@ -1002,7 +1002,7 @@ final class Doctrine */ public static function generateMigrationsFromModels($migrationsPath, $modelsPath = null) { - $builder = new Doctrine_Migration_Builder($migrationsPath); + $builder = new Doctrine_Builder_Migration($migrationsPath); return $builder->generateMigrationsFromModels($modelsPath); } diff --git a/lib/Doctrine/Import/Builder/BaseClass.php b/lib/Doctrine/Builder.php similarity index 67% rename from lib/Doctrine/Import/Builder/BaseClass.php rename to lib/Doctrine/Builder.php index 3d6173fb0..881dfaffe 100644 --- a/lib/Doctrine/Import/Builder/BaseClass.php +++ b/lib/Doctrine/Builder.php @@ -1,44 +1,37 @@ -. - */ -Doctrine::autoload('Doctrine_Import_Builder'); -/** - * @package Doctrine - * @url http://www.phpdoctrine.org - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @author Jukka Hassinen - * @version $Id$ - */ - -/** - * class Doctrine_Import_Builder_BaseClass - * Builds a Doctrine_Record base class definition based on a schema. - * - * @package Doctrine - * @subpackage Import - * @link www.phpdoctrine.com - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @since 1.0 - * @version $Revision$ - * @author Konsta Vesterinen - */ -class Doctrine_Import_Builder_BaseClass extends Doctrine_Import_Builder -{ +. + */ + +/** + * Doctrine_Builder + * + * @package Doctrine + * @subpackage Builder + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision: 3570 $ + * @author Konsta Vesterinen + * @author Jonathan H. Wage + */ +abstract class Doctrine_Builder +{ + } \ No newline at end of file diff --git a/lib/Doctrine/Import/Builder/Exception.php b/lib/Doctrine/Builder/Exception.php similarity index 79% rename from lib/Doctrine/Import/Builder/Exception.php rename to lib/Doctrine/Builder/Exception.php index 4f2d2c93c..8c524ce06 100644 --- a/lib/Doctrine/Import/Builder/Exception.php +++ b/lib/Doctrine/Builder/Exception.php @@ -1,42 +1,45 @@ -. - */ -Doctrine::autoload('Doctrine_Import_Exception'); -/** - * @package Doctrine - * @subpackage Import - * @url http://www.phpdoctrine.org - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @author Jukka Hassinen - * @version $Id$ - */ - -/** - * class Doctrine_Import_Builder_Exception - * @package Doctrine - * @subpackage Import - * @link www.phpdoctrine.com - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @since 1.0 - * @version $Revision$ - * @author Konsta Vesterinen - */ -class Doctrine_Import_Builder_Exception extends Doctrine_Import_Exception -{ } \ No newline at end of file +. + */ +Doctrine::autoload('Doctrine_Exception'); +/** + * @package Doctrine + * @subpackage Import + * @url http://www.phpdoctrine.org + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Jukka Hassinen + * @version $Id: Exception.php 3570 2008-01-22 22:52:53Z jwage $ + */ + +/** + * Doctrine_Builder_Exception + * + * @package Doctrine + * @subpackage Builder + * @link www.phpdoctrine.com + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @since 1.0 + * @version $Revision: 3570 $ + * @author Konsta Vesterinen + * @author Jonathan H. Wage + */ +class Doctrine_Builder_Exception extends Doctrine_Exception +{ +} \ No newline at end of file diff --git a/lib/Doctrine/Migration/Builder.php b/lib/Doctrine/Builder/Migration.php similarity index 99% rename from lib/Doctrine/Migration/Builder.php rename to lib/Doctrine/Builder/Migration.php index d322d8f5a..61c14f1f9 100644 --- a/lib/Doctrine/Migration/Builder.php +++ b/lib/Doctrine/Builder/Migration.php @@ -23,7 +23,7 @@ * Doctrine_Migration_Builder * * @package Doctrine - * @subpackage Migration + * @subpackage Builder * @author Konsta Vesterinen * @author Jonathan H. Wage * @license http://www.opensource.org/licenses/lgpl-license.php LGPL @@ -31,7 +31,7 @@ * @since 1.0 * @version $Revision: 2939 $ */ -class Doctrine_Migration_Builder +class Doctrine_Builder_Migration extends Doctrine_Builder { /** * migrationsPath diff --git a/lib/Doctrine/Import/Builder.php b/lib/Doctrine/Builder/Record.php similarity index 98% rename from lib/Doctrine/Import/Builder.php rename to lib/Doctrine/Builder/Record.php index 9327c532b..a3633eb74 100644 --- a/lib/Doctrine/Import/Builder.php +++ b/lib/Doctrine/Builder/Record.php @@ -26,7 +26,7 @@ * based on a database schema. * * @package Doctrine - * @subpackage Import + * @subpackage Builder * @link www.phpdoctrine.com * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @since 1.0 @@ -36,7 +36,7 @@ * @author Nicolas BĂ©rard-Nault * @author Jonathan H. Wage */ -class Doctrine_Import_Builder +class Doctrine_Builder_Record { /** * Path @@ -625,7 +625,7 @@ END; public function buildDefinition(array $definition) { if ( ! isset($definition['className'])) { - throw new Doctrine_Import_Builder_Exception('Missing class name.'); + throw new Doctrine_Builder_Exception('Missing class name.'); } $abstract = isset($definition['abstract']) && $definition['abstract'] === true ? 'abstract ':null; @@ -667,7 +667,7 @@ END; public function buildRecord(array $definition) { if ( !isset($definition['className'])) { - throw new Doctrine_Import_Builder_Exception('Missing class name.'); + throw new Doctrine_Builder_Exception('Missing class name.'); } if ($this->generateBaseClasses()) { @@ -802,7 +802,7 @@ END; } if (isset($bytes) && $bytes === false) { - throw new Doctrine_Import_Builder_Exception("Couldn't write file " . $writePath); + throw new Doctrine_Builder_Exception("Couldn't write file " . $writePath); } } } \ No newline at end of file diff --git a/lib/Doctrine/Import.php b/lib/Doctrine/Import.php index afa5ea196..339988ea3 100644 --- a/lib/Doctrine/Import.php +++ b/lib/Doctrine/Import.php @@ -207,7 +207,7 @@ class Doctrine_Import extends Doctrine_Connection_Module continue; } - $builder = new Doctrine_Import_Builder(); + $builder = new Doctrine_Builder_Record(); $builder->setTargetPath($directory); $builder->setOptions($options); diff --git a/lib/Doctrine/Import/Schema.php b/lib/Doctrine/Import/Schema.php index b9e69905a..036281439 100644 --- a/lib/Doctrine/Import/Schema.php +++ b/lib/Doctrine/Import/Schema.php @@ -146,7 +146,7 @@ class Doctrine_Import_Schema */ public function importSchema($schema, $format = 'yml', $directory = null, $models = array()) { - $builder = new Doctrine_Import_Builder(); + $builder = new Doctrine_Builder_Record(); $builder->setTargetPath($directory); $builder->setOptions($this->getOptions()); diff --git a/lib/Doctrine/Migration.php b/lib/Doctrine/Migration.php index e7d1aa73a..53a45b46b 100644 --- a/lib/Doctrine/Migration.php +++ b/lib/Doctrine/Migration.php @@ -22,15 +22,13 @@ /** * Doctrine_Migration * - * this class represents a database view - * * @package Doctrine * @subpackage Migration * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.phpdoctrine.com * @since 1.0 * @version $Revision: 1080 $ - * @author Jonathan H. Wage + * @author Jonathan H. Wage */ class Doctrine_Migration { diff --git a/lib/Doctrine/Migration/Diff.php b/lib/Doctrine/Migration/Diff.php new file mode 100644 index 000000000..160e4ec2c --- /dev/null +++ b/lib/Doctrine/Migration/Diff.php @@ -0,0 +1,35 @@ +. + */ + +/** + * Doctrine_Migration_Diff + * + * @package Doctrine + * @subpackage Migration + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision: 1080 $ + * @author Jonathan H. Wage + */ +class Doctrine_Migration_Diff +{ +} \ No newline at end of file diff --git a/lib/Doctrine/Record/Generator.php b/lib/Doctrine/Record/Generator.php index 6496889c4..310c989bc 100644 --- a/lib/Doctrine/Record/Generator.php +++ b/lib/Doctrine/Record/Generator.php @@ -266,7 +266,7 @@ abstract class Doctrine_Record_Generator extends Doctrine_Record_Abstract { $options['className'] = $this->_options['className']; - $builder = new Doctrine_Import_Builder(); + $builder = new Doctrine_Builder_Record(); if ($this->_options['generateFiles']) { if (isset($this->_options['generatePath']) && $this->_options['generatePath']) { diff --git a/tests/Import/BuilderTestCase.php b/tests/Import/BuilderTestCase.php index 39383d2e5..f677fca30 100644 --- a/tests/Import/BuilderTestCase.php +++ b/tests/Import/BuilderTestCase.php @@ -36,7 +36,7 @@ class Doctrine_Import_Builder_TestCase extends Doctrine_UnitTestCase { $table = $this->conn->getTable('Phonenumber'); - $builder = new Doctrine_Import_Builder(); + $builder = new Doctrine_Builder_Record(); $rel = $builder->buildRelationDefinition($table->getRelations());