class StaticTrustedCallbackHelper
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Security/StaticTrustedCallbackHelper.php \Drupal\Core\Security\StaticTrustedCallbackHelper
- 10 core/lib/Drupal/Core/Security/StaticTrustedCallbackHelper.php \Drupal\Core\Security\StaticTrustedCallbackHelper
- 9 core/lib/Drupal/Core/Security/StaticTrustedCallbackHelper.php \Drupal\Core\Security\StaticTrustedCallbackHelper
Defines a class for performing trusted callbacks in a static context.
Hierarchy
- class \Drupal\Core\Security\StaticTrustedCallbackHelper uses \Drupal\Core\Security\DoTrustedCallbackTrait
Expanded class hierarchy of StaticTrustedCallbackHelper
3 files declare their use of StaticTrustedCallbackHelper
- Datelist.php in core/
lib/ Drupal/ Core/ Datetime/ Element/ Datelist.php - Datetime.php in core/
lib/ Drupal/ Core/ Datetime/ Element/ Datetime.php - DoTrustedCallbackTraitTest.php in core/
tests/ Drupal/ Tests/ Core/ Security/ DoTrustedCallbackTraitTest.php
File
-
core/
lib/ Drupal/ Core/ Security/ StaticTrustedCallbackHelper.php, line 8
Namespace
Drupal\Core\SecurityView source
class StaticTrustedCallbackHelper {
use DoTrustedCallbackTrait;
/**
* Performs a callback.
*
* @param callable $callback
* The callback to call. Note that callbacks which are objects and use the
* magic method __invoke() are not supported.
* @param array $args
* The arguments to pass the callback.
* @param 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.
* @param 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 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 \Drupal\Core\Security\TrustedCallbackInterface
* @see \Drupal\Core\Security\DoTrustedCallbackTrait::doTrustedCallback()
*/
public static function callback(callable $callback, array $args, string $message, $extra_trusted_interface = NULL) {
if (func_num_args() > 4) {
@trigger_error('Calling Drupal\\Core\\Security\\StaticTrustedCallbackHelper::callback() with 5 arguments is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. See https://www.drupal.org/node/3627046', E_USER_DEPRECATED);
$extra_trusted_interface = func_get_arg(4);
}
return (new static())->doTrustedCallback($callback, $args, $message, $extra_trusted_interface);
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary |
|---|---|---|---|
| DoTrustedCallbackTrait::doTrustedCallback | public | function | Performs a callback. |
| StaticTrustedCallbackHelper::callback | public static | function | Performs a callback. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.