Ever wondered when certain hooks get executed? Which hooks got fired along the request?
Open /wire/core/WireHooks.php, find the method "runHooks" and paste this at the very top of this method:
$logfile = wire()->config->paths->root . 'hooks.txt';
$tooOld = is_file($logfile) && filemtime($logfile) < time() - 5;
if ($tooOld) unlink($logfile);
$logData = get_class($object) . "::$method\n";
file_put_contents($logfile, $logData, FILE_APPEND);
This will write a log of all hookable methods to hooks.txt and it will probably begin like this:
ProcessWire\FileCompiler::compile
ProcessWire\FileCompiler::compile
ProcessWire\FileCompiler::compile
ProcessWire\FileCompiler::compile
ProcessWire\Fields::load
ProcessWire\Fieldgroups::load
ProcessWire\Templates::load
ProcessWire\Fieldgroup::setQuietly
ProcessWire\Fieldgroup::callUnknown
(maaaany more lines)
And it will most likely end with "ProcessWire\ProcessWire::finished" 🙂
Now you can play around with this logfile and view different pages. For example when opening a page for editing you will have a portion of this in the log (ProcessPageEdit::buildForm...):
ProcessWire\ProcessPageEdit::breadcrumb
ProcessWire\JqueryCore::use
ProcessWire\JqueryUI::use
ProcessWire\ProcessPageEdit::execute
ProcessWire\HutPage::setEditor
ProcessWire\ProcessPageEdit::buildForm
ProcessWire\ProcessPageEdit::buildFormContent
ProcessWire\Field::getInputfield
ProcessWire\Field::getInputfield
ProcessWire\Field::getInputfield
ProcessWire\Field::getInputfield
ProcessWire\Field::getInputfield
ProcessWire\Field::getInputfield
ProcessWire\Field::getInputfield
ProcessWire\Field::changed
ProcessWire\Field::changed
ProcessWire\Field::getInputfield
ProcessWire\Field::changed
ProcessWire\Field::getInputfield
ProcessWire\Field::getInputfield
ProcessWire\Field::getInputfield
ProcessWire\HutPage::viewable
ProcessWire\Pages::find
ProcessWire\PageFinder::find
ProcessWire\PageFinder::getQuery
ProcessWire\HutPage::addable
ProcessWire\ProcessPageEdit::buildFormChildren
ProcessWire\WireInputData::int
ProcessWire\WireInputData::callUnknown
ProcessWire\WireInputData::int
ProcessWire\WireInputData::callUnknown
You can also use grep to find the hooks you are looking for, for example:
cat hooks.txt | grep ProcessWire::
ProcessWire\ProcessWire::init
ProcessWire\ProcessWire::ready
ProcessWire\ProcessWire::finished
ProcessWire\ProcessWire::finished
This has helped me today to find the correct spot to hook into. Maybe it also helps anyone else. Have fun!
PS: Don't forget to remove this once you are done with inspecting, of course!