getExtensionById('tao'); } /** * * Return all lib alias with relative path * * @author Lionel Lecaque, lionel@taotesting.com * @return array */ public function getLibAliasMap() { $extensionsAliases = []; $assetservice = ServiceManager::getServiceManager()->get(AssetService::SERVICE_ID); foreach (ClientLibRegistry::getRegistry()->getMap() as $alias => $lib) { if (is_array($lib) && isset($lib['extId']) && isset($lib['path'])) { $extensionsAliases[$alias] = $assetservice->getJsBaseWww($lib['extId']) . $lib['path']; } elseif (is_string($lib)) { $extensionsAliases[$alias] = str_replace(ROOT_URL, '../../../', $lib); } else { throw new \common_exception_InconsistentData('Invalid ' . self::getConfigId() . ' entry found'); } } return $extensionsAliases; } /** * Register a new path for given alias, trigger a warning if path already register * * @author Lionel Lecaque, lionel@taotesting.com * @param string $id * @param string $fullPath * @throws \common_exception_Error */ public function register($id, $fullPath) { /** @var AssetService $assetService */ $assetService = ServiceManager::getServiceManager()->get(AssetService::SERVICE_ID); if (self::getRegistry()->isRegistered($id)) { common_Logger::w('Lib already registered'); } if (substr($fullPath, 0, strlen('../../../')) == '../../../') { $fullPath = ROOT_URL . substr($fullPath, strlen('../../../')); } $found = false; foreach (\common_ext_ExtensionsManager::singleton()->getInstalledExtensions() as $ext) { if (strpos($fullPath, $assetService->getJsBaseWww($ext->getId())) === 0) { $found = true; self::getRegistry()->set($id, [ 'extId' => $ext->getId(), 'path' => substr($fullPath, strlen($assetService->getJsBaseWww($ext->getId()))) ]); break; } } if ($found == false) { throw new \common_exception_Error('Path "' . $fullPath . '" is not a valid asset path in Tao'); } } }