File tree 3 files changed +13
-11
lines changed
3 files changed +13
-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
17
use ApiPlatform \Metadata \Exception \InvalidArgumentException ;
17
18
use ApiPlatform \Metadata \GetCollection ;
18
19
use ApiPlatform \Metadata \Post ;
19
- use ApiPlatform \Metadata \Tests \Fixtures \StateOptions ;
20
20
use ApiPlatform \OpenApi \Model \ExternalDocumentation ;
21
21
use ApiPlatform \OpenApi \Model \Operation as OpenApiOperation ;
22
22
use ApiPlatform \OpenApi \Model \Parameter ;
@@ -451,10 +451,12 @@ private function buildStateOptions(\SimpleXMLElement $resource): ?OptionsInterfa
451
451
}
452
452
$ elasticsearchOptions = $ stateOptions ->elasticsearchOptions ?? null ;
453
453
if ($ elasticsearchOptions ) {
454
- return new StateOptions (
455
- isset ($ elasticsearchOptions ['index ' ]) ? (string ) $ elasticsearchOptions ['index ' ] : null ,
456
- isset ($ elasticsearchOptions ['type ' ]) ? (string ) $ elasticsearchOptions ['type ' ] : null ,
457
- );
454
+ if (class_exists (Options::class)) {
455
+ return new Options (
456
+ isset ($ elasticsearchOptions ['index ' ]) ? (string ) $ elasticsearchOptions ['index ' ] : null ,
457
+ isset ($ elasticsearchOptions ['type ' ]) ? (string ) $ elasticsearchOptions ['type ' ] : null ,
458
+ );
459
+ }
458
460
}
459
461
460
462
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
17
use ApiPlatform \Metadata \Exception \InvalidArgumentException ;
17
18
use ApiPlatform \Metadata \GetCollection ;
18
19
use ApiPlatform \Metadata \Post ;
19
- use ApiPlatform \Metadata \Tests \Fixtures \StateOptions ;
20
20
use ApiPlatform \OpenApi \Model \ExternalDocumentation ;
21
21
use ApiPlatform \OpenApi \Model \Operation as OpenApiOperation ;
22
22
use ApiPlatform \OpenApi \Model \Parameter ;
@@ -410,7 +410,9 @@ private function buildStateOptions(array $resource): ?OptionsInterface
410
410
$ configuration = reset ($ stateOptions );
411
411
switch (key ($ stateOptions )) {
412
412
case 'elasticsearchOptions ' :
413
- return new StateOptions ($ configuration ['index ' ] ?? null , $ configuration ['type ' ] ?? null );
413
+ if (class_exists (Options::class)) {
414
+ return new Options ($ configuration ['index ' ] ?? null , $ configuration ['type ' ] ?? null );
415
+ }
414
416
}
415
417
416
418
return null ;
Original file line number Diff line number Diff line change 36
36
use ApiPlatform \Metadata \Tests \Extractor \Adapter \XmlResourceAdapter ;
37
37
use ApiPlatform \Metadata \Tests \Extractor \Adapter \YamlResourceAdapter ;
38
38
use ApiPlatform \Metadata \Tests \Fixtures \ApiResource \Comment ;
39
- use ApiPlatform \Metadata \Tests \Fixtures \StateOptions ;
40
39
use ApiPlatform \Metadata \Util \CamelCaseToSnakeCaseNameConverter ;
41
40
use ApiPlatform \OpenApi \Model \ExternalDocumentation ;
42
41
use ApiPlatform \OpenApi \Model \Operation as OpenApiOperation ;
43
42
use ApiPlatform \OpenApi \Model \RequestBody ;
44
- use ApiPlatform \State \OptionsInterface ;
45
43
use PHPUnit \Framework \AssertionFailedError ;
46
44
use PHPUnit \Framework \TestCase ;
47
45
use Symfony \Component \WebLink \Link ;
@@ -720,7 +718,7 @@ private function withGraphQlOperations(array $values, ?array $fixtures): array
720
718
return $ operations ;
721
719
}
722
720
723
- private function withStateOptions (array $ values ): ? OptionsInterface
721
+ private function withStateOptions (array $ values )
724
722
{
725
723
if (!$ values ) {
726
724
return null ;
@@ -733,7 +731,7 @@ private function withStateOptions(array $values): ?OptionsInterface
733
731
$ configuration = reset ($ values );
734
732
switch (key ($ values )) {
735
733
case 'elasticsearchOptions ' :
736
- return new StateOptions ( $ configuration [ ' index ' ] ?? null , $ configuration [ ' type ' ] ?? null ) ;
734
+ return null ;
737
735
}
738
736
739
737
throw new \LogicException (sprintf ('Unsupported "%s" state options. ' , key ($ values )));
You can’t perform that action at this time.
0 commit comments