[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/zend/Zend/Service/Amazon/Ec2/ -> Region.php (source)

   1  <?php
   2  /**
   3   * Zend Framework
   4   *
   5   * LICENSE
   6   *
   7   * This source file is subject to the new BSD license that is bundled
   8   * with this package in the file LICENSE.txt.
   9   * It is also available through the world-wide-web at this URL:
  10   * http://framework.zend.com/license/new-bsd
  11   * If you did not receive a copy of the license and are unable to
  12   * obtain it through the world-wide-web, please send an email
  13   * to [email protected] so we can send you a copy immediately.
  14   *
  15   * @category   Zend
  16   * @package    Zend_Service_Amazon
  17   * @subpackage Ec2
  18   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  20   * @version    $Id$
  21   */
  22  
  23  /**
  24   * @see Zend_Service_Amazon_Ec2_Abstract
  25   */
  26  require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
  27  
  28  /**
  29   * An Amazon EC2 interface to query which Regions your account has access to.
  30   *
  31   * @category   Zend
  32   * @package    Zend_Service_Amazon
  33   * @subpackage Ec2
  34   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  35   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  36   */
  37  class Zend_Service_Amazon_Ec2_Region extends Zend_Service_Amazon_Ec2_Abstract
  38  {
  39  
  40      /**
  41       * Describes availability zones that are currently available to the account
  42       * and their states.
  43       *
  44       * @param string|array $region              Name of an region.
  45       * @return array                            An array that contains all the return items.  Keys: regionName and regionUrl.
  46       */
  47      public function describe($region = null)
  48      {
  49          $params = array();
  50          $params['Action'] = 'DescribeRegions';
  51  
  52          if(is_array($region) && !empty($region)) {
  53              foreach($region as $k=>$name) {
  54                  $params['Region.' . ($k+1)] = $name;
  55              }
  56          } elseif($region) {
  57              $params['Region.1'] = $region;
  58          }
  59  
  60          $response = $this->sendRequest($params);
  61  
  62          $xpath  = $response->getXPath();
  63          $nodes  = $xpath->query('//ec2:item');
  64  
  65          $return = array();
  66          foreach ($nodes as $k => $node) {
  67              $item = array();
  68              $item['regionName']   = $xpath->evaluate('string(ec2:regionName/text())', $node);
  69              $item['regionUrl']  = $xpath->evaluate('string(ec2:regionUrl/text())', $node);
  70  
  71              $return[] = $item;
  72              unset($item);
  73          }
  74  
  75          return $return;
  76      }
  77  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1