From 440a5f80aa56377ddafd441204a30e3bb933f4c3 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Thu, 18 Jan 2024 21:01:51 +0000 Subject: [PATCH 1/2] 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, From 24d2c16021ae955b065b481971bc9681bdf1ab61 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Thu, 18 Jan 2024 21:02:57 +0000 Subject: [PATCH 2/2] Update ComponentManager.php --- packages/support/src/Components/ComponentManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/support/src/Components/ComponentManager.php b/packages/support/src/Components/ComponentManager.php index 53a556843ed..932161f3d09 100644 --- a/packages/support/src/Components/ComponentManager.php +++ b/packages/support/src/Components/ComponentManager.php @@ -27,9 +27,9 @@ final public function __construct() { } - public static function isResolved(): void + public static function isResolved(): bool { - app()->resolved(static::class); + return app()->resolved(static::class); } public static function register(): void