Jump to content

Find all PW hooks (Windows)


slkwrm
 Share

Recommended Posts

I saw this twit of Ryan on how to find all hooks of PW, but it works only for Linux.

I use Windows at home, so I surfed some sites to find how to do the same thing on my OS.

Use this:

d:
cd d:\xampp\htdocs\processwire
findstr /s /i /l /n /c:"function ___" *.* > hooks.txt

Of course, you have to substitute disk and path, so your root processwire folder is specified.

You'll get hooks.txt, containing all lines with hookable functions and its line number in the file. Use Ctrl+F to search a needed string.

If you are really lazy, just use the file attached  :)

hooks.txt

Link to comment
Share on other sites

Thanks for posting that. Hooks in ProcessWire are one of those things that is still evolving, so rather than try to cover every possibility and publish an official list of hooks, I'm taking the strategy of letting it evolve a bit first and adding new hooks as needs surface.

Looking at an grep (or findstr) of all available hooks doesn't tell the full story. By that I mean that one shouldn't give up if they find there is no hook for something they need to do. Instead, post in the forum or email me and I'll make an existing function hookable or add a new one to cover a need. Likewise, one shouldn't assume that all the hooks that appear are recommended... Over time I've been discovering that several things that are hookable don't really need to be (though I don't plan on removing any hooks).

As the software matures more, we will eventually have a good idea of all the hooks that make sense and will publish an official list of hooks. But until then, the grep (or findstr) is the best way to see them all. I just wanted to make sure I gave that type of list some context and encourage people to get in touch as new hookable needs surface.

Link to comment
Share on other sites

Good to know system's getting more mature. I see it when tracking commits on github and downloading new versions. The more I dive into PW the more I like it ;D Unfortunately, I don't have much experience in webdev, but I'm learning a lot of things here. Thank you, guys!

Ryan, I have a bit offtopic question. Do you have a UML class diagram of PW? I would be very handy to see the whole structure of the system to better understand its architecture.

Link to comment
Share on other sites

No UML diagrams at present. I'll use UML when a client project calls for it, but don't personally find it helpful in my own (or others) work unless I don't know the language the code is written in. Too much of a code thinker I guess. Though I'm certainly not opposed to it and it it helps others then I'm sure it'll see a place in the code docs someday. Ultimately, understanding the class structure of PW is not necessary to use the API in full or develop modules for it. PW is really focused on delivering an external interface that doesn't require inside system knowledge. However, if you are interested, understanding the Wire, WireData and WireArray classes gives a solid foundation for understanding how everything in PW works.

Link to comment
Share on other sites

  • 1 year later...

@Luke, just for the sake of clarity: those are all available hooks, which doesn't necessarily mean they'd be "recommended" or "popular".. not sure if that makes such a huge difference though -- I think Ryan once said something about "not removing hooks once they've been in use in order not to break things." Still, some common sense might be useful here :)

Link to comment
Share on other sites

Yes, true. But I think it really depends what someone is doing what hooks are considered useful. Although I think hooks for "Page" could be more useful then for "Module", but that really depends. A somewhat extended documentation on hooks may be useful and some sort of cookbook as it can be found in the HelloWorldModule.

What are popular things you write hooks for? 

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...