You are here

function ClassFinder::registerNamespaceRoot in X Autoload 7.4

Same name and namespace in other branches
  1. 7.5 src/ClassFinder/ClassFinder.php \Drupal\xautoload\ClassFinder\ClassFinder::registerNamespaceRoot()

Register a PSR-0 root folder for a given namespace.

Parameters

string $namespace: The namespace, e.g. "My\Namespace", to cover all classes within that, e.g. My\Namespace\SomeClass, or My\Namespace\Xyz\SomeClass. This does not cover the root-level class, e.g. My\Namespace

string $root_path: The deep path, e.g. "../lib", if classes reside in e.g. My\Namespace\SomeClass -> ../lib/My/Namespace/SomeClass.php

\Drupal\xautoload\DirectoryBehavior\DirectoryBehaviorInterface $behavior: If TRUE, then we are not sure if the directory at $path actually exists. If during the process we find the directory to be nonexistent, we unregister the path.

Overrides ExtendedClassFinderInterface::registerNamespaceRoot

File

lib/ClassFinder/ClassFinder.php, line 285

Class

ClassFinder

Namespace

Drupal\xautoload\ClassFinder

Code

function registerNamespaceRoot($namespace, $root_path, $behavior = NULL) {
  if (!isset($behavior)) {
    $behavior = $this->defaultBehavior;
  }
  $logical_base_path = Util::namespaceLogicalPath($namespace);
  $deep_path = strlen($root_path) ? rtrim($root_path, '/') . '/' . $logical_base_path : $logical_base_path;
  $this->namespaceMap
    ->registerDeepPath($logical_base_path, $deep_path, $behavior);
}