From a4c7a895077f46111a4b63686d87b6b22e66c88d Mon Sep 17 00:00:00 2001 From: encoder64 Date: Sun, 27 Jul 2014 17:28:06 +0300 Subject: [PATCH] className fix: If namespace is not set then ClassName will be cut of --- .../ORM/Tools/EntityRepositoryGenerator.php | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php b/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php index b074afa06..e94749069 100644 --- a/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php +++ b/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php @@ -57,12 +57,10 @@ class extends */ public function generateEntityRepositoryClass($fullClassName) { - $className = substr($fullClassName, strrpos($fullClassName, '\\') + 1, strlen($fullClassName)); - $variables = array( '' => $this->generateEntityRepositoryNamespace($fullClassName), '' => $this->generateEntityRepositoryName($fullClassName), - '' => $className + '' => $this->generateClassName($fullClassName) ); return str_replace(array_keys($variables), array_values($variables), self::$_template); @@ -82,6 +80,26 @@ class extends return $namespace; } + /** + * Generates the class name + * + * @param string $fullClassName + * + * @return string + */ + protected function generateClassName($fullClassName) + { + $namespace = $this->getClassNamespace($fullClassName); + + $className = $fullClassName; + + if ($namespace) { + $className = substr($fullClassName, strrpos($fullClassName, '\\') + 1, strlen($fullClassName)); + } + + return $className; + } + /** * Generates the namespace statement, if class do not have namespace, return empty string instead. *