Soma Posted March 3, 2013 Share Posted March 3, 2013 Captain Hook ProcessWire Hooks Cheatsheet http://somatonic.github.com/Captain-Hook/ or on processwire.com http://processwire.com/api/hooks/ I created a simple list with a live search for all hookable methods available in the core. All methods prefixed with a "___" (3 underscores) are hookable. Methods can be made hookable by simply adding those ___ to it. ------------------------- I usually don't really need this, but thought it would be good to have an official list for reference. I used Sublime Text2 for searching and dumb a file with a search for " ___" in wire core. From this list I created a html file with a php script and added some fuzzy live search, similar to the API cheatsheet. If you use Sublime Text 2 like me you can simple use Goto Anything command super+p to show a fuzzy search for files. Enter a class name you want to search for. For example "fields" or "process page edit" you will recieve a list of files found in PW. Highlight the file and typ a @ to see the symbol list quickly or select the file and super+r the get the symbol list. 21 2 Link to comment Share on other sites More sharing options...
pwired Posted March 3, 2013 Share Posted March 3, 2013 You like doing this kinda stuff, don't you. Thanks and saved the list. 1 Link to comment Share on other sites More sharing options...
Nico Knoll Posted March 3, 2013 Share Posted March 3, 2013 Really lovely! 1 Link to comment Share on other sites More sharing options...
Soma Posted March 3, 2013 Author Share Posted March 3, 2013 Thank you guys. Yes I love doing the simple things and I loved to cheat in school. Anything more than list causes me headaches. 2 Link to comment Share on other sites More sharing options...
renobird Posted March 4, 2013 Share Posted March 4, 2013 Soma, You are removing all my excuses for not learning how to code modules. Dangit. 3 Link to comment Share on other sites More sharing options...
ryan Posted March 4, 2013 Share Posted March 4, 2013 I love the name Soma. Great idea. Seems like we should link or mirror this like we're doing with the cheatsheet. Since I regularly add new hooks, how is it best kept up-to-date? Link to comment Share on other sites More sharing options...
Soma Posted March 4, 2013 Author Share Posted March 4, 2013 Thanks Ryan. The name was in my head since a long time. All these hooking... It's easy, it takes me 5 minutes to update. Download new repo, file search in sublime, copy result file over, hit refresh, upload new index.html. 1 Link to comment Share on other sites More sharing options...
ryan Posted March 5, 2013 Share Posted March 5, 2013 Thanks again for making this. I have added it in the middle of the API navigation. 1 Link to comment Share on other sites More sharing options...
Soma Posted March 5, 2013 Author Share Posted March 5, 2013 Just let me know when I can refresh Captain Hook. 1 Link to comment Share on other sites More sharing options...
horst Posted March 5, 2013 Share Posted March 5, 2013 http://www.swisscinema.org/gimage/b9b371458ab7c314f88b81c553f6ce51.jpg 1 Link to comment Share on other sites More sharing options...
netcarver Posted March 5, 2013 Share Posted March 5, 2013 Like, like, like, like, like. Link to comment Share on other sites More sharing options...
Soma Posted April 11, 2013 Author Share Posted April 11, 2013 Just updated Captain Hook to 0.2 with latest dev version (+14 new entries) Enjoy 3 Link to comment Share on other sites More sharing options...
kongondo Posted April 11, 2013 Share Posted April 11, 2013 Just updated Captain Hook to 0.2 with latest dev version (+14 new entries) Enjoy Version still reads 0.1 on both though Link to comment Share on other sites More sharing options...
Soma Posted April 11, 2013 Author Share Posted April 11, 2013 I pushed update to github pages, but it's still not updated... give it some time... 3 Link to comment Share on other sites More sharing options...
Soma Posted November 1, 2013 Author Share Posted November 1, 2013 I just updated the sheet to 0.3 with hooks from latest dev version. + 22 hooks registered. - added teppo's article to info section links (http://www.flamingruby.com/blog/using-hooks-to-alter-default-behavior-of-processwire/) - added link to ryan's tutorial using hook to add method to PageArray (http://processwire.com/talk/topic/4834-simple-hooks-tutorial-turn-a-pagearray-into-a-list-of-links/) 8 Link to comment Share on other sites More sharing options...
owzim Posted May 9, 2014 Share Posted May 9, 2014 The current Captain Hook's line numbers are not in sync with the dev branch. Perhaps there should be a stable Captain Hook which points to the master branch and a version for the dev branch, which suggests that line numbers could be out of sync because of Ryan adding stuff in the core, obviously. An example I just saw: #843: public function ___saveModuleConfigData($className, array $configData) { I'm sure there are more. OR: Ryan runs the generator before every commit =) There is a generator, right? Link to comment Share on other sites More sharing options...
Soma Posted May 10, 2014 Author Share Posted May 10, 2014 Thanks for mention it owzim, coincidently I just looked at that the day before you, and also seen that some lines are out of sync. I was thinking if there's a way to automate it or make it easier to update. Currently I just do it manually scanning with SublimeText and take the result list to convert it to html. I'm just not sure what the easiest or best method could be. If anyone got a good idea or knows how, please share. Two versions, one for stable and one latest dev would be cool. For myself I'm not really using it the sheet, as I use SublimeText to quick find classes and symbols to quickly get an overview of the ___ methods. So a matter of a few seconds to look them up. Link to comment Share on other sites More sharing options...
owzim Posted May 11, 2014 Share Posted May 11, 2014 I just patched together some simple PHP code to scan for hooks: https://gist.github.com/owzim/6f7c2ef6394f25e04269 I think we could go from there and build a shell script that clones/pulls the PW repo checks out master and generates html > captain-hook-master.html checks out dev and generates html > captain-hook-dev.html updates the github page What do you think? 2 Link to comment Share on other sites More sharing options...
owzim Posted May 11, 2014 Share Posted May 11, 2014 @Soma, I just setup the whole thing, see: https://github.com/owzim/PWCaptainHookCLI Now the output of the array only has to be integrated into your html. 7 Link to comment Share on other sites More sharing options...
Soma Posted May 11, 2014 Author Share Posted May 11, 2014 Sounds very cool. Thanks owzim , ill take a look when I get time. Link to comment Share on other sites More sharing options...
kixe Posted September 15, 2014 Share Posted September 15, 2014 tried to hook, but didn't work, then I realized only two undescores. Shouldn't this to be hookable, since $event object is only used in hooks? Is there an underscore missing?wire/core/HookEvent.php /** * Return a string representing the HookEvent * */ public function __toString() { $s = $this->object->className() . '::' . $this->method . '('; foreach($this->arguments as $a) $s .= is_string($a) ? '"' . $a . '", ' : "$a, "; $s = rtrim($s, ", ") . ")"; return $s; } Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 15, 2014 Share Posted September 15, 2014 Nope, __toString is a magic method. 2 Link to comment Share on other sites More sharing options...
kixe Posted September 15, 2014 Share Posted September 15, 2014 thanks ... it still lacks many large stones in my personal php wall. But it is easier to learn in the PW Surrounding then elsewhere. Isn't it? 1 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 15, 2014 Share Posted September 15, 2014 It's ProcessWire that gives me continuity to. (Before PW OOP was mostly a mystery for me) 1 Link to comment Share on other sites More sharing options...
pwFoo Posted September 15, 2014 Share Posted September 15, 2014 Yes, PW is great to learn PHP, module development, hooks... 1 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