Skip to content

Commit f84d25a

Browse files
committed
[DoctrineBridge] Remove dead code
Signed-off-by: Alexander M. Turek <[email protected]>
1 parent 63d3ff6 commit f84d25a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

PropertyInfo/DoctrineExtractor.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111

1212
namespace Symfony\Bridge\Doctrine\PropertyInfo;
1313

14+
use Doctrine\Common\Collections\Collection;
1415
use Doctrine\DBAL\Types\Types;
1516
use Doctrine\ORM\EntityManagerInterface;
1617
use Doctrine\ORM\Mapping\ClassMetadata;
1718
use Doctrine\ORM\Mapping\ClassMetadataInfo;
19+
use Doctrine\ORM\Mapping\Embedded;
1820
use Doctrine\ORM\Mapping\MappingException as OrmMappingException;
1921
use Doctrine\Persistence\Mapping\MappingException;
2022
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
@@ -30,7 +32,6 @@
3032
class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeExtractorInterface, PropertyAccessExtractorInterface
3133
{
3234
private $entityManager;
33-
private $classMetadataFactory;
3435

3536
public function __construct(EntityManagerInterface $entityManager)
3637
{
@@ -48,7 +49,7 @@ public function getProperties(string $class, array $context = [])
4849

4950
$properties = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames());
5051

51-
if ($metadata instanceof ClassMetadataInfo && class_exists(\Doctrine\ORM\Mapping\Embedded::class) && $metadata->embeddedClasses) {
52+
if ($metadata instanceof ClassMetadataInfo && class_exists(Embedded::class) && $metadata->embeddedClasses) {
5253
$properties = array_filter($properties, function ($property) {
5354
return !str_contains($property, '.');
5455
});
@@ -90,7 +91,7 @@ public function getTypes(string $class, string $property, array $context = [])
9091

9192
if (isset($associationMapping['indexBy'])) {
9293
/** @var ClassMetadataInfo $subMetadata */
93-
$subMetadata = $this->entityManager ? $this->entityManager->getClassMetadata($associationMapping['targetEntity']) : $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
94+
$subMetadata = $this->entityManager->getClassMetadata($associationMapping['targetEntity']);
9495

9596
// Check if indexBy value is a property
9697
$fieldName = $associationMapping['indexBy'];
@@ -103,7 +104,7 @@ public function getTypes(string $class, string $property, array $context = [])
103104

104105
/** @var ClassMetadataInfo $subMetadata */
105106
$indexProperty = $subMetadata->getSingleAssociationReferencedJoinColumnName($fieldName);
106-
$subMetadata = $this->entityManager ? $this->entityManager->getClassMetadata($associationMapping['targetEntity']) : $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
107+
$subMetadata = $this->entityManager->getClassMetadata($associationMapping['targetEntity']);
107108

108109
//Not a property, maybe a column name?
109110
if (null === ($typeOfField = $subMetadata->getTypeOfField($indexProperty))) {
@@ -122,14 +123,14 @@ public function getTypes(string $class, string $property, array $context = [])
122123
return [new Type(
123124
Type::BUILTIN_TYPE_OBJECT,
124125
false,
125-
'Doctrine\Common\Collections\Collection',
126+
Collection::class,
126127
true,
127128
new Type($collectionKeyType),
128129
new Type(Type::BUILTIN_TYPE_OBJECT, false, $class)
129130
)];
130131
}
131132

132-
if ($metadata instanceof ClassMetadataInfo && class_exists(\Doctrine\ORM\Mapping\Embedded::class) && isset($metadata->embeddedClasses[$property])) {
133+
if ($metadata instanceof ClassMetadataInfo && class_exists(Embedded::class) && isset($metadata->embeddedClasses[$property])) {
133134
return [new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class'])];
134135
}
135136

@@ -207,8 +208,8 @@ public function isWritable(string $class, string $property, array $context = [])
207208
private function getMetadata(string $class): ?ClassMetadata
208209
{
209210
try {
210-
return $this->entityManager ? $this->entityManager->getClassMetadata($class) : $this->classMetadataFactory->getMetadataFor($class);
211-
} catch (MappingException | OrmMappingException $exception) {
211+
return $this->entityManager->getClassMetadata($class);
212+
} catch (MappingException|OrmMappingException $exception) {
212213
return null;
213214
}
214215
}

0 commit comments

Comments
 (0)