Skip to content

Commit 58e7b2c

Browse files
author
Michael Moravec
committed
Remove direct dependencies on doctrine/common
1 parent f724bab commit 58e7b2c

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Diff for: Form/DoctrineOrmTypeGuesser.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
use Doctrine\Common\Persistence\ManagerRegistry;
1515
use Doctrine\Common\Persistence\Mapping\MappingException;
16+
use Doctrine\Common\Persistence\Proxy;
1617
use Doctrine\DBAL\Types\Type;
1718
use Doctrine\ORM\Mapping\ClassMetadataInfo;
1819
use Doctrine\ORM\Mapping\MappingException as LegacyMappingException;
1920
use Symfony\Component\Form\FormTypeGuesserInterface;
2021
use Symfony\Component\Form\Guess\Guess;
2122
use Symfony\Component\Form\Guess\TypeGuess;
2223
use Symfony\Component\Form\Guess\ValueGuess;
23-
use Doctrine\Common\Util\ClassUtils;
2424

2525
class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
2626
{
@@ -162,7 +162,7 @@ public function guessPattern($class, $property)
162162
protected function getMetadata($class)
163163
{
164164
// normalize class name
165-
$class = ClassUtils::getRealClass(ltrim($class, '\\'));
165+
$class = self::getRealClass(ltrim($class, '\\'));
166166

167167
if (array_key_exists($class, $this->cache)) {
168168
return $this->cache[$class];
@@ -179,4 +179,13 @@ protected function getMetadata($class)
179179
}
180180
}
181181
}
182+
183+
private static function getRealClass(string $class): string
184+
{
185+
if (false === $pos = strrpos($class, '\\'.Proxy::MARKER.'\\')) {
186+
return $class;
187+
}
188+
189+
return substr($class, $pos + Proxy::MARKER_LENGTH + 2);
190+
}
182191
}

Diff for: composer.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
],
1818
"require": {
1919
"php": "^7.1.3",
20-
"doctrine/common": "~2.4",
20+
"doctrine/collections": "~1.0",
21+
"doctrine/event-manager": "~1.0",
22+
"doctrine/persistence": "~1.0",
2123
"symfony/polyfill-ctype": "~1.8",
2224
"symfony/polyfill-mbstring": "~1.0"
2325
},
@@ -33,9 +35,12 @@
3335
"symfony/expression-language": "~3.4|~4.0",
3436
"symfony/validator": "~3.4|~4.0",
3537
"symfony/translation": "~3.4|~4.0",
38+
"doctrine/annotations": "~1.0",
39+
"doctrine/cache": "~1.6",
3640
"doctrine/data-fixtures": "1.0.*",
3741
"doctrine/dbal": "~2.4",
38-
"doctrine/orm": "^2.4.5"
42+
"doctrine/orm": "^2.4.5",
43+
"doctrine/reflection": "~1.0"
3944
},
4045
"conflict": {
4146
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",

0 commit comments

Comments
 (0)