コード例 #1
0
ファイル: sites.php プロジェクト: slivermon/cli
 /**
  * List Sites in Cache
  *
  * ## OPTIONS
  *
  * [--rebuild]
  * @subcommand cache
  */
 public function cache($args, $assoc_args)
 {
     $sites_cache = new Terminus\SitesCache();
     if (isset($assoc_args['rebuild'])) {
         $sites_cache->rebuild();
     }
     $sites = $sites_cache->all();
     $data = array();
     foreach ($sites as $name => $id) {
         $data[] = array('name' => $name, 'id' => $id);
     }
     $this->handleDisplay($data, $args);
 }
コード例 #2
0
ファイル: Sites.php プロジェクト: serundeputy/cli
 /**
  * Fetches model data from API and instantiates its model instances
  *
  * @param array $options params to pass to url request
  * @return Sites
  */
 public function fetch(array $options = array())
 {
     if (empty($this->models)) {
         $cache = $this->sites_cache->all();
         if (count($cache) === 0) {
             $this->rebuildCache();
             $cache = $this->sites_cache->all();
         }
         foreach ($cache as $name => $model) {
             $this->add($this->objectify($model));
         }
     }
     return $this;
 }
コード例 #3
0
ファイル: Input.php プロジェクト: rvtraveller/terminus
 /**
  * Input helper that provides interactive site list
  *
  * @param [array]  $args  The args passed in from argv
  * @param [string] $key   Args key to search for
  * @param [string] $label Prompt for STDOUT
  * @return [string] Site name
  */
 public static function sitename($args = array(), $key = 'site', $label = 'Choose site')
 {
     // return early if sitename is provided in args
     if (isset($args[$key])) {
         return $args[$key];
     }
     if (isset($_SERVER['TERMINUS_SITE'])) {
         return $_SERVER['TERMINUS_SITE'];
     }
     $sitesCache = new SitesCache();
     $sitenames = array_map(function ($site_cache) {
         return $site_cache['name'];
     }, $sitesCache->all());
     $choices = array();
     foreach ($sitenames as $sitename) {
         $choices[$sitename] = $sitename;
     }
     $menu = self::menu($choices, $default = null, $label);
     return $menu;
 }