Пример #1
0
 /**
  * Handle a hack file entry.
  *
  * @param string $fileName The name of the file to handle..
  *
  * @return void
  */
 private function handleHackFile($fileName)
 {
     $logger = $this->logger;
     $previous = spl_autoload_functions();
     include $fileName;
     $found = $this->determineRegisteredAutoLoader($previous);
     foreach ($found as $index => $loader) {
         $hackName = basename($fileName) . '.' . $index;
         $this->enumLoader->add($this->compileHack($loader, $hackName), $hackName);
     }
     $logger->debug('Custom class loader hack {file} loaded {count} auto load functions.', array('file' => $fileName, 'count' => count($found)));
 }
 /**
  * Prepare the composer fallback loader.
  *
  * @param EnumeratingClassLoader $enumLoader The enum loader to add to.
  *
  * @param string                 $baseDir    The base dir where the composer.json resides.
  *
  * @param array                  $composer   The contents of the composer.json.
  *
  * @return void
  */
 private function prepareComposerFallbackLoader(EnumeratingClassLoader $enumLoader, $baseDir, $composer)
 {
     $vendorDir = $baseDir . DIRECTORY_SEPARATOR . 'vendor';
     if (isset($composer['extra']['vendor-dir'])) {
         $vendorDir = $baseDir . DIRECTORY_SEPARATOR . $composer['extra']['vendor-dir'];
     }
     if (!is_dir($vendorDir)) {
         return;
     }
     $loader = new ClassLoader();
     if ($map = $this->includeIfExists($vendorDir . '/composer/autoload_namespaces.php')) {
         foreach ($map as $namespace => $path) {
             $loader->set($namespace, $path);
         }
     }
     if ($map = $this->includeIfExists($vendorDir . '/composer/autoload_psr4.php')) {
         foreach ($map as $namespace => $path) {
             $loader->setPsr4($namespace, $path);
         }
     }
     if ($classMap = $this->includeIfExists($vendorDir . '/composer/autoload_classmap.php')) {
         $loader->addClassMap($classMap);
     }
     $enumLoader->add(array($loader, 'loadClass'), 'composer.fallback');
 }