Skip to content

Commit 095599c

Browse files
make:entity Use the namespace instead of the full class name for MappingDriver (#1054)
1 parent 9b96324 commit 095599c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Doctrine/DoctrineHelper.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@ public function doesClassUseDriver(string $className, string $driverClass): bool
9191
// if the class should be generated with attributes or annotations. If this exception is thrown, we will check based on the
9292
// namespaces for the given $className and compare it with the doctrine configuration to get the correct MappingDriver.
9393

94-
return $this->isInstanceOf($this->getMappingDriverForNamespace($className), $driverClass);
94+
// extract the new class's namespace from the full $className to check the namespace of the new class against the doctrine configuration.
95+
$classNameComponents = explode('\\', $className);
96+
if (1 < \count($classNameComponents)) {
97+
array_pop($classNameComponents);
98+
}
99+
$classNamespace = implode('\\', $classNameComponents);
100+
101+
return $this->isInstanceOf($this->getMappingDriverForNamespace($classNamespace), $driverClass);
95102
}
96103

97104
if (null === $em) {

0 commit comments

Comments
 (0)