コード例 #1
0
ファイル: InventoryGetApi.php プロジェクト: jkinner/ringside
 /**
  * Returns an array containing information on an API.
  *
  * @return array info on an API
  */
 public function execute()
 {
     $_apiNamePieces = explode('.', $this->apiName);
     $_apiNamespace = $_apiNamePieces[0];
     $_apiPkg = $_apiNamePieces[1];
     $_apiShortName = $_apiNamePieces[2];
     $_apiClassFile = ucfirst($_apiPkg) . ucfirst($_apiShortName) . '.php';
     // we need to scan the rest locations so we can get the full path info
     $_restLocations = M3_Util_Settings::getRestLocations();
     $_deployedApiLocations = M3_Util_Settings::getDeployedApiLocations();
     $_foundPathname = null;
     foreach ($_restLocations as $_restLocation) {
         foreach ($_deployedApiLocations as $_deployedApiLocation) {
             $_dir = M3_Util_File::buildPathName($_restLocation, $_deployedApiLocation);
             $_pathname = M3_Util_File::buildPathName($_dir, $_apiClassFile);
             if (file_exists($_pathname)) {
                 $_foundPathname = $_pathname;
                 break;
             }
         }
         if (!is_null($_foundPathname)) {
             break;
         }
     }
     $_info = array();
     if (!is_null($_foundPathname)) {
         $_info['api_name'] = $this->apiName;
         $_info['pathname'] = $_foundPathname;
     }
     return array('api' => $_info);
 }
コード例 #2
0
ファイル: InventoryGetApis.php プロジェクト: jkinner/ringside
 /**
  * Returns the APIs that are currently deployed in the given rest directory name.
  * The returned names will be the full REST API name that REST clients can use
  * to invoke the APIs.  This includes the three-parts to the REST API:
  * <namespace>.<package>.<class>; e.g. "m3.inventory.getApis"
  *
  * @param $apiNamespace the namespace of the APIs found in the given directory
  * @param $restDir the directory name where the API classes can be found
  *
  * @return array names of all APIs deployed in the server in the given directory
  *         the array is associative, where the key is the API name and the value
  *         is the php file that implements that API
  */
 private function getApiNamesInDirectory($apiNamespace, $restDir)
 {
     $_rootDirs = M3_Util_Settings::getRestLocations();
     $_names = array();
     foreach ($_rootDirs as $_dir) {
         $_fullApiDirectory = $_dir . $restDir;
         if (file_exists($_fullApiDirectory)) {
             $_files = scandir($_fullApiDirectory);
             foreach ($_files as $_file) {
                 if (!is_dir($_file)) {
                     $_apiName = $this->determineApiName($_file);
                     if (!empty($_apiName)) {
                         $_name = $apiNamespace . '.' . $_apiName;
                         if (!$this->isIgnoredName($_name)) {
                             $_names[$_name] = $_fullApiDirectory . '/' . $_file;
                         }
                     }
                 }
             }
         }
     }
     return $_names;
 }