bitmatix Posted August 15, 2012 Share Posted August 15, 2012 I have a module class MyModule extends WireData implements Module, ConfigurableModule { and I wonder why I could not use: $this->pages->get(123); I always have to do: Wire::getFuel('pages')->get(123); Does anyone knows what's going wrong? Link to comment Share on other sites More sharing options...
Wanze Posted August 15, 2012 Share Posted August 15, 2012 Where exactly are you calling this? If you're inside a static method, you don't have access to the "$this" object, you can use $page = wire('pages')->get(123); 1 Link to comment Share on other sites More sharing options...
bitmatix Posted August 15, 2012 Author Share Posted August 15, 2012 No, it's not in a static function, it's in a public function. $page = wire('pages')->get(123); Doesn't also work EDIT: "wire('pages')->...." does work! Link to comment Share on other sites More sharing options...
Wanze Posted August 15, 2012 Share Posted August 15, 2012 Can you post the error message or say what exactly isn't working? Because it should work ;-) Link to comment Share on other sites More sharing options...
ryan Posted August 15, 2012 Share Posted August 15, 2012 The only reason why $this->pages->get(123); wouldn't work in a class that extends Wire or WireData (as yours does) is if you added your own implementation for a get() or __get() method. That's because something like $this->pages (or $this->any API var) gets routed through both get() and __get() in Wire/WireData. The nice thing about wire('pages') or wire('any API var') is that it works anywhere. Also wanted to mention that wire('pages'); is the new Wire::getFuel('pages'). They are both equivalent, but the getFuel() one just looks ugly. You'll see it used in some older modules and core code, but there's no reason to use it anymore. (though also no real reason to change it if you already are, as it's not going to be deprecated either). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now