function StaticTrustedCallbackHelper::callback
Same name in other branches
- 9 core/lib/Drupal/Core/Security/StaticTrustedCallbackHelper.php \Drupal\Core\Security\StaticTrustedCallbackHelper::callback()
- 10 core/lib/Drupal/Core/Security/StaticTrustedCallbackHelper.php \Drupal\Core\Security\StaticTrustedCallbackHelper::callback()
Performs a callback.
Parameters
callable $callback: The callback to call. Note that callbacks which are objects and use the magic method __invoke() are not supported.
array $args: The arguments to pass the callback.
string $message: The error message if the callback is not trusted. If the message contains "%s" it will be replaced in with the resolved callback.
string $error_type: (optional) The type of error to trigger. One of:
Defaults to TrustedCallbackInterface::THROW_EXCEPTION.
string $extra_trusted_interface: (optional) An additional interface that if implemented by the callback object means any public methods on that object are trusted.
Return value
mixed The callback's return value.
Throws
\Drupal\Core\Security\UntrustedCallbackException Exception thrown if the callback is not trusted and $error_type equals TrustedCallbackInterface::THROW_EXCEPTION.
See also
\Drupal\Core\Security\TrustedCallbackInterface
\Drupal\Core\Security\DoTrustedCallbackTrait::doTrustedCallback()
2 calls to StaticTrustedCallbackHelper::callback()
- Datelist::processDatelist in core/
lib/ Drupal/ Core/ Datetime/ Element/ Datelist.php - Expands a date element into an array of individual elements.
- Datetime::processDatetime in core/
lib/ Drupal/ Core/ Datetime/ Element/ Datetime.php - Expands a datetime element type into date and/or time elements.
File
-
core/
lib/ Drupal/ Core/ Security/ StaticTrustedCallbackHelper.php, line 42
Class
- StaticTrustedCallbackHelper
- Defines a class for performing trusted callbacks in a static context.
Namespace
Drupal\Core\SecurityCode
public static function callback(callable $callback, array $args, string $message, $error_type = TrustedCallbackInterface::THROW_EXCEPTION, $extra_trusted_interface = NULL) {
return (new static())->doTrustedCallback($callback, $args, $message, $error_type, $extra_trusted_interface);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.