protected function Renderer::doCallback in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::doCallback()
- 10 core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::doCallback()
Performs a callback.
Parameters
string $callback_type: The type of the callback. For example, '#post_render'.
string|callable $callback: The callback to perform.
array $args: The arguments to pass to the callback.
Return value
mixed The callback's return value.
See also
\Drupal\Core\Security\TrustedCallbackInterface
1 call to Renderer::doCallback()
- Renderer::doRender in core/
lib/ Drupal/ Core/ Render/ Renderer.php - See the docs for ::render().
File
- core/
lib/ Drupal/ Core/ Render/ Renderer.php, line 765
Class
- Renderer
- Turns a render array into a HTML string.
Namespace
Drupal\Core\RenderCode
protected function doCallback($callback_type, $callback, array $args) {
if (is_string($callback)) {
$double_colon = strpos($callback, '::');
if ($double_colon === FALSE) {
$callback = $this->controllerResolver
->getControllerFromDefinition($callback);
}
elseif ($double_colon > 0) {
$callback = explode('::', $callback, 2);
}
}
$message = sprintf('Render %s callbacks must be methods of a class that implements \\Drupal\\Core\\Security\\TrustedCallbackInterface or be an anonymous function. The callback was %s. Support for this callback implementation is deprecated in 8.8.0 and will be removed in Drupal 9.0.0. See https://www.drupal.org/node/2966725', $callback_type, '%s');
// Add \Drupal\Core\Render\Element\RenderCallbackInterface as an extra
// trusted interface so that:
// - All public methods on Render elements are considered trusted.
// - Helper classes that contain only callback methods can implement this
// instead of TrustedCallbackInterface.
return $this
->doTrustedCallback($callback, $args, $message, TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION, RenderCallbackInterface::class);
}