7
7
use Bornfight \JsonApiDocumentation \Documentation \EntityDetailsService ;
8
8
use Bornfight \JsonApiDocumentation \Documentation \JsonApiClassParser ;
9
9
use Bornfight \JsonApiDocumentation \Documentation \RouteFactory ;
10
+ use Doctrine \Inflector \Inflector ;
11
+ use Doctrine \Inflector \LanguageInflectorFactory ;
10
12
use Exception ;
11
13
use Symfony \Bundle \MakerBundle \Str ;
12
14
use Symfony \Component \Console \Command \Command ;
13
15
use Symfony \Component \Console \Input \InputInterface ;
14
16
use Symfony \Component \Console \Output \OutputInterface ;
15
17
use Symfony \Component \Console \Style \SymfonyStyle ;
16
18
use Symfony \Component \Filesystem \Filesystem ;
17
- use Symfony \Component \String \Inflector \EnglishInflector ;
18
- use Symfony \Component \String \Inflector \InflectorInterface ;
19
19
use Symfony \Component \Yaml \Exception \ParseException ;
20
20
use Symfony \Component \Yaml \Yaml ;
21
21
@@ -35,7 +35,7 @@ class ApiDocumentationCommand extends Command
35
35
*/
36
36
private $ routeFactory ;
37
37
/**
38
- * @var InflectorInterface
38
+ * @var Inflector
39
39
*/
40
40
private $ inflector ;
41
41
/**
@@ -51,16 +51,13 @@ class ApiDocumentationCommand extends Command
51
51
*/
52
52
private $ customHandlers ;
53
53
54
- /**
55
- * @SuppressWarnings(PHPMD.ExcessiveParameterList)
56
- */
57
- public function __construct (iterable $ customHandlers , string $ projectDir , Filesystem $ filesystem , RouteFactory $ routeFactory , EntityDetailsService $ entityDetailsService , JsonApiClassParser $ jsonApiClassParser )
54
+ public function __construct (iterable $ customHandlers , string $ projectDir , Filesystem $ filesystem , RouteFactory $ routeFactory , EntityDetailsService $ entityDetailsService , JsonApiClassParser $ jsonApiClassParser , LanguageInflectorFactory $ languageInflectorFactory )
58
55
{
59
56
parent ::__construct ();
60
57
$ this ->projectDir = $ projectDir ;
61
58
$ this ->filesystem = $ filesystem ;
62
59
$ this ->routeFactory = $ routeFactory ;
63
- $ this ->inflector = new EnglishInflector ();
60
+ $ this ->inflector = $ languageInflectorFactory -> build ();
64
61
$ this ->entityDetails = $ entityDetailsService ->getEntityDetails ();
65
62
$ this ->jsonApiClassParser = $ jsonApiClassParser ;
66
63
$ this ->customHandlers = $ customHandlers ;
@@ -103,7 +100,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
103
100
continue ;
104
101
}
105
102
106
- $ routePath = Str::asRoutePath ($ this ->inflector ->pluralize ($ className )[ 0 ] );
103
+ $ routePath = Str::asRoutePath ($ this ->inflector ->pluralize ($ className ));
107
104
$ routeWithId = $ routePath . '/{id} ' ;
108
105
109
106
$ attributes = $ this ->jsonApiClassParser ->getTransformerAttributes ($ className );
0 commit comments