@SamC it's really as simple as that: https://processwire.com/blog/posts/new-ajax-driven-inputs-conditional-hooks-template-family-settings-and-more/#new-conditional-hooks
Update 2022:
$wire->addHookAfter('Pages::saved', function(HookEvent $event) {
$page = $event->arguments('page');
bd('page saved');
bd($event, 'event');
bd($event->object, 'event->object');
bd($event->arguments(), 'event->arguments');
});
in the beginning it can be a little confusing when to use event->object, event->arguments and event->return but with the help of tracy you can quickly bring light into the dark: add the code above to the tracy console, set the radio on the right to load it on "ready" (same as placing the code in the site/ready.php file) and save any page:
$event->arguments('page') is the same as using $event->arguments(0) that you will see very often and in the tracy dump you see that 0 is simply the key for the first argument in that hookevent. you can also collapse the "data" property of the hookevent and you would see the same:
You can also use your IDE to quickly find what the HookEvent is returning/containing in which hook. Let's take the common saveReady hook as an example:
We know that the hook is attached as Pages::saveReady (eg because we have read that somewhere)
That means that the hook is part of the "Pages" class, which is located at "/wire/core/Pages.php" - that's easy to find out using CTRL+P in VSCode:
Searching for "___saveReady" lets us find the corresponding method:
Now we see, that we have ONE "arguments", being Page $page - this means $event->arguments(0) would return the page being ready for saving
$event->object would be the class, here "Pages"
$event->return is the return value of that method, here $data (line 1739)
Edit: There's some additional explanations in this post: https://processwire.com/talk/topic/27248-pagestrashtemplatefoo-vs-pagestemplatefootrash/?do=findComment&comment=224659
#search afraid of hooks