Example #1
0
 public static function getSupportedPackages()
 {
     static $packageList = array();
     if (!$packageList) {
         foreach (Config::package_dirs() as $dir) {
             foreach (glob($dir . "/phpdotnet/phd/Package/*", GLOB_ONLYDIR) as $item) {
                 $baseitem = basename($item);
                 if ($baseitem[0] != '.') {
                     $packageList[] = $baseitem;
                 }
             }
         }
     }
     return $packageList;
 }
Example #2
0
 public static function autoload($name)
 {
     // Only try autoloading classes we know about (i.e. from our own namespace)
     if (strncmp('phpdotnet\\phd\\', $name, 14) === 0) {
         $filename = DIRECTORY_SEPARATOR . str_replace(array('\\', '_'), DIRECTORY_SEPARATOR, $name) . '.php';
         foreach (Config::package_dirs() as $dir) {
             $file = $dir . $filename;
             // Using fopen() because it has use_include_path parameter.
             if (!($fp = @fopen($file, 'r', true))) {
                 continue;
             }
             fclose($fp);
             require $file;
             return false;
         }
         v('Cannot find file for %s: %s', $name, $file, E_USER_ERROR);
     }
     return false;
 }
Example #3
0
 public function option_packagedir($k, $v)
 {
     $packages = Config::package_dirs();
     foreach ((array) $v as $key => $val) {
         if ($path = realpath($val)) {
             if (!in_array($path, $packages)) {
                 $packages[] = $path;
             }
         } else {
             v('Invalid path: %s', $val, E_USER_WARNING);
         }
     }
     Config::set_package_dirs($packages);
 }