本文整理汇总了PHP中Terminus\Helpers\Input::confirm方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::confirm方法的具体用法?PHP Input::confirm怎么用?PHP Input::confirm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terminus\Helpers\Input
的用法示例。
在下文中一共展示了Input::confirm方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* Delete a machine token from your account
*
* ## OPTIONS
* [--machine-token-id=<id>]
* : UUID or name of the site you want to delete
*
* [--force]
* : to skip the confirmations
*/
public function delete($args, $assoc_args)
{
$user = Session::getUser();
$id = $assoc_args['machine-token-id'];
if (empty($id)) {
$this->failure('You must specify a machine token id to delete.');
}
// Find the token
$machine_token = $user->machine_tokens->get($assoc_args['machine-token-id']);
if (empty($machine_token)) {
$this->failure('There are no machine tokens with the id {id}.', array('id' => $id));
}
$name = $machine_token->get('device_name');
if (!isset($assoc_args['force']) && !Terminus::getConfig('yes')) {
//If the force option isn't used, we'll ask you some annoying questions
Input::confirm(array('message' => 'Are you sure you want to delete %s?', 'context' => $name));
}
$this->log()->info('Deleting {name} ...', array('name' => $name));
$response = $machine_token->delete();
if ($response['status_code'] == 200) {
$this->log()->info('Deleted {name}!', array('name' => $name));
} else {
$this->failure('There was an problem deleting the machine token.');
}
}
示例2: wipe
/**
* Complete wipe and reset a site
*
* ## OPTIONS
*
* [--site=<site>]
* : Site to use
*
* [--env=<env>]
* : Environment to be wiped
*/
public function wipe($args, $assoc_args)
{
$site = $this->sites->get(Input::sitename($assoc_args));
$env = $site->environments->get(Input::env(array('args' => $assoc_args, 'site' => $site)));
Input::confirm(sprintf('Are you sure you want to wipe %s-%s?', $site->get('name'), $env->get('id')));
$workflow = $env->wipe();
$workflow->wait();
$this->log()->info('Successfully wiped {site}-{env}', array('site' => $site->get('name'), 'env' => $env->get('id')));
}
示例3: destinationIsValid
/**
* Ensures that the given destination is valid
*
* @param string $destination Location of directory to ensure viability of
* @param bool $make True to create destination if it does not exist
* @return string Same as the parameter
* @throws TerminusException
*/
function destinationIsValid($destination, $make = true)
{
if (file_exists($destination) and !is_dir($destination)) {
throw new TerminusException('Destination given is a file. It must be a directory.');
}
if (!is_dir($destination)) {
if (!$make) {
$make = Input::confirm(array('message' => 'Directory does not exists. Create it now?'));
}
if ($make) {
mkdir($destination, 0755);
}
}
return $destination;
}
示例4: sites
/**
* List an organization's sites
*
* ## OPTIONS
*
* <add|remove|list>
* : subfunction to run
*
* [--org=<id|name>]
* : Organization UUID or name
*
* [--tag=<tag>]
* : Tag name to filter sites list by
*
* [--site=<site>]
* : Site to add to or remove from organization
*
* @subcommand sites
*/
public function sites($args, $assoc_args)
{
$action = array_shift($args);
$org_id = Input::orgId(array('args' => $assoc_args, 'allow_none' => false));
// TODO: clarify that these are OrganizationMemberships, not Organization models
$orgs = new UserOrganizationMemberships();
$org = $orgs->get($org_id);
$org_info = $org->get('organization');
$org_model = new Organization($org_info);
$memberships = $org->site_memberships->all();
switch ($action) {
case 'add':
if (isset($assoc_args['site'])) {
if ($this->siteIsMember($memberships, $assoc_args['site'])) {
$this->failure('{site} is already a member of {org}', array('site' => $assoc_args['site'], 'org' => $org_info->profile->name));
} else {
$site = $this->sites->get($assoc_args['site']);
}
} else {
$site = $this->sites->get(Input::menu(array('choices' => $this->getNonmemberSiteList($memberships), 'message' => 'Choose site')));
}
Input::confirm(array('message' => 'Are you sure you want to add %s to %s ?', 'context' => array($site->get('name'), $org_info->profile->name)));
$workflow = $org_model->site_memberships->addMember($site);
$workflow->wait();
$this->workflowOutput($workflow);
break;
case 'remove':
if (isset($assoc_args['site'])) {
if (!$this->siteIsMember($memberships, $assoc_args['site'])) {
$this->failure('{site} is not a member of {org}', array('site' => $assoc_args['site'], 'org' => $org_info->profile->name));
} else {
$site = $this->sites->get($assoc_args['site']);
}
} else {
$site = $this->sites->get(Input::menu(array('choices' => $this->getMemberSiteList($memberships), 'message' => 'Choose site')));
}
$member = $org_model->site_memberships->get($site->get('id'));
Input::confirm(array('message' => 'Are you sure you want to remove %s from %s ?', 'context' => array($site->get('name'), $org_info->profile->name)));
$workflow = $member->removeMember();
$workflow->wait();
$this->workflowOutput($workflow);
break;
case 'list':
default:
foreach ($memberships as $membership) {
if (isset($assoc_args['tag']) && !in_array($assoc_args['tag'], $membership->get('tags'))) {
continue;
}
$site = $membership->get('site');
$data_array = array('name' => null, 'id' => null, 'service_level' => null, 'framework' => null, 'created' => null, 'tags' => $membership->get('tags'));
foreach ($data_array as $key => $value) {
if ($value == null && isset($site->{$key})) {
$data_array[$key] = $site->{$key};
}
}
$data_array['created'] = date('Y-m-dTH:i:s', strtotime($data_array['created']));
$data[] = $data_array;
}
$this->output()->outputRecordList($data);
break;
}
}
示例5: massUpdate
/**
* Update all 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
*
* [--cached]
* : Set to prevent rebuilding of sites cache
*
* @subcommand mass-update
*/
public function massUpdate($args, $assoc_args)
{
// Ensure the sitesCache is up to date
if (!isset($assoc_args['cached'])) {
$this->sites->rebuildCache();
}
$upstream = Input::optional(array('key' => 'upstream', 'choices' => $assoc_args, 'default' => false));
$data = array();
$report = Input::optional(array('key' => 'report', 'choices' => $assoc_args, 'default' => false));
$confirm = Input::optional(array('key' => 'confirm', 'choices' => $assoc_args, 'default' => false));
$tag = Input::optional(array('key' => 'tag', 'choices' => $assoc_args, 'default' => false));
$org = '';
if ($tag) {
$org = Input::orgId(array('args' => $assoc_args));
}
$sites = $this->sites->filterAllByTag($tag, $org);
// Start status messages.
if ($upstream) {
$this->log()->info('Looking for sites using {upstream}.', compact('upstream'));
}
foreach ($sites as $site) {
$context = array('site' => $site->get('name'));
$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 && 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') {
$message = '{site} has available updates, but is in SFTP mode.';
$message .= ' Switch to Git mode to apply updates.';
$this->log()->warning($message, $context);
$data[$site->get('name')] = array('site' => $site->get('name'), 'status' => 'Needs update - switch to Git mode');
continue;
}
$updatedb = !Input::optional(array('key' => 'updatedb', 'choices' => $assoc_args, 'default' => false));
$xoption = !Input::optional(array('key' => 'xoption', 'choices' => $assoc_args, 'default' => 'theirs'));
if (!$report) {
$message = 'Apply upstream updates to %s ';
$message .= '( run update.php:%s, xoption:%s ) ';
$confirmed = Input::confirm(array('message' => $message, 'context' => array($site->get('name'), var_export($updatedb, 1), var_export($xoption, 1)), 'exit' => false));
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}.', $context);
$backup = $env->createBackup(array('element' => 'all'));
// Only continue if the backup was successful.
if ($backup) {
$this->log()->info('Backup of {site} created.', $context);
$this->log()->info('Updating {site}.', $context);
$response = $site->applyUpstreamUpdates($env->get('id'), $updatedb, $xoption);
$data[$site->get('name')]['status'] = 'Updated';
$this->log()->info('{site} is updated.', $context);
} else {
$data[$site->get('name')]['status'] = 'Backup failed';
$this->failure('There was a problem backing up {site}. Update aborted.', $context);
}
}
//.........这里部分代码省略.........