apply naming strategy on ClassMetadata
This commit is contained in:
parent
8b1f60c9f8
commit
83a9458653
@ -21,7 +21,8 @@ namespace Doctrine\ORM\Mapping;
|
||||
|
||||
use ReflectionClass, ReflectionProperty;
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata AS IClassMetadata;
|
||||
|
||||
use Doctrine\ORM\DefaultNamingStrategy;
|
||||
use Doctrine\ORM\NamingStrategy;
|
||||
/**
|
||||
* A <tt>ClassMetadata</tt> instance holds all the object-relational mapping metadata
|
||||
* of an entity and it's associations.
|
||||
@ -61,13 +62,15 @@ class ClassMetadata extends ClassMetadataInfo implements IClassMetadata
|
||||
* metadata of the class with the given name.
|
||||
*
|
||||
* @param string $entityName The name of the entity class the new instance is used for.
|
||||
* @param NamingStrategy $namingStrategy
|
||||
*/
|
||||
public function __construct($entityName)
|
||||
public function __construct($entityName, NamingStrategy $namingStrategy = null)
|
||||
{
|
||||
$namingStrategy = $namingStrategy ?: new DefaultNamingStrategy();
|
||||
$this->reflClass = new ReflectionClass($entityName);
|
||||
$this->namespace = $this->reflClass->getNamespaceName();
|
||||
$this->table['name'] = $this->reflClass->getShortName();
|
||||
parent::__construct($this->reflClass->getName()); // do not use $entityName, possible case-problems
|
||||
$this->table['name'] = $namingStrategy->classToTableName($this->reflClass->getShortName());
|
||||
parent::__construct($this->reflClass->getName(),$namingStrategy); // do not use $entityName, possible case-problems
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,6 +21,8 @@ namespace Doctrine\ORM\Mapping;
|
||||
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use ReflectionClass;
|
||||
use Doctrine\ORM\DefaultNamingStrategy;
|
||||
use Doctrine\ORM\NamingStrategy;
|
||||
|
||||
/**
|
||||
* A <tt>ClassMetadata</tt> instance holds all the object-relational mapping metadata
|
||||
@ -512,7 +514,7 @@ class ClassMetadataInfo
|
||||
{
|
||||
$this->name = $entityName;
|
||||
$this->rootEntityName = $entityName;
|
||||
$this->namingStrategy = $namingStrategy ?: new \Doctrine\ORM\DefaultNamingStrategy();
|
||||
$this->namingStrategy = $namingStrategy ?: new DefaultNamingStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user