File tree 2 files changed +5
-16
lines changed 2 files changed +5
-16
lines changed Original file line number Diff line number Diff line change @@ -44,13 +44,14 @@ public function getRealClass($target)
44
44
*
45
45
* @param object|string $entity Entity object or FQCN
46
46
*
47
- * @return ClassMetadata
47
+ * @return ClassMetadata|null
48
48
*/
49
49
public function getClassMetadata ($ entity )
50
50
{
51
51
$ fqcn = $ this ->getRealClass ($ entity );
52
+
52
53
if (null === $ entityManager = $ this ->doctrine ->getManagerForClass ($ fqcn )) {
53
- throw DoctrineUtilsException:: unsupportedClass ( $ fqcn ) ;
54
+ return null ;
54
55
}
55
56
56
57
return $ entityManager ->getClassMetadata ($ fqcn );
@@ -125,4 +126,4 @@ public function dump($entity): array
125
126
126
127
return $ dump ;
127
128
}
128
- }
129
+ }
Original file line number Diff line number Diff line change 6
6
7
7
class DoctrineUtilsException extends RuntimeException implements SymfonyCommonExceptionInterface
8
8
{
9
- /**
10
- * Unsupported class exception
11
- *
12
- * @param string $fqcn FQCN
13
- *
14
- * @return $this
15
- */
16
- public static function unsupportedClass ($ fqcn )
17
- {
18
- return new self ("Unsupported class ' $ fqcn'. " );
19
- }
20
-
21
9
/**
22
10
* Unsupported entity primary key
23
11
*
@@ -29,4 +17,4 @@ public static function unsupportedPrimaryKey($fqcn)
29
17
{
30
18
return new self ("Unsupported ' $ fqcn' primary key, supports only entities with single field primary key. " );
31
19
}
32
- }
20
+ }
You can’t perform that action at this time.
0 commit comments