You are here

function mymodule_libraries_info in X Autoload 7.3

Same name and namespace in other branches
  1. 7.5 xautoload.api.php \mymodule_libraries_info()
  2. 7.2 xautoload.api.php \mymodule_libraries_info()
  3. 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($api). This means, you can use the same methods on the $api object.

TODO: The $api object should be specified by an interface.

Return value

array Same as explained in libraries module, but with added key 'xautoload'.

File

./xautoload.api.php, line 58
Hooks provided by X Autoload.

Code

function mymodule_libraries_info() {
  return array(
    'example-lib' => array(
      'name' => 'Example library',
      'vendor url' => 'http://www.example.com',
      'download url' => 'http://github.com/example/my-php-api',
      'version' => '1.0',
      'xautoload' => function ($api) {

        /**
         * @var xautoload_InjectedAPI_hookXautoload $api
         */

        // Register a namespace with PSR-0 root in <library dir>/lib/.
        // The second argument is relative to the directory of the library, so
        // PSR-0 root will be e.g. "sites/all/libraries/example-lib/lib".
        $api
          ->namespaceRoot('ExampleVendor\\ExampleLib', 'lib');
      },
    ),
  );
}