function mymodule_libraries_info in X Autoload 7.5
Same name and namespace in other branches
- 7.2 xautoload.api.php \mymodule_libraries_info()
- 7.3 xautoload.api.php \mymodule_libraries_info()
- 7.4 xautoload.api.php \mymodule_libraries_info()
Implements hook_libraries_info()
Allows to register PSR-0 (or other) class folders for your libraries. (those things living in sites/all/libraries)
The original documentation for this hook is at libraries module, libraries.api.php
X Autoload extends the capabilities of this hook, by adding an "xautoload" key. This key takes a callback or closure function, which has the same signature as hook_xautoload($adapter). This means, you can use the same methods on the $api object.
Return value
array[] Same as explained in libraries module, but with added key 'xautoload'.
File
- ./
xautoload.api.php, line 67 - Hooks provided by X Autoload.
Code
function mymodule_libraries_info() {
return array(
'ruebenkraut' => array(
'name' => 'Rübenkraut library',
'vendor url' => 'http://www.example.com',
'download url' => 'http://github.com/example/ruebenkraut',
'version' => '1.0',
'xautoload' => function ($adapter) {
/**
* @var \Drupal\xautoload\Adapter\LocalDirectoryAdapter $adapter
* An adapter object that can register stuff into the class loader.
*/
// Register a namespace with PSR-0 root in
// 'sites/all/libraries/ruebenkraut/src'.
$adapter
->add('Rueben\\Kraut\\', 'src');
},
),
'gurkentraum' => array(
'name' => 'Gurkentraum library',
'xautoload' => function ($adapter) {
/** @var \Drupal\xautoload\Adapter\LocalDirectoryAdapter $adapter */
// Scan sites/all/libraries/ruebenkraut/composer.json to look for
// autoload information.
$adapter
->composerJson('composer.json');
},
),
);
}