public static function newFromServiceCatalog($catalog, $token, $region = CDN::DEFAULT_REGION) {
    $c = count($catalog);
    for ($i = 0; $i < $c; ++$i) {
      if ($catalog[$i]['type'] == self::SERVICE_TYPE) {
        foreach ($catalog[$i]['endpoints'] as $endpoint) {
          if (isset($endpoint['publicURL']) && $endpoint['region'] == $region) {
            /*
            $parts = parse_url($endpoint['publicURL']);
            $base = $parts['scheme'] . '://' . $parts['host'];
            if (isset($parts['port'])) {
              $base .= ':' . $parts['port'];
            }
            //$base = $endpoint['publicURL'];
            $cdn = new CDN($token, $base, $endpoint['tenantId']);
            //$cdn->url = $endpoint['publicURL'];
             */
            $cdn = new CDN($token, $endpoint['publicURL']);

            return $cdn;
          }
        }
      }
    }
    return FALSE;
  }
public static function newFromServiceCatalog($catalog, $token, $region = CDN::DEFAULT_REGION) {
    $c = count($catalog);
    for ($i = 0; $i < $c; ++$i) {
      if ($catalog[$i]['type'] == self::SERVICE_TYPE) {
        foreach ($catalog[$i]['endpoints'] as $endpoint) {
          if (isset($endpoint['publicURL']) && $endpoint['region'] == $region) {
            /*
            $parts = parse_url($endpoint['publicURL']);
            $base = $parts['scheme'] . '://' . $parts['host'];
            if (isset($parts['port'])) {
              $base .= ':' . $parts['port'];
            }
            //$base = $endpoint['publicURL'];
            $cdn = new CDN($token, $base, $endpoint['tenantId']);
            //$cdn->url = $endpoint['publicURL'];
             */
            $cdn = new CDN($token, $endpoint['publicURL']);

            return $cdn;
          }
        }
      }
    }
    return FALSE;
  }
public static function newFromServiceCatalog ( $ catalog , $ token , $ region = CDN :: DEFAULT_REGION ) { $ c = count ( $ catalog ) ; for ( $ i = 0 ; $ i < $ c ; ++ $ i ) { if ( $ catalog [ $ i ] [ 'type' ] == self :: SERVICE_TYPE ) { foreach ( $ catalog [ $ i ] [ 'endpoints' ] as $ endpoint ) { if ( isset ( $ endpoint [ 'publicURL' ] ) && $ endpoint [ 'region' ] == $ region ) { /*
            $parts = parse_url($endpoint['publicURL']);
            $base = $parts['scheme'] . '://' . $parts['host'];
            if (isset($parts['port'])) {
              $base .= ':' . $parts['port'];
            }
            //$base = $endpoint['publicURL'];
            $cdn = new CDN($token, $base, $endpoint['tenantId']);
            //$cdn->url = $endpoint['publicURL'];
             */ $ cdn = new CDN ( $ token , $ endpoint [ 'publicURL' ] ) ; return $ cdn ; } } } } return FALSE ; }
Create a new CDN object based on a service catalog.

The IdentityServices class contains a service catalog, which tracks all
services that the present account can access. The service catalog
contains data necessary to connect to a CDN endpoint. This builder
simplifies the process of creating a new CDN by accepting a service
catalog and discovering the CDN service automatically.

In the vast majority of cases, this is the easiest way to proceed. If,
however, a service catalog has multiple CDN instances (a possibility,
though not currently supported), the present method has no means of
determining which should be used. It simply chooses the first CDN
service endpoint.

This uses the tenant ID that is found in the service catalog.

Either of the following work:
@code
<?php

// Use a full service catalog:
$fullCatalog = $identityService->serviceCatalog();
$cdn = CDN::newFromServiceCatalog($fullCatalog);

// Use a filtered service catalog:
$catalog = $identitySerice->serviceCatalog(CDN::SERVICE_TYPE);
$cdn = CDN::newFromServiceCatalog($catalog);
?>
@endcode

@param array $catalog
A service catalog; see HPCloud::Services::IdentityServices::serviceCatalog().
@param string $token
The token.
@retval boolean
@retval HPCloud::Storage::CDN
@return boolean|\HPCloud\Storage\CDN
A CDN object or FALSE if no CDN services could be found
in the catalog.
Create a new CDN object based on a service catalog .