|
13 | 13 |
|
14 | 14 | namespace ApiPlatform\Metadata\Extractor; |
15 | 15 |
|
16 | | -use ApiPlatform\Elasticsearch\State\Options; |
| 16 | +use ApiPlatform\Doctrine\Odm\State\Options as OdmOptions; |
| 17 | +use ApiPlatform\Doctrine\Orm\State\Options as OrmOptions; |
| 18 | +use ApiPlatform\Elasticsearch\State\Options as ElasticsearchOptions; |
17 | 19 | use ApiPlatform\Metadata\Exception\InvalidArgumentException; |
18 | 20 | use ApiPlatform\Metadata\GetCollection; |
19 | 21 | use ApiPlatform\Metadata\HeaderParameter; |
@@ -454,14 +456,24 @@ private function buildStateOptions(\SimpleXMLElement $resource): ?OptionsInterfa |
454 | 456 | if (!$stateOptions) { |
455 | 457 | return null; |
456 | 458 | } |
457 | | - $elasticsearchOptions = $stateOptions->elasticsearchOptions ?? null; |
458 | | - if ($elasticsearchOptions) { |
459 | | - if (class_exists(Options::class)) { |
460 | | - return new Options( |
461 | | - isset($elasticsearchOptions['index']) ? (string) $elasticsearchOptions['index'] : null, |
462 | | - isset($elasticsearchOptions['type']) ? (string) $elasticsearchOptions['type'] : null, |
463 | | - ); |
464 | | - } |
| 459 | + |
| 460 | + if (isset($stateOptions->elasticsearchOptions) && class_exists(ElasticsearchOptions::class)) { |
| 461 | + return new ElasticsearchOptions( |
| 462 | + isset($stateOptions->elasticsearchOptions['index']) ? (string) $stateOptions->elasticsearchOptions['index'] : null, |
| 463 | + isset($stateOptions->elasticsearchOptions['type']) ? (string) $stateOptions->elasticsearchOptions['type'] : null, |
| 464 | + ); |
| 465 | + } |
| 466 | + |
| 467 | + if (isset($stateOptions->doctrineOdmOptions) && class_exists(OdmOptions::class)) { |
| 468 | + return new OdmOptions( |
| 469 | + isset($stateOptions->doctrineOdmOptions['documentClass']) ? (string) $stateOptions->doctrineOdmOptions['documentClass'] : null, |
| 470 | + ); |
| 471 | + } |
| 472 | + |
| 473 | + if (isset($stateOptions->doctrineOrmOptions) && class_exists(OrmOptions::class)) { |
| 474 | + return new OrmOptions( |
| 475 | + isset($stateOptions->doctrineOrmOptions['entityClass']) ? (string) $stateOptions->doctrineOrmOptions['entityClass'] : null, |
| 476 | + ); |
465 | 477 | } |
466 | 478 |
|
467 | 479 | return null; |
|
0 commit comments