Merge "API: Pretty-printed responses should always use HTTP status 200"
[lhc/web/wiklou.git] / includes / utils / AutoloadGenerator.php
index de52cd9..319b5d4 100644 (file)
@@ -11,7 +11,7 @@
  *     $gen = new AutoloadGenerator( __DIR__ );
  *     $gen->readDir( __DIR__ . '/includes' );
  *     $gen->readFile( __DIR__ . '/foo.php' )
- *     $gen->generateAutoload();
+ *     $gen->getAutoload();
  */
 class AutoloadGenerator {
        const FILETYPE_JSON = 'json';
@@ -160,6 +160,7 @@ class AutoloadGenerator {
         *
         * @param {string} $commandName Command name to include in comment
         * @param {string} $filename of PHP file to put autoload information in.
+        * @return string
         */
        protected function generatePHPAutoload( $commandName, $filename ) {
                // No existing JSON file found; update/generate PHP file
@@ -229,7 +230,7 @@ EOD;
 
                $fileinfo = $this->getTargetFileinfo();
 
-               if ( $fileinfo['type'] === AutoloadGenerator::FILETYPE_JSON ) {
+               if ( $fileinfo['type'] === self::FILETYPE_JSON ) {
                        return $this->generateJsonAutoload( $fileinfo['filename'] );
                } else {
                        return $this->generatePHPAutoload( $commandName, $fileinfo['filename'] );
@@ -247,17 +248,17 @@ EOD;
        public function getTargetFileinfo() {
                $fileinfo = [
                        'filename' => $this->basepath . '/autoload.php',
-                       'type' => AutoloadGenerator::FILETYPE_PHP
+                       'type' => self::FILETYPE_PHP
                ];
                if ( file_exists( $this->basepath . '/extension.json' ) ) {
                        $fileinfo = [
                                'filename' => $this->basepath . '/extension.json',
-                               'type' => AutoloadGenerator::FILETYPE_JSON
+                               'type' => self::FILETYPE_JSON
                        ];
                } elseif ( file_exists( $this->basepath . '/skin.json' ) ) {
                        $fileinfo = [
                                'filename' => $this->basepath . '/skin.json',
-                               'type' => AutoloadGenerator::FILETYPE_JSON
+                               'type' => self::FILETYPE_JSON
                        ];
                }
 
@@ -290,6 +291,10 @@ EOD;
                foreach ( glob( $this->basepath . '/*.php' ) as $file ) {
                        $this->readFile( $file );
                }
+
+               // Legacy aliases
+               $this->forceClassPath( 'DatabaseBase',
+                       $this->basepath . '/includes/libs/rdbms/database/Database.php' );
        }
 }