/** * Get a resource URL from its vCloud entity ID. * * @param VMware_VCloud_SDK_Service $service * @param string $eid vCloud entity ID * @return string|null * @since Version 1.5.0 */ public static function getUrlByEntityId($service, $eid) { $url = $service->getBaseUrl() . '/entity/' . $eid; $entity = $service->get($url); $links = self::getContainedLinks(null, 'alternate', $entity); if (1 == count($links)) { return $links[0]->get_href(); } return null; }
/** * Get a class name of an SDK object from a URI of a VMware * vCloud resource entity or the entry point of resource entity. * * @param VMware_VCloud_SDK_Service $svc * @param string $url URL of the resource entity or the entry point * @return string|null * @access private */ private static function getClassnameByUrl($svc, $url) { $urlMap = self::$urlMap; $baseUrl = $svc->getBaseUrl(); $rest = substr($url, strlen($baseUrl) + 1); $restArr = explode('/', $rest); if (preg_match('/^vm-|vapp-|vappTemplate-/', end($restArr), $matches)) { $key = substr_replace($matches[0], '', -1); } else { if (!preg_match('/^admin|extension$/', end($restArr))) { array_splice($restArr, count($restArr) - 1); //remove id } $key = implode('/', $restArr); } $className = "VMware_VCloud_SDK_{$urlMap[$key]}"; return class_exists($className) ? $className : null; }