One or more of the following functions is called if the given interval has passed.
You can hook into any of these functions and your hook will be called at the given interval.
Usage
$lazyCron->every30Seconds(int $seconds);
Arguments
Name | Type(s) | Description |
---|---|---|
seconds | int | The number of seconds that have actually elapsed. Most likely not useful, but provided just in case. |
Hooking LazyCron::every30Seconds(…)
You can add your own hook events that are executed either before or after the Lazy
method is executed. Examples of both are included below. A good place for hook code such as this is in your /site/ready.php file.
Hooking before
The 'before' hooks are called immediately before each Lazy
method call is executed. This type of hook is especially useful for modifying arguments before they are sent to the method.
$this->addHookBefore('LazyCron::every30Seconds', function(HookEvent $event) {
// Get the object the event occurred on, if needed
$LazyCron = $event->object;
// Get values of arguments sent to hook (and optionally modify them)
$seconds = $event->arguments(0);
/* Your code here, perhaps modifying arguments */
// Populate back arguments (if you have modified them)
$event->arguments(0, $seconds);
});
Hooking after
The 'after' hooks are called immediately after each Lazy
method call is executed. This type of hook is especially useful for modifying the value that was returned by the method call.
$this->addHookAfter('LazyCron::every30Seconds', function(HookEvent $event) {
// Get the object the event occurred on, if needed
$LazyCron = $event->object;
// An 'after' hook can retrieve and/or modify the return value
$return = $event->return;
// Get values of arguments sent to hook (if needed)
$seconds = $event->arguments(0);
/* Your code here, perhaps modifying the return value */
// Populate back return value, if you have modified it
$event->return = $return;
});
LazyCron methods and properties
API reference based on ProcessWire core version 3.0.244