File tree Expand file tree Collapse file tree 8 files changed +61
-7
lines changed
Elasticsearch/Metadata/Document/Factory Expand file tree Collapse file tree 8 files changed +61
-7
lines changed Original file line number Diff line number Diff line change 14
14
namespace ApiPlatform \Core \Annotation ;
15
15
16
16
use ApiPlatform \Core \Exception \InvalidArgumentException ;
17
- use Doctrine \ Common \ Inflector \Inflector ;
17
+ use ApiPlatform \ Core \ Util \Inflector ;
18
18
19
19
/**
20
20
* Hydrates attributes from annotation's parameters.
Original file line number Diff line number Diff line change 16
16
use ApiPlatform \Core \Bridge \Elasticsearch \Exception \IndexNotFoundException ;
17
17
use ApiPlatform \Core \Bridge \Elasticsearch \Metadata \Document \DocumentMetadata ;
18
18
use ApiPlatform \Core \Metadata \Resource \Factory \ResourceMetadataFactoryInterface ;
19
- use Doctrine \ Common \ Inflector \Inflector ;
19
+ use ApiPlatform \ Core \ Util \Inflector ;
20
20
use Elasticsearch \Client ;
21
21
use Elasticsearch \Common \Exceptions \Missing404Exception ;
22
22
Original file line number Diff line number Diff line change 16
16
use ApiPlatform \Core \Api \OperationType ;
17
17
use ApiPlatform \Core \Api \OperationTypeDeprecationHelper ;
18
18
use ApiPlatform \Core \Exception \InvalidArgumentException ;
19
- use Doctrine \ Common \ Inflector \Inflector ;
19
+ use ApiPlatform \ Core \ Util \Inflector ;
20
20
21
21
/**
22
22
* Generates the Symfony route name associated with an operation name and a resource short name.
Original file line number Diff line number Diff line change 21
21
use ApiPlatform \Core \Metadata \Property \Factory \PropertyNameCollectionFactoryInterface ;
22
22
use ApiPlatform \Core \Metadata \Resource \Factory \ResourceMetadataFactoryInterface ;
23
23
use ApiPlatform \Core \Metadata \Resource \ResourceMetadata ;
24
- use Doctrine \ Common \ Inflector \Inflector ;
24
+ use ApiPlatform \ Core \ Util \Inflector ;
25
25
use GraphQL \Type \Definition \InputObjectType ;
26
26
use GraphQL \Type \Definition \NullableType ;
27
27
use GraphQL \Type \Definition \Type as GraphQLType ;
Original file line number Diff line number Diff line change 13
13
14
14
namespace ApiPlatform \Core \Operation ;
15
15
16
- use Doctrine \ Common \ Inflector \Inflector ;
16
+ use ApiPlatform \ Core \ Util \Inflector ;
17
17
18
18
/**
19
19
* Generate a path name with a dash separator according to a string and whether it's a collection or not.
Original file line number Diff line number Diff line change 13
13
14
14
namespace ApiPlatform \Core \Operation ;
15
15
16
- use Doctrine \ Common \ Inflector \Inflector ;
16
+ use ApiPlatform \ Core \ Util \Inflector ;
17
17
18
18
/**
19
19
* Generate a path name with an underscore separator according to a string and whether it's a collection or not.
Original file line number Diff line number Diff line change 15
15
16
16
use ApiPlatform \Core \Annotation \ApiFilter ;
17
17
use Doctrine \Common \Annotations \Reader ;
18
- use Doctrine \Common \Inflector \Inflector ;
19
18
20
19
/**
21
20
* Generates a service id for a generic filter.
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the API Platform project.
5
+ *
6
+ * (c) Kévin Dunglas <[email protected] >
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ declare (strict_types=1 );
13
+
14
+ namespace ApiPlatform \Core \Util ;
15
+
16
+ use Doctrine \Common \Inflector \Inflector as LegacyInflector ;
17
+ use Doctrine \Inflector \Inflector as InflectorObject ;
18
+ use Doctrine \Inflector \InflectorFactory ;
19
+
20
+ /**
21
+ * Facade for Doctrine Inflector.
22
+ *
23
+ * This class allows us to maintain compatibility with Doctrine Inflector 1.3 and 2.0 at the same time.
24
+ *
25
+ * @internal
26
+ */
27
+ final class Inflector
28
+ {
29
+ /**
30
+ * @var InflectorObject
31
+ */
32
+ private static $ instance ;
33
+
34
+ private static function getInstance (): InflectorObject
35
+ {
36
+ return self ::$ instance
37
+ ?? self ::$ instance = InflectorFactory::create ()->build ();
38
+ }
39
+
40
+ /**
41
+ * @see LegacyInflector::tableize()
42
+ */
43
+ public static function tableize (string $ word ): string
44
+ {
45
+ return class_exists (InflectorFactory::class) ? self ::getInstance ()->tableize ($ word ) : LegacyInflector::tableize ($ word );
46
+ }
47
+
48
+ /**
49
+ * @see LegacyInflector::pluralize()
50
+ */
51
+ public static function pluralize (string $ word ): string
52
+ {
53
+ return class_exists (InflectorFactory::class) ? self ::getInstance ()->pluralize ($ word ) : LegacyInflector::pluralize ($ word );
54
+ }
55
+ }
You can’t perform that action at this time.
0 commit comments