You are here

function ComposerJsonTargetDir::writeToAdapter in X Autoload 7.5

Same name and namespace in other branches
  1. 7.4 lib/Discovery/ComposerJsonTargetDir.php \Drupal\xautoload\Discovery\ComposerJsonTargetDir::writeToAdapter()

Parameters

ClassFinderAdapter $adapter:

Throws

\Exception

Overrides ComposerJson::writeToAdapter

File

src/Discovery/ComposerJsonTargetDir.php, line 31

Class

ComposerJsonTargetDir

Namespace

Drupal\xautoload\Discovery

Code

function writeToAdapter(ClassFinderAdapter $adapter) {
  $data = $this->data;
  if (!empty($data['include-path'])) {
    $paths = $this
      ->pathsResolveTargetDir((array) $data['include-path']);
    $this
      ->addIncludePaths($paths, $this->pathPrefix);
  }
  if (!empty($data['autoload']['psr-0'])) {
    $this
      ->addMultipleWithTargetDir($adapter, $data['autoload']['psr-0']);
  }
  if (!empty($data['autoload']['psr-4'])) {
    throw new \Exception("PSR-4 is incompatible with target-dir.");
  }
  if (!empty($data['autoload']['classmap'])) {
    $paths = $this
      ->pathsResolveTargetDir($data['autoload']['classmap']);
    $this
      ->addClassmapSources($adapter, $paths);
  }
  if (!empty($data['autoload']['files'])) {
    $paths = $this
      ->pathsResolveTargetDir($data['autoload']['files']);
    foreach ($paths as $file) {
      require $this->pathPrefix . $file;
    }
  }
}