From 58e7b2c486bda9fac27e9fa6111d780f41f3ffc7 Mon Sep 17 00:00:00 2001 From: Michael Moravec Date: Fri, 15 Jun 2018 02:15:56 +0200 Subject: [PATCH] Remove direct dependencies on doctrine/common --- Form/DoctrineOrmTypeGuesser.php | 13 +++++++++++-- composer.json | 9 +++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Form/DoctrineOrmTypeGuesser.php b/Form/DoctrineOrmTypeGuesser.php index 4a2a3a2f..9ed60273 100644 --- a/Form/DoctrineOrmTypeGuesser.php +++ b/Form/DoctrineOrmTypeGuesser.php @@ -13,6 +13,7 @@ use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Common\Persistence\Mapping\MappingException; +use Doctrine\Common\Persistence\Proxy; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\MappingException as LegacyMappingException; @@ -20,7 +21,6 @@ use Symfony\Component\Form\Guess\Guess; use Symfony\Component\Form\Guess\TypeGuess; use Symfony\Component\Form\Guess\ValueGuess; -use Doctrine\Common\Util\ClassUtils; class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface { @@ -162,7 +162,7 @@ public function guessPattern($class, $property) protected function getMetadata($class) { // normalize class name - $class = ClassUtils::getRealClass(ltrim($class, '\\')); + $class = self::getRealClass(ltrim($class, '\\')); if (array_key_exists($class, $this->cache)) { return $this->cache[$class]; @@ -179,4 +179,13 @@ protected function getMetadata($class) } } } + + private static function getRealClass(string $class): string + { + if (false === $pos = strrpos($class, '\\'.Proxy::MARKER.'\\')) { + return $class; + } + + return substr($class, $pos + Proxy::MARKER_LENGTH + 2); + } } diff --git a/composer.json b/composer.json index 4f6e21f7..78345d65 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,9 @@ ], "require": { "php": "^7.1.3", - "doctrine/common": "~2.4", + "doctrine/collections": "~1.0", + "doctrine/event-manager": "~1.0", + "doctrine/persistence": "~1.0", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0" }, @@ -33,9 +35,12 @@ "symfony/expression-language": "~3.4|~4.0", "symfony/validator": "~3.4|~4.0", "symfony/translation": "~3.4|~4.0", + "doctrine/annotations": "~1.0", + "doctrine/cache": "~1.6", "doctrine/data-fixtures": "1.0.*", "doctrine/dbal": "~2.4", - "doctrine/orm": "^2.4.5" + "doctrine/orm": "^2.4.5", + "doctrine/reflection": "~1.0" }, "conflict": { "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",