\Drupflare\Anachron\Drupal\Extension IncludeTimePath

Finds an extension's path while its own file is being included and no container exists yet.

Drupal 7 modules start with require_once drupal_get_path('module', 'x') . '/x.inc';. Drupal 11 includes procedural module files while it compiles a container, before \Drupal holds one, so the path resolver service is out of reach. The file being included is on the call stack, and its directory is the answer.

Summary

Methods
Properties
Constants
find
No public properties found
No public constants found
No protected methods found
No protected properties found
No protected constants found
No private methods found
No private properties found
EXTENSIONS

Constant

EXTENSIONS

EXTENSIONS = ['module', 'install', 'inc', 'theme', 'profile', 'engine']

File extensions an extension's main file can have.

Methods

find()

find(string  $name, array>  $trace, string  $root) : string|null

Looks for the extension's file among the frames of a backtrace.

Parameters

string $name

The extension machine name.

array> $trace

Frames as debug_backtrace() returns them.

string $root

The application root the answer is relative to.

Returns

string|null —

The directory relative to the root, or null when no frame belongs to the extension.