small refactorings
This commit is contained in:
parent
b3de3fb942
commit
be5aac16fd
@ -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
|
* 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.
|
* @param boolean $prepend Whether to prepend or append the new column to the column list.
|
||||||
* By default the column gets appended.
|
* By default the column gets appended.
|
||||||
* @throws Doctrine_ClassMetadata_Exception If trying use wrongly typed parameter.
|
* @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)) {
|
if (is_string($options)) {
|
||||||
$options = explode('|', $options);
|
$options = explode('|', $options);
|
||||||
@ -598,11 +589,11 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
|
|||||||
* By default the column gets appended.
|
* By default the column gets appended.
|
||||||
* @throws Doctrine_Table_Exception if trying use wrongly typed parameter
|
* @throws Doctrine_Table_Exception if trying use wrongly typed parameter
|
||||||
* @return void
|
* @return void
|
||||||
* @deprecated
|
* @deprecated Use mapColumn()
|
||||||
*/
|
*/
|
||||||
public function setColumn($name, $type, $length = null, $options = array(), $prepend = false)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,7 +127,7 @@ class Doctrine_ClassMetadata_Factory
|
|||||||
foreach ($parentClass->getColumns() as $name => $definition) {
|
foreach ($parentClass->getColumns() as $name => $definition) {
|
||||||
$fullName = "$name as " . $parentClass->getFieldName($name);
|
$fullName = "$name as " . $parentClass->getFieldName($name);
|
||||||
$definition['inherited'] = true;
|
$definition['inherited'] = true;
|
||||||
$subClass->addMappedColumn($fullName, $definition['type'], $definition['length'],
|
$subClass->mapColumn($fullName, $definition['type'], $definition['length'],
|
||||||
$definition);
|
$definition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ class CmsUser extends Doctrine_Record
|
|||||||
{
|
{
|
||||||
public static function initMetadata($class)
|
public static function initMetadata($class)
|
||||||
{
|
{
|
||||||
$class->setColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => true));
|
$class->mapColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => true));
|
||||||
$class->setColumn('username', 'string', 255);
|
$class->mapColumn('username', 'string', 255);
|
||||||
$class->setColumn('name', 'string', 255);
|
$class->mapColumn('name', 'string', 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,6 @@ class ForumAdministrator extends ForumUser
|
|||||||
{
|
{
|
||||||
public static function initMetadata($class)
|
public static function initMetadata($class)
|
||||||
{
|
{
|
||||||
$class->addMappedColumn('foo', 'string', 50);
|
$class->mapColumn('foo', 'string', 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,13 +14,13 @@ class ForumUser extends Doctrine_Record
|
|||||||
$class->setSubclasses(array('ForumAdministrator'));
|
$class->setSubclasses(array('ForumAdministrator'));
|
||||||
|
|
||||||
// the discriminator column
|
// the discriminator column
|
||||||
$class->addMappedColumn('dtype', 'string', 50);
|
$class->mapColumn('dtype', 'string', 50);
|
||||||
|
|
||||||
// property mapping
|
// property mapping
|
||||||
$class->addMappedColumn('id', 'integer', 4, array(
|
$class->mapColumn('id', 'integer', 4, array(
|
||||||
'primary' => true,
|
'primary' => true,
|
||||||
'autoincrement' => true));
|
'autoincrement' => true));
|
||||||
$class->addMappedColumn('username', 'string', 50);
|
$class->mapColumn('username', 'string', 50);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
public function testMetadataSetupOnClassTableInheritanceHierarchy()
|
public function testMetadataSetupOnClassTableInheritanceHierarchy()
|
||||||
{
|
{
|
||||||
$userClass = $this->conn->getMetadata('Metadata_User');
|
$userClass = $this->conn->getClassMetadata('Metadata_User');
|
||||||
$this->assertTrue($userClass instanceof Doctrine_ClassMetadata);
|
$this->assertTrue($userClass instanceof Doctrine_ClassMetadata);
|
||||||
$this->assertEqual('cti_user', $userClass->getTableName());
|
$this->assertEqual('cti_user', $userClass->getTableName());
|
||||||
$this->assertEqual(4, count($userClass->getFields()));
|
$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->setSubclasses(array('Metadata_Manager', 'Metadata_Customer', 'Metadata_SuperManager'));
|
||||||
$class->mapField('cti_id as id', 'integer', 4, array('primary' => true, 'autoincrement' => true));
|
$class->mapColumn('cti_id as id', 'integer', 4, array('primary' => true, 'autoincrement' => true));
|
||||||
$class->mapField('cti_foo as foo', 'integer', 4);
|
$class->mapColumn('cti_foo as foo', 'integer', 4);
|
||||||
$class->mapField('cti_name as name', 'string', 50);
|
$class->mapColumn('cti_name as name', 'string', 50);
|
||||||
$class->mapField('type', 'integer', 1);
|
$class->mapColumn('type', 'integer', 1);
|
||||||
|
|
||||||
//$class->setNamedQuery('findByName', 'SELECT u.* FROM User u WHERE u.name = ?');
|
//$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->setTableName('cti_manager');
|
||||||
$class->setSubclasses(array('Metadata_SuperManager'));
|
$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)
|
public static function initMetadata(Doctrine_ClassMetadata $class)
|
||||||
{
|
{
|
||||||
$class->setTableName('cti_customer');
|
$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)
|
public static function initMetadata(Doctrine_ClassMetadata $class)
|
||||||
{
|
{
|
||||||
$class->setTableName('cti_supermanager');
|
$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->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->mapColumn('cti_id as id', 'integer', 4, array('primary' => true, 'autoincrement' => true));
|
||||||
$class->mapField('cti_foo as foo', 'integer', 4);
|
$class->mapColumn('cti_foo as foo', 'integer', 4);
|
||||||
$class->mapField('cti_name as name', 'string', 50);
|
$class->mapColumn('cti_name as name', 'string', 50);
|
||||||
$class->mapField('type', 'integer', 1);
|
$class->mapColumn('type', 'integer', 1);
|
||||||
|
|
||||||
//$class->setNamedQuery('findByName', 'SELECT u.* FROM User u WHERE u.name = ?');
|
//$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->setTableName('cti_manager');
|
||||||
$class->setSubclasses(array('Metadata_STI_SuperManager'));
|
$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)
|
public static function initMetadata($class)
|
||||||
{
|
{
|
||||||
$class->setTableName('cti_customer');
|
$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)
|
public static function initMetadata($class)
|
||||||
{
|
{
|
||||||
$class->setTableName('cti_supermanager');
|
$class->setTableName('cti_supermanager');
|
||||||
$class->mapField('ctism_gosutitle as gosutitle', 'varchar', 50, array());
|
$class->mapColumn('ctism_gosutitle as gosutitle', 'varchar', 50, array());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user