File tree Expand file tree Collapse file tree
Eloquent/Serializer/Mapping/Loader
Tests/Eloquent/Serializer/Mapping/Loader Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
4242 }
4343
4444 $ refl = $ classMetadata ->getReflectionClass ();
45+ if ($ refl ->isAbstract ()) {
46+ return false ;
47+ }
48+
4549 /** @var Model */
4650 $ model = $ refl ->newInstanceWithoutConstructor ();
4751 $ attributesMetadata = $ classMetadata ->getAttributesMetadata ();
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the API Platform project.
5+ *
6+ * (c) Kévin Dunglas <dunglas@gmail.com>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ declare (strict_types=1 );
13+
14+ namespace ApiPlatform \Laravel \Tests \Eloquent \Serializer \Mapping \Loader ;
15+
16+ use ApiPlatform \Laravel \Eloquent \Metadata \ModelMetadata ;
17+ use ApiPlatform \Laravel \Eloquent \Serializer \Mapping \Loader \RelationMetadataLoader ;
18+ use Orchestra \Testbench \TestCase ;
19+ use Symfony \Component \Serializer \Mapping \ClassMetadata ;
20+ use Workbench \App \Models \AbstractModel ;
21+
22+ class RelationMetadataLoaderTest extends TestCase
23+ {
24+ /**
25+ * @see https://github.com/api-platform/core/issues/7911
26+ */
27+ public function testLoadClassMetadataReturnsFalseForAbstractModelWithoutInstantiating (): void
28+ {
29+ $ loader = new RelationMetadataLoader (new ModelMetadata ());
30+
31+ $ result = $ loader ->loadClassMetadata (new ClassMetadata (AbstractModel::class));
32+
33+ $ this ->assertFalse ($ result );
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the API Platform project.
5+ *
6+ * (c) Kévin Dunglas <dunglas@gmail.com>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ declare (strict_types=1 );
13+
14+ namespace Workbench \App \Models ;
15+
16+ use Illuminate \Database \Eloquent \Model ;
17+
18+ abstract class AbstractModel extends Model
19+ {
20+ }
You can’t perform that action at this time.
0 commit comments