diff --git a/src/moduleutils/PhutilBootloader.php b/src/moduleutils/PhutilBootloader.php --- a/src/moduleutils/PhutilBootloader.php +++ b/src/moduleutils/PhutilBootloader.php @@ -9,6 +9,7 @@ private $extensionMaps = array(); private $currentLibrary = null; private $classTree = array(); + private $inMemoryMaps = array(); public static function getInstance() { if (!self::$instance) { @@ -25,6 +26,13 @@ return $this->classTree; } + public function registerInMemoryLibrary($name, $map) { + $this->registeredLibraries[$name] = "memory:$name"; + $this->inMemoryMaps[$name] = $map; + + $this->getLibraryMap($name); + } + public function registerLibrary($name, $path) { if (basename($path) != '__phutil_library_init__.php') { throw new PhutilBootloaderException( @@ -104,10 +112,15 @@ if (empty($this->libraryMaps[$name])) { $root = $this->getLibraryRoot($name); $this->currentLibrary = $name; - $okay = include $root.'/__phutil_library_map__.php'; - if (!$okay) { - throw new PhutilBootloaderException( - "Include of '{$root}/__phutil_library_map__.php' failed!"); + + if (isset($this->inMemoryMaps[$name])) { + $this->libraryMaps[$name] = $this->inMemoryMaps[$name]; + } else { + $okay = include $root.'/__phutil_library_map__.php'; + if (!$okay) { + throw new PhutilBootloaderException( + "Include of '{$root}/__phutil_library_map__.php' failed!"); + } } $map = $this->libraryMaps[$name];