| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | namespace LaravelUi5\OData\Protocol\Execution; |
| 6: | |
| 7: | use LaravelUi5\OData\Http\ODataResponse; |
| 8: | use LaravelUi5\OData\Protocol\Planning\MetadataQueryPlan; |
| 9: | use LaravelUi5\OData\Service\Serialization\CsdlSerializer; |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | final readonly class MetadataHandler |
| 18: | { |
| 19: | public function handle(MetadataQueryPlan $plan): ODataResponse |
| 20: | { |
| 21: | $xml = (new CsdlSerializer)->serialize($plan->edmx); |
| 22: | |
| 23: | $response = new ODataResponse(null, 200, [ |
| 24: | 'Content-Type' => 'application/xml;charset=utf-8', |
| 25: | 'OData-Version' => '4.0', |
| 26: | ]); |
| 27: | |
| 28: | $response->setCallback(static function () use ($xml): void { |
| 29: | echo $xml; |
| 30: | }); |
| 31: | |
| 32: | return $response; |
| 33: | } |
| 34: | } |
| 35: | |