Jump to content

Cannot use "$this->pages->get()" in my module


bitmatix
 Share

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...