| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | namespace LaravelUi5\OData\Service\Resolver; |
| 6: | |
| 7: | use LaravelUi5\OData\Service\Contracts\ResolverBindingInterface; |
| 8: | use LaravelUi5\OData\Service\Contracts\RuntimeSchemaBuilderInterface; |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | final readonly class ResolverMap |
| 18: | { |
| 19: | |
| 20: | |
| 21: | |
| 22: | public function __construct(private array $bindings) {} |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | public function applyTo(RuntimeSchemaBuilderInterface $builder): void |
| 28: | { |
| 29: | $container = $builder->getEdmx()->getEntityContainer(); |
| 30: | |
| 31: | foreach ($this->bindings as $entitySetName => $binding) { |
| 32: | $set = $container->getEntitySet($entitySetName); |
| 33: | if ($set !== null) { |
| 34: | $builder->bindEntitySet($set, $binding->createResolver()); |
| 35: | } |
| 36: | } |
| 37: | } |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | public function getBindings(): array |
| 43: | { |
| 44: | return $this->bindings; |
| 45: | } |
| 46: | } |
| 47: | |