Add this object to your render tree and it will expose a unique URL which, when
executed directly will perform a PHP callback that you set().
Callback function run when triggered, i.e. when it's urlTrigger param value is present in the $_GET request.
The current callback will be set within the $_GET[Callback::URL_QUERY_TARGET] and will be set to urlTrigger as well.
$button = Button::addTo($layout);
$button->set('Click to do something')->link(
Callback::addTo($button)
->set(function () {
do_something();
})
->getUrl()
);
| Methods |
public
|
add(AbstractView $object, array $args = []): AbstractView
|
#
|
protected
|
init(): void
Called when view becomes part of render tree. You can override it but avoid
placing any "heavy processing" here.
Called when view becomes part of render tree. You can override it but avoid
placing any "heavy processing" here.
Overrides
Overriden by
|
#
|
public
|
setUrlTrigger(string $trigger = null): void
|
#
|
public
|
getUrlTrigger(): string
|
#
|
public
|
set<T>(
Closure(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed): T $fx = null,
array $fxArgs = null,
): T|null
Executes user-specified action when callback is triggered.
Executes user-specified action when callback is triggered.
Overriden by
|
#
|
public
|
terminateJson(View $view): void
Terminate this callback by rendering the given view.
Terminate this callback by rendering the given view.
|
#
|
public
|
isTriggered(): bool
Return true if urlTrigger is part of the request.
Return true if urlTrigger is part of the request.
|
#
|
public
|
getTriggeredValue(): string
|
#
|
public
|
canTerminate(): bool
Only current callback can terminate.
Only current callback can terminate.
|
#
|
public
|
canTrigger(): bool
Allow callback to be triggered or not.
Allow callback to be triggered or not.
|
#
|
public
|
getJsUrl(string $value = 'ajax'): string
Return URL that will trigger action on this callback. If you intend to request
the URL directly in your browser (as…
Return URL that will trigger action on this callback. If you intend to request
the URL directly in your browser (as iframe, new tab, or document location), you
should use getUrl instead.
|
#
|
public
|
getUrl(string $value = 'callback'): string
Return URL that will trigger action on this callback. If you intend to request
the URL loading from inside JavaScript,…
Return URL that will trigger action on this callback. If you intend to request
the URL loading from inside JavaScript, it's always advised to use getJsUrl instead.
Overriden by
|
#
|
private
|
getUrlArguments(string $value = null): array
Return proper URL argument for this callback.
Return proper URL argument for this callback.
|
#
|