From ddca3cacd7b8d32473d1ccf05e35a25f413cb433 Mon Sep 17 00:00:00 2001 From: Bart Jaskulski <bjaskulski@protonmail.com> Date: Mon, 8 Jul 2024 09:07:36 +0200 Subject: [PATCH] feat: allow specifing target plugin at boot Signed-off-by: Bart Jaskulski <bjaskulski@protonmail.com> --- src/Init.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Init.php b/src/Init.php index 504f76d..5b0a869 100644 --- a/src/Init.php +++ b/src/Init.php @@ -48,13 +48,18 @@ final class Init { } } - public function boot() { + /** + * @param string|null $filename Filename of the booted plugin. May be null, if called from plugin's main file. + */ + public function boot( string? $filename = null ) { if ( self::$bootable === false ) { return; } - $backtrace = \debug_backtrace( \DEBUG_BACKTRACE_IGNORE_ARGS, 1 ); - $filename = $backtrace[0]['file']; + if ( $filename === null ) { + $backtrace = \debug_backtrace( \DEBUG_BACKTRACE_IGNORE_ARGS, 1 ); + $filename = $backtrace[0]['file']; + } $extensions = new ExtensionsSet( new BuiltinExtension(), -- GitLab