support short class name
This commit is contained in:
parent
368cf73f89
commit
0f081d7c45
@ -1326,10 +1326,7 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
$mapping['sourceEntity'] = $this->name;
|
$mapping['sourceEntity'] = $this->name;
|
||||||
|
|
||||||
if (isset($mapping['targetEntity'])) {
|
if (isset($mapping['targetEntity'])) {
|
||||||
if (strlen($this->namespace) > 0 && strpos($mapping['targetEntity'], '\\') === false) {
|
$mapping['targetEntity'] = $this->fullyQualifiedClassName($mapping['targetEntity']);
|
||||||
$mapping['targetEntity'] = $this->namespace . '\\' . $mapping['targetEntity'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$mapping['targetEntity'] = ltrim($mapping['targetEntity'], '\\');
|
$mapping['targetEntity'] = ltrim($mapping['targetEntity'], '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1917,11 +1914,7 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
public function setSubclasses(array $subclasses)
|
public function setSubclasses(array $subclasses)
|
||||||
{
|
{
|
||||||
foreach ($subclasses as $subclass) {
|
foreach ($subclasses as $subclass) {
|
||||||
if (strpos($subclass, '\\') === false && strlen($this->namespace)) {
|
$this->subClasses[] = $this->fullyQualifiedClassName($subclass);
|
||||||
$this->subClasses[] = $this->namespace . '\\' . $subclass;
|
|
||||||
} else {
|
|
||||||
$this->subClasses[] = $subclass;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2274,11 +2267,9 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
|
|
||||||
$queryMapping['isSelfClass'] = true;
|
$queryMapping['isSelfClass'] = true;
|
||||||
$queryMapping['resultClass'] = $this->name;
|
$queryMapping['resultClass'] = $this->name;
|
||||||
|
|
||||||
} else if (strlen($this->namespace) > 0 && strpos($queryMapping['resultClass'], '\\') === false) {
|
|
||||||
$queryMapping['resultClass'] = $this->namespace . '\\' . $queryMapping['resultClass'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$queryMapping['resultClass'] = $this->fullyQualifiedClassName($queryMapping['resultClass']);
|
||||||
$queryMapping['resultClass'] = ltrim($queryMapping['resultClass'], '\\');
|
$queryMapping['resultClass'] = ltrim($queryMapping['resultClass'], '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2317,10 +2308,9 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
$entityResult['isSelfClass'] = true;
|
$entityResult['isSelfClass'] = true;
|
||||||
$entityResult['entityClass'] = $this->name;
|
$entityResult['entityClass'] = $this->name;
|
||||||
|
|
||||||
} else if (strlen($this->namespace) > 0 && strpos($entityResult['entityClass'], '\\') === false) {
|
|
||||||
$entityResult['entityClass'] = $this->namespace . '\\' . $entityResult['entityClass'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$entityResult['entityClass'] = $this->fullyQualifiedClassName($entityResult['entityClass']);
|
||||||
$resultMapping['entities'][$key]['entityClass'] = ltrim($entityResult['entityClass'], '\\');
|
$resultMapping['entities'][$key]['entityClass'] = ltrim($entityResult['entityClass'], '\\');
|
||||||
$resultMapping['entities'][$key]['isSelfClass'] = $entityResult['isSelfClass'];
|
$resultMapping['entities'][$key]['isSelfClass'] = $entityResult['isSelfClass'];
|
||||||
|
|
||||||
@ -2432,11 +2422,7 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
*/
|
*/
|
||||||
public function setCustomRepositoryClass($repositoryClassName)
|
public function setCustomRepositoryClass($repositoryClassName)
|
||||||
{
|
{
|
||||||
if ($repositoryClassName !== null && strpos($repositoryClassName, '\\') === false
|
$this->customRepositoryClassName = $this->fullyQualifiedClassName($repositoryClassName);
|
||||||
&& strlen($this->namespace) > 0) {
|
|
||||||
$repositoryClassName = $this->namespace . '\\' . $repositoryClassName;
|
|
||||||
}
|
|
||||||
$this->customRepositoryClassName = $repositoryClassName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2605,10 +2591,7 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
*/
|
*/
|
||||||
public function addDiscriminatorMapClass($name, $className)
|
public function addDiscriminatorMapClass($name, $className)
|
||||||
{
|
{
|
||||||
if (strlen($this->namespace) > 0 && strpos($className, '\\') === false) {
|
$className = $this->fullyQualifiedClassName($className);
|
||||||
$className = $this->namespace . '\\' . $className;
|
|
||||||
}
|
|
||||||
|
|
||||||
$className = ltrim($className, '\\');
|
$className = ltrim($className, '\\');
|
||||||
$this->discriminatorMap[$name] = $className;
|
$this->discriminatorMap[$name] = $className;
|
||||||
|
|
||||||
@ -3030,4 +3013,17 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
}
|
}
|
||||||
return $relations;
|
return $relations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $className
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function fullyQualifiedClassName($className)
|
||||||
|
{
|
||||||
|
if ($className !== null && strpos($className, '\\') === false && strlen($this->namespace) > 0) {
|
||||||
|
return $this->namespace . '\\' . $className;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $className;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,6 @@ class AnnotationDriver extends AbstractAnnotationDriver
|
|||||||
|
|
||||||
// Check for JoinTable annotations
|
// Check for JoinTable annotations
|
||||||
if ($associationOverride->joinTable) {
|
if ($associationOverride->joinTable) {
|
||||||
$joinTable = null;
|
|
||||||
$joinTableAnnot = $associationOverride->joinTable;
|
$joinTableAnnot = $associationOverride->joinTable;
|
||||||
$joinTable = array(
|
$joinTable = array(
|
||||||
'name' => $joinTableAnnot->name,
|
'name' => $joinTableAnnot->name,
|
||||||
@ -421,17 +420,16 @@ class AnnotationDriver extends AbstractAnnotationDriver
|
|||||||
$entityListenersAnnot = $classAnnotations['Doctrine\ORM\Mapping\EntityListeners'];
|
$entityListenersAnnot = $classAnnotations['Doctrine\ORM\Mapping\EntityListeners'];
|
||||||
|
|
||||||
foreach ($entityListenersAnnot->value as $listener) {
|
foreach ($entityListenersAnnot->value as $listener) {
|
||||||
|
$listener = $metadata->fullyQualifiedClassName($listener);
|
||||||
|
|
||||||
if ( ! class_exists($listener)) {
|
if ( ! class_exists($listener)) {
|
||||||
throw new \InvalidArgumentException("Indefined class \"$listener\"");
|
throw new \InvalidArgumentException("Indefined class \"$listener\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
$listener = new \ReflectionClass($listener);
|
$listener = new \ReflectionClass($listener);
|
||||||
|
|
||||||
foreach ($listener->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
|
foreach ($listener->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
|
||||||
foreach ($this->getMethodCallbacks($method) as $value) {
|
foreach ($this->getMethodCallbacks($method) as $value) {
|
||||||
list($callback, $event) = $value;
|
$metadata->addEntityListener($value[1], $listener->name, $value[0]);
|
||||||
$metadata->addEntityListener($event, $listener->name, $callback);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -447,8 +445,7 @@ class AnnotationDriver extends AbstractAnnotationDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->getMethodCallbacks($method) as $value) {
|
foreach ($this->getMethodCallbacks($method) as $value) {
|
||||||
list($callback, $event) = $value;
|
$metadata->addLifecycleCallback($value[0], $value[1]);
|
||||||
$metadata->addLifecycleCallback($callback, $event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace Doctrine\Tests\Models\Company;
|
|||||||
* @Table(name="company_contracts")
|
* @Table(name="company_contracts")
|
||||||
* @InheritanceType("SINGLE_TABLE")
|
* @InheritanceType("SINGLE_TABLE")
|
||||||
* @DiscriminatorColumn(name="discr", type="string")
|
* @DiscriminatorColumn(name="discr", type="string")
|
||||||
* @EntityListeners({"Doctrine\Tests\Models\Company\ContractSubscriber"})
|
* @EntityListeners({"ContractSubscriber"})
|
||||||
* @DiscriminatorMap({
|
* @DiscriminatorMap({
|
||||||
* "fix" = "CompanyFixContract",
|
* "fix" = "CompanyFixContract",
|
||||||
* "flexible" = "CompanyFlexContract",
|
* "flexible" = "CompanyFlexContract",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user