Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ModuleHandler.php

function ModuleHandler::alterDeprecated

Overrides ModuleHandlerInterface::alterDeprecated

File

core/lib/Drupal/Core/Extension/ModuleHandler.php, line 492

Class

ModuleHandler
Class that manages modules in a Drupal installation.

Namespace

Drupal\Core\Extension

Code

public function alterDeprecated($description, $type, &$data, &$context1 = NULL, &$context2 = NULL) {
    // Invoke the alter hook. This has the side effect of populating
    // $this->alterEventListeners.
    $this->alter($type, $data, $context1, $context2);
    // The $type parameter can be an array. alter() will deal with this
    // internally, but we have to extract the proper $cid in order to discover
    // implementations.
    $cid = $type;
    if (is_array($type)) {
        $cid = implode(',', $type);
        $extra_types = $type;
        $type = array_shift($extra_types);
    }
    if (!empty($this->alterEventListeners[$cid])) {
        $functions = [];
        foreach ($this->alterEventListeners[$cid] as $listener) {
            if (is_string($listener)) {
                $functions[] = substr($listener, 1);
            }
            else {
                $functions[] = get_class($listener[0]) . '::' . $listener[1];
            }
        }
        $message = 'The deprecated alter hook hook_' . $type . '_alter() is implemented in these locations: ' . implode(', ', $functions) . '.';
        @trigger_error($message . ' ' . $description, E_USER_DEPRECATED);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal