本文整理汇总了PHP中Terminus\Helpers\Input::sitename方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::sitename方法的具体用法?PHP Input::sitename怎么用?PHP Input::sitename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terminus\Helpers\Input
的用法示例。
在下文中一共展示了Input::sitename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Sites
/**
* Invoke `drush` commands on a Pantheon development site
*
* <commands>...
* : The Drush commands you intend to run.
*
* [--<flag>=<value>]
* : Additional Drush flag(s) to pass in to the command.
*
* [--site=<site>]
* : The name (DNS shortname) of your site on Pantheon.
*
* [--env=<environment>]
* : Your Pantheon environment. Default: dev
*
*/
function __invoke($args, $assoc_args)
{
$environment = Input::env($assoc_args);
$sites = new Sites();
$site = $sites->get(Input::sitename($assoc_args));
if (!$site) {
throw new TerminusException("Command could not be completed. Unknown site specified.");
}
$server = array('user' => "{$environment}.{$site->get('id')}", 'host' => "appserver.{$environment}.{$site->get('id')}.drush.in", 'port' => '2222');
if (strpos(TERMINUS_HOST, 'onebox') !== FALSE) {
$server['user'] = "appserver.{$environment}.{$site->get('id')}";
$server['host'] = TERMINUS_HOST;
}
# Sanitize assoc args so we don't try to pass our own flags.
# TODO: DRY this out?
unset($assoc_args['site']);
if (isset($assoc_args['env'])) {
unset($assoc_args['env']);
}
# Create user-friendly output
$command = implode($args, ' ');
$flags = '';
foreach ($assoc_args as $k => $v) {
if (isset($v) && (string) $v != '') {
$flags .= "--{$k}={$v} ";
} else {
$flags .= "--{$k} ";
}
}
$this->log()->info("Running drush {cmd} {flags} on {site}-{env}", array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
$this->send_command($server, 'drush', $args, $assoc_args);
}
示例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: Sites
/**
* Invoke `wp` commands on a Pantheon development site
*
* <commands>...
* : The WP-CLI commands you intend to run.
*
* [--<flag>=<value>]
* : Additional WP-CLI flag(s) to pass in to the command.
*
* [--site=<site>]
* : The name (DNS shortname) of your site on Pantheon.
*
* [--env=<environment>]
* : Your Pantheon environment. Default: dev
*
*/
function __invoke($args, $assoc_args)
{
$environment = Input::env($assoc_args);
$sites = new Sites();
$site = $sites->get(Input::sitename($assoc_args));
if (!$site) {
throw new TerminusException("Command could not be completed. Unknown site specified.");
}
# see https://github.com/pantheon-systems/titan-mt/blob/master/dashboardng/app/workshops/site/models/environment.coffee
$server = array('user' => "{$environment}.{$site->get('id')}", 'host' => "appserver.{$environment}.{$site->get('id')}.drush.in", 'port' => '2222');
if (strpos(TERMINUS_HOST, 'onebox') !== FALSE) {
$server['user'] = "appserver.{$environment}.{$site->get('id')}";
$server['host'] = TERMINUS_HOST;
}
# Sanitize assoc args so we don't try to pass our own flags.
# TODO: DRY this out?
unset($assoc_args['site']);
if (isset($assoc_args['env'])) {
unset($assoc_args['env']);
}
# Create user-friendly output
$command = implode($args, ' ');
$flags = '';
foreach ($assoc_args as $k => $v) {
if (isset($v) && (string) $v != '') {
$flags .= "--{$k}=" . escapeshellarg($v) . ' ';
} else {
$flags .= "--{$k} ";
}
}
$this->log()->info("Running wp {cmd} {flags} on {site}-{env}", array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
$this->send_command($server, 'wp', $args, $assoc_args);
}
示例4: implode
/**
* Invoke `wp` commands on a Pantheon development site
*
* <commands>...
* : The WP-CLI commands you intend to run.
*
* [--<flag>=<value>]
* : Additional WP-CLI flag(s) to pass in to the command.
*
* [--site=<site>]
* : The name (DNS shortname) of your site on Pantheon.
*
* [--env=<environment>]
* : Your Pantheon environment. Default: dev
*
*/
function __invoke($args, $assoc_args)
{
$command = implode($args, ' ');
$this->checkCommand($command);
$sites = new Sites();
$site = $sites->get(Input::sitename($assoc_args));
$environment = Input::env(array('args' => $assoc_args, 'site' => $site));
if (!$site) {
$this->failure('Command could not be completed. Unknown site specified.');
}
/**
* See https://github.com/pantheon-systems/titan-mt/blob/master/..
* ..dashboardng/app/workshops/site/models/environment.coffee
*/
$server = $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $environment));
// Sanitize assoc args so we don't try to pass our own flags.
unset($assoc_args['site']);
if (isset($assoc_args['env'])) {
unset($assoc_args['env']);
}
// Create user-friendly output
$flags = '';
foreach ($assoc_args as $k => $v) {
if (isset($v) && (string) $v != '') {
$flags .= "--{$k}=" . escapeshellarg($v) . ' ';
} else {
$flags .= "--{$k} ";
}
}
$this->log()->info('Running wp {cmd} {flags} on {site}-{env}', array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
$result = $this->sendCommand($server, 'wp', $args, $assoc_args);
if (Terminus::getConfig('format') != 'normal') {
$this->output()->outputRecordList($result);
}
}
示例5: show
/**
* Show operation details for a workflow
*
* ## OPTIONS
* [--workflow_id]
* : Uuid of workflow to show
* [--site=<site>]
* : Site from which to list workflows
*
* @subcommand show
*/
public function show($args, $assoc_args)
{
$site = $this->sites->get(Input::sitename($assoc_args));
$workflow = Input::workflow($site, $assoc_args, 'workflow_id');
$workflow_data = $workflow->serialize();
if (Terminus::getConfig('format') == 'normal') {
$operations_data = $workflow_data['operations'];
unset($workflow_data['operations']);
$this->output()->outputRecord($workflow_data);
if (count($operations_data)) {
$this->log()->info('Workflow operations:');
$this->output()->outputRecordList($operations_data);
} else {
$this->log()->info('Workflow has no operations');
}
} else {
$this->output()->outputRecordList($workflow_data);
}
}
示例6: __invoke
/**
* Invoke `wp` commands on a Pantheon development site
*
* <commands>...
* : The WP-CLI command you intend to run with its arguments, in quotes
*
* [--site=<site>]
* : The name (DNS shortname) of your site on Pantheon
*
* [--env=<environment>]
* : Your Pantheon environment. Default: dev
*
*/
public function __invoke($args, $assoc_args)
{
$command = array_pop($args);
$this->checkCommand($command);
$sites = new Sites();
$site = $sites->get(Input::sitename($assoc_args));
$environment = Input::env(array('args' => $assoc_args, 'site' => $site));
if (!$site) {
$this->failure('Command could not be completed. Unknown site specified.');
}
/**
* See https://github.com/pantheon-systems/titan-mt/blob/master/..
* ..dashboardng/app/workshops/site/models/environment.coffee
*/
$server = $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $environment));
$this->log()->info('Running wp {cmd} on {site}-{env}', array('cmd' => $command, 'site' => $site->get('name'), 'env' => $environment));
$result = $this->sendCommand(array('server' => $server, 'remote_exec' => 'wp', 'command' => $command));
if (Terminus::getConfig('format') != 'normal') {
$this->output()->outputRecordList($result);
}
}
示例7: __invoke
/**
* Invoke `drush` commands on a Pantheon development site
*
* <commands>...
* : The WP-CLI command you intend to run, with its arguments
*
* [--site=<site>]
* : The name (DNS shortname) of your site on Pantheon
*
* [--env=<environment>]
* : Your Pantheon environment. Default: dev
*
*/
public function __invoke($args, $assoc_args)
{
$command = array_pop($args);
$this->checkCommand($command);
$sites = new Sites();
$assoc_args['site'] = Input::sitename($assoc_args);
$site = $sites->get($assoc_args['site']);
if (!$site) {
$this->failure('Command could not be completed. Unknown site specified.');
}
$assoc_args['env'] = $environment = Input::env(array('args' => $assoc_args, 'site' => $site));
$server = $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $environment));
if (in_array(Terminus::getConfig('format'), array('bash', 'json', 'silent'))) {
$assoc_args['pipe'] = 1;
}
$this->log()->info("Running drush {cmd} on {site}-{env}", array('cmd' => $command, 'site' => $site->get('name'), 'env' => $environment));
$result = $this->sendCommand(array('server' => $server, 'remote_exec' => 'drush', 'command' => $command));
if (Terminus::getConfig('format') != 'normal') {
$this->output()->outputRecordList($result);
}
}
示例8: index
/**
* List Worflows for a Site
*
* ## OPTIONS
* [--site=<site>]
* : Site from which to list workflows
*
* @subcommand list
*/
public function index($args, $assoc_args)
{
$site = $this->sites->get(Input::sitename($assoc_args));
$workflows = $site->workflows->all();
$data = array();
foreach ($workflows as $workflow) {
$user = 'Pantheon';
if (isset($workflow->get('user')->email)) {
$user = $workflow->get('user')->email;
}
if ($workflow->get('total_time')) {
$elapsed_time = $workflow->get('total_time');
} else {
$elapsed_time = time() - $workflow->get('created_at');
}
$data[] = array('id' => $workflow->id, 'env' => $workflow->get('environment'), 'workflow' => $workflow->get('description'), 'user' => $user, 'status' => $workflow->get('phase'), 'time' => sprintf("%ds", $elapsed_time));
}
if (count($data) == 0) {
$this->log()->warning('No workflows have been run on {site}', array('site' => $site->get('name')));
}
$this->output()->outputRecordList($data, array('update' => 'Last update'));
}
示例9: 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);
}
示例10: __invoke
/**
* Invoke `drush` commands on a Pantheon development site
*
* <commands>...
* : The Drush commands you intend to run.
*
* [--<flag>=<value>]
* : Additional Drush flag(s) to pass in to the command.
*
* [--site=<site>]
* : The name (DNS shortname) of your site on Pantheon.
*
* [--env=<environment>]
* : Your Pantheon environment. Default: dev
*
*/
public function __invoke($args, $assoc_args)
{
$command = implode($args, ' ');
$this->checkCommand($command);
$sites = new Sites();
$assoc_args['site'] = Input::sitename($assoc_args);
$site = $sites->get($assoc_args['site']);
if (!$site) {
$this->failure('Command could not be completed. Unknown site specified.');
}
$assoc_args['env'] = $environment = Input::env($assoc_args);
$server = $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $environment));
# Sanitize assoc args so we don't try to pass our own flags.
# TODO: DRY this out?
if (isset($assoc_args['site'])) {
unset($assoc_args['site']);
}
if (isset($assoc_args['env'])) {
unset($assoc_args['env']);
}
# Create user-friendly output
$flags = '';
foreach ($assoc_args as $k => $v) {
if (isset($v) && (string) $v != '') {
$flags .= "--{$k}={$v} ";
} else {
$flags .= "--{$k} ";
}
}
if (in_array(Terminus::getConfig('format'), array('bash', 'json', 'silent'))) {
$assoc_args['pipe'] = 1;
}
$this->log()->info("Running drush {cmd} {flags} on {site}-{env}", array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
$result = $this->sendCommand($server, 'drush', $args, $assoc_args);
if (Terminus::getConfig('format') != 'normal') {
$this->output()->outputRecordList($result);
}
}
示例11: sites
/**
* List an organizations sites
*
* ## OPTIONS
*
* [--org=<org>]
* : Organization name or 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)
{
$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::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;
}
$sites = $org->getSites();
$data = array();
foreach ($sites as $site) {
if (isset($assoc_args['tag']) && !in_array($assoc_args['tag'], $site->tags)) {
continue;
}
$data[] = array('name' => $site->site->name, 'id' => $site->site->id, '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), 'tags' => $site->tags);
}
$this->handleDisplay($data);
}
示例12: logs
/**
* Show quicksilver logs from a workflow
*
* ## OPTIONS
* [--latest]
* : Display the most-recent workflow with logs
* [--workflow_id]
* : Uuid of workflow to fetch logs for
* [--site=<site>]
* : Site from which to list workflows
*
* @subcommand logs
*/
public function logs($args, $assoc_args)
{
$site = $this->sites->get(Input::sitename($assoc_args));
if (isset($assoc_args['latest'])) {
$site->workflows->fetchWithOperationsAndLogs(array('paged' => false));
$workflow = $site->workflows->findLatestWithLogs();
if (is_null($workflow)) {
return $this->failure('No recent workflows contain logs');
}
} else {
$site->workflows->fetchWithOperations(array('paged' => false));
$workflows = $site->workflows->all();
$workflow = Input::workflow($workflows, $assoc_args, 'workflow_id');
$workflow->fetchWithLogs();
}
if (Terminus::getConfig('format') == 'normal') {
$operations = $workflow->operations();
if (count($operations) == 0) {
$this->log()->info('Workflow has no operations');
return;
}
$operations_with_logs = array_filter($operations, function ($operation) {
return $operation->get('log_output');
});
if (count($operations_with_logs) == 0) {
$this->log()->info('Workflow has no operations with logs');
return;
}
foreach ($operations as $operation) {
if ($operation->get('log_output')) {
$operation_data = $operation->serialize();
$this->output()->outputRecord($operation_data);
}
}
} else {
$workflow_data = $workflow->serialize();
$operations_data = $workflow_data['operations'];
$this->output()->outputRecordList($operations_data);
}
}
示例13: workflows
/**
* List a site's workflows
*
* ## OPTIONS
* [--site=<site>]
* : Site to check
*
* @subcommand workflows
*/
public function workflows($args, $assoc_args)
{
$site = $this->sites->get(Input::sitename($assoc_args));
$workflows = $site->workflows->all();
$data = array();
foreach ($workflows as $workflow) {
$user = 'Pantheon';
if (isset($workflow->get('user')->email)) {
$user = $workflow->get('user')->email;
}
$data[] = array('workflow' => $workflow->get('description'), 'user' => $user, 'status' => $workflow->get('phase'), 'update' => date('Y-m-dTH:i:s', $workflow->get('created_at') + $workflow->get('total_time')), 'tasks' => $workflow->get('number_of_tasks'), 'complete' => $workflow->get('step'));
}
if (count($data) == 0) {
$this->log()->warning('No workflows have been run on {site}', array('site' => $site->getName()));
}
$this->output()->outputRecordList($data, array('update' => 'Last update'));
}
示例14: workflows
/**
* List a site's workflows
*
* ## OPTIONS
* [--site=<site>]
* : Site to check
*
* @subcommand workflows
*/
public function workflows($args, $assoc_args)
{
$site = SiteFactory::instance(Input::sitename($assoc_args));
$workflows = $site->getWorkflows();
$data = array();
foreach ($workflows as $workflow) {
$user = 'Pantheon';
if (isset($workflow->get('user')->email)) {
$user = $workflow->get('user')->email;
}
$data[] = array('workflow' => $workflow->get('description'), 'user' => $user, 'status' => $workflow->get('phase'), 'last_update' => date('Y-m-dTH:i:s', $workflow->get('created_at') + $workflow->get('total_time')), 'tasks/complete' => $workflow->get('step') . '/' . $workflow->get('number_of_tasks'));
}
if (count($data) > 0) {
$this->constructTableForResponse($data);
} else {
Terminus::error('No workflows have been run on ' . $site->getName());
}
}
示例15: loadBackup
/**
* Loads a single backup
*
* @params [array] $assoc_args Parameters and flags from the command line
* @return [boolean] Always true, else the function has thrown an exception
*/
private function loadBackup($assoc_args)
{
$site = $this->sites->get(Input::sitename($assoc_args));
$env = $site->environments->get(Input::env(array('args' => $assoc_args, 'site' => $site)));
$assoc_args['to'] = '/tmp';
$assoc_args['element'] = 'database';
if (isset($assoc_args['database'])) {
$database = $assoc_args['database'];
} else {
$database = escapeshellarg(Terminus::prompt('Name of database to import to'));
}
if (isset($assoc_args['username'])) {
$username = $assoc_args['username'];
} else {
$username = escapeshellarg(Terminus::prompt('Username'));
}
if (isset($assoc_args['password'])) {
$password = $assoc_args['password'];
} else {
$password = escapeshellarg(Terminus::prompt('Password'));
}
exec('mysql -e "show databases"', $stdout, $exit);
if ($exit != 0) {
$this->failure('MySQL does not appear to be installed on your server.');
}
$assoc_args['env'] = $env->get('id');
$target = $this->backup(array('get'), $assoc_args);
$target = '/tmp/' . Utils\getFilenameFromUrl($target);
if (!file_exists($target)) {
$this->failure('Cannot read database file {target}', compact('target'));
}
$this->log()->info('Unziping database');
exec("gunzip {$target}", $stdout, $exit);
// trim the gz of the target
$target = Utils\sqlFromZip($target);
$target = escapeshellarg($target);
exec(sprintf('mysql %s -u %s -p"%s" < %s', $database, $username, $password, $target), $stdout, $exit);
if ($exit != 0) {
$this->failure('Could not import database');
}
$this->log()->info('{target} successfully imported to {db}', array('target' => $target, 'db' => $database));
return true;
}