|
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;
|
|
33 | 32 | use Flat3\Lodata\Helper\JSON;
|
34 | 33 | use Flat3\Lodata\Helper\PropertyValue;
|
35 | 34 | use Flat3\Lodata\Helper\PropertyValues;
|
36 |
| -use Flat3\Lodata\Interfaces\AnnotationFactoryInterface; |
37 | 35 | use Flat3\Lodata\Interfaces\EntitySet\ComputeInterface;
|
38 | 36 | use Flat3\Lodata\Interfaces\EntitySet\CountInterface;
|
39 | 37 | use Flat3\Lodata\Interfaces\EntitySet\CreateInterface;
|
@@ -112,8 +110,7 @@ public function __construct(string $model, ?EntityType $entityType = null)
|
112 | 110 |
|
113 | 111 | $name = self::convertClassName($model);
|
114 | 112 | if (!$entityType) {
|
115 |
| - $identifier = app(Endpoint::class)->getNamespace().'.'.EntityType::convertClassName($model); |
116 |
| - $entityType = new EntityType($identifier); |
| 113 | + $entityType = new EntityType(EntityType::convertClassName($model)); |
117 | 114 | }
|
118 | 115 |
|
119 | 116 | parent::__construct($name, $entityType);
|
@@ -790,28 +787,30 @@ public function discover(): self
|
790 | 787 | }
|
791 | 788 |
|
792 | 789 | /** @var ReflectionMethod $reflectionMethod */
|
793 |
| - foreach (Discovery::getReflectedMethods($this->model) as $reflectionMethod) |
794 |
| - foreach ($reflectionMethod->getAttributes() as $attribute) { |
795 |
| - |
796 |
| - $instance = $attribute->newInstance(); |
797 |
| - if ($instance instanceof LodataRelationship) { |
798 |
| - $relationshipMethod = $reflectionMethod->getName(); |
799 |
| - |
800 |
| - try { |
801 |
| - $this->discoverRelationship( |
802 |
| - $relationshipMethod, |
803 |
| - $instance->getName(), |
804 |
| - $instance->getDescription(), |
805 |
| - $instance->isNullable() |
806 |
| - ); |
807 |
| - } catch (ConfigurationException $e) { |
808 |
| - } |
809 |
| - } |
810 |
| - else if ($instance instanceof AnnotationFactoryInterface) { |
811 |
| - $this->addAnnotation($instance->toAnnotation()); |
812 |
| - } |
| 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; |
813 | 799 | }
|
814 | 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) { |
| 811 | + } |
| 812 | + } |
| 813 | + |
815 | 814 | return $this;
|
816 | 815 | }
|
817 | 816 | }
|
0 commit comments