本文整理汇总了PHP中Terminus\Helpers\Input::string方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::string方法的具体用法?PHP Input::string怎么用?PHP Input::string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terminus\Helpers\Input
的用法示例。
在下文中一共展示了Input::string方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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')));
}
}
示例2: import
/**
* Import a zip archive == see this article for more info:
* http://helpdesk.getpantheon.com/customer/portal/articles/1458058-importing-a-wordpress-site
*
* ## OPTIONS
*
* [--site=<site>]
* : Site to use
*
* [--url=<url>]
* : URL of archive to import
*
* [--element=<element>]
* : Site element to import (i.e. code, files, db, or all)
*
* @subcommand import
*/
public function import($args, $assoc_args)
{
$site = SiteFactory::instance(Input::site($assoc_args));
$url = Input::string($assoc_args, 'url', "URL of archive to import");
if (!$url) {
Terminus::error("Please enter a URL.");
}
if (!isset($assoc_args['element'])) {
$element_options = array('code', 'database', 'files', 'all');
$element_key = Input::menu($element_options, 'all', 'Which element are you importing?');
$element = $element_options[$element_key];
} else {
$element = $assoc_args['element'];
}
$import = $site->import($url, $element);
if ($import) {
Terminus::line('Import started, you can now safely kill this script without interfering.');
$result = $this->waitOnWorkflow('sites', $site->getId(), $import->id);
if ($result->result !== 'succeeded') {
Terminus::error($result->reason);
} else {
Terminus::success("Import complete");
}
}
}
示例3: import
/**
* Import a new site
* @package 2.0
*
* ## OPTIONS
*
* [--url=<url>]
* : URL of archive to import
*
* [--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"
*
* @subcommand create-from-import
*/
public function import($args, $assoc_args)
{
$url = Input::string($assoc_args, 'url', "URL of archive to import");
if (!$url) {
Terminus::error("Please enter a URL.");
}
$assoc_args['import'] = $url;
Terminus::launch_self('sites', array('create'), $assoc_args);
}
示例4: 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;
}
示例5: testStringReturnsString
function testStringReturnsString()
{
$args = array('args' => array('key' => 'value'), 'key' => 'key', 'default' => false);
$string = Input::string($args);
$this->assertInternalType('string', $string);
$this->assertEquals('value', $string);
}
示例6: 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.');
}
}
示例7: getSiteCreateOptions
/**
* A helper function for getting/prompting for the site create options.
*
* @param array $assoc_args Arguments from command
* @return array
*/
private function getSiteCreateOptions($assoc_args)
{
$options = array();
$options['label'] = Input::string(array('args' => $assoc_args, 'key' => 'label', 'message' => '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 {
$message = 'Machine name of the site; used as part of the default URL';
$message .= " (if left blank will be {$suggested_name})";
$options['name'] = Input::string(array('args' => $assoc_args, 'key' => 'site', 'message' => $message, 'deafult' => $suggested_name));
}
if (isset($assoc_args['org'])) {
$options['organization_id'] = Input::orgId(array('args' => $assoc_args, 'default' => false));
}
return $options;
}
示例8: import
/**
* Import a new site
* @package 2.0
*
* ## OPTIONS
*
* [--url=<url>]
* : Url of archive to import
*
* [--name=<name>]
* : Name of the site to create (machine-readable)
*
* [--label=<label>]
* : Label for the site
*
* [--org=<org>]
* : UUID of organization to add this site to
*
* @subcommand create-from-import
*/
public function import($args, $assoc_args)
{
$url = Input::string($assoc_args, 'url', "Url of archive to import");
$label = Input::string($assoc_args, 'label', "Human readable label for the site");
$slug = Utils\sanitize_name($label);
$name = Input::string($assoc_args, 'name', "Machine name of the site; used as part of the default URL [ if left blank will be {$slug}]");
$name = $name ? $name : $slug;
$organization = Terminus::menu(Input::orglist(), false, "Choose organization");
if (!$url) {
Terminus::error("Please enter a url.");
}
Terminus::launch_self('sites', array('create'), array('label' => $label, 'name' => $name, 'org' => $organization));
Terminus::launch_self('site', array('import'), array('url' => $url, 'site' => $name, 'nocache' => True));
}