-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
153/maintenance mode #174
153/maintenance mode #174
Conversation
# Although Drush isn't needed/used, the version that Lando includes by default | ||
# has a bug that causes all build steps to fail. We therefore need to update | ||
# Drush to the latest version just to make sure that build steps run properly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to keep this comment for now, since it explains why we need to specify the Drush version. It's because Lando defaults to 1.4.0 (https://github.com/lando/backdrop/blob/505b65ebf113887a4d341f252a543c5d8c4ca83d/recipes/backdrop/builder.js#L48) but that version doesn't include this necessary change: backdrop-contrib/backdrop-drush-extension#232 (need a new release for that).
@@ -4,6 +4,7 @@ | |||
<file>backdrop/BeeCoreTest.php</file> | |||
<file>backdrop/CacheCommandsTest.php</file> | |||
<file>backdrop/ConfigCommandsTest.php</file> | |||
<file>backdrop/StateCommandsTest.php</file> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of the tests are listed alphabetically. Can we move this one down appropriately?
<?php | ||
/** | ||
* @file | ||
* Command(s) for getting and setting backdrop states. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Command(s) for getting and setting backdrop states. | |
* Command(s) for getting and setting Backdrop states. |
* Implements hook_bee_command(). | ||
*/ | ||
function state_bee_command() { | ||
return [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backdrop hasn't yet changed to using the short array syntax, and neither has Bee. So for consistency with the rest of the code we should use the longer syntax.
If we really want to change to the short syntax, we need a new issue to address this throughout all of Bee.
'description' => bt('Get the value of a Backdrop state.'), | ||
'callback' => 'state_get_bee_callback', | ||
'arguments' => [ | ||
'state' => bt('The name of the state to get.'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know much about states, but is it worth making this optional so you can run bee state-get
to see a list of all states and their values...? (similar to bee config-get
)
Looks like state_initialize()
would do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about this some more, and this can be a followup issue if there's interest. So happy to leave this as-is for now.
$output_all = shell_exec('bee state-get maintenance_mode'); | ||
$this->assertStringContainsString('0', $output_all); | ||
$this->assertStringContainsString('maintenance_mode', $output_all); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$output_all = shell_exec('bee state-get maintenance_mode'); | |
$this->assertStringContainsString('0', $output_all); | |
$this->assertStringContainsString('maintenance_mode', $output_all); | |
$output = shell_exec('bee state-get maintenance_mode'); | |
$this->assertStringContainsString("The value of the 'maintenance_mode' state is: 0", $output); |
$output = shell_exec('bee state-get maintenance_mode'); | ||
$this->assertStringContainsString('maintenance_mode', $output); | ||
$this->assertStringContainsString('0', $output); | ||
|
||
$output = shell_exec('bee state-set maintenance_mode 1'); | ||
$this->assertStringContainsString('1', $output); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$output = shell_exec('bee state-get maintenance_mode'); | |
$this->assertStringContainsString('maintenance_mode', $output); | |
$this->assertStringContainsString('0', $output); | |
$output = shell_exec('bee state-set maintenance_mode 1'); | |
$this->assertStringContainsString('1', $output); | |
// Make sure maintenance_mode is '0'. | |
$output = shell_exec('bee state-get maintenance_mode'); | |
$this->assertStringContainsString("The value of the 'maintenance_mode' state is: 0", $output); | |
// Set maintenance_mode to '1'. | |
$output = shell_exec('bee state-set maintenance_mode 1'); | |
$this->assertStringContainsString("The 'maintenance_mode' state was set to: 1", $output); | |
// Make sure maintenance_mode is '1'. | |
$output = shell_exec('bee state-get maintenance_mode'); | |
$this->assertStringContainsString("The value of the 'maintenance_mode' state is: 1", $output); |
$this->assertStringContainsString('1', $output); | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
/** |
$this->assertStringContainsString('maintenance_mode', $output); | ||
$this->assertStringContainsString('1', $output); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->assertStringContainsString('maintenance_mode', $output); | |
$this->assertStringContainsString('1', $output); | |
$this->assertStringContainsString("The 'maintenance_mode' state was set to: 1", $output); |
$this->assertStringContainsString('1', $output); | ||
|
||
$output = shell_exec('bee state-set maintenance_mode 0'); | ||
$this->assertStringContainsString('0', $output); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->assertStringContainsString('0', $output); | |
$this->assertStringContainsString("The 'maintenance_mode' state was set to: 0", $output); |
$msg = bt('The value of the Backdrop state named "@state" is "@value".', [ | ||
'@state' => $arguments['state'], | ||
'@value' => $value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'm now thinking this should be displayed via the return value, rather than a message... See https://github.com/backdrop-contrib/bee/blob/1.x-1.x/API.md#command_bee_callback for details and bee config-get
for an example (though I don't mind outputting something like the text above as opposed to just the value itself).
@serundeputy what you've done here is great and will be a fantastic addition to bee. Thank you. Do you have capacity to address @BWPanda 's feedback? If not, are you happy for me to work on that branch to get it over the line? |
@yorkshire-pudding yes; please pick up the branch. thanks! |
Update branch with commits from 1.x-1.x
Superceded by PR #232 which incorporates this work and the feedback. |
Adding commands:
bee state-get <STATE>
bee state-set <STATE> <VALUE>
bee maintenance-mode <VALUE>