function public static function Bootstrap::deprecated

8.x-3.x Bootstrap.php public static Bootstrap::deprecated($caller = NULL, $show_message = NULL, TranslatableMarkup $message = NULL)

Logs and displays a warning about a deprecated function/method being used.


string $caller: Optional. The function or Class::method that should be shown as deprecated. If not set, it will be extrapolated automatically from the backtrace. This is primarily used when this method is being invoked from inside another method that isn't technically deprecated but has to support deprecated functionality.

bool $show_message: Flag indicating whether to show a message to the user. If TRUE, it will force show the message. If FALSE, it will only log the message. If not set, the message will be shown based on whether the current user is an administrator and if the theme has suppressed deprecated warnings.

\Drupal\Core\StringTranslation\TranslatableMarkup $message: Optional. The message to show/log. If not set, it will be determined automatically based on the caller.


The primary class for the Drupal Bootstrap base theme.



Source src/Bootstrap.php (line 581)

public static function deprecated($caller = NULL, $show_message = NULL, TranslatableMarkup $message = NULL) {
  $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);

  // Extrapolate the caller.
  if (!isset($caller) && !empty($backtrace[1]) && ($info = $backtrace[1])) {
    $caller = (!empty($info['class']) ? $info['class'] . '::' : '') . $info['function'];

  // Remove class namespace.
  $method = FALSE;
  if (is_string($caller) && strpos($caller, '::') !== FALSE && ($parts = explode('\\', $caller))) {
    $method = TRUE;
    $caller = array_pop($parts);

  if (!isset($message)) {
    $message = t('The following @type has been deprecated: <a href=":url" target="_blank">@title</a>. Please check the logs for a more detailed backtrace on where it is being invoked.', [
      '@type' => $method ? 'method' : 'function',
      ':url' => static::apiSearchUrl($caller),
      '@title' => $caller,

  if ($show_message || (!isset($show_message) && static::isAdmin() && !static::getTheme()->getSetting('suppress_deprecated_warnings', FALSE))) {
    static::message($message, 'warning');

  // Log message and accompanying backtrace.
  \Drupal::logger('bootstrap')->warning('<div>@message</div><pre><code>@backtrace</code></pre>', [
    '@message' => $message,
    '@backtrace' => Markup::create(print_r($backtrace, TRUE)),