本文整理汇总了PHP中Terminus\Helpers\Input::yesno方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::yesno方法的具体用法?PHP Input::yesno怎么用?PHP Input::yesno使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terminus\Helpers\Input
的用法示例。
在下文中一共展示了Input::yesno方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mass_update
/**
* Update alls dev sites with an available upstream update.
*
* ## OPTIONS
*
* [--report]
* : If set output will contain list of sites and whether they are up-to-date
*
* [--upstream=<upstream>]
* : Specify a specific upstream to check for updating.
*
* [--no-updatedb]
* : Use flag to skip running update.php after the update has applied
*
* [--xoption=<theirs|ours>]
* : Corresponds to git's -X option, set to 'theirs' by default -- https://www.kernel.org/pub/software/scm/git/docs/git-merge.html
*
* @subcommand mass-update
*/
public function mass_update($args, $assoc_args)
{
$sites = SiteFactory::instance();
$env = 'dev';
$upstream = Input::optional('upstream', $assoc_args, false);
$data = array();
$report = Input::optional('report', $assoc_args, false);
$confirm = Input::optional('confirm', $assoc_args, false);
// Start status messages.
if ($upstream) {
Terminus::line('Looking for sites using ' . $upstream . '.');
}
foreach ($sites as $site) {
$updates = $site->getUpstreamUpdates();
if (!isset($updates->behind)) {
// No updates, go back to start.
continue;
}
// Check for upstream argument and site upstream URL match.
$siteUpstream = $site->info('upstream');
if ($upstream and isset($siteUpstream->url)) {
if ($siteUpstream->url != $upstream) {
// Uptream doesn't match, go back to start.
continue;
}
}
if ($updates->behind > 0) {
$data[$site->getName()] = array('site' => $site->getName(), 'status' => "Needs update");
$noupdatedb = Input::optional($assoc_args, 'updatedb', false);
$update = $noupdatedb ? false : true;
$xoption = Input::optional($assoc_args, 'xoption', 'theirs');
if (!$report) {
$confirmed = Input::yesno("Apply upstream updatefs to %s ( run update.php:%s, xoption:%s ) ", array($site->getName(), var_export($update, 1), var_export($xoption, 1)));
if (!$confirmed) {
continue;
}
// Suer says No, go back to start.
// Backup the DB so the client can restore if something goes wrong.
Terminus::line('Backing up ' . $site->getName() . '.');
$backup = $site->environment('dev')->createBackup(array('element' => 'all'));
// Only continue if the backup was successful.
if ($backup) {
Terminus::success("Backup of " . $site->getName() . " created.");
Terminus::line('Updating ' . $site->getName() . '.');
// Apply the update, failure here would trigger a guzzle exception so no need to validate success.
$response = $site->applyUpstreamUpdates($env, $update, $xoption);
$data[$site->getName()]['status'] = 'Updated';
Terminus::success($site->getName() . ' is updated.');
} else {
$data[$site->getName()]['status'] = 'Backup failed';
Terminus::error('There was a problem backing up ' . $site->getName() . '. Update aborted.');
}
}
} else {
if (isset($assoc_args['report'])) {
$data[$site->getName()] = array('site' => $site->getName(), 'status' => "Up to date");
}
}
}
if (!empty($data)) {
sort($data);
$this->handleDisplay($data);
} else {
Terminus::line('No sites in need up updating.');
}
}
示例2: mass_update
/**
* Update alls dev sites with an available upstream update.
*
* ## OPTIONS
*
* [--report]
* : If set output will contain list of sites and whether they are up-to-date
*
* [--upstream=<upstream>]
* : Specify a specific upstream to check for updating.
*
* [--no-updatedb]
* : Use flag to skip running update.php after the update has applied
*
* [--xoption=<theirs|ours>]
* : Corresponds to git's -X option, set to 'theirs' by default -- https://www.kernel.org/pub/software/scm/git/docs/git-merge.html
*
* [--tag=<tag>]
* : Tag to filter by
*
* [--org=<id>]
* : Only necessary if using --tag. Organization which has tagged the site thusly
*
* [--cached]
* : Set to prevent rebuilding of sites cache
*
* @subcommand mass-update
*/
public function mass_update($args, $assoc_args)
{
// Ensure the sitesCache is up to date
if (!isset($assoc_args['cached'])) {
$this->sites->rebuildCache();
}
$upstream = Input::optional('upstream', $assoc_args, false);
$data = array();
$report = Input::optional('report', $assoc_args, false);
$confirm = Input::optional('confirm', $assoc_args, false);
$tag = Input::optional('tag', $assoc_args, false);
$org = '';
if ($tag) {
$org = Input::orgid($assoc_args, 'org');
}
$sites = $this->sites->filterAllByTag($tag, $org);
// Start status messages.
if ($upstream) {
$this->log()->info('Looking for sites using ' . $upstream . '.');
}
foreach ($sites as $site) {
$site->fetch();
$updates = $site->getUpstreamUpdates();
if (!isset($updates->behind)) {
// No updates, go back to start.
continue;
}
// Check for upstream argument and site upstream URL match.
$siteUpstream = $site->info('upstream');
if ($upstream and isset($siteUpstream->url)) {
if ($siteUpstream->url != $upstream) {
// Uptream doesn't match, go back to start.
continue;
}
}
if ($updates->behind > 0) {
$data[$site->get('name')] = array('site' => $site->get('name'), 'status' => "Needs update");
$env = $site->environments->get('dev');
if ($env->getConnectionMode() == 'sftp') {
$this->log()->warning('{site} has available updates, but is in SFTP mode. Switch to Git mode to apply updates.', array('site' => $site->get('name')));
$data[$site->get('name')] = array('site' => $site->get('name'), 'status' => "Needs update - switch to Git mode");
continue;
}
$updatedb = !Input::optional($assoc_args, 'updatedb', false);
$xoption = Input::optional($assoc_args, 'xoption', 'theirs');
if (!$report) {
$confirmed = Input::yesno("Apply upstream updates to %s ( run update.php:%s, xoption:%s ) ", array($site->get('name'), var_export($updatedb, 1), var_export($xoption, 1)));
if (!$confirmed) {
continue;
}
// User says No, go back to start.
// Backup the DB so the client can restore if something goes wrong.
$this->log()->info('Backing up ' . $site->get('name') . '.');
$backup = $env->createBackup(array('element' => 'all'));
// Only continue if the backup was successful.
if ($backup) {
$this->log()->info("Backup of " . $site->get('name') . " created.");
$this->log()->info('Updating ' . $site->get('name') . '.');
// Apply the update, failure here would trigger a guzzle exception so no need to validate success.
$response = $site->applyUpstreamUpdates($env->get('id'), $updatedb, $xoption);
$data[$site->get('name')]['status'] = 'Updated';
$this->log()->info($site->get('name') . ' is updated.');
} else {
$data[$site->get('name')]['status'] = 'Backup failed';
$this->log()->error('There was a problem backing up ' . $site->get('name') . '. Update aborted.');
}
}
} else {
if (isset($assoc_args['report'])) {
$data[$site->get('name')] = array('site' => $site->get('name'), 'status' => "Up to date");
}
}
//.........这里部分代码省略.........