add support for NamingStrategy
This commit is contained in:
parent
eac34b6d6a
commit
8bdb713073
3 changed files with 49 additions and 1 deletions
|
@ -548,4 +548,29 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
|||
return isset($this->_attributes['defaultRepositoryClassName']) ?
|
||||
$this->_attributes['defaultRepositoryClassName'] : 'Doctrine\ORM\EntityRepository';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set naming strategy.
|
||||
*
|
||||
* @since 2.3
|
||||
* @param NamingStrategy $namingStrategy
|
||||
*/
|
||||
public function setNamingStrategy(NamingStrategy $namingStrategy)
|
||||
{
|
||||
$this->_attributes['namingStrategy'] = $namingStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get naming strategy..
|
||||
*
|
||||
* @since 2.3
|
||||
* @return NamingStrategy
|
||||
*/
|
||||
public function getNamingStrategy()
|
||||
{
|
||||
if (!isset($this->_attributes['namingStrategy'])) {
|
||||
$this->_attributes['namingStrategy'] = new DefaultNamingStrategy();
|
||||
}
|
||||
return $this->_attributes['namingStrategy'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -385,7 +385,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
|||
*/
|
||||
protected function newClassMetadataInstance($className)
|
||||
{
|
||||
return new ClassMetadata($className);
|
||||
return new ClassMetadata($className, $this->em->getConfiguration()->getNamingStrategy());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -392,6 +392,29 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
|||
$this->assertEquals("INT unsigned NOT NULL", $class->fieldMappings['id']['columnDefinition']);
|
||||
$this->assertEquals("VARCHAR(255) NOT NULL", $class->fieldMappings['value']['columnDefinition']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-559
|
||||
*/
|
||||
public function testNamingStrategy()
|
||||
{
|
||||
$driver = $this->_loadDriver();
|
||||
$em = $this->_getTestEntityManager();
|
||||
$factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
|
||||
$em->getConfiguration()->setMetadataDriverImpl($driver);
|
||||
$factory->setEntityManager($em);
|
||||
|
||||
|
||||
$this->assertInstanceOf('Doctrine\ORM\DefaultNamingStrategy', $em->getConfiguration()->getNamingStrategy());
|
||||
$em->getConfiguration()->setNamingStrategy(new \Doctrine\ORM\UnderscoreNamingStrategy('upper'));
|
||||
$this->assertInstanceOf('Doctrine\ORM\UnderscoreNamingStrategy', $em->getConfiguration()->getNamingStrategy());
|
||||
|
||||
$class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType');
|
||||
|
||||
$this->assertEquals('ID', $class->columnNames['id']);
|
||||
$this->assertEquals('NAME', $class->columnNames['name']);
|
||||
$this->assertEquals('DDC1476ENTITY_WITH_DEFAULT_FIELD_TYPE', $class->table['name']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue