Skip to content

Instantly share code, notes, and snippets.

@donquixote
Created November 5, 2012 16:15
Show Gist options
  • Select an option

  • Save donquixote/4018045 to your computer and use it in GitHub Desktop.

Select an option

Save donquixote/4018045 to your computer and use it in GitHub Desktop.

Revisions

  1. donquixote revised this gist Nov 5, 2012. 1 changed file with 20 additions and 5 deletions.
    25 changes: 20 additions & 5 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    <?php

    /**
    * Implements hook_libraries_info()
    */
    function taleo_libraries_info() {
    return array(
    'Taleo' => array(
    @@ -9,16 +12,31 @@ function taleo_libraries_info() {
    );
    }

    /**
    * 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');
    $api->namespaceRoot('Taleo\Main\Taleo', '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', '');
    @@ -29,6 +47,3 @@ function _taleo_getjobs() {
    $taleo->login();
    }

    // This returns an error:
    // Fatal error: Class 'Taleo\Main\Taleo' not found in
    // C:\cygwin\home\DELLAIEP\www\jobs.localhost\sites\all\modules\custom\taleo\taleo.module on line 461.
  2. donquixote revised this gist Nov 5, 2012. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -4,16 +4,16 @@ function taleo_libraries_info() {
    return array(
    'Taleo' => array(
    'name' => 'Taleo PHP Library',
    'xautoload' => 'taleo_xautoload',
    'xautoload' => '_taleo_xautoload',
    ),
    );
    }

    function taleo_xautoload($api) {
    $api->namespaceRoot('Guzzle', '/vendor/guzzle/guzzle/src');
    $api->namespaceRoot('Monolog\Handler\StreamHandler', '/vendor/monolog/monolog/src');
    $api->namespaceRoot('Monolog\Logger', '/vendor/monolog/monolog/src');
    $api->namespaceRoot('Taleo\Main\Taleo', '/src');
    function _taleo_xautoload($api) {
    $api->namespaceRoot('Guzzle', 'vendor/guzzle/guzzle/src');
    $api->namespaceRoot('Monolog\Handler\StreamHandler', 'vendor/monolog/monolog/src');
    $api->namespaceRoot('Monolog\Logger', 'vendor/monolog/monolog/src');
    $api->namespaceRoot('Taleo\Main\Taleo', 'src');
    }


  3. @drupol drupol revised this gist Nov 5, 2012. 1 changed file with 22 additions and 5 deletions.
    27 changes: 22 additions & 5 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -8,10 +8,27 @@ function taleo_libraries_info() {
    ),
    );
    }

    function taleo_xautoload($api) {
    $path = libraries_get_path('Taleo', TRUE);
    $api->namespaceRoot('Guzzle', $path . '/vendor/guzzle/guzzle/src');
    $api->namespaceRoot('Monolog\Handler\StreamHandler', $path . '/vendor/monolog/monolog/src');
    $api->namespaceRoot('Monolog\Logger', $path . '/vendor/monolog/monolog/src');
    $api->namespaceRoot('Taleo\Main\Taleo', $path . '/src');
    $api->namespaceRoot('Guzzle', '/vendor/guzzle/guzzle/src');
    $api->namespaceRoot('Monolog\Handler\StreamHandler', '/vendor/monolog/monolog/src');
    $api->namespaceRoot('Monolog\Logger', '/vendor/monolog/monolog/src');
    $api->namespaceRoot('Taleo\Main\Taleo', '/src');
    }


    /**
    * Helper function to get all jobs from the Taleo database.
    */
    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();
    }

    // This returns an error:
    // Fatal error: Class 'Taleo\Main\Taleo' not found in
    // C:\cygwin\home\DELLAIEP\www\jobs.localhost\sites\all\modules\custom\taleo\taleo.module on line 461.
  4. @drupol drupol created this gist Nov 5, 2012.
    17 changes: 17 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    <?php

    function taleo_libraries_info() {
    return array(
    'Taleo' => array(
    'name' => 'Taleo PHP Library',
    'xautoload' => 'taleo_xautoload',
    ),
    );
    }
    function taleo_xautoload($api) {
    $path = libraries_get_path('Taleo', TRUE);
    $api->namespaceRoot('Guzzle', $path . '/vendor/guzzle/guzzle/src');
    $api->namespaceRoot('Monolog\Handler\StreamHandler', $path . '/vendor/monolog/monolog/src');
    $api->namespaceRoot('Monolog\Logger', $path . '/vendor/monolog/monolog/src');
    $api->namespaceRoot('Taleo\Main\Taleo', $path . '/src');
    }