当前位置: 首页>>代码示例>>PHP>>正文


PHP Input::string方法代码示例

本文整理汇总了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')));
     }
 }
开发者ID:4aficiona2,项目名称:cli,代码行数:67,代码来源:SiteCommand.php

示例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");
         }
     }
 }
开发者ID:spleshka,项目名称:cli,代码行数:42,代码来源:site.php

示例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);
 }
开发者ID:xwp,项目名称:pantheon-cli,代码行数:32,代码来源:sites.php

示例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;
 }
开发者ID:blueprintmrk,项目名称:cli,代码行数:26,代码来源:sites.php

示例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);
 }
开发者ID:serundeputy,项目名称:cli,代码行数:7,代码来源:test-input-helper.php

示例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.');
     }
 }
开发者ID:skyywalk3rr,项目名称:cli,代码行数:52,代码来源:site.php

示例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;
 }
开发者ID:RazzYoshi,项目名称:cli,代码行数:28,代码来源:SitesCommand.php

示例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));
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:34,代码来源:sites.php


注:本文中的Terminus\Helpers\Input::string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。