Welcome Guest, Not a member yet? Register   Sign In
Yahoo! BOSS Library
#1

[eluser]Fabdrol[/eluser]
Hi Guys!

I'm writing a (simple) Yahoo! BOSS Library for CodeIgniter.
Just ran into a little problem.

According to the User Guide, it's possible to pass arguments to a lib using the loader Class...

Quote:Passing Parameters When Initializing Your Class

In the library loading function you can dynamically pass data as an array via the second parameter and it will be passed to your class constructor:

Code:
$params = array('type' => 'large', 'color' => 'red');

$this->load->library('Someclass', $params);

If you use this feature you must set up your class constructor to expect data:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Someclass {

    function Someclass($params)
    {
        // Do something with $params
    }
}

?>

Now, I tried to implement this, but I keep getting errors that the constructor misses it's parameters.

My code:
First try:
Code:
class Yahoo {

  function __construct($api_key) {
    $this->api_key = $api_key;
  }

}

Second try
Code:
class Yahoo {

  function Yahoo($api_key) {
    $this->api_key = $api_key;
  }

}

Loader part:
Code:
$this->load->library('yahoo', $api_key);

I hope somebody knows why it doesn't work!

Thanks!
Fabian


Messages In This Thread
Yahoo! BOSS Library - by El Forum - 10-06-2009, 03:17 PM
Yahoo! BOSS Library - by El Forum - 10-06-2009, 03:46 PM
Yahoo! BOSS Library - by El Forum - 10-06-2009, 04:05 PM
Yahoo! BOSS Library - by El Forum - 10-06-2009, 09:43 PM
Yahoo! BOSS Library - by El Forum - 10-07-2009, 03:08 AM
Yahoo! BOSS Library - by El Forum - 10-07-2009, 03:18 AM
Yahoo! BOSS Library - by El Forum - 10-07-2009, 08:14 AM
Yahoo! BOSS Library - by El Forum - 10-11-2009, 07:02 AM
Yahoo! BOSS Library - by El Forum - 10-11-2009, 07:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB