File tree Expand file tree Collapse file tree 3 files changed +50
-11
lines changed Expand file tree Collapse file tree 3 files changed +50
-11
lines changed Original file line number Diff line number Diff line change 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 ;
@@ -468,13 +470,23 @@ private function buildStateOptions(\SimpleXMLElement $resource): ?OptionsInterfa
468
470
if (!$ stateOptions ) {
469
471
return null ;
470
472
}
471
- $ elasticsearchOptions = $ stateOptions ->elasticsearchOptions ?? null ;
472
- if ($ elasticsearchOptions ) {
473
- if (class_exists (Options::class)) {
474
- return new Options (
475
- isset ($ elasticsearchOptions ['index ' ]) ? (string ) $ elasticsearchOptions ['index ' ] : null ,
476
- );
477
- }
473
+
474
+ if (isset ($ stateOptions ->elasticsearchOptions ) && class_exists (ElasticsearchOptions::class)) {
475
+ return new ElasticsearchOptions (
476
+ isset ($ stateOptions ->elasticsearchOptions ['index ' ]) ? (string ) $ stateOptions ->elasticsearchOptions ['index ' ] : null ,
477
+ );
478
+ }
479
+
480
+ if (isset ($ stateOptions ->doctrineOdmOptions ) && class_exists (OdmOptions::class)) {
481
+ return new OdmOptions (
482
+ isset ($ stateOptions ->doctrineOdmOptions ['documentClass ' ]) ? (string ) $ stateOptions ->doctrineOdmOptions ['documentClass ' ] : null ,
483
+ );
484
+ }
485
+
486
+ if (isset ($ stateOptions ->doctrineOrmOptions ) && class_exists (OrmOptions::class)) {
487
+ return new OrmOptions (
488
+ isset ($ stateOptions ->doctrineOrmOptions ['entityClass ' ]) ? (string ) $ stateOptions ->doctrineOrmOptions ['entityClass ' ] : null ,
489
+ );
478
490
}
479
491
480
492
return null ;
Original file line number Diff line number Diff line change 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 ;
@@ -417,9 +419,20 @@ private function buildStateOptions(array $resource): ?OptionsInterface
417
419
$ configuration = reset ($ stateOptions );
418
420
switch (key ($ stateOptions )) {
419
421
case 'elasticsearchOptions ' :
420
- if (class_exists (Options ::class)) {
421
- return new Options ($ configuration ['index ' ] ?? null );
422
+ if (class_exists (ElasticsearchOptions ::class)) {
423
+ return new ElasticsearchOptions ($ configuration ['index ' ] ?? null );
422
424
}
425
+ break ;
426
+ case 'doctrineOdmOptions ' :
427
+ if (class_exists (OdmOptions::class)) {
428
+ return new OdmOptions ($ configuration ['documentClass ' ] ?? null );
429
+ }
430
+ break ;
431
+ case 'doctrineOrmOptions ' :
432
+ if (class_exists (OrmOptions::class)) {
433
+ return new OrmOptions ($ configuration ['entityClass ' ] ?? null );
434
+ }
435
+ break ;
423
436
}
424
437
425
438
return null ;
Original file line number Diff line number Diff line change 386
386
<xsd : complexType name =" stateOptions" >
387
387
<xsd : choice >
388
388
<xsd : element ref =" elasticsearchOptions" />
389
+ <xsd : element ref =" doctrineOdmOptions" />
390
+ <xsd : element ref =" doctrineOrmOptions" />
389
391
</xsd : choice >
390
392
</xsd : complexType >
391
393
395
397
</xsd : complexType >
396
398
</xsd : element >
397
399
400
+ <xsd : element name =" doctrineOdmOptions" >
401
+ <xsd : complexType >
402
+ <xsd : attribute name =" documentClass" type =" xsd:string" />
403
+ </xsd : complexType >
404
+ </xsd : element >
405
+
406
+ <xsd : element name =" doctrineOrmOptions" >
407
+ <xsd : complexType >
408
+ <xsd : attribute name =" entityClass" type =" xsd:string" />
409
+ </xsd : complexType >
410
+ </xsd : element >
411
+
398
412
<xsd : element name =" link" >
399
413
<xsd : complexType >
400
414
<xsd : attribute name =" rel" type =" xsd:string" />
You can’t perform that action at this time.
0 commit comments