class ProceduralCall

Calls procedural hook implementations for backwards compatibility.

@internal

Hierarchy

Expanded class hierarchy of ProceduralCall

3 files declare their use of ProceduralCall
HookCollectorPass.php in core/lib/Drupal/Core/Hook/HookCollectorPass.php
HookCollectorPassTest.php in core/tests/Drupal/Tests/Core/Hook/HookCollectorPassTest.php
ModuleHandlerTest.php in core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php

File

core/lib/Drupal/Core/Extension/ProceduralCall.php, line 12

Namespace

Drupal\Core\Extension
View source
final class ProceduralCall {
    
    /**
     * @param array $includes
     *   An associated array, key is a function name, value is the name of the
     *   include file the function lives in, if any.
     */
    public function __construct(array $includes) {
    }
    
    /**
     * Calls a function in the root namespace.
     *
     * __call() does not support references https://bugs.php.net/bug.php?id=71256
     * Because of this, ModuleHandler::getHookListeners() inlines this
     * method so it is not called anywhere in core.
     */
    public function __call($name, $args) : mixed {
        $this->loadFile($name);
        return ('\\' . $name)(...$args);
    }
    
    /**
     * Loads the file a function lives in, if any.
     *
     * @param $function
     *   The name of the function.
     */
    public function loadFile($function) : void {
        if (isset($this->includes[$function])) {
            include_once $this->includes[$function];
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary
ProceduralCall::loadFile public function Loads the file a function lives in, if any.
ProceduralCall::__call public function Calls a function in the root namespace.
ProceduralCall::__construct public function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.