13
13
use Symfony \Component \Console \Output \OutputInterface ;
14
14
use Symfony \Component \Console \Input \InputOption ;
15
15
use Symfony \Component \Console \Command \Command ;
16
+ use Symfony \Component \Filesystem \Filesystem ;
17
+ use Symfony \Component \Yaml \Parser ;
16
18
use Drupal \Console \Command \Shared \ChainFilesTrait ;
17
19
use Drupal \Console \Command \Shared \InputTrait ;
18
20
use Drupal \Console \Style \DrupalStyle ;
19
21
use Drupal \Console \Command \Shared \CommandTrait ;
20
22
23
+
21
24
/**
22
25
* Class ChainCommand
23
26
* @package Drupal\Console\Command\Chain
@@ -28,6 +31,27 @@ class ChainCommand extends Command
28
31
use ChainFilesTrait;
29
32
use InputTrait;
30
33
34
+
35
+ protected $ fileUtil ;
36
+ protected $ chainQueue ;
37
+ protected $ configurationManager ;
38
+ protected $ appRoot ;
39
+
40
+ /**
41
+ * ChainCommand constructor.
42
+ * @param $fileUtil
43
+ * @param $chainQueue
44
+ * @param $configurationManager
45
+ * @param $appRoot
46
+ */
47
+ public function __construct ($ fileUtil , $ chainQueue , $ configurationManager , $ appRoot ) {
48
+ $ this ->fileUtil = $ fileUtil ;
49
+ $ this ->chainQueue = $ chainQueue ;
50
+ $ this ->configurationManager = $ configurationManager ;
51
+ $ this ->appRoot = $ appRoot ;
52
+ parent ::__construct ();
53
+ }
54
+
31
55
/**
32
56
* {@inheritdoc}
33
57
*/
@@ -57,7 +81,6 @@ protected function interact(InputInterface $input, OutputInterface $output)
57
81
{
58
82
$ io = new DrupalStyle ($ input , $ output );
59
83
$ file = $ input ->getOption ('file ' );
60
- $ fileUtil = $ this ->getApplication ()->getContainerHelper ()->get ('file_util ' );
61
84
62
85
if (!$ file ) {
63
86
$ files = $ this ->getChainFiles (true );
@@ -68,7 +91,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
68
91
);
69
92
}
70
93
71
- $ file = $ fileUtil ->calculateRealPath ($ file );
94
+ $ file = $ this -> fileUtil ->calculateRealPath ($ file );
72
95
$ input ->setOption ('file ' , $ file );
73
96
74
97
$ chainContent = file_get_contents ($ file );
@@ -113,16 +136,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
113
136
$ learning = $ input ->hasOption ('learning ' )?$ input ->getOption ('learning ' ):false ;
114
137
115
138
$ file = $ input ->getOption ('file ' );
116
- $ fileUtil = $ this ->getApplication ()->getContainerHelper ()->get ('file_util ' );
117
- $ fileSystem = $ this ->getApplication ()->getContainerHelper ()->get ('filesystem ' );
118
139
119
140
if (!$ file ) {
120
141
$ io ->error ($ this ->trans ('commands.chain.messages.missing_file ' ));
121
142
122
143
return 1 ;
123
144
}
124
145
125
- $ file = $ fileUtil ->calculateRealPath ($ file );
146
+ $ fileSystem = new Filesystem ();
147
+
148
+ $ file = $ this ->fileUtil ->calculateRealPath ($ file );
126
149
127
150
if (!$ fileSystem ->exists ($ file )) {
128
151
$ io ->error (
@@ -230,7 +253,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
230
253
$ placeholderResolver = new RegexPlaceholderResolver ($ inlinePlaceHolderData , '%{{ ' , '}} ' );
231
254
$ chainContent = $ placeholderResolver ->resolvePlaceholder ($ chainContent );
232
255
233
- $ parser = $ this -> getApplication ()-> getContainerHelper ()-> get ( ' parser ' );
256
+ $ parser = new Parser ( );
234
257
$ configData = $ parser ->parse ($ chainContent );
235
258
236
259
$ commands = [];
@@ -259,8 +282,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
259
282
}
260
283
}
261
284
262
- $ this ->get ('chain_queue ' )
263
- ->addCommand (
285
+ $ this ->chainQueue ->addCommand (
264
286
$ command ['command ' ],
265
287
$ moduleInputs ,
266
288
$ interactive ,
0 commit comments