From 440a5f80aa56377ddafd441204a30e3bb933f4c3 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Thu, 18 Jan 2024 21:01:51 +0000 Subject: [PATCH] fix: configureUsing() Octane --- .../support/src/Components/ComponentManager.php | 5 +++++ packages/support/src/Concerns/Configurable.php | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/packages/support/src/Components/ComponentManager.php b/packages/support/src/Components/ComponentManager.php index b4f60a31e02..53a556843ed 100644 --- a/packages/support/src/Components/ComponentManager.php +++ b/packages/support/src/Components/ComponentManager.php @@ -27,6 +27,11 @@ final public function __construct() { } + public static function isResolved(): void + { + app()->resolved(static::class); + } + public static function register(): void { app()->scopedIf( diff --git a/packages/support/src/Concerns/Configurable.php b/packages/support/src/Concerns/Configurable.php index 37b77d283c0..f979ce79f16 100644 --- a/packages/support/src/Concerns/Configurable.php +++ b/packages/support/src/Concerns/Configurable.php @@ -9,6 +9,20 @@ trait Configurable { public static function configureUsing(Closure $modifyUsing, ?Closure $during = null, bool $isImportant = false): mixed { + if (! ($during || ComponentManager::isResolved())) { + app()->resolving( + ComponentManager::class, + fn (ComponentManager $manager) => $manager->configureUsing( + static::class, + $modifyUsing, + $during, + $isImportant, + ), + ); + + return null; + } + return ComponentManager::resolve()->configureUsing( static::class, $modifyUsing,