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