|
32 | 32 | use Flat3\Lodata\Helper\JSON;
|
33 | 33 | use Flat3\Lodata\Helper\PropertyValue;
|
34 | 34 | use Flat3\Lodata\Helper\PropertyValues;
|
| 35 | +use Flat3\Lodata\Interfaces\AnnotationFactoryInterface; |
35 | 36 | use Flat3\Lodata\Interfaces\EntitySet\ComputeInterface;
|
36 | 37 | use Flat3\Lodata\Interfaces\EntitySet\CountInterface;
|
37 | 38 | use Flat3\Lodata\Interfaces\EntitySet\CreateInterface;
|
@@ -787,29 +788,27 @@ public function discover(): self
|
787 | 788 | }
|
788 | 789 |
|
789 | 790 | /** @var ReflectionMethod $reflectionMethod */
|
790 |
| - foreach (Discovery::getReflectedMethods($this->model) as $reflectionMethod) { |
791 |
| - /** @var LodataRelationship $relationshipInstance */ |
792 |
| - $relationshipInstance = Discovery::getFirstMethodAttributeInstance( |
793 |
| - $reflectionMethod, |
794 |
| - LodataRelationship::class |
795 |
| - ); |
796 |
| - |
797 |
| - if (!$relationshipInstance) { |
798 |
| - continue; |
799 |
| - } |
800 |
| - |
801 |
| - $relationshipMethod = $reflectionMethod->getName(); |
802 |
| - |
803 |
| - try { |
804 |
| - $this->discoverRelationship( |
805 |
| - $relationshipMethod, |
806 |
| - $relationshipInstance->getName(), |
807 |
| - $relationshipInstance->getDescription(), |
808 |
| - $relationshipInstance->isNullable() |
809 |
| - ); |
810 |
| - } catch (ConfigurationException $e) { |
| 791 | + foreach (Discovery::getReflectedMethods($this->model) as $reflectionMethod) |
| 792 | + foreach ($reflectionMethod->getAttributes() as $attribute) { |
| 793 | + |
| 794 | + $instance = $attribute->newInstance(); |
| 795 | + if ($instance instanceof LodataRelationship) { |
| 796 | + $relationshipMethod = $reflectionMethod->getName(); |
| 797 | + |
| 798 | + try { |
| 799 | + $this->discoverRelationship( |
| 800 | + $relationshipMethod, |
| 801 | + $instance->getName(), |
| 802 | + $instance->getDescription(), |
| 803 | + $instance->isNullable() |
| 804 | + ); |
| 805 | + } catch (ConfigurationException $e) { |
| 806 | + } |
| 807 | + } |
| 808 | + else if ($instance instanceof AnnotationFactoryInterface) { |
| 809 | + $this->addAnnotation($instance->toAnnotation()); |
| 810 | + } |
811 | 811 | }
|
812 |
| - } |
813 | 812 |
|
814 | 813 | return $this;
|
815 | 814 | }
|
|
0 commit comments