Skip to content

Commit 6d83eea

Browse files
committed
If an Entity attribute for the group was not found, just continue
1 parent 47d98c8 commit 6d83eea

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
@@ -64,7 +64,11 @@ public function __invoke(): ArrayObject
6464
->getMetadataFactory()
6565
->getMetadataFor($reflectionClass->getName());
6666

67-
$this->buildMetadataForEntity($reflectionClass);
67+
// If an Entity attribute does not exist, skip this entity
68+
if (! $this->buildMetadataForEntity($reflectionClass)) {
69+
continue;
70+
}
71+
6872
$this->buildMetadataForFields($entityClassMetadata, $reflectionClass);
6973
$this->buildMetadataForAssociations($reflectionClass);
7074
}
@@ -82,9 +86,10 @@ public function __invoke(): ArrayObject
8286
* The buildmetadata* functions exist to simplify the buildMetadata
8387
* function.
8488
*/
85-
private function buildMetadataForEntity(ReflectionClass $reflectionClass): void
89+
private function buildMetadataForEntity(ReflectionClass $reflectionClass): bool
8690
{
87-
$entityInstance = null;
91+
$entityInstance = null;
92+
$entityAttributeFound = false;
8893

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

103+
$entityAttributeFound = true;
104+
98105
// Only one matching instance per group is allowed
99106
assert(
100107
! $entityInstance,
@@ -116,6 +123,8 @@ private function buildMetadataForEntity(ReflectionClass $reflectionClass): void
116123
$this->getTypeName($reflectionClass->getName()),
117124
];
118125
}
126+
127+
return $entityAttributeFound;
119128
}
120129

121130
/**

0 commit comments

Comments
 (0)