I have a custom api endpoint to generate a static json file with keywords of each page.
Is it possible to trigger these endpoint from a hook (e.g. page.create:after) to generate it again?
In Kirby 2 it was possible, but in Kirby 3 i have some issues with the Remote-Class:
Could not resolve: xyz.test (Domain name not found)
xyz.test is just a local domain.
'hooks' => [
'page.update:after' => function ($page) {
$email = 'mail@me.com';
$password = 'xxx';
Remote::get('https://xyz.test/api/search/keywords', [
'headers' => [
'Authorization: Basic ' . base64_encode($email . ':' . $password)
]
]);
}
]
This worked for me in my local valet environment, but obviously not for the TO:
Thinking of new way: Is it possible to call a function from another plugin inside of a hook?
So the proposed solution didn’t work for you, either? Have you tested the code on a remote server yet?
It works on a remote server. I don’t like the solution for locale environments, because every dev needs to tweak his environment.
To call a function from another plugin would be the better solution for my case. Is it possible?
I think it should be no problem to use a function defined in another plugin within a hook.