22
33namespace Utilitte \Doctrine ;
44
5+ use Doctrine \Common \Proxy \Proxy ;
56use Doctrine \ORM \EntityManagerInterface ;
67use InvalidArgumentException ;
78use LogicException ;
@@ -90,17 +91,15 @@ public function extractIdentityMany(iterable $entities, bool $allowMixing = fals
9091 );
9192 }
9293
93- $ className = get_class ($ entity );
94-
95- if (!$ className ) {
96- throw new LogicException ('Cannot get class name ' );
97- }
98-
9994 if (!$ allowMixing ) {
10095 if (!$ type ) {
101- $ type = $ className ;
96+ $ type = get_class ($ entity );
97+
98+ if (!$ type ) {
99+ throw new LogicException ('Cannot get class name ' );
100+ }
102101 } else {
103- $ this ->checkType ($ className , $ type );
102+ $ this ->checkType ($ entity , $ type );
104103 }
105104 }
106105
@@ -110,11 +109,11 @@ public function extractIdentityMany(iterable $entities, bool $allowMixing = fals
110109 return $ ids ;
111110 }
112111
113- private function checkType (string $ class , string $ type ): void
112+ private function checkType (object $ entity , string $ type ): void
114113 {
115- if ($ type ! == $ class ) {
114+ if (get_class ( $ entity ) !== $ type && ! $ entity instanceof Proxy && get_parent_class ( $ entity ) ! == $ type ) {
116115 throw new InvalidArgumentException (
117- sprintf ('Given array must be an array of %s, %s contained in array ' , $ type , $ class )
116+ sprintf ('Given array must be an array of %s, %s contained in array ' , $ type , $ entity )
118117 );
119118 }
120119 }
0 commit comments