You are here

function xautoload_ClassFinder_Prefix::registerPrefixRoot in X Autoload 7.2

Same name and namespace in other branches
  1. 7.3 lib/ClassFinder/Prefix.php \xautoload_ClassFinder_Prefix::registerPrefixRoot()

Register a PEAR-style root path for a given class prefix.

Parameters

string $prefix: Prefix, e.g. "My_Prefix", for classes like "My_Prefix_SomeClass". This does ALSO cover the class named "My_Prefix" itself.

string $root_path: Root path, e.g. "../lib" or "../src", so that classes can be placed e.g. My_Prefix_SomeClass -> ../lib/My/Prefix/SomeClass.php My_Prefix -> ../lib/My/Prefix.php

File

lib/ClassFinder/Prefix.php, line 24

Class

xautoload_ClassFinder_Prefix

Code

function registerPrefixRoot($prefix, $root_path, $lazy_check = TRUE) {
  $subdir = str_replace('_', DIRECTORY_SEPARATOR, $prefix);
  $deep_path = strlen($root_path) ? $root_path . DIRECTORY_SEPARATOR . $subdir : $subdir;
  $this
    ->registerPrefixDeepLocation($prefix, $deep_path, $lazy_check);

  // We assume that the class named $prefix is also found at this path.
  $this
    ->registerClass($prefix, $deep_path . '.php');
}