You are here

function ClassFinderAdapter::add in X Autoload 7.5

Same name and namespace in other branches
  1. 7.4 lib/Adapter/ClassFinderAdapter.php \Drupal\xautoload\Adapter\ClassFinderAdapter::add()

Adds a PSR-0 style prefix. Alias for ->addPsr0().

Parameters

string $prefix:

string[]|string $paths:

Overrides CommonRegistrationInterface::add

1 call to ClassFinderAdapter::add()
ClassFinderAdapter::addPsr0 in src/Adapter/ClassFinderAdapter.php
Adds a PSR-0 style prefix. Alias for ->add().

File

src/Adapter/ClassFinderAdapter.php, line 187

Class

ClassFinderAdapter
An instance of this class is passed around to implementations of hook_xautoload(). It acts as a wrapper around the ClassFinder, to register stuff.

Namespace

Drupal\xautoload\Adapter

Code

function add($prefix, $paths) {
  if (FALSE === strpos($prefix, '\\')) {

    // Due to the ambiguity of PSR-0, this could be either PEAR-like or namespaced.
    $logical_base_path = Util::prefixLogicalPath($prefix);
    foreach ((array) $paths as $root_path) {
      $deep_path = strlen($root_path) ? rtrim($root_path, '/') . '/' . $logical_base_path : $logical_base_path;
      $this->prefixMap
        ->registerDeepPath($logical_base_path, $deep_path, $this->defaultBehavior);
    }
  }

  // Namespaced PSR-0
  $logical_base_path = Util::namespaceLogicalPath($prefix);
  foreach ((array) $paths as $root_path) {
    $deep_path = strlen($root_path) ? rtrim($root_path, '/') . '/' . $logical_base_path : $logical_base_path;
    $this->namespaceMap
      ->registerDeepPath($logical_base_path, $deep_path, $this->psr0Behavior);
  }
}