Skip to content

Instantly share code, notes, and snippets.

@donquixote
Created November 5, 2012 16:15
Show Gist options
  • Save donquixote/4018045 to your computer and use it in GitHub Desktop.
Save donquixote/4018045 to your computer and use it in GitHub Desktop.
<?php
/**
* Implements hook_libraries_info()
*/
function taleo_libraries_info() {
return array(
'Taleo' => array(
'name' => 'Taleo PHP Library',
'xautoload' => '_taleo_xautoload',
),
);
}
/**
* xautoload callback for Taleo library.
*
* Notes:
* - We can't name this taleo_xautoload(), because this would
* be a recognized as a hook implementation of hook_xautoload().
* - We could make this an anonymous function directly in
* hook_libraries_info().
*/
function _taleo_xautoload($api) {
// $api already knows the library, so all paths are relative,
// and we specify them *without preceding slash*.
$api->namespaceRoot('Guzzle', 'vendor/guzzle/guzzle/src');
$api->namespaceRoot('Monolog\Handler\StreamHandler', 'vendor/monolog/monolog/src');
$api->namespaceRoot('Monolog\Logger', 'vendor/monolog/monolog/src');
// We want the class Taleo\Main\Taleo, which is NOT in the
// namespace Taleo\Main\Taleo\. Therefore the following does not work:
// $api->namespaceRoot('Taleo\Main\Taleo', 'src');
// Instead, we register the parent namespace:
$api->namespaceRoot('Taleo\Main', 'src');
}
/**
* Helper function to get all jobs from the Taleo database.
* (as an example where the Taleo classes are used)
*/
function _taleo_getjobs() {
$orgCode = variable_get('taleo_company_code', '');
$user = variable_get('taleo_username', '');
$password = variable_get('taleo_password', '');
$taleo = new \Taleo\Main\Taleo($user, $password, $orgCode);
$taleo->login();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment