|
33 | 33 | use Flat3\Lodata\Helper\JSON;
|
34 | 34 | use Flat3\Lodata\Helper\PropertyValue;
|
35 | 35 | use Flat3\Lodata\Helper\PropertyValues;
|
| 36 | +use Flat3\Lodata\Interfaces\AnnotationFactoryInterface; |
36 | 37 | use Flat3\Lodata\Interfaces\EntitySet\ComputeInterface;
|
37 | 38 | use Flat3\Lodata\Interfaces\EntitySet\CountInterface;
|
38 | 39 | use Flat3\Lodata\Interfaces\EntitySet\CreateInterface;
|
@@ -866,29 +867,27 @@ public function discover(): self
|
866 | 867 | }
|
867 | 868 |
|
868 | 869 | /** @var ReflectionMethod $reflectionMethod */
|
869 |
| - foreach (Discovery::getReflectedMethods($this->model) as $reflectionMethod) { |
870 |
| - /** @var LodataRelationship $relationshipInstance */ |
871 |
| - $relationshipInstance = Discovery::getFirstMethodAttributeInstance( |
872 |
| - $reflectionMethod, |
873 |
| - LodataRelationship::class |
874 |
| - ); |
875 |
| - |
876 |
| - if (!$relationshipInstance) { |
877 |
| - continue; |
878 |
| - } |
879 |
| - |
880 |
| - $relationshipMethod = $reflectionMethod->getName(); |
881 |
| - |
882 |
| - try { |
883 |
| - $this->discoverRelationship( |
884 |
| - $relationshipMethod, |
885 |
| - $relationshipInstance->getName(), |
886 |
| - $relationshipInstance->getDescription(), |
887 |
| - $relationshipInstance->isNullable() |
888 |
| - ); |
889 |
| - } catch (ConfigurationException $e) { |
| 870 | + foreach (Discovery::getReflectedMethods($this->model) as $reflectionMethod) |
| 871 | + foreach ($reflectionMethod->getAttributes() as $attribute) { |
| 872 | + |
| 873 | + $instance = $attribute->newInstance(); |
| 874 | + if ($instance instanceof LodataRelationship) { |
| 875 | + $relationshipMethod = $reflectionMethod->getName(); |
| 876 | + |
| 877 | + try { |
| 878 | + $this->discoverRelationship( |
| 879 | + $relationshipMethod, |
| 880 | + $instance->getName(), |
| 881 | + $instance->getDescription(), |
| 882 | + $instance->isNullable() |
| 883 | + ); |
| 884 | + } catch (ConfigurationException $e) { |
| 885 | + } |
| 886 | + } |
| 887 | + else if ($instance instanceof AnnotationFactoryInterface) { |
| 888 | + $this->addAnnotation($instance->toAnnotation()); |
| 889 | + } |
890 | 890 | }
|
891 |
| - } |
892 | 891 |
|
893 | 892 | return $this;
|
894 | 893 | }
|
|
0 commit comments