4 class xautoload_InjectedAPI_hookXautoload
{
7 protected
$extensionDir;
10 * @param xautoload_ClassFinder $finder
13 function __construct($finder) {
14 $this->finder
= $finder;
18 * Register an additional namespace for this module.
19 * Note: Drupal\<module name>\ is already registered for <module dir>/lib.
21 * @param string $namespace
23 * @param string $psr_0_root_dir
25 * If $relative is TRUE, this is relative to the current module dir.
26 * If $relative is FALSE, this is an absolute path.
27 * @param boolean $relative
28 * Whether or not the path is relative to the current extension dir.
30 function namespaceRoot($namespace, $psr_0_root_dir = NULL
, $relative = TRUE
) {
31 $psr_0_root_dir = $this->processDir($psr_0_root_dir, $relative);
32 $this->finder
->registerNamespaceRoot($namespace, $psr_0_root_dir);
36 * Register an additional namespace for this module.
37 * Note: Drupal\<module name>\ is already registered for <module dir>/lib.
39 * @param string $namespace
41 * @param string $prefix_root_dir
43 * If $relative is TRUE, this is relative to the extension module dir.
44 * If $relative is FALSE, this is an absolute path.
45 * @param boolean $relative
46 * Whether or not the path is relative to the current extension dir.
48 function prefixRoot($prefix, $prefix_root_dir = NULL
, $relative = TRUE
) {
49 $prefix_root_dir = $this->processDir($prefix_root_dir, $relative);
50 $this->finder
->registerPrefixRoot($prefix, $prefix_root_dir);
54 * Register an additional namespace for this module.
55 * Note: Drupal\<module name>\ is already registered for <module dir>/lib.
57 * @param string $namespace
59 * @param string $psr_0_root_dir
61 * If $relative is TRUE, this is relative to the current extension dir.
62 * If $relative is FALSE, this is an absolute path.
63 * @param boolean $relative
64 * Whether or not the path is relative to the current extension dir.
66 function namespaceDeep($namespace, $namespace_deep_dir = NULL
, $relative = TRUE
) {
67 $namespace_deep_dir = $this->processDir($namespace_deep_dir, $relative);
68 $this->finder
->registerNamespaceDeep($namespace, $namespace_deep_dir);
72 * Register an additional namespace for this module.
73 * Note: Drupal\<module name>\ is already registered for <module dir>/lib.
75 * @param string $namespace
77 * @param string $prefix_deep_dir
79 * If $relative is TRUE, this is relative to the current extension dir.
80 * If $relative is FALSE, this is an absolute path.
81 * @param boolean $relative
82 * Whether or not the path is relative to the current extension dir.
84 function prefixDeep($prefix, $prefix_deep_dir = NULL
, $relative = TRUE
) {
85 $prefix_root_dir = $this->processDir($prefix_deep_dir, $relative);
86 $this->finder
->registerPrefixDeep($prefix, $prefix_deep_dir);
90 * Legacy: Plugins were called "Handler" before.
92 function namespaceHandler($namespace, $plugin) {
93 $this->finder
->registerNamespacePlugin($namespace, $plugin);
97 * Legacy: Plugins were called "Handler" before.
99 function prefixHandler($prefix, $plugin) {
100 $this->finder
->registerPrefixPlugin($prefix, $plugin);
104 * Register a namespace plugin object
106 function namespacePlugin($namespace, $plugin) {
107 $this->finder
->registerNamespacePlugin($namespace, $plugin);
111 * Register a prefix plugin object
113 function prefixPlugin($prefix, $plugin) {
114 $this->finder
->registerPrefixPlugin($prefix, $plugin);
118 * Process a given directory to make it relative to Drupal root,
119 * instead of relative to the current extension dir.
121 protected
function processDir($dir, $relative) {
123 $dir = $this->extensionDir .
'/lib';
126 // Root dir is relative to module root.
128 $dir = $this->extensionDir
;
131 $dir = $this->extensionDir .
'/' .
$dir;
135 // Leave the $dir as it is.
141 * Set a module to use as base for relative paths.
143 function setModule($module) {
144 $this->extensionDir
= drupal_get_path('module', $module);
148 * Set a theme to use as base for relative paths.
150 function setTheme($theme) {
151 $this->extensionDir
= drupal_get_path('theme', $theme);
155 * Set a library to use as base for relative paths.
157 function setLibrary($library) {
158 if (!module_exists('libraries')) {
159 throw new
Exception('Libraries module not installed.');
161 $this->extensionDir
= libraries_get_path($library);
165 * Explicitly set the base for relative paths.
167 function setExtensionDir($dir) {
168 $this->extensionDir
= $dir;