Skip to content

Commit 14bc31a

Browse files
authored
Merge pull request #193 from TomHAnderson/hotfix/require-entity-attribute-12-5
If an Entity attribute for the group was not found, just continue
2 parents 49531a3 + d3106d3 commit 14bc31a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/Metadata/MetadataFactory.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ public function getMetadata(): Metadata
6363
->getMetadataFactory()
6464
->getMetadataFor($reflectionClass->getName());
6565

66-
$this->buildMetadataForEntity($reflectionClass);
66+
// If an Entity attribute does not exist, skip this entity
67+
if (! $this->buildMetadataForEntity($reflectionClass)) {
68+
continue;
69+
}
70+
6771
$this->buildMetadataForFields($entityClassMetadata, $reflectionClass);
6872
$this->buildMetadataForAssociations($reflectionClass);
6973
}
@@ -81,9 +85,10 @@ public function getMetadata(): Metadata
8185
* The buildmetadata* functions exist to simplify the buildMetadata
8286
* function.
8387
*/
84-
private function buildMetadataForEntity(ReflectionClass $reflectionClass): void
88+
private function buildMetadataForEntity(ReflectionClass $reflectionClass): bool
8589
{
86-
$entityInstance = null;
90+
$entityInstance = null;
91+
$entityAttributeFound = false;
8792

8893
// Fetch attributes for the entity class filterd by Attribute\Entity
8994
foreach ($reflectionClass->getAttributes(Attribute\Entity::class) as $attribute) {
@@ -94,6 +99,8 @@ private function buildMetadataForEntity(ReflectionClass $reflectionClass): void
9499
continue;
95100
}
96101

102+
$entityAttributeFound = true;
103+
97104
// Only one matching instance per group is allowed
98105
assert(
99106
! $entityInstance,
@@ -115,6 +122,8 @@ private function buildMetadataForEntity(ReflectionClass $reflectionClass): void
115122
$this->getTypeName($reflectionClass->getName()),
116123
];
117124
}
125+
126+
return $entityAttributeFound;
118127
}
119128

120129
/**

0 commit comments

Comments
 (0)