|
20 | 20 | use Flat3\Lodata\Drivers\SQL\SQLOrderBy;
|
21 | 21 | use Flat3\Lodata\Drivers\SQL\SQLSchema;
|
22 | 22 | use Flat3\Lodata\Drivers\SQL\SQLWhere;
|
23 |
| -use Flat3\Lodata\Endpoint; |
24 | 23 | use Flat3\Lodata\Entity;
|
25 | 24 | use Flat3\Lodata\EntitySet;
|
26 | 25 | use Flat3\Lodata\EntityType;
|
|
34 | 33 | use Flat3\Lodata\Helper\JSON;
|
35 | 34 | use Flat3\Lodata\Helper\PropertyValue;
|
36 | 35 | use Flat3\Lodata\Helper\PropertyValues;
|
37 |
| -use Flat3\Lodata\Interfaces\AnnotationFactoryInterface; |
38 | 36 | use Flat3\Lodata\Interfaces\EntitySet\ComputeInterface;
|
39 | 37 | use Flat3\Lodata\Interfaces\EntitySet\CountInterface;
|
40 | 38 | use Flat3\Lodata\Interfaces\EntitySet\CreateInterface;
|
@@ -116,8 +114,7 @@ public function __construct(string $model, ?EntityType $entityType = null)
|
116 | 114 |
|
117 | 115 | $name = self::convertClassName($model);
|
118 | 116 | if (!$entityType) {
|
119 |
| - $identifier = app(Endpoint::class)->getNamespace().'.'.EntityType::convertClassName($model); |
120 |
| - $entityType = new EntityType($identifier); |
| 117 | + $entityType = new EntityType(EntityType::convertClassName($model)); |
121 | 118 | }
|
122 | 119 |
|
123 | 120 | parent::__construct($name, $entityType);
|
@@ -869,28 +866,30 @@ public function discover(): self
|
869 | 866 | }
|
870 | 867 |
|
871 | 868 | /** @var ReflectionMethod $reflectionMethod */
|
872 |
| - foreach (Discovery::getReflectedMethods($this->model) as $reflectionMethod) |
873 |
| - foreach ($reflectionMethod->getAttributes() as $attribute) { |
874 |
| - |
875 |
| - $instance = $attribute->newInstance(); |
876 |
| - if ($instance instanceof LodataRelationship) { |
877 |
| - $relationshipMethod = $reflectionMethod->getName(); |
878 |
| - |
879 |
| - try { |
880 |
| - $this->discoverRelationship( |
881 |
| - $relationshipMethod, |
882 |
| - $instance->getName(), |
883 |
| - $instance->getDescription(), |
884 |
| - $instance->isNullable() |
885 |
| - ); |
886 |
| - } catch (ConfigurationException $e) { |
887 |
| - } |
888 |
| - } |
889 |
| - else if ($instance instanceof AnnotationFactoryInterface) { |
890 |
| - $this->addAnnotation($instance->toAnnotation()); |
891 |
| - } |
| 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; |
892 | 878 | }
|
893 | 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) { |
| 890 | + } |
| 891 | + } |
| 892 | + |
894 | 893 | return $this;
|
895 | 894 | }
|
896 | 895 | }
|
0 commit comments