Yahoo! BOSS Library |
[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 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 { Second try Code: class Yahoo { Loader part: Code: $this->load->library('yahoo', $api_key); I hope somebody knows why it doesn't work! Thanks! Fabian
[eluser]Zack Kitzmiller[/eluser]
I've never really been able to get this to work right, and have tried several times. I ended up using a $config[] array.
[eluser]Fabdrol[/eluser]
Yeah, I've got a 'temp' solution by caching the CI instance and fetching a $config item.. But I really want it the 'normal' way. Please, CI Folkes! talk to us!
[eluser]renownedmedia[/eluser]
I saw a post mention this not to long ago... I think it was determined that ellislab broke that functionality a few versions ago and nobody really missed it
[eluser]Fabdrol[/eluser]
That's quite fubar... So there isn't any way to make a library work like a 'regular' php class? I'll dive into that loader class... don't like this! thanks for your comments! Fabian ps.: strange that there isn't any CI crew to say anything on this ;-)
[eluser]pistolPete[/eluser]
As of CI 1.7.0, the passed parameters must be in an array. I submitted a bug report back then: http://codeigniter.com/bug_tracker/bug/5709/
[eluser]InsiteFX[/eluser]
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'); Enjoy InsiteFX
[eluser]Fabdrol[/eluser]
Great, got it worked out now. I'll post the CI Boss lib online with some documentation today.
[eluser]Fabdrol[/eluser]
As promised, I posted the project online. 2 versions: one for CI, and one regular PHP class. I'll be updating the Lib during time, as it is for a client project. The project page: http://code.google.com/p/yahoo-boss-php/ |
Welcome Guest, Not a member yet? Register Sign In |