-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathFrontendVersionCommands.php
99 lines (89 loc) · 2.69 KB
/
FrontendVersionCommands.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
namespace Drupal\va_gov_content_release\Commands;
use Drupal\va_gov_content_release\Frontend\Frontend;
use Drupal\va_gov_content_release\FrontendVersion\FrontendVersionInterface;
use Drush\Commands\DrushCommands;
/**
* A Drush interface to the frontend version service.
*/
class FrontendVersionCommands extends DrushCommands {
/**
* The Frontend Version service.
*
* @var \Drupal\va_gov_content_release\FrontendVersion\FrontendVersionInterface
*/
protected $frontendVersion;
/**
* Constructor.
*
* @param \Drupal\va_gov_content_release\FrontendVersion\FrontendVersionInterface $frontendVersion
* The frontend version service.
*/
public function __construct(
FrontendVersionInterface $frontendVersion
) {
$this->frontendVersion = $frontendVersion;
}
/**
* Get the frontend.
*
* @param string $frontend
* The frontend whose version we are getting.
*
* @return \Drupal\va_gov_content_release\Frontend\Frontend
* The frontend.
*/
public function getFrontend(string $frontend) {
try {
return Frontend::from($frontend);
}
catch (\Throwable $exception) {
$this->io()->error($exception->getMessage());
exit(1);
}
}
/**
* Get the frontend version.
*
* @param string $frontend
* The frontend whose version we are getting.
*
* @command va-gov-content-release:frontend-version:get
* @aliases va-gov-content-release-frontend-version-get
*/
public function getVersion(string $frontend = 'content_build') {
$frontend = $this->getFrontend($frontend);
$value = $this->frontendVersion->getVersion($frontend);
$this->io()->write($value);
}
/**
* Reset the frontend version.
*
* @param string $frontend
* The frontend whose version we are resetting.
*
* @command va-gov-content-release:frontend-version:reset
* @aliases va-gov-content-release-frontend-version-reset
*/
public function resetVersion(string $frontend = 'content_build') {
$frontend = $this->getFrontend($frontend);
$this->frontendVersion->resetVersion($frontend);
$this->io()->success('Frontend version reset.');
}
/**
* Set the frontend version.
*
* @param string $frontend
* The frontend whose version we are getting.
* @param string $version
* The version to set.
*
* @command va-gov-content-release:frontend-version:set
* @aliases va-gov-content-release-frontend-version-set
*/
public function setVersion(string $frontend = 'content_build', $version = '_default') {
$frontend = $this->getFrontend($frontend);
$this->frontendVersion->setVersion($frontend, $version);
$this->io()->success('Frontend version set to ' . $version);
}
}