7
7
8
8
use Magento \MagentoCloud \Command \Build ;
9
9
use Magento \MagentoCloud \Command \DbDump ;
10
- use Magento \MagentoCloud \Command \CronUnlock ;
11
10
use Magento \MagentoCloud \Command \Deploy ;
12
11
use Magento \MagentoCloud \Command \ConfigDump ;
12
+ use Magento \MagentoCloud \Command \Prestart ;
13
13
use Magento \MagentoCloud \Command \PostDeploy ;
14
14
use Magento \MagentoCloud \Config \ValidatorInterface ;
15
15
use Magento \MagentoCloud \Config \Validator as ConfigValidator ;
16
16
use Magento \MagentoCloud \DB \Data \ConnectionInterface ;
17
17
use Magento \MagentoCloud \DB \Data \ReadConnection ;
18
18
use Magento \MagentoCloud \Filesystem \DirectoryCopier ;
19
+ use Magento \MagentoCloud \Filesystem \DirectoryList ;
20
+ use Magento \MagentoCloud \Filesystem \Flag ;
19
21
use Magento \MagentoCloud \Process \ProcessInterface ;
20
22
use Magento \MagentoCloud \Process \ProcessComposite ;
21
23
use Magento \MagentoCloud \Process \Build as BuildProcess ;
22
24
use Magento \MagentoCloud \Process \DbDump as DbDumpProcess ;
23
25
use Magento \MagentoCloud \Process \Deploy as DeployProcess ;
24
26
use Magento \MagentoCloud \Process \ConfigDump as ConfigDumpProcess ;
27
+ use Magento \MagentoCloud \Process \Prestart as PrestartProcess ;
25
28
use Magento \MagentoCloud \Process \PostDeploy as PostDeployProcess ;
26
29
use Psr \Container \ContainerInterface ;
27
30
use Magento \MagentoCloud \Process ;
@@ -39,12 +42,11 @@ class Container implements ContainerInterface
39
42
private $ container ;
40
43
41
44
/**
42
- * @param string $root
43
- * @param array $config
45
+ * @param DirectoryList $directoryList
44
46
*
45
47
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
46
48
*/
47
- public function __construct (string $ root , array $ config )
49
+ public function __construct (DirectoryList $ directoryList )
48
50
{
49
51
/**
50
52
* Creating concrete container.
@@ -57,8 +59,8 @@ public function __construct(string $root, array $config)
57
59
$ this ->container ->instance (ContainerInterface::class, $ this );
58
60
$ this ->container ->singleton (
59
61
\Magento \MagentoCloud \Filesystem \DirectoryList::class,
60
- function () use ($ root , $ config ) {
61
- return new \ Magento \ MagentoCloud \ Filesystem \ DirectoryList ( $ root , $ config ) ;
62
+ function () use ($ directoryList ) {
63
+ return $ directoryList ;
62
64
}
63
65
);
64
66
$ this ->container ->singleton (\Magento \MagentoCloud \Filesystem \FileList::class);
@@ -70,6 +72,16 @@ function () use ($root, $config) {
70
72
$ fileList ->getComposer ()
71
73
);
72
74
});
75
+ $ this ->container ->singleton (
76
+ Flag \Pool::class,
77
+ function () {
78
+ return new Flag \Pool ([
79
+ Flag \Manager::FLAG_REGENERATE => 'var/.regenerate ' ,
80
+ Flag \Manager::FLAG_STATIC_CONTENT_DEPLOY_IN_BUILD => '.static_content_deploy ' ,
81
+ Flag \Manager::FLAG_STATIC_CONTENT_DEPLOY_PENDING => 'var/.static_content_deploy_pending ' ,
82
+ ]);
83
+ }
84
+ );
73
85
/**
74
86
* Interface to implementation binding.
75
87
*/
@@ -82,14 +94,8 @@ function () use ($root, $config) {
82
94
\Magento \MagentoCloud \DB \Dump::class
83
95
);
84
96
$ this ->container ->singleton (\Magento \MagentoCloud \Config \Environment::class);
85
- $ this ->container ->singleton (\Magento \MagentoCloud \Config \Build::class);
86
- $ this ->container ->singleton (\Magento \MagentoCloud \Config \Deploy::class);
87
- $ this ->container ->singleton (\Psr \Log \LoggerInterface::class, function () {
88
- return new \Monolog \Logger (
89
- 'default ' ,
90
- $ this ->container ->make (\Magento \MagentoCloud \App \Logger \Pool::class)->getHandlers ()
91
- );
92
- });
97
+ $ this ->container ->singleton (\Magento \MagentoCloud \Config \State::class);
98
+ $ this ->container ->singleton (\Psr \Log \LoggerInterface::class, \Magento \MagentoCloud \App \Logger::class);
93
99
$ this ->container ->singleton (\Magento \MagentoCloud \Package \Manager::class);
94
100
$ this ->container ->singleton (\Magento \MagentoCloud \Package \MagentoVersion::class);
95
101
$ this ->container ->singleton (\Magento \MagentoCloud \Util \UrlManager::class);
@@ -101,6 +107,17 @@ function () use ($root, $config) {
101
107
$ this ->container ->singleton (DirectoryCopier \CopyStrategy::class);
102
108
$ this ->container ->singleton (DirectoryCopier \SymlinkStrategy::class);
103
109
$ this ->container ->singleton (DirectoryCopier \StrategyFactory::class);
110
+ $ this ->container ->singleton (\Magento \MagentoCloud \Config \Stage \Build::class);
111
+ $ this ->container ->singleton (\Magento \MagentoCloud \Config \Stage \Deploy::class);
112
+ $ this ->container ->singleton (\Magento \MagentoCloud \Config \RepositoryFactory::class);
113
+ $ this ->container ->singleton (
114
+ \Magento \MagentoCloud \Config \Stage \BuildInterface::class,
115
+ \Magento \MagentoCloud \Config \Stage \Build::class
116
+ );
117
+ $ this ->container ->singleton (
118
+ \Magento \MagentoCloud \Config \Stage \DeployInterface::class,
119
+ \Magento \MagentoCloud \Config \Stage \Deploy::class
120
+ );
104
121
/**
105
122
* Contextual binding.
106
123
*/
@@ -153,6 +170,10 @@ function () use ($root, $config) {
153
170
$ this ->container ->make (DeployProcess \CompressStaticContent::class),
154
171
$ this ->container ->make (DeployProcess \DisableGoogleAnalytics::class),
155
172
$ this ->container ->make (DeployProcess \UnlockCronJobs::class),
173
+ /**
174
+ * Remove this line after implementation post-deploy hook
175
+ */
176
+ $ this ->container ->make (PostDeployProcess \Backup::class),
156
177
/**
157
178
* Cache clean process must remain the last one in deploy chain.
158
179
* Do not add any processes after it.
@@ -199,6 +220,16 @@ function () use ($root, $config) {
199
220
],
200
221
]);
201
222
});
223
+ $ this ->container ->when (Prestart::class)
224
+ ->needs (ProcessInterface::class)
225
+ ->give (function () {
226
+ return $ this ->container ->makeWith (ProcessComposite::class, [
227
+ 'processes ' => [
228
+ $ this ->container ->make (PrestartProcess \DeployStaticContent::class),
229
+ $ this ->container ->make (PrestartProcess \CompressStaticContent::class),
230
+ ],
231
+ ]);
232
+ });
202
233
$ this ->container ->when (DeployProcess \InstallUpdate \ConfigUpdate \Urls::class)
203
234
->needs (ProcessInterface::class)
204
235
->give (function () {
@@ -246,16 +277,6 @@ function () use ($root, $config) {
246
277
'system/websites ' ,
247
278
];
248
279
});
249
- $ this ->container ->when (DeployProcess \PreDeploy::class);
250
- $ this ->container ->when (CronUnlock::class)
251
- ->needs (ProcessInterface::class)
252
- ->give (function () {
253
- return $ this ->container ->makeWith (ProcessComposite::class, [
254
- 'processes ' => [
255
- $ this ->container ->make (DeployProcess \UnlockCronJobs::class),
256
- ],
257
- ]);
258
- });
259
280
$ this ->container ->when (DeployProcess \PreDeploy::class)
260
281
->needs (ProcessInterface::class)
261
282
->give (function () {
@@ -277,9 +298,15 @@ function () use ($root, $config) {
277
298
],
278
299
]);
279
300
});
280
- $ this ->container ->when (\Magento \MagentoCloud \Config \Build::class)
281
- ->needs (\Magento \MagentoCloud \Filesystem \Reader \ReaderInterface::class)
282
- ->give (\Magento \MagentoCloud \Config \Build \Reader::class);
301
+ $ this ->container ->when (PrestartProcess \DeployStaticContent::class)
302
+ ->needs (ProcessInterface::class)
303
+ ->give (function () {
304
+ return $ this ->container ->makeWith (ProcessComposite::class, [
305
+ 'processes ' => [
306
+ $ this ->get (PrestartProcess \DeployStaticContent \Generate::class),
307
+ ],
308
+ ]);
309
+ });
283
310
$ this ->container ->when (BuildProcess \DeployStaticContent::class)
284
311
->needs (ProcessInterface::class)
285
312
->give (function () {
@@ -306,6 +333,7 @@ function () use ($root, $config) {
306
333
->give (function () {
307
334
return $ this ->container ->make (ProcessComposite::class, [
308
335
'processes ' => [
336
+ $ this ->container ->make (PostDeployProcess \Backup::class),
309
337
$ this ->container ->make (PostDeployProcess \CleanCache::class),
310
338
],
311
339
]);
@@ -341,4 +369,16 @@ public function set($abstract, $concrete, bool $shared = true)
341
369
$ this ->container ->forgetInstance ($ abstract );
342
370
$ this ->container ->bind ($ abstract , $ concrete , $ shared );
343
371
}
372
+
373
+ /**
374
+ * Creates instance with params.
375
+ *
376
+ * @param string $abstract The class name to create
377
+ * @param array $params Associative array of constructor params
378
+ * @return object The resolved object
379
+ */
380
+ public function create (string $ abstract , array $ params = [])
381
+ {
382
+ return $ this ->container ->make ($ abstract , $ params );
383
+ }
344
384
}
0 commit comments