本文整理汇总了PHP中Terminus\Helpers\Input::orgid方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::orgid方法的具体用法?PHP Input::orgid怎么用?PHP Input::orgid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terminus\Helpers\Input
的用法示例。
在下文中一共展示了Input::orgid方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'])) {
$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($this->getNonmemberSiteList($memberships), null, 'Choose site'));
}
Terminus::confirm('Are you sure you want to add %s to %s ?', 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'])) {
$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($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 ?', 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;
}
}
示例2: 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);
}
示例3: testOrgHelpers
/**
* @vcr input_helper_org_helpers
*/
function testOrgHelpers()
{
$orglist = Input::orglist();
$this->assertInternalType('array', $orglist);
$this->assertArrayHasKey('-', $orglist);
$this->assertArrayHasKey('d59379eb-0c23-429c-a7bc-ff51e0a960c2', $orglist);
// test normal usage
$args = array('org' => 'Terminus Testing');
$org = Input::orgname($args, 'org');
$this->assertEquals('Terminus Testing', $org);
// test case where an orgid is sent and a name should be returned
$args = array('org' => 'd59379eb-0c23-429c-a7bc-ff51e0a960c2');
$org = Input::orgname($args, 'org');
$this->assertEquals('Terminus Testing', $org);
// test case where an orgid is sent and a name should be returned
$args = array('org' => 'd59379eb-0c23-429c-a7bc-ff51e0a960c2');
$org = Input::orgid($args, 'org');
$this->assertEquals('d59379eb-0c23-429c-a7bc-ff51e0a960c2', $org);
$args = array('org' => 'Terminus Testing');
$org = Input::orgid($args, 'org');
$this->assertEquals('d59379eb-0c23-429c-a7bc-ff51e0a960c2', $org);
}
示例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: tags
/**
* Manage site organization tags
*
* ## OPTIONS
*
* <add|remove|list>
* : subfunction to run
*
* [--site=<site>]
* : Site's name
*
* [--org=<name|id>]
* : Organization to apply tag with
*
* [--tag=<tag>]
* : Tag to add or remove
*
* @subcommand tags
*/
public function tags($args, $assoc_args)
{
$action = array_shift($args);
$site = $this->sites->get(Input::sitename($assoc_args));
$org = Input::orgid($assoc_args, 'org');
if ($site->organizationIsMember($org)) {
switch ($action) {
case 'add':
$tag = Input::string($assoc_args, 'tag', 'Enter a tag to add');
$response = $site->addTag($tag, $org);
$context = array('tag' => $tag, 'site' => $site->get('name'));
if ($response['status_code'] == 200) {
$this->log()->info('Tag "{tag}" has been added to {site}', $context);
} else {
$this->failure('Tag "{tag}" could not be added to {site}', $context);
}
break;
case 'remove':
$tags = $site->getTags($org);
if (count($tags) === 0) {
$message = 'This organization does not have any tags associated';
$message .= ' with this site.';
$this->failure($message);
} elseif (!isset($assoc_args['tag']) || !in_array($assoc_args['tag'], $tags)) {
$tag = $tags[Input::menu($tags, null, 'Select a tag to delete')];
} else {
$tag = $assoc_args['tag'];
}
$response = $site->removeTag($tag, $org);
$context = array('tag' => $tag, 'site' => $site->get('name'));
if ($response['status_code'] == 200) {
$this->log()->info('Tag "{tag}" has been removed from {site}', $context);
} else {
$this->failure('Tag "{tag}" could not be removed from {site}', $context);
}
break;
case 'list':
default:
$tags = $site->getTags($org);
$this->output()->outputRecord(compact('tags'));
break;
}
} else {
$message = '{site} is not a member of an organization,';
$message .= ' which is necessary to associate a tag with a site.';
$this->failure($message, array('site' => $site->get('name')));
}
}
示例6: create
/**
* Create a new site
*
* ## OPTIONS
*
* [--product=<productid>]
* : Specify the product to create
*
* [--name=<name>]
* : (deprecated) use --site instead
*
* [--site=<site>]
* : Name of the site to create (machine-readable)
*
* [--label=<label>]
* : Label for the site
*
* [--org=<org>]
* : UUID of organization to add this site to; or "None"
*
* [--import=<url>]
* : A url to import a valid archive from
*/
public function create($args, $assoc_args)
{
$sites = SiteFactory::instance();
// setup data
$data = array();
$data['label'] = Input::string($assoc_args, 'label', "Human readable label for the site");
$slug = Utils\sanitize_name($data['label']);
// this ugly logic is temporarily if to handle the deprecated --name flag and preserve backward compatibility. it can be removed in the next major release.
if (array_key_exists('name', $assoc_args)) {
$data['site_name'] = $assoc_args['name'];
} elseif (array_key_exists('site', $assoc_args)) {
$data['site_name'] = $assoc_args['site'];
} else {
$data['site_name'] = Input::string($assoc_args, 'site', "Machine name of the site; used as part of the default URL [ if left blank will be {$slug}]", $slug);
}
if ($orgid = Input::orgid($assoc_args, 'org', false)) {
$data['organization_id'] = $orgid;
}
if (!isset($assoc_args['import'])) {
$product = Input::product($assoc_args, 'product');
$data['deploy_product'] = array('product_id' => $product['id']);
Terminus::line(sprintf("Creating new %s installation ... ", $product['longname']));
}
$params = array('body' => json_encode($data), 'headers' => array('Content-type' => 'application/json'));
// run the workflow
$workflow = Workflow::createWorkflow('create_site', 'users', new User());
$workflow->setMethod('POST');
$workflow->setParams($data);
$workflow->start();
$workflow->refresh();
$details = $workflow->status();
$site_id = $details->final_task->site_id;
if ($details->result !== 'failed' and $details->result !== 'aborted') {
Terminus\Loggers\Regular::coloredOutput('%G' . vsprintf('New "site" %s now building with "UUID" %s', array($data['site_name'], $site_id)));
}
$workflow->wait();
Terminus::success("Pow! You created a new site!");
$this->cache->flush(null, 'session');
if (isset($assoc_args['import'])) {
Terminus::launch_self('site', array('import'), array('url' => $assoc_args['import'], 'site' => $data['site_name'], 'element' => 'all', 'nocache' => True));
}
return true;
}
示例7: organizations
/**
* List site organizations
*
* ## OPTIONS
*
* <list|add|remove>
* : subfunction to run
*
* [--site=<site>]
* : Site's name
*
* [--org=<org>]
* : Organization name
*
* [--role=<role>]
* : Max role for organization on this site ... default "team_member"
*
*/
public function organizations($args, $assoc_args)
{
$action = array_shift($args);
$site = SiteFactory::instance(Input::site($assoc_args));
$data = array();
switch ($action) {
case 'add':
$role = Input::optional('role', $assoc_args, 'team_member');
$org = Input::orgname($assoc_args, 'org');
$workflow = $site->addMembership('organization', $org, $role);
$workflow->wait();
Terminus::success("Organization successfully added");
$orgs = $site->memberships();
break;
case 'remove':
$org = Input::orgid($assoc_args, 'org');
$workflow = $site->removeMembership('organization', $org);
$workflow->wait();
Terminus::success("Organization successfully removed");
$orgs = $site->memberships();
break;
case 'default':
case 'list':
$orgs = $site->memberships();
break;
}
if (empty($orgs)) {
Terminus::error("No organizations");
}
// format the data
foreach ($orgs as $org) {
$data[] = array('label' => "{$org->organization->profile->name}", 'name' => $org->organization->profile->machine_name, 'role' => $org->role, 'id' => $org->organization_id);
}
$this->handleDisplay($data);
}
示例8: 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");
}
}
//.........这里部分代码省略.........
示例9: create
/**
* Create a new site
*
* ## OPTIONS
*
* [--site=<site>]
* : Name of the site to create (machine-readable)
*
* [--name=<name>]
* : (deprecated) use --site instead
*
* [--label=<label>]
* : Label for the site
*
* [--product=<productid>]
* : Specify the upstream product to use
*
* [--import=<url>]
* : A url to import a valid archive
*
* [--org=<org>]
* : UUID of organization into which to add this site
*
*/
public function create($args, $assoc_args)
{
$options = array();
$options['label'] = Input::string($assoc_args, 'label', "Human readable label for the site");
$suggested_name = Utils\sanitize_name($options['label']);
if (array_key_exists('name', $assoc_args)) {
// Deprecated but kept for backwards compatibility
$options['name'] = $assoc_args['name'];
} elseif (array_key_exists('site', $assoc_args)) {
$options['name'] = $assoc_args['site'];
} else {
$options['name'] = Input::string($assoc_args, 'site', "Machine name of the site; used as part of the default URL (if left blank will be {$suggested_name})", $suggested_name);
}
if ($org_id = Input::orgid($assoc_args, 'org', false)) {
$options['organization_id'] = $org_id;
}
if (!isset($assoc_args['import'])) {
$product = Input::product($assoc_args, 'product');
$options['product_id'] = $product['id'];
Terminus::line(sprintf("Creating new %s installation ... ", $product['longname']));
}
$workflow = Site::create($options);
$workflow->wait();
Terminus::success("Pow! You created a new site!");
// Add Site to SitesCache
$site_id = $workflow->attributes->final_task->site_id;
$site = new Site($site_id);
$site->fetch();
$cache_membership = array('id' => $site_id, 'name' => $options['name'], 'service_level' => $site->attributes->service_level, 'framework' => $site->attributes->framework);
if ($org_id) {
$org = new Organization($org_id);
$cache_membership['membership'] = array('id' => $org_id, 'name' => $org->profile->name, 'type' => 'organization');
} else {
$user_id = Session::getValue('user_uuid');
$cache_membership['membership'] = array('id' => $user_id, 'name' => 'Team', 'type' => 'team');
}
$sites_cache = new Terminus\SitesCache();
$sites_cache->add($cache_membership);
if (isset($assoc_args['import'])) {
sleep(10);
//To stop erroenous site-DNE errors
Terminus::launch_self('site', array('import'), array('url' => $assoc_args['import'], 'site' => $options['name'], 'element' => 'all'));
} else {
Terminus::launch_self('site', array('info'), array('site' => $options['name']));
}
return true;
}
示例10: tags
/**
* Manage site organization tags
*
* ## OPTIONS
*
* <add|remove>
* : subfunction to run
*
* [--site=<site>]
* : Site's name
*
* [--org=<name|id>]
* : Organization to apply tag with
*
* [--tag=<tag>]
* : Tag to add or remove
*
* @subcommand tags
*/
public function tags($args, $assoc_args)
{
$action = array_shift($args);
$site = SiteFactory::instance(Input::sitename($assoc_args));
$org = Input::orgid($assoc_args, 'org');
if ($site->organizationIsMember($org)) {
$data = array();
switch ($action) {
case 'add':
$verb = 'added to';
$tag = Input::string($assoc_args, 'tag', 'Enter a tag to add');
$response = $site->addTag($tag, $org);
break;
case 'remove':
$verb = 'removed from';
$tags = $site->getTags($org);
if (count($tags) === 0) {
Terminus::error('This organization does not have any tags' . ' associated with this site.');
} elseif (!isset($assoc_args['tag']) || !in_array($assoc_args['tag'], $tags)) {
$tag = $tags[Input::menu($tags, null, 'Select a tag to delete')];
} else {
$tag = $assoc_args['tag'];
}
$response = $site->removeTag($tag, $org);
break;
}
$message = 'Tag %s %s %s %s';
$messages = array('success' => sprintf($message, '"' . $tag . '"', 'has been', $verb, $site->getName()), 'failure' => sprintf($message, '"' . $tag . '"', 'could not be', $verb, $site->getName()));
$this->responseOutput($response, $messages);
} else {
Terminus::error($site->getName() . ' is not a member of an organization, ' . 'which is necessary to associate a tag with a site.');
}
}
示例11: team
/**
* List an organization's team members
*
* ## OPTIONS
*
* [--org=<id|name>]
* : Organization UUID or name
*
* @subcommand team
*/
public function team($args, $assoc_args)
{
$org_id = Input::orgid($assoc_args, 'org', null, array('allow_none' => false));
$orgs = new UserOrganizationMemberships();
$org = $orgs->get($org_id);
if (is_null($org)) {
$message = 'The organization {org} is either invalid or you haven\'t';
$message .= ' permission sufficient to access its data.';
$this->failure($message, array('org' => $assoc_args['org']));
}
$org_info = $org->get('organization');
$org_model = new Organization($org_info);
$memberships = $org->user_memberships->all();
$data = array();
foreach ($memberships as $membership) {
$member = $membership->get('user');
$first_name = $last_name = null;
if (isset($member->profile->firstname)) {
$first_name = $member->profile->firstname;
}
if (isset($member->profile->lastname)) {
$last_name = $member->profile->lastname;
}
$data[$member->id] = array('first' => $first_name, 'last' => $last_name, 'email' => $member->email, 'uuid' => $member->id);
}
$this->output()->outputRecordList($data);
return $data;
}
示例12: create
/**
* Create a new site
*
* ## OPTIONS
*
* [--site=<site>]
* : Name of the site to create (machine-readable)
*
* [--name=<name>]
* : (deprecated) use --site instead
*
* [--label=<label>]
* : Label for the site
*
* [--upstream=<upstreamid>]
* : Specify the upstream upstream to use
*
* [--import=<url>]
* : A url to import a valid archive
*
* [--org=<id>]
* : UUID of organization into which to add this site
*
*/
public function create($args, $assoc_args)
{
$options = array();
$options['label'] = Input::string($assoc_args, 'label', "Human-readable label for the site");
$suggested_name = Utils\sanitize_name($options['label']);
if (array_key_exists('name', $assoc_args)) {
// Deprecated but kept for backwards compatibility
$options['name'] = $assoc_args['name'];
} elseif (array_key_exists('site', $assoc_args)) {
$options['name'] = $assoc_args['site'];
} elseif (isset($_SERVER['TERMINUS_SITE'])) {
$options['name'] = $_SERVER['TERMINUS_SITE'];
} else {
$options['name'] = Input::string($assoc_args, 'site', "Machine name of the site; used as part of the default URL (if left blank will be {$suggested_name})", $suggested_name);
}
if (isset($assoc_args['org'])) {
$options['organization_id'] = Input::orgid($assoc_args, 'org', false);
}
if (!isset($assoc_args['import'])) {
$upstream = Input::upstream($assoc_args, 'upstream');
$options['upstream_id'] = $upstream->get('id');
Terminus::line(sprintf("Creating new %s installation ... ", $upstream->get('longname')));
}
$workflow = $this->sites->addSite($options);
$workflow->wait();
$this->workflowOutput($workflow);
// Add Site to SitesCache
$final_task = $workflow->get('final_task');
$this->sites->addSiteToCache($final_task->site_id);
if (isset($assoc_args['import'])) {
sleep(10);
//To stop erroenous site-DNE errors
Terminus::launch_self('site', array('import'), array('url' => $assoc_args['import'], 'site' => $options['name'], 'element' => 'all'));
} else {
Terminus::launch_self('site', array('info'), array('site' => $options['name']));
}
return true;
}
示例13: create
/**
* Create a new site
*
* ## OPTIONS
*
* [--site=<site>]
* : Name of the site to create (machine-readable)
*
* [--name=<name>]
* : (deprecated) use --site instead
*
* [--label=<label>]
* : Label for the site
*
* [--product=<productid>]
* : Specify the upstream product to use
*
* [--import=<url>]
* : A url to import a valid archive
*
* [--org=<org>]
* : UUID of organization into which to add this site
*
*/
public function create($args, $assoc_args)
{
$options = array();
$options['label'] = Input::string($assoc_args, 'label', "Human readable label for the site");
$suggested_name = Utils\sanitize_name($options['label']);
if (array_key_exists('name', $assoc_args)) {
// Deprecated but kept for backwards compatibility
$options['name'] = $assoc_args['name'];
} elseif (array_key_exists('site', $assoc_args)) {
$options['name'] = $assoc_args['site'];
} else {
$options['name'] = Input::string($assoc_args, 'site', "Machine name of the site; used as part of the default URL (if left blank will be {$suggested_name})", $suggested_name);
}
if ($org_id = Input::orgid($assoc_args, 'org', false)) {
$options['organization_id'] = $org_id;
}
if (!isset($assoc_args['import'])) {
$product = Input::product($assoc_args, 'product');
$options['product_id'] = $product['id'];
Terminus::line(sprintf("Creating new %s installation ... ", $product['longname']));
}
$workflow = Site::create($options);
$workflow->wait();
Terminus::success("Pow! You created a new site!");
// Add Name->ID mapping to SitesCache
$site_id = $workflow->status()->final_task->site_id;
$sites_cache = new Terminus\SitesCache();
$sites_cache->add(array($options['name'] => $site_id));
if (isset($assoc_args['import'])) {
sleep(10);
//To stop erroenous site-DNE errors
Terminus::launch_self('site', array('import'), array('url' => $assoc_args['import'], 'site' => $options['name'], 'element' => 'all'));
} else {
Terminus::launch_self('site', array('info'), array('site' => $options['name']));
}
return true;
}
示例14: getSiteCreateOptions
/**
* A helper function for getting/prompting for the site create options.
*
* @param [array] $assoc_args Arguments from command
* @return [array]
*/
static function getSiteCreateOptions($assoc_args)
{
$options = array();
$options['label'] = Input::string($assoc_args, 'label', 'Human-readable label for the site');
$suggested_name = Utils\sanitizeName($options['label']);
if (array_key_exists('name', $assoc_args)) {
// Deprecated but kept for backwards compatibility
$options['name'] = $assoc_args['name'];
} elseif (array_key_exists('site', $assoc_args)) {
$options['name'] = $assoc_args['site'];
} elseif (isset($_SERVER['TERMINUS_SITE'])) {
$options['name'] = $_SERVER['TERMINUS_SITE'];
} else {
$options['name'] = Input::string($assoc_args, 'site', "Machine name of the site; used as part of the default URL (if left blank will be {$suggested_name})", $suggested_name);
}
if (isset($assoc_args['org'])) {
$options['organization_id'] = Input::orgid($assoc_args, 'org', false);
}
return $options;
}