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 1313
1414namespace ApiPlatform \Metadata \Extractor ;
1515
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 ;
1719use ApiPlatform \Metadata \Exception \InvalidArgumentException ;
1820use ApiPlatform \Metadata \GetCollection ;
1921use ApiPlatform \Metadata \HeaderParameter ;
@@ -468,13 +470,23 @@ private function buildStateOptions(\SimpleXMLElement $resource): ?OptionsInterfa
468470 if (!$ stateOptions ) {
469471 return null ;
470472 }
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+ );
478490 }
479491
480492 return null ;
Original file line number Diff line number Diff line change 1313
1414namespace ApiPlatform \Metadata \Extractor ;
1515
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 ;
1719use ApiPlatform \Metadata \Exception \InvalidArgumentException ;
1820use ApiPlatform \Metadata \GetCollection ;
1921use ApiPlatform \Metadata \HeaderParameter ;
@@ -417,9 +419,20 @@ private function buildStateOptions(array $resource): ?OptionsInterface
417419 $ configuration = reset ($ stateOptions );
418420 switch (key ($ stateOptions )) {
419421 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 );
422424 }
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 ;
423436 }
424437
425438 return null ;
Original file line number Diff line number Diff line change 386386 <xsd : complexType name =" stateOptions" >
387387 <xsd : choice >
388388 <xsd : element ref =" elasticsearchOptions" />
389+ <xsd : element ref =" doctrineOdmOptions" />
390+ <xsd : element ref =" doctrineOrmOptions" />
389391 </xsd : choice >
390392 </xsd : complexType >
391393
395397 </xsd : complexType >
396398 </xsd : element >
397399
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+
398412 <xsd : element name =" link" >
399413 <xsd : complexType >
400414 <xsd : attribute name =" rel" type =" xsd:string" />
You can’t perform that action at this time.
0 commit comments