From be5aac16fd1fd89aebe69c00a96168872746fd9f Mon Sep 17 00:00:00 2001 From: romanb Date: Sat, 16 Feb 2008 19:10:16 +0000 Subject: [PATCH] small refactorings --- lib/Doctrine/ClassMetadata.php | 15 +++--------- lib/Doctrine/ClassMetadata/Factory.php | 2 +- tests/models/cms/CmsUser.php | 6 ++--- tests/models/forum/ForumAdministrator.php | 2 +- tests/models/forum/ForumUser.php | 6 ++--- tests_old/Metadata/FactoryTestCase.php | 30 +++++++++++------------ 6 files changed, 26 insertions(+), 35 deletions(-) diff --git a/lib/Doctrine/ClassMetadata.php b/lib/Doctrine/ClassMetadata.php index 075f32391..e013e9996 100644 --- a/lib/Doctrine/ClassMetadata.php +++ b/lib/Doctrine/ClassMetadata.php @@ -479,14 +479,6 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab } } - /** - * @deprecated - */ - public function mapField($name, $type, $length = null, $options = array(), $prepend = false) - { - return $this->setColumn($name, $type, $length, $options, $prepend); - } - /** * addMappedColumn * @@ -497,9 +489,8 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab * @param boolean $prepend Whether to prepend or append the new column to the column list. * By default the column gets appended. * @throws Doctrine_ClassMetadata_Exception If trying use wrongly typed parameter. - * @deprecated */ - public function addMappedColumn($name, $type, $length = null, $options = array(), $prepend = false) + public function mapColumn($name, $type, $length = null, $options = array(), $prepend = false) { if (is_string($options)) { $options = explode('|', $options); @@ -598,11 +589,11 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab * By default the column gets appended. * @throws Doctrine_Table_Exception if trying use wrongly typed parameter * @return void - * @deprecated + * @deprecated Use mapColumn() */ public function setColumn($name, $type, $length = null, $options = array(), $prepend = false) { - return $this->addMappedColumn($name, $type, $length, $options, $prepend); + return $this->mapColumn($name, $type, $length, $options, $prepend); } /** diff --git a/lib/Doctrine/ClassMetadata/Factory.php b/lib/Doctrine/ClassMetadata/Factory.php index 80fc61f0a..7af986947 100644 --- a/lib/Doctrine/ClassMetadata/Factory.php +++ b/lib/Doctrine/ClassMetadata/Factory.php @@ -127,7 +127,7 @@ class Doctrine_ClassMetadata_Factory foreach ($parentClass->getColumns() as $name => $definition) { $fullName = "$name as " . $parentClass->getFieldName($name); $definition['inherited'] = true; - $subClass->addMappedColumn($fullName, $definition['type'], $definition['length'], + $subClass->mapColumn($fullName, $definition['type'], $definition['length'], $definition); } } diff --git a/tests/models/cms/CmsUser.php b/tests/models/cms/CmsUser.php index b6cb0607f..cfa93db2d 100644 --- a/tests/models/cms/CmsUser.php +++ b/tests/models/cms/CmsUser.php @@ -3,8 +3,8 @@ class CmsUser extends Doctrine_Record { public static function initMetadata($class) { - $class->setColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => true)); - $class->setColumn('username', 'string', 255); - $class->setColumn('name', 'string', 255); + $class->mapColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => true)); + $class->mapColumn('username', 'string', 255); + $class->mapColumn('name', 'string', 255); } } diff --git a/tests/models/forum/ForumAdministrator.php b/tests/models/forum/ForumAdministrator.php index 0d51d7085..0df442ab0 100644 --- a/tests/models/forum/ForumAdministrator.php +++ b/tests/models/forum/ForumAdministrator.php @@ -4,6 +4,6 @@ class ForumAdministrator extends ForumUser { public static function initMetadata($class) { - $class->addMappedColumn('foo', 'string', 50); + $class->mapColumn('foo', 'string', 50); } } \ No newline at end of file diff --git a/tests/models/forum/ForumUser.php b/tests/models/forum/ForumUser.php index bd2ec6216..4ca9e8556 100644 --- a/tests/models/forum/ForumUser.php +++ b/tests/models/forum/ForumUser.php @@ -14,13 +14,13 @@ class ForumUser extends Doctrine_Record $class->setSubclasses(array('ForumAdministrator')); // the discriminator column - $class->addMappedColumn('dtype', 'string', 50); + $class->mapColumn('dtype', 'string', 50); // property mapping - $class->addMappedColumn('id', 'integer', 4, array( + $class->mapColumn('id', 'integer', 4, array( 'primary' => true, 'autoincrement' => true)); - $class->addMappedColumn('username', 'string', 50); + $class->mapColumn('username', 'string', 50); } } \ No newline at end of file diff --git a/tests_old/Metadata/FactoryTestCase.php b/tests_old/Metadata/FactoryTestCase.php index ac57a9999..fdde5abc1 100644 --- a/tests_old/Metadata/FactoryTestCase.php +++ b/tests_old/Metadata/FactoryTestCase.php @@ -22,7 +22,7 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase public function testMetadataSetupOnClassTableInheritanceHierarchy() { - $userClass = $this->conn->getMetadata('Metadata_User'); + $userClass = $this->conn->getClassMetadata('Metadata_User'); $this->assertTrue($userClass instanceof Doctrine_ClassMetadata); $this->assertEqual('cti_user', $userClass->getTableName()); $this->assertEqual(4, count($userClass->getFields())); @@ -156,10 +156,10 @@ class Metadata_User extends Doctrine_Record ) ); $class->setSubclasses(array('Metadata_Manager', 'Metadata_Customer', 'Metadata_SuperManager')); - $class->mapField('cti_id as id', 'integer', 4, array('primary' => true, 'autoincrement' => true)); - $class->mapField('cti_foo as foo', 'integer', 4); - $class->mapField('cti_name as name', 'string', 50); - $class->mapField('type', 'integer', 1); + $class->mapColumn('cti_id as id', 'integer', 4, array('primary' => true, 'autoincrement' => true)); + $class->mapColumn('cti_foo as foo', 'integer', 4); + $class->mapColumn('cti_name as name', 'string', 50); + $class->mapColumn('type', 'integer', 1); //$class->setNamedQuery('findByName', 'SELECT u.* FROM User u WHERE u.name = ?'); } @@ -171,7 +171,7 @@ class Metadata_Manager extends Metadata_User { $class->setTableName('cti_manager'); $class->setSubclasses(array('Metadata_SuperManager')); - $class->mapField('ctim_salary as salary', 'varchar', 50, array()); + $class->mapColumn('ctim_salary as salary', 'varchar', 50, array()); } } @@ -180,7 +180,7 @@ class Metadata_Customer extends Metadata_User public static function initMetadata(Doctrine_ClassMetadata $class) { $class->setTableName('cti_customer'); - $class->setColumn('ctic_bonuspoints as bonuspoints', 'varchar', 50, array()); + $class->mapColumn('ctic_bonuspoints as bonuspoints', 'varchar', 50, array()); } } @@ -189,7 +189,7 @@ class Metadata_SuperManager extends Metadata_Manager public static function initMetadata(Doctrine_ClassMetadata $class) { $class->setTableName('cti_supermanager'); - $class->mapField('ctism_gosutitle as gosutitle', 'varchar', 50, array()); + $class->mapColumn('ctism_gosutitle as gosutitle', 'varchar', 50, array()); } } @@ -210,10 +210,10 @@ class Metadata_STI_User extends Doctrine_Record ) ); $class->setSubclasses(array('Metadata_STI_Manager', 'Metadata_STI_Customer', 'Metadata_STI_SuperManager')); - $class->mapField('cti_id as id', 'integer', 4, array('primary' => true, 'autoincrement' => true)); - $class->mapField('cti_foo as foo', 'integer', 4); - $class->mapField('cti_name as name', 'string', 50); - $class->mapField('type', 'integer', 1); + $class->mapColumn('cti_id as id', 'integer', 4, array('primary' => true, 'autoincrement' => true)); + $class->mapColumn('cti_foo as foo', 'integer', 4); + $class->mapColumn('cti_name as name', 'string', 50); + $class->mapColumn('type', 'integer', 1); //$class->setNamedQuery('findByName', 'SELECT u.* FROM User u WHERE u.name = ?'); } @@ -225,7 +225,7 @@ class Metadata_STI_Manager extends Metadata_STI_User { $class->setTableName('cti_manager'); $class->setSubclasses(array('Metadata_STI_SuperManager')); - $class->mapField('ctim_salary as salary', 'varchar', 50, array()); + $class->mapColumn('ctim_salary as salary', 'varchar', 50, array()); } } @@ -234,7 +234,7 @@ class Metadata_STI_Customer extends Metadata_STI_User public static function initMetadata($class) { $class->setTableName('cti_customer'); - $class->setColumn('ctic_bonuspoints as bonuspoints', 'varchar', 50, array()); + $class->mapColumn('ctic_bonuspoints as bonuspoints', 'varchar', 50, array()); } } @@ -243,7 +243,7 @@ class Metadata_STI_SuperManager extends Metadata_STI_Manager public static function initMetadata($class) { $class->setTableName('cti_supermanager'); - $class->mapField('ctism_gosutitle as gosutitle', 'varchar', 50, array()); + $class->mapColumn('ctism_gosutitle as gosutitle', 'varchar', 50, array()); } }