本文整理汇总了PHP中Terminus::confirm方法的典型用法代码示例。如果您正苦于以下问题:PHP Terminus::confirm方法的具体用法?PHP Terminus::confirm怎么用?PHP Terminus::confirm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terminus
的用法示例。
在下文中一共展示了Terminus::confirm方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sites
/**
* List an organization's sites
*
* ## OPTIONS
*
* [--org=<id>]
* : Organization id
*
* [--tag=<tag>]
* : Tag name to filter sites list by
*
* [--add=<site>]
* : Site to add to organization
*
* [--remove=<site>]
* : Site to remove from organization
*
* @subcommand sites
*
*/
public function sites($args, $assoc_args)
{
$org_id = Input::orgid($assoc_args, 'org', null, array('allow_none' => false));
$org = new Organization($org_id);
if (isset($assoc_args['add'])) {
$add = SiteFactory::instance(Input::sitename($assoc_args, 'add'));
Terminus::confirm("Are you sure you want to add %s to %s ?", $assoc_args, array($add->getName(), $org->name));
$org->addSite($add);
Terminus::success("Added site!");
return true;
}
if (isset($assoc_args['remove'])) {
$remove = SiteFactory::instance(Input::sitename($assoc_args, 'remove'));
Terminus::confirm("Are you sure you want to remove %s to %s ?", $assoc_args, array($remove->getName(), $org->name));
$org->removeSite($remove);
Terminus::success("Removed site!");
return true;
}
$org->siteMemberships->fetch();
$memberships = $org->siteMemberships->all();
foreach ($memberships as $membership) {
if (isset($assoc_args['tag']) && !in_array($assoc_args['tag'], $membership->get('tags'))) {
continue;
}
$site = $membership->get('site');
$data[] = array('name' => $site->name, 'id' => $site->id, 'service_level' => $site->service_level, 'framework' => $site->framework, 'created' => date('Y-m-d H:i:s', $site->created), 'tags' => $membership->get('tags'));
}
$this->handleDisplay($data);
}
示例2: sites
/**
* List an organizations sites
*
* ## OPTIONS
*
* [--org=<org>]
* : Organization name or Id
*
* [--add=<site>]
* : Site to add to organization
*
* [--remove=<site>]
* : Site to remove from organization
*
* @subcommand sites
*
*/
public function sites($args, $assoc_args)
{
$orgs = array();
$user = new User();
foreach ($user->organizations() as $id => $org) {
$orgs[$id] = $org->name;
}
if (!isset($assoc_args['org']) or empty($assoc_args['org'])) {
$selected_org = Terminus::menu($orgs, false, "Choose an organization");
} else {
$selected_org = $assoc_args['org'];
}
$org = new Organization($selected_org);
if (isset($assoc_args['add'])) {
$add = SiteFactory::instance(Input::site($assoc_args, 'add'));
Terminus::confirm("Are you sure you want to add %s to %s ?", $assoc_args, array($add->getName(), $org->name));
$org->addSite($add);
Terminus::success("Added site!");
return true;
}
if (isset($assoc_args['remove'])) {
$remove = SiteFactory::instance(Input::site($assoc_args, 'remove'));
Terminus::confirm("Are you sure you want to remove %s to %s ?", $assoc_args, array($remove->getName(), $org->name));
$org->removeSite($remove);
Terminus::success("Removed site!");
return true;
}
$sites = $org->getSites();
$data = array();
foreach ($sites as $site) {
$data[] = array('name' => $site->site->name, 'service level' => isset($site->site->service_level) ? $site->site->service_level : '', 'framework' => isset($site->site->framework) ? $site->site->framework : '', 'created' => date('Y-m-d H:i:s', $site->site->created));
}
$this->handleDisplay($data);
}
示例3: destination_is_valid
/**
* Ensures that the given destination is valid
*
* @param [string] $destination Location of directory to ensure viability of
* @param [boolean] $make True to create destination if it does not exist
* @return [string] $destination Same as the parameter
*/
function destination_is_valid($destination, $make = true)
{
if (file_exists($destination) and !is_dir($destination)) {
\Terminus::error("Destination given is a file. It must be a directory.");
}
if (!is_dir($destination)) {
if (!$make) {
$make = \Terminus::confirm("Directory does not exists. Create it now?");
}
if ($make) {
mkdir($destination, 0755);
}
}
return $destination;
}
示例4: sites
/**
* List an organization's sites
*
* ## OPTIONS
*
* [--org=<id|name>]
* : Organization UUID or name
*
* [--tag=<tag>]
* : Tag name to filter sites list by
*
* [--add=<site>]
* : Site to add to organization
*
* [--remove=<site>]
* : Site to remove from organization
*
* @subcommand sites
*
*/
public function sites($args, $assoc_args)
{
$org_id = Input::orgid($assoc_args, 'org', null, array('allow_none' => false));
$orgs = new UserOrganizationMemberships();
$org = $orgs->get($org_id);
$memberships = $org->site_memberships;
if (isset($assoc_args['add'])) {
$site = $this->sites->get(Input::sitename($assoc_args, 'add'));
Terminus::confirm('Are you sure you want to add %s to %s ?', $assoc_args, array($site->get('name'), $org->get('name')));
$memberships->addMember($site);
Terminus::success('Added site!');
return true;
}
if (isset($assoc_args['remove'])) {
$site_id = $assoc_args['remove'];
$member = $memberships->get($assoc_args['remove']);
$site = $member->get('site');
Terminus::confirm('Are you sure you want to remove %s from %s ?', $assoc_args, array($site->name, $org->get('name')));
$member->removeMember();
Terminus::success('Removed site!');
return true;
}
$memberships = $org->getSites();
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', $data_array['created']);
$data[] = $data_array;
}
$this->outputter->outputRecordList($data);
}
示例5: delete
/**
* Delete a site from pantheon
*
* ## OPTIONS
* --site=<site>
* : Id of the site you want to delete
*
* [--all]
* : Just kidding ... we won't let you do that.
*
* [--force]
* : to skip the confirmations
*
*/
function delete($args, $assoc_args)
{
$site_to_delete = SiteFactory::instance(@$assoc_args['site']);
if (!$site_to_delete) {
foreach (SiteFactory::instance() as $id => $site) {
$site->id = $id;
$sites[] = $site;
$menu[] = $site->information->name;
}
$index = Terminus::menu($menu, null, "Select a site to delete");
$site_to_delete = $sites[$index];
}
if (!isset($assoc_args['force']) and !Terminus::get_config('yes')) {
// if the force option isn't used we'll ask you some annoying questions
Terminus::confirm(sprintf("Are you sure you want to delete %s?", $site_to_delete->information->name));
Terminus::confirm("Are you really sure?");
}
Terminus::line(sprintf("Deleting %s ...", $site_to_delete->information->name));
$response = \Terminus_Command::request('sites', $site_to_delete->id, '', 'DELETE');
Terminus::success("Deleted %s!", $site_to_delete->information->name);
}
示例6: upstream_updates
/**
* Show or apply upstream updates
*
* ## OPTIONS
*
* [--site=<site>]
* : Site to check
*
* [--update=<env>]
* : Do update on dev env
*
* @alias upstream-updates
**/
public function upstream_updates($args, $assoc_args)
{
$site = SiteFactory::instance(Input::site($assoc_args));
$upstream = $site->getUpstreamUpdates();
// data munging as usual
$data = array();
if (isset($upstream->remote_url) && isset($upstream->behind)) {
// The $upstream object returns a value of [behind] -> 1 if there is an
// upstream update that has not been applied to Dev.
$data[$upstream->remote_url] = $upstream->behind > 0 ? "Updates Available" : "Up-to-date";
$this->_constructTableForResponse($data, array('Upstream', 'Status'));
if (!isset($upstream) or empty($upstream->update_log)) {
Terminus::success("No updates to show");
}
$upstreams = (array) $upstream->update_log;
if (!empty($upstreams)) {
$data = array();
foreach ($upstreams as $commit) {
$data = array('hash' => $commit->hash, 'datetime' => $commit->datetime, 'message' => $commit->message, 'author' => $commit->author);
$this->handleDisplay($data, $args);
echo PHP_EOL;
}
}
} else {
$this->handleDisplay('There was a problem checking your upstream status. Please try again.');
echo PHP_EOL;
}
if (isset($assoc_args['update']) and !empty($upstream->update_log)) {
$env = 'dev';
Terminus::confirm(sprintf("Are you sure you want to apply the upstream updates to %s-dev", $site->getName(), $env));
$response = $site->applyUpstreamUpdates($env);
if (@$response->id) {
$this->waitOnWorkflow('sites', $site->getId(), $response->id);
} else {
Terminus::success("Updates applied");
}
}
}
示例7: 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($assoc_args, 'env'));
Terminus::confirm('Are you sure you want to wipe {site}-{env}?', array('site' => $site->get('name'), 'env' => $env->get('id')));
$workflow = $env->wipe();
$workflow->wait();
$this->log()->info('Successfully wiped {site}-{env}', array('site' => $site->get('name'), 'env' => $env->get('id')));
}
示例8: 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 = SiteFactory::instance(Input::sitename($assoc_args));
$environment_id = Input::env($assoc_args, 'env');
Terminus::confirm(sprintf("Are you sure you want to wipe %s - %s?", $site->getName(), $environment_id));
$workflow = $site->environment($environment_id)->wipe();
$workflow->wait();
Terminus::success(sprintf("Successfully wiped %s - %s", $site->getName(), $environment_id));
}
示例9: 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($assoc_args, 'env'));
Terminus::confirm(sprintf('Are you sure you want to wipe %s - %s?', $site->get('name'), $env->get('id')));
$workflow = $env->wipe();
$workflow->wait();
Terminus::success(sprintf('Successfully wiped %s - %s', $site->get('name'), $env->get('id')));
}
示例10: 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($assoc_args, 'org', null, array('allow_none' => false));
$orgs = new UserOrganizationMemberships();
$org = $orgs->get($org_id);
$org_info = $org->get('organization');
$memberships = $org->site_memberships->all();
switch ($action) {
case 'add':
if (isset($assoc_args['site'])) {
if ($this->siteIsMember($memberships, $assoc_args['site'])) {
throw new TerminusException('{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($this->getNonmemberSiteList($memberships), null, 'Choose site'));
}
Terminus::confirm('Are you sure you want to add %s to %s ?', $assoc_args, array($site->get('name'), $org_info->profile->name));
$workflow = $org->site_memberships->addMember($site);
$workflow->wait();
$this->workflowOutput($workflow);
break;
case 'remove':
if (isset($assoc_args['site'])) {
if (!$this->siteIsMember($memberships, $assoc_args['site'])) {
throw new TerminusException('{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($this->getMemberSiteList($memberships), null, 'Choose site'));
}
$member = $org->site_memberships->get($site->get('id'));
Terminus::confirm('Are you sure you want to remove %s from %s ?', $assoc_args, 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', $data_array['created']);
$data[] = $data_array;
}
$this->output()->outputRecordList($data);
break;
}
}
示例11: delete
/**
* Delete a site from pantheon
*
* ## OPTIONS
* [--site=<site>]
* : ID of the site you want to delete
*
* [--force]
* : to skip the confirmations
*/
function delete($args, $assoc_args)
{
$sitename = Input::sitename($assoc_args);
$site_id = $this->sitesCache->findID($sitename);
$site_to_delete = new Site($site_id);
if (!isset($assoc_args['force']) and !Terminus::get_config('yes')) {
// if the force option isn't used we'll ask you some annoying questions
Terminus::confirm(sprintf("Are you sure you want to delete %s?", $site_to_delete->information->name));
Terminus::confirm("Are you really sure?");
}
Terminus::line(sprintf("Deleting %s ...", $site_to_delete->information->name));
$response = \Terminus_Command::request('sites', $site_to_delete->id, '', 'DELETE');
$this->sitesCache->remove($sitename);
Terminus::success("Deleted %s!", $sitename);
}